• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java KeyAttachment类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



KeyAttachment类属于org.apache.tomcat.util.net.NioEndpoint包,在下文中一共展示了KeyAttachment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
        }
    }

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:21,代码来源:AjpNioProcessor.java


示例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);
        }
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:16,代码来源:Http11NioProcessor.java


示例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());
                }
            }
        }
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:20,代码来源:Http11NioProcessor.java


示例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);
		}
	}

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:19,代码来源:AjpNioProcessor.java


示例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());
				}
			}
		}
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:20,代码来源:Http11NioProcessor.java


示例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);
        }
    }
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:30,代码来源:AjpNioProcessor.java


示例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);
        }
    }

}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:21,代码来源:AjpNioProcessor.java


示例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;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:26,代码来源:Http11NioProcessor.java


示例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);
        }
    }

}
 
开发者ID:sdw2330976,项目名称:apache-tomcat-7.0.57,代码行数:21,代码来源:AjpNioProcessor.java


示例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;
}
 
开发者ID:sdw2330976,项目名称:apache-tomcat-7.0.57,代码行数:25,代码来源:Http11NioProcessor.java


示例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);
        }
    }
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:29,代码来源:AjpNioProcessor.java


示例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();
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:27,代码来源:AjpNioProcessor.java


示例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);
    }
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:20,代码来源:Http11NioProtocol.java


示例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());
            }
        }
    }
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:17,代码来源:Http11NioProcessor.java


示例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;
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:17,代码来源:Http11NioProcessor.java


示例16: action

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
@SuppressWarnings("incomplete-switch") // Other cases are handled by action()
protected void actionInternal(ActionCode actionCode, Object param) {

    switch (actionCode) {
    case ASYNC_COMPLETE: {
        if (asyncStateMachine.asyncComplete()) {
            ((NioEndpoint)endpoint).processSocket(this.socketWrapper.getSocket(),
                    SocketStatus.OPEN_READ, false);
        }
        break;
    }
    case ASYNC_SETTIMEOUT: {
        if (param == null) return;
        long timeout = ((Long)param).longValue();
        final KeyAttachment ka =
                (KeyAttachment)socketWrapper.getSocket().getAttachment();
        ka.setTimeout(timeout);
        break;
    }
    case ASYNC_DISPATCH: {
        if (asyncStateMachine.asyncDispatch()) {
            ((NioEndpoint)endpoint).processSocket(this.socketWrapper.getSocket(),
                    SocketStatus.OPEN_READ, true);
        }
        break;
    }
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:36,代码来源:AjpNioProcessor.java


示例17: output

import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected void output(byte[] src, int offset, int length)
        throws IOException {
    
    KeyAttachment att =
            (KeyAttachment) socketWrapper.getSocket().getAttachment();
    if ( att == null ) throw new IOException("Key must be cancelled");

    ByteBuffer writeBuffer =
            socketWrapper.getSocket().getBufHandler().getWriteBuffer();

    int thisTime = 0;
    int written = 0;
    while (written < length) {
        int toWrite = Math.min(length - written, writeBuffer.remaining());
        writeBuffer.put(src, offset + written, toWrite);
        
        writeBuffer.flip();

        long writeTimeout = att.getWriteTimeout();
        Selector selector = null;
        try {
            selector = pool.get();
        } catch ( IOException x ) {
            //ignore
        }
        try {
            thisTime = pool.write(writeBuffer, socketWrapper.getSocket(),
                    selector, writeTimeout, true);
        } finally { 
            writeBuffer.clear();
            if ( selector != null ) pool.put(selector);
        }
        written += thisTime;
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:37,代码来源:AjpNioProcessor.java


示例18: 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
        switch (socketWrapper.getSocket().getPoller().processSendfile(
                key, (KeyAttachment) socketWrapper, true)) {
        case DONE:
            // If sendfile is complete, no need to break keep-alive loop
            sendfileData = null;
            return false;
        case PENDING:
            sendfileInProgress = true;
            return true;
        case ERROR:
            // Write failed
            if (log.isDebugEnabled()) {
                log.debug(sm.getString("http11processor.sendfile.error"));
            }
            setErrorState(ErrorState.CLOSE_NOW, null);
            return true;
        }
    }
    return false;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:31,代码来源:Http11NioProcessor.java


示例19: cancel

import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
public void cancel(SelectionKey sk, KeyAttachment key, int ops){
    if (sk!=null) {
        sk.cancel();
        sk.attach(null);
        if (SelectionKey.OP_WRITE==(ops&SelectionKey.OP_WRITE)) countDown(key.getWriteLatch());
        if (SelectionKey.OP_READ==(ops&SelectionKey.OP_READ))countDown(key.getReadLatch());
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:9,代码来源:NioBlockingSelector.java


示例20: remove

import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
public void remove(final KeyAttachment key, final int ops) {
    Runnable r = new Runnable() {
        @Override
        public void run() {
            if ( key == null ) return;
            NioChannel nch = key.getChannel();
            if ( nch == null ) return;
            SocketChannel ch = nch.getIOChannel();
            if ( ch == null ) return;
            SelectionKey sk = ch.keyFor(selector);
            try {
                if (sk == null) {
                    if (SelectionKey.OP_WRITE==(ops&SelectionKey.OP_WRITE)) countDown(key.getWriteLatch());
                    if (SelectionKey.OP_READ==(ops&SelectionKey.OP_READ))countDown(key.getReadLatch());
                } else {
                    if (sk.isValid()) {
                        sk.interestOps(sk.interestOps() & (~ops));
                        if (SelectionKey.OP_WRITE==(ops&SelectionKey.OP_WRITE)) countDown(key.getWriteLatch());
                        if (SelectionKey.OP_READ==(ops&SelectionKey.OP_READ))countDown(key.getReadLatch());
                        if (sk.interestOps()==0) {
                            sk.cancel();
                            sk.attach(null);
                        }
                    }else {
                        sk.cancel();
                        sk.attach(null);
                    }
                }
            }catch (CancelledKeyException cx) {
                if (sk!=null) {
                    sk.cancel();
                    sk.attach(null);
                }
            }
        }
    };
    events.offer(r);
    wakeup();
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:40,代码来源:NioBlockingSelector.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java INimbus类代码示例发布时间:2022-05-22
下一篇:
Java MKSuggestionResult类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap