当前位置: 首页>>代码示例>>Java>>正文


Java TTransportException类代码示例

本文整理汇总了Java中org.apache.thrift.transport.TTransportException的典型用法代码示例。如果您正苦于以下问题:Java TTransportException类的具体用法?Java TTransportException怎么用?Java TTransportException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TTransportException类属于org.apache.thrift.transport包,在下文中一共展示了TTransportException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createServerTransport

import org.apache.thrift.transport.TTransportException; //导入依赖的package包/类
private static TServerSocket createServerTransport(boolean secure)
        throws TTransportException
{
    if (!secure) {
        return new TServerSocket(0);
    }

    try {
        SSLContext serverSslContext = ClientTestUtils.getServerSslContext();
        SSLServerSocket serverSocket = (SSLServerSocket) serverSslContext.getServerSocketFactory().createServerSocket(0);
        return new TServerSocket(serverSocket);
    }
    catch (Exception e) {
        throw new TTransportException("Error initializing secure socket", e);
    }
}
 
开发者ID:airlift,项目名称:drift,代码行数:17,代码来源:TestClientsWithApacheServer.java

示例2: createClientSocket

import org.apache.thrift.transport.TTransportException; //导入依赖的package包/类
private static TSocket createClientSocket(boolean secure, HostAndPort address)
        throws TTransportException
{
    if (!secure) {
        return new TSocket(address.getHost(), address.getPort());
    }

    try {
        SSLContext serverSslContext = ClientTestUtils.getClientSslContext();
        SSLSocket clientSocket = (SSLSocket) serverSslContext.getSocketFactory().createSocket(address.getHost(), address.getPort());
        //            clientSocket.setSoTimeout(timeout);
        return new TSocket(clientSocket);
    }
    catch (Exception e) {
        throw new TTransportException("Error initializing secure socket", e);
    }
}
 
开发者ID:airlift,项目名称:drift,代码行数:18,代码来源:LegacyApacheThriftTesterUtil.java

示例3: start

import org.apache.thrift.transport.TTransportException; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void start() {
  try {
    InetSocketAddress bindAddr = new InetSocketAddress(host, port);
    serverTransport = new TServerSocket(bindAddr);
    ThriftFlumeEventServer.Processor processor =
        new ThriftFlumeEventServer.Processor(new ThriftFlumeEventServerImpl());
    server = new TThreadPoolServer(
        new TThreadPoolServer.Args(serverTransport).processor(processor));
  } catch (TTransportException e) {
    throw new FlumeException("Failed starting source", e);
  }
  ThriftHandler thriftHandler = new ThriftHandler(server);
  thriftHandlerThread = new Thread(thriftHandler);
  thriftHandlerThread.start();
  super.start();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:19,代码来源:ThriftLegacySource.java

示例4: startServer

import org.apache.thrift.transport.TTransportException; //导入依赖的package包/类
@BeforeClass
public static void startServer() throws InterruptedException, TTransportException, ConfigurationException, IOException, URISyntaxException  {
    if (! started) {
        EmbeddedCassandraServerHelper.startEmbeddedCassandra(CASSANDRA_UNIT_RANDOM_PORT_YAML, CASSANDRA_TIMEOUT);
        Cluster cluster = new Cluster.Builder().addContactPoints("127.0.0.1").withPort(getNativeTransportPort()).build();
        Session session = cluster.connect();
        String createQuery = "CREATE KEYSPACE " + CASSANDRA_UNIT_KEYSPACE + " WITH replication={'class' : 'SimpleStrategy', 'replication_factor':1}";
        session.execute(createQuery);
        String useKeyspaceQuery = "USE " + CASSANDRA_UNIT_KEYSPACE;
        session.execute(useKeyspaceQuery);
        CQLDataLoader dataLoader = new CQLDataLoader(session);
        applyScripts(dataLoader, "config/cql/changelog/", "*.cql");
        started = true;
    }
}
 
开发者ID:xm-online,项目名称:xm-ms-timeline,代码行数:16,代码来源:AbstractCassandraTest.java

示例5: load

import org.apache.thrift.transport.TTransportException; //导入依赖的package包/类
@Override
public Pair<TTransport, Bmv2DeviceThriftClient> load(DeviceId deviceId)
        throws TTransportException {
    log.debug("Instantiating new client... > deviceId={}", deviceId);
    // Make the expensive call
    Bmv2Device device = Bmv2Device.of(deviceId);
    TTransport transport = new TSocket(device.thriftServerHost(), device.thriftServerPort());
    TProtocol protocol = new TBinaryProtocol(transport);
    // Our BMv2 device implements multiple Thrift services, create a client for each one on the same transport.
    Standard.Client standardClient = new Standard.Client(
            new TMultiplexedProtocol(protocol, "standard"));
    SimpleSwitch.Client simpleSwitch = new SimpleSwitch.Client(
            new TMultiplexedProtocol(protocol, "simple_switch"));
    // Wrap clients so to automatically have synchronization and resiliency to connectivity errors
    Standard.Iface safeStandardClient = SafeThriftClient.wrap(standardClient,
                                                              Standard.Iface.class,
                                                              options);
    SimpleSwitch.Iface safeSimpleSwitchClient = SafeThriftClient.wrap(simpleSwitch,
                                                                      SimpleSwitch.Iface.class,
                                                                      options);
    Bmv2DeviceThriftClient client = new Bmv2DeviceThriftClient(deviceId,
                                                               transport,
                                                               safeStandardClient,
                                                               safeSimpleSwitchClient);
    return Pair.of(transport, client);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:Bmv2ControllerImpl.java

示例6: invoke

import org.apache.thrift.transport.TTransportException; //导入依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

    // Thrift transport layer is not thread-safe (it's a wrapper on a socket), hence we need locking.
    synchronized (transport) {

        LOG.debug("Invoking method... > fromThread={}, method={}, args={}",
                  Thread.currentThread().getId(), method.getName(), args);

        try {

            return method.invoke(baseClient, args);
        } catch (InvocationTargetException e) {
            if (e.getTargetException() instanceof TTransportException) {
                TTransportException cause = (TTransportException) e.getTargetException();

                if (RESTARTABLE_CAUSES.contains(cause.getType())) {
                    // Try to reconnect. If fail, a TTransportException will be thrown.
                    reconnectOrThrowException();
                    try {
                        // If here, transport has been successfully open, hence new exceptions will be thrown.
                        return method.invoke(baseClient, args);
                    } catch (InvocationTargetException e1) {
                        LOG.debug("Exception: {}", e1.getTargetException());
                        throw e1.getTargetException();
                    }
                }
            }
            // Target exception is neither a TTransportException nor a restartable cause.
            LOG.debug("Exception: {}", e.getTargetException());
            throw e.getTargetException();
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:35,代码来源:SafeThriftClient.java

示例7: flush

import org.apache.thrift.transport.TTransportException; //导入依赖的package包/类
@Override
public void flush() throws TTransportException {
    synchronized (sendLock) {
        byte[] bytes = new byte[MAX_BUFFER_SIZE];
        int length = writeBuffer.position();

        writeBuffer.flip();
        writeBuffer.get(bytes, 0, length);

        try {
            socket.send(new DatagramPacket(bytes, length));
        } catch (IOException e) {
            throw new TTransportException(e);
        } finally {
            writeBuffer.clear();
        }
    }
}
 
开发者ID:uber-java,项目名称:tally,代码行数:19,代码来源:TUdpClient.java

示例8: write

import org.apache.thrift.transport.TTransportException; //导入依赖的package包/类
@Override
public void write(byte[] bytes, int offset, int length) throws TTransportException {
    if (!isOpen()) {
        throw new TTransportException(TTransportException.NOT_OPEN);
    }

    synchronized (sendLock) {
        if (writeBuffer.position() + length > MAX_BUFFER_SIZE) {
            throw new TTransportException(
                String.format("Message size too large: %d is greater than available size %d",
                    length,
                    MAX_BUFFER_SIZE - writeBuffer.position()
                )
            );
        }

        writeBuffer.put(bytes, offset, length);
    }
}
 
开发者ID:uber-java,项目名称:tally,代码行数:20,代码来源:TUdpTransport.java

示例9: emitMetricBatch

import org.apache.thrift.transport.TTransportException; //导入依赖的package包/类
public void emitMetricBatch(MetricBatch batch) throws TTransportException {
    lock.writeLock().lock();

    batches.add(batch);

    if (countBatches) {
        phaser.arrive();
    }

    for (Metric metric : batch.getMetrics()) {
        metrics.add(metric);

        if (!countBatches) {
            phaser.arrive();
        }
    }

    lock.writeLock().unlock();

    throw new TTransportException(TTransportException.END_OF_FILE, "complete");
}
 
开发者ID:uber-java,项目名称:tally,代码行数:22,代码来源:MockM3Service.java

示例10: createServerSocket

import org.apache.thrift.transport.TTransportException; //导入依赖的package包/类
private TServerSocket createServerSocket(boolean useSSL, int port) throws IOException, TTransportException {
  TServerSocket serverSocket = null;
  // enable SSL support for HMS
  List<String> sslVersionBlacklist = new ArrayList<>();
  for (String sslVersion : hiveConf.getVar(ConfVars.HIVE_SSL_PROTOCOL_BLACKLIST).split(",")) {
    sslVersionBlacklist.add(sslVersion);
  }
  if (!useSSL) {
    serverSocket = HiveAuthUtils.getServerSocket(null, port);
  } else {
    String keyStorePath = hiveConf.getVar(ConfVars.HIVE_METASTORE_SSL_KEYSTORE_PATH).trim();
    if (keyStorePath.isEmpty()) {
      throw new IllegalArgumentException(
          ConfVars.HIVE_METASTORE_SSL_KEYSTORE_PASSWORD.varname + " Not configured for SSL connection");
    }
    String keyStorePassword = ShimLoader.getHadoopShims().getPassword(hiveConf,
        HiveConf.ConfVars.HIVE_METASTORE_SSL_KEYSTORE_PASSWORD.varname);
    serverSocket = HiveAuthUtils.getServerSSLSocket(null, port, keyStorePath, keyStorePassword, sslVersionBlacklist);
  }
  return serverSocket;
}
 
开发者ID:HotelsDotCom,项目名称:waggle-dance,代码行数:22,代码来源:MetaStoreProxyServer.java

示例11: ServerThread

import org.apache.thrift.transport.TTransportException; //导入依赖的package包/类
ServerThread() throws TTransportException {
   TMultiplexedProcessor processor = new TMultiplexedProcessor();
   for (String beanName : serviceMap.keySet()) {
      IThriftServerService serverService = (IThriftServerService) serviceMap.getService(beanName);
      String processorName = serverService.getName();
      TProcessor tProcessor = serverService.getProcessor(serverService);
      processor.registerProcessor(processorName, tProcessor);
      logger.info("Register a processorName {} processorImpl {}", processorName, tProcessor);
   }

   logger.info("init default TServerTransport in addr {} port {}", applicationProperties.getAddr(), applicationProperties.getPort());
   TServerTransport tServerTransport = new TServerSocket(new InetSocketAddress(applicationProperties.getAddr(),
           applicationProperties.getPort()));
   TThreadPoolServer.Args args = new TThreadPoolServer.Args(tServerTransport);
   args.processor(processor);
   args.protocolFactory(tProtocolFactory);
   server = new TThreadPoolServer(args);
}
 
开发者ID:somewhereMrli,项目名称:albedo-thrift,代码行数:19,代码来源:ThriftServer.java

示例12: TsfileConnection

import org.apache.thrift.transport.TTransportException; //导入依赖的package包/类
public TsfileConnection(String url, Properties info) throws SQLException, TTransportException {
if (url == null) {
    throw new TsfileURLException("Input url cannot be null");
}
params = Utils.parseURL(url, info);

supportedProtocols.add(TSProtocolVersion.TSFILE_SERVICE_PROTOCOL_V1);

openTransport();
client = new TSIService.Client(new TBinaryProtocol(transport));
// open client session
openSession();
// Wrap the client with a thread-safe proxy to serialize the RPC calls
client = newSynchronizedClient(client);
autoCommit = false;
   }
 
开发者ID:thulab,项目名称:iotdb-jdbc,代码行数:17,代码来源:TsfileConnection.java

示例13: getTThreadPoolServer

import org.apache.thrift.transport.TTransportException; //导入依赖的package包/类
private static TServer getTThreadPoolServer(TProtocolFactory protocolFactory,
                                            TProcessor processor,
                                            TTransportFactory transportFactory,
                                            int workerThreads,
                                            InetSocketAddress inetSocketAddress,
                                            int backlog,
                                            int clientTimeout)
    throws TTransportException {
  TServerTransport serverTransport = new TServerSocket(
                                         new TServerSocket.ServerSocketTransportArgs().
                                             bindAddr(inetSocketAddress).backlog(backlog).
                                             clientTimeout(clientTimeout));
  log.info("starting HBase ThreadPool Thrift server on " + inetSocketAddress.toString());
  TThreadPoolServer.Args serverArgs = new TThreadPoolServer.Args(serverTransport);
  serverArgs.processor(processor);
  serverArgs.transportFactory(transportFactory);
  serverArgs.protocolFactory(protocolFactory);
  if (workerThreads > 0) {
    serverArgs.maxWorkerThreads(workerThreads);
  }
  return new TThreadPoolServer(serverArgs);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:ThriftServer.java

示例14: ensureMockCassandraRunningAndEstablished

import org.apache.thrift.transport.TTransportException; //导入依赖的package包/类
/**
 * Ensures that the Mock Cassandra instance is up and running. Will reinit
 * the database every time it is called.
 *
 * @param cassandraKeyspace Cassandra keyspace to setup.
 * @return A cluster object.
 * @throws ConfigurationException
 * @throws IOException
 * @throws InterruptedException
 * @throws TTransportException
 */
public static Cluster ensureMockCassandraRunningAndEstablished(String cassandraKeyspace) throws ConfigurationException, IOException, InterruptedException, TTransportException
{
    Cluster cluster;
    long timeout = 60000;
    EmbeddedCassandraServerHelper.startEmbeddedCassandra(timeout);
    cluster = Cluster.builder().addContactPoints("127.0.0.1").withPort(9142).build();
    //Thread.sleep(20000);//time to let cassandra startup
    final Metadata metadata = cluster.getMetadata();

    Session session = cluster.connect();
    Utils.initDatabase(DB_CQL, session);
    session = cluster.connect(cassandraKeyspace);

    logger.info("Connected to cluster: " + metadata.getClusterName() + '\n');
    return cluster;
}
 
开发者ID:PearsonEducation,项目名称:Docussandra,代码行数:28,代码来源:Fixtures.java

示例15: resolveHost

import org.apache.thrift.transport.TTransportException; //导入依赖的package包/类
public InetAddress resolveHost() throws TTransportException {
  // TODO: SW: JDK's InetAddress has an inbuilt cache but it is no good
  // and does not honour DNS TTL etc. Custom DNSCacheService should be
  // added for better behaviour.

  // InetAddress addr = DNSCacheService.getInstance().lookupCache(hostName);
  try {
    return InetAddress.getByName(this.hostName);
  } catch (UnknownHostException uhe) {
    // use ipAddress if available
    if (this.ipAddress != null) {
      try {
        return InetAddress.getByName(this.ipAddress);
      } catch (UnknownHostException e) {
        throw new TTransportException(e);
      }
    }
    else {
      throw new TTransportException(uhe);
    }
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:23,代码来源:HostAddress.java


注:本文中的org.apache.thrift.transport.TTransportException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。