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


Java TNonblockingTransport.close方法代码示例

本文整理汇总了Java中org.apache.thrift.transport.TNonblockingTransport.close方法的典型用法代码示例。如果您正苦于以下问题:Java TNonblockingTransport.close方法的具体用法?Java TNonblockingTransport.close怎么用?Java TNonblockingTransport.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.thrift.transport.TNonblockingTransport的用法示例。


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

示例1: handleAccept

import org.apache.thrift.transport.TNonblockingTransport; //导入方法依赖的package包/类
/**
 * Accept a new connection.
 */
private void handleAccept() {
  final TNonblockingTransport client = doAccept();
  if (client != null) {
    // Pass this connection to a selector thread
    final SelectorThread targetThread = threadChooser.nextThread();

    if (args.acceptPolicy == Args.AcceptPolicy.FAST_ACCEPT || invoker == null) {
      doAddAccept(targetThread, client);
    } else {
      // FAIR_ACCEPT
      try {
        invoker.submit(new Runnable() {
          public void run() {
            doAddAccept(targetThread, client);
          }
        });
      } catch (RejectedExecutionException rx) {
        LOGGER.warn("ExecutorService rejected accept registration!", rx);
        // close immediately
        client.close();
      }
    }
  }
}
 
开发者ID:apache,项目名称:incubator-tephra,代码行数:28,代码来源:TThreadedSelectorServerWithFix.java

示例2: registerAccepted

import org.apache.thrift.transport.TNonblockingTransport; //导入方法依赖的package包/类
private void registerAccepted(TNonblockingTransport accepted) {
  SelectionKey clientKey = null;
  try {
    clientKey = accepted.registerSelector(selector, SelectionKey.OP_READ);

    FrameBuffer frameBuffer = createFrameBuffer(accepted, clientKey, SelectorThread.this);

    clientKey.attach(frameBuffer);
  } catch (IOException e) {
    LOGGER.warn("Failed to register accepted connection to selector!", e);
    if (clientKey != null) {
      cleanupSelectionKey(clientKey);
    }
    accepted.close();
  }
}
 
开发者ID:adityayadav76,项目名称:internet_of_things_simulator,代码行数:17,代码来源:TThreadedSelectorServer.java

示例3: registerAccepted

import org.apache.thrift.transport.TNonblockingTransport; //导入方法依赖的package包/类
private void registerAccepted(TNonblockingTransport accepted) {
  SelectionKey clientKey = null;
  try {
    clientKey = accepted.registerSelector(selector, SelectionKey.OP_READ);

    FrameBuffer frameBuffer = new FrameBuffer(accepted, clientKey, SelectorThread.this);
    clientKey.attach(frameBuffer);
  } catch (IOException e) {
    LOGGER.warn("Failed to register accepted connection to selector!", e);
    if (clientKey != null) {
      cleanupSelectionKey(clientKey);
    }
    accepted.close();
  }
}
 
开发者ID:apache,项目名称:incubator-tephra,代码行数:16,代码来源:TThreadedSelectorServerWithFix.java

示例4: test_AsyncClient

import org.apache.thrift.transport.TNonblockingTransport; //导入方法依赖的package包/类
@Test
public void test_AsyncClient() throws Throwable {
	Random rnd = new Random(System.nanoTime());

	TProtocolFactory[] protfacs = new TProtocolFactory[] { new TCompactProtocol.Factory(),
			new TBinaryProtocol.Factory(), new TJSONProtocol.Factory(),
			new TSimpleJSONProtocol.Factory(TCalculator.Iface.class, false) };

	TProtocolFactory protocolFactory = protfacs[rnd.nextInt(protfacs.length)];

	System.out.println("protocolFactory: " + protocolFactory);

	TAsyncClientManager clientManager = new TAsyncClientManager();
	TNonblockingTransport transport = new TNonblockingSocket(HOST, PORT);
	TCalculator.AsyncClient client = new TCalculator.AsyncClient(protocolFactory, clientManager, transport);
	final int num1 = rnd.nextInt(Integer.MAX_VALUE / 2 - 1);
	final int num2 = rnd.nextInt(Integer.MAX_VALUE / 2 - 1);

	final CountDownLatch latch = new CountDownLatch(1);
	final Throwable[] exceptions = new Throwable[1];
	AsyncMethodCallback<TCalculator.AsyncClient.add_call> resultHandler = new AsyncMethodCallback<TCalculator.AsyncClient.add_call>() {
		@Override
		public void onComplete(TCalculator.AsyncClient.add_call response) {
			System.out.println("onComplete!");
			try {
				int result = response.getResult();
				Assert.assertEquals(num1 + num2, result);
			} catch (Throwable e) {
				exceptions[0] = e;
			} finally {
				latch.countDown();
			}
		}

		@Override
		public void onError(Exception exception) {
			System.err.println("onError!");
			exception.printStackTrace();
			latch.countDown();
		}

	};
	client.add(num1, num2, resultHandler);
	latch.await();
	transport.close();
	if (exceptions[0] != null) {
		throw exceptions[0];
	}
}
 
开发者ID:houkx,项目名称:nettythrift,代码行数:50,代码来源:DemoClientTraditionalTEST.java

示例5: doAddAccept

import org.apache.thrift.transport.TNonblockingTransport; //导入方法依赖的package包/类
private void doAddAccept(SelectorThread thread, TNonblockingTransport client) {
  if (!thread.addAcceptedConnection(client)) {
    client.close();
  }
}
 
开发者ID:apache,项目名称:incubator-tephra,代码行数:6,代码来源:TThreadedSelectorServerWithFix.java


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