本文整理汇总了Java中org.apache.mina.core.future.CloseFuture类的典型用法代码示例。如果您正苦于以下问题:Java CloseFuture类的具体用法?Java CloseFuture怎么用?Java CloseFuture使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CloseFuture类属于org.apache.mina.core.future包,在下文中一共展示了CloseFuture类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doStop
import org.apache.mina.core.future.CloseFuture; //导入依赖的package包/类
@Override
protected void doStop() throws Exception {
if (configuration.isClientMode() && configuration.getProtocol().equals("tcp")) {
LOG.info("Disconnect from server address: {} using connector: {}", address, connector);
if (session != null) {
CloseFuture closeFuture = session.close(true);
closeFuture.awaitUninterruptibly();
}
connector.dispose(true);
} else {
LOG.info("Unbinding from server address: {} using acceptor: {}", address, acceptor);
if (address instanceof InetSocketAddress) {
// need to check if the address is IPV4 all network address
if ("0.0.0.0".equals(((InetSocketAddress)address).getAddress().getHostAddress())) {
LOG.info("Unbind the server address {}", acceptor.getLocalAddresses());
acceptor.unbind(acceptor.getLocalAddresses());
} else {
acceptor.unbind(address);
}
} else {
acceptor.unbind(address);
}
}
super.doStop();
}
示例2: operationComplete
import org.apache.mina.core.future.CloseFuture; //导入依赖的package包/类
public void operationComplete(CloseFuture future) {
AbstractIoSession session = (AbstractIoSession) future.getSession();
session.scheduledWriteBytes.set(0);
session.scheduledWriteMessages.set(0);
session.readBytesThroughput = 0;
session.readMessagesThroughput = 0;
session.writtenBytesThroughput = 0;
session.writtenMessagesThroughput = 0;
}
示例3: close
import org.apache.mina.core.future.CloseFuture; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public final CloseFuture close(boolean rightNow) {
if (!isClosing()) {
if (rightNow) {
return close();
}
return closeOnFlush();
} else {
return closeFuture;
}
}
示例4: addSession
import org.apache.mina.core.future.CloseFuture; //导入依赖的package包/类
/**
* Add the session for being checked for idle.
* @param session the session to check
*/
public void addSession(AbstractIoSession session) {
sessions.add(session);
CloseFuture closeFuture = session.getCloseFuture();
// isn't service reponsability to remove the session nicely ?
closeFuture.addListener(sessionCloseListener);
}
示例5: closeConnection
import org.apache.mina.core.future.CloseFuture; //导入依赖的package包/类
private void closeConnection() {
if (session != null) {
CloseFuture closeFuture = session.close(true);
closeFuture.awaitUninterruptibly();
}
connector.dispose(true);
}
示例6: close
import org.apache.mina.core.future.CloseFuture; //导入依赖的package包/类
@Override
public void close() throws IOException {
CloseFuture closeFuture = session.close(false);
closeFuture.awaitUninterruptibly();
if (!closeFuture.isClosed())
throw new IOException("Session not closed");
}
示例7: run
import org.apache.mina.core.future.CloseFuture; //导入依赖的package包/类
/**
* Run the test suites.
*/
public void run() {
logger.info("client runs");
try {
for ( currentIndex = 0; currentIndex < this.testcases.size(); currentIndex++ ) {
Class clazz = this.testcaseClasses.get(currentIndex);
Object object = this.testcases.get(currentIndex);
ProtoTest protoTest = (ProtoTest) clazz.getAnnotation(ProtoTest.class);
int times = protoTest.times();
logger.info("run the " + this.testcaseClasses.get(currentIndex) + " cases for " + times + " times.");
for ( int i=0; i<times; i++ ) {
Method method = clazz.getDeclaredMethod("generateMessge", Map.class);
MessageLite request = (MessageLite)method.invoke(object, context);
sendRequest(request);
sema.acquire();
}
}
if ( !longRunning ) {
CloseFuture future = session.close(false);
future.await();
logger.info("client exit");
}
} catch (Throwable e) {
logger.error(e.getMessage(), e);
}
}
示例8: disconnect
import org.apache.mina.core.future.CloseFuture; //导入依赖的package包/类
/**
* disconnect existing connection to LLRP device.
*/
public void disconnect(){
//IoSession session = future.getSession();
if (session != null && session.isConnected()){
CloseFuture future = session.close();
// MINA 2.0
// future.awaitUninterruptibly();
}
}
示例9: closeOnFlush
import org.apache.mina.core.future.CloseFuture; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public final CloseFuture closeOnFlush() {
if (!isClosing()) {
getWriteRequestQueue().offer(CLOSE_REQUEST);
getProcessor().flush(this);
}
return closeFuture;
}
示例10: closeNow
import org.apache.mina.core.future.CloseFuture; //导入依赖的package包/类
@Override
public final CloseFuture closeNow() {
synchronized (closeFuture) {
if (isClosing()) {
return closeFuture;
}
closing = true;
}
getFilterChain().fireFilterClose();
return closeFuture;
}
示例11: disconnect
import org.apache.mina.core.future.CloseFuture; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void disconnect() {
if (future != null) {
try {
// session will be null if connect failed
if (session != null) {
// close, now
CloseFuture closeFuture = session.closeNow();
// now wait for the close to be completed
if (closeFuture.await(1000, TimeUnit.MILLISECONDS)) {
if (!future.isCanceled()) {
if (future.cancel()) {
log.debug("Connect future cancelled after close future");
}
}
}
} else if (future.cancel()) {
log.debug("Connect future cancelled");
}
} catch (Exception e) {
log.warn("Exception during disconnect", e);
} finally {
// we can now dispose the connector
socketConnector.dispose(false);
}
}
super.disconnect();
}
示例12: getCloseFuture
import org.apache.mina.core.future.CloseFuture; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public final CloseFuture getCloseFuture() {
return closeFuture;
}
示例13: closeOnFlush
import org.apache.mina.core.future.CloseFuture; //导入依赖的package包/类
private final CloseFuture closeOnFlush() {
getWriteRequestQueue().offer(this, CLOSE_REQUEST);
getProcessor().flush(this);
return closeFuture;
}
示例14: close
import org.apache.mina.core.future.CloseFuture; //导入依赖的package包/类
@Override
public ChannelHandler close() {
CloseFuture closeFuture = session.close(false);
return new MinaChannelHandler(closeFuture);
}
示例15: close
import org.apache.mina.core.future.CloseFuture; //导入依赖的package包/类
@Override
public CloseFuture close(boolean bln) {
return null;
}