本文整理汇总了Java中org.apache.tomcat.util.net.NioEndpoint.KeyAttachment类的典型用法代码示例。如果您正苦于以下问题:Java KeyAttachment类的具体用法?Java KeyAttachment怎么用?Java KeyAttachment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KeyAttachment类属于org.apache.tomcat.util.net.NioEndpoint包,在下文中一共展示了KeyAttachment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resetTimeouts
import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected void resetTimeouts() {
// The NIO connector uses the timeout configured on the wrapper in the
// poller. Therefore, it needs to be reset once asycn processing has
// finished.
final KeyAttachment attach =
(KeyAttachment)socketWrapper.getSocket().getAttachment();
if (!getErrorState().isError() && attach != null &&
asyncStateMachine.isAsyncDispatching()) {
long soTimeout = endpoint.getSoTimeout();
//reset the timeout
if (keepAliveTimeout > 0) {
attach.setTimeout(keepAliveTimeout);
} else {
attach.setTimeout(soTimeout);
}
}
}
示例2: resetTimeouts
import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected void resetTimeouts() {
final NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment)socketWrapper.getSocket().getAttachment();
if (!getErrorState().isError() && attach != null &&
asyncStateMachine.isAsyncDispatching()) {
long soTimeout = endpoint.getSoTimeout();
//reset the timeout
if (keepAlive) {
attach.setTimeout(keepAliveTimeout);
} else {
attach.setTimeout(soTimeout);
}
}
}
示例3: setCometTimeouts
import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected void setCometTimeouts(SocketWrapper<NioChannel> socketWrapper) {
// Comet support
SelectionKey key = socketWrapper.getSocket().getIOChannel().keyFor(
socketWrapper.getSocket().getPoller().getSelector());
if (key != null) {
NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment) key.attachment();
if (attach != null) {
attach.setComet(comet);
if (comet) {
Integer comettimeout = (Integer) request.getAttribute(
org.apache.coyote.Constants.COMET_TIMEOUT_ATTR);
if (comettimeout != null) {
attach.setTimeout(comettimeout.longValue());
}
}
}
}
}
示例4: resetTimeouts
import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected void resetTimeouts() {
// The NIO connector uses the timeout configured on the wrapper in the
// poller. Therefore, it needs to be reset once asycn processing has
// finished.
final KeyAttachment attach = (KeyAttachment) socketWrapper.getSocket().getAttachment();
if (!getErrorState().isError() && attach != null && asyncStateMachine.isAsyncDispatching()) {
long soTimeout = endpoint.getSoTimeout();
// reset the timeout
if (keepAliveTimeout > 0) {
attach.setTimeout(keepAliveTimeout);
} else {
attach.setTimeout(soTimeout);
}
}
}
示例5: setCometTimeouts
import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected void setCometTimeouts(SocketWrapper<NioChannel> socketWrapper) {
// Comet support
SelectionKey key = socketWrapper.getSocket().getIOChannel()
.keyFor(socketWrapper.getSocket().getPoller().getSelector());
if (key != null) {
NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment) key.attachment();
if (attach != null) {
attach.setComet(comet);
if (comet) {
Integer comettimeout = (Integer) request
.getAttribute(org.apache.coyote.Constants.COMET_TIMEOUT_ATTR);
if (comettimeout != null) {
attach.setTimeout(comettimeout.longValue());
}
}
}
}
}
示例6: actionInternal
import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
/**
* Send an action to the connector.
*
* @param actionCode Type of the action
* @param param Action parameter
*/
@Override
protected void actionInternal(ActionCode actionCode, Object param) {
if (actionCode == ActionCode.ASYNC_COMPLETE) {
if (asyncStateMachine.asyncComplete()) {
((NioEndpoint)endpoint).processSocket(this.socketWrapper.getSocket(),
SocketStatus.OPEN_READ, false);
}
} else if (actionCode == ActionCode.ASYNC_SETTIMEOUT) {
if (param == null) return;
long timeout = ((Long)param).longValue();
final KeyAttachment ka =
(KeyAttachment)socketWrapper.getSocket().getAttachment(false);
ka.setTimeout(timeout);
} else if (actionCode == ActionCode.ASYNC_DISPATCH) {
if (asyncStateMachine.asyncDispatch()) {
((NioEndpoint)endpoint).processSocket(this.socketWrapper.getSocket(),
SocketStatus.OPEN_READ, true);
}
}
}
示例7: resetTimeouts
import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected void resetTimeouts() {
// The NIO connector uses the timeout configured on the wrapper in the
// poller. Therefore, it needs to be reset once asycn processing has
// finished.
final KeyAttachment attach =
(KeyAttachment)socketWrapper.getSocket().getAttachment(false);
if (!error && attach != null &&
asyncStateMachine.isAsyncDispatching()) {
long soTimeout = endpoint.getSoTimeout();
//reset the timeout
if (keepAliveTimeout > 0) {
attach.setTimeout(keepAliveTimeout);
} else {
attach.setTimeout(soTimeout);
}
}
}
示例8: breakKeepAliveLoop
import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected boolean breakKeepAliveLoop(
SocketWrapper<NioChannel> socketWrapper) {
openSocket = keepAlive;
// Do sendfile as needed: add socket to sendfile and end
if (sendfileData != null && !error) {
((KeyAttachment) socketWrapper).setSendfileData(sendfileData);
sendfileData.keepAlive = keepAlive;
SelectionKey key = socketWrapper.getSocket().getIOChannel().keyFor(
socketWrapper.getSocket().getPoller().getSelector());
//do the first write on this thread, might as well
if (socketWrapper.getSocket().getPoller().processSendfile(key,
(KeyAttachment) socketWrapper, true)) {
sendfileInProgress = true;
} else {
// Write failed
if (log.isDebugEnabled()) {
log.debug(sm.getString("http11processor.sendfile.error"));
}
error = true;
}
return true;
}
return false;
}
示例9: resetTimeouts
import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected void resetTimeouts() {
// The NIO connector uses the timeout configured on the wrapper in the
// poller. Therefore, it needs to be reset once asycn processing has
// finished.
final KeyAttachment attach =
(KeyAttachment)socketWrapper.getSocket().getAttachment(false);
if (!getErrorState().isError() && attach != null &&
asyncStateMachine.isAsyncDispatching()) {
long soTimeout = endpoint.getSoTimeout();
//reset the timeout
if (keepAliveTimeout > 0) {
attach.setTimeout(keepAliveTimeout);
} else {
attach.setTimeout(soTimeout);
}
}
}
示例10: breakKeepAliveLoop
import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected boolean breakKeepAliveLoop(SocketWrapper<NioChannel> socketWrapper) {
openSocket = keepAlive;
// Do sendfile as needed: add socket to sendfile and end
if (sendfileData != null && !getErrorState().isError()) {
((KeyAttachment) socketWrapper).setSendfileData(sendfileData);
sendfileData.keepAlive = keepAlive;
SelectionKey key = socketWrapper.getSocket().getIOChannel().keyFor(
socketWrapper.getSocket().getPoller().getSelector());
//do the first write on this thread, might as well
if (socketWrapper.getSocket().getPoller().processSendfile(key,
(KeyAttachment) socketWrapper, true)) {
sendfileInProgress = true;
} else {
// Write failed
if (log.isDebugEnabled()) {
log.debug(sm.getString("http11processor.sendfile.error"));
}
setErrorState(ErrorState.CLOSE_NOW, null);
}
return true;
}
return false;
}
示例11: actionInternal
import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
/**
* Send an action to the connector.
*
* @param actionCode Type of the action
* @param param Action parameter
*/
@Override
protected void actionInternal(ActionCode actionCode, Object param) {
if (actionCode == ActionCode.ASYNC_COMPLETE) {
if (asyncStateMachine.asyncComplete()) {
((NioEndpoint)endpoint).processSocket(this.socket,
SocketStatus.OPEN, false);
}
} else if (actionCode == ActionCode.ASYNC_SETTIMEOUT) {
if (param == null) return;
long timeout = ((Long)param).longValue();
final KeyAttachment ka = (KeyAttachment)socket.getAttachment(false);
if (keepAliveTimeout > 0) {
ka.setTimeout(timeout);
}
} else if (actionCode == ActionCode.ASYNC_DISPATCH) {
if (asyncStateMachine.asyncDispatch()) {
((NioEndpoint)endpoint).processSocket(this.socket,
SocketStatus.OPEN, true);
}
}
}
示例12: output
import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected void output(byte[] src, int offset, int length)
throws IOException {
ByteBuffer writeBuffer = socket.getBufHandler() .getWriteBuffer();
writeBuffer.put(src, offset, length);
writeBuffer.flip();
NioEndpoint.KeyAttachment att = (NioEndpoint.KeyAttachment)socket.getAttachment(false);
if ( att == null ) throw new IOException("Key must be cancelled");
long writeTimeout = att.getTimeout();
Selector selector = null;
try {
selector = pool.get();
} catch ( IOException x ) {
//ignore
}
try {
pool.write(writeBuffer, socket, selector, writeTimeout, true,
null);
}finally {
if ( selector != null ) pool.put(selector);
}
writeBuffer.clear();
}
示例13: longPoll
import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected void longPoll(SocketWrapper<NioChannel> socket,
Http11NioProcessor processor) {
connections.put(socket.getSocket(), processor);
if (processor.isAsync()) {
socket.setAsync(true);
} else {
// Either:
// - this is comet request
// - the request line/headers have not been completely
// read
SelectionKey key = socket.getSocket().getIOChannel().keyFor(
socket.getSocket().getPoller().getSelector());
key.interestOps(SelectionKey.OP_READ);
((KeyAttachment) socket).interestOps(
SelectionKey.OP_READ);
}
}
示例14: setCometTimeouts
import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected void setCometTimeouts(SocketWrapper<NioChannel> socketWrapper) {
// Comet support
SelectionKey key = socketWrapper.getSocket().getIOChannel().keyFor(
socketWrapper.getSocket().getPoller().getSelector());
if (key != null) {
NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment) key.attachment();
if (attach != null) {
attach.setComet(comet);
if (comet) {
Integer comettimeout = (Integer) request.getAttribute("org.apache.tomcat.comet.timeout");
if (comettimeout != null) attach.setTimeout(comettimeout.longValue());
}
}
}
}
示例15: breakKeepAliveLoop
import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected boolean breakKeepAliveLoop(
SocketWrapper<NioChannel> socketWrapper) {
// Do sendfile as needed: add socket to sendfile and end
if (sendfileData != null && !error) {
((KeyAttachment) socketWrapper).setSendfileData(sendfileData);
sendfileData.keepAlive = keepAlive;
SelectionKey key = socketWrapper.getSocket().getIOChannel().keyFor(
socketWrapper.getSocket().getPoller().getSelector());
//do the first write on this thread, might as well
openSocket = socketWrapper.getSocket().getPoller().processSendfile(key,
(KeyAttachment) socketWrapper, true, true);
return true;
}
return false;
}