本文整理汇总了Java中org.apache.tomcat.jni.Pool类的典型用法代码示例。如果您正苦于以下问题:Java Pool类的具体用法?Java Pool怎么用?Java Pool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Pool类属于org.apache.tomcat.jni包,在下文中一共展示了Pool类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.apache.tomcat.jni.Pool; //导入依赖的package包/类
/**
* Create the sendfile poller. With some versions of APR, the maximum
* poller size will be 62 (recompiling APR is necessary to remove this
* limitation).
*/
protected void init() {
pool = Pool.create(serverSockPool);
int size = sendfileSize;
if (size <= 0) {
size = (OS.IS_WIN32 || OS.IS_WIN64) ? (1 * 1024) : (16 * 1024);
}
sendfilePollset = allocatePoller(size, pool, getSoTimeout());
if (sendfilePollset == 0 && size > 1024) {
size = 1024;
sendfilePollset = allocatePoller(size, pool, getSoTimeout());
}
if (sendfilePollset == 0) {
size = 62;
sendfilePollset = allocatePoller(size, pool, getSoTimeout());
}
desc = new long[size * 2];
sendfileData = new HashMap<Long, SendfileData>(size);
addS = new ArrayList<SendfileData>();
}
示例2: destroy
import org.apache.tomcat.jni.Pool; //导入依赖的package包/类
/**
* Deallocate APR memory pools, and close server socket.
*/
public void destroy() throws Exception {
if (running) {
stop();
}
Pool.destroy(serverSockPool);
serverSockPool = 0;
// Close server socket
Socket.close(serverSock);
serverSock = 0;
sslContext = 0;
// Close all APR memory pools and resources
Pool.destroy(rootPool);
rootPool = 0;
initialized = false;
}
示例3: init
import org.apache.tomcat.jni.Pool; //导入依赖的package包/类
/**
* Create the sendfile poller. With some versions of APR, the maximum poller size will
* be 62 (recompiling APR is necessary to remove this limitation).
*/
protected void init() {
pool = Pool.create(serverSockPool);
int size = sendfileSize;
sendfilePollset = allocatePoller(size, pool, soTimeout);
if (sendfilePollset == 0 && size > 1024) {
size = 1024;
sendfilePollset = allocatePoller(size, pool, soTimeout);
}
if (sendfilePollset == 0) {
size = 62;
sendfilePollset = allocatePoller(size, pool, soTimeout);
}
desc = new long[size * 2];
sendfileData = new HashMap<Long, SendfileData>(size);
addS = new ArrayList<SendfileData>();
}
示例4: init
import org.apache.tomcat.jni.Pool; //导入依赖的package包/类
/**
* Create the sendfile poller. With some versions of APR, the maximum
* poller size will be 62 (recompiling APR is necessary to remove this
* limitation).
*/
protected void init() {
pool = Pool.create(serverSockPool);
int size = sendfileSize;
if (size <= 0) {
size = (OS.IS_WIN32 || OS.IS_WIN64) ? (1 * 1024) : (16 * 1024);
}
sendfilePollset = allocatePoller(size, pool, getSoTimeout());
if (sendfilePollset == 0 && size > 1024) {
size = 1024;
sendfilePollset = allocatePoller(size, pool, getSoTimeout());
}
if (sendfilePollset == 0) {
size = 62;
sendfilePollset = allocatePoller(size, pool, getSoTimeout());
}
desc = new long[size * 2];
sendfileData = new HashMap<Long, SendfileData>(size);
addS = new ArrayList<SendfileData>();
}
示例5: destroyPull
import org.apache.tomcat.jni.Pool; //导入依赖的package包/类
void destroyPull() {
if (shutdowned)
return;
// Causes segfault in AprSocketSource.poll() method, so this function must be called from it
try {
Socket.close(socket);
// or
// Socket.shutdown(socket, Socket.APR_SHUTDOWN_READWRITE);
Pool.destroy(pool);
} catch (Exception e) {
s_logger.info("[ignored]"
+ "failure during network cleanup: " + e.getLocalizedMessage());
}
}
示例6: init
import org.apache.tomcat.jni.Pool; //导入依赖的package包/类
/**
* Create the sendfile poller. With some versions of APR, the maximum poller size will
* be 62 (recompiling APR is necessary to remove this limitation).
*/
protected void init() {
pool = Pool.create(serverSockPool);
int size = sendfileSize / sendfileThreadCount;
sendfilePollset = allocatePoller(size, pool, socketProperties.getSoTimeout());
if (sendfilePollset == 0 && size > 1024) {
size = 1024;
sendfilePollset = allocatePoller(size, pool, socketProperties.getSoTimeout());
}
if (sendfilePollset == 0) {
size = 62;
sendfilePollset = allocatePoller(size, pool, socketProperties.getSoTimeout());
}
desc = new long[size * 2];
sendfileData = new HashMap<Long, SendfileData>(size);
addS = new ArrayList<SendfileData>();
addCount = 0;
}
示例7: unbind
import org.apache.tomcat.jni.Pool; //导入依赖的package包/类
/**
* Deallocate APR memory pools, and close server socket.
*/
@Override
public void unbind() throws Exception {
if (running) {
stop();
}
// Destroy pool if it was initialised
if (serverSockPool != 0) {
Pool.destroy(serverSockPool);
serverSockPool = 0;
}
// Close server socket if it was initialised
if (serverSock != 0) {
Socket.close(serverSock);
serverSock = 0;
}
sslContext = 0;
// Close all APR memory pools and resources if initialised
if (rootPool != 0) {
Pool.destroy(rootPool);
rootPool = 0;
}
handler.recycle();
}
示例8: destroy
import org.apache.tomcat.jni.Pool; //导入依赖的package包/类
/**
* Destroy the poller.
*/
protected void destroy() {
sendfileRunning = false;
// Wait for polltime before doing anything, so that the poller threads
// exit, otherwise parallel destruction of sockets which are still
// in the poller can cause problems
try {
synchronized (this) {
this.notify();
this.wait(pollTime / 1000);
}
} catch (InterruptedException e) {
// Ignore
}
// Close any socket remaining in the add queue
for (int i = (addS.size() - 1); i >= 0; i--) {
SendfileData data = addS.get(i);
closeSocket(data.socket);
}
// Close all sockets still in the poller
int rv = Poll.pollset(sendfilePollset, desc);
if (rv > 0) {
for (int n = 0; n < rv; n++) {
closeSocket(desc[n*2+1]);
}
}
Pool.destroy(pool);
sendfileData.clear();
}
示例9: add
import org.apache.tomcat.jni.Pool; //导入依赖的package包/类
/**
* Add the sendfile data to the sendfile poller. Note that in most cases,
* the initial non blocking calls to sendfile will return right away, and
* will be handled asynchronously inside the kernel. As a result,
* the poller will never be used.
*
* @param data containing the reference to the data which should be snet
* @return true if all the data has been sent right away, and false
* otherwise
*/
public boolean add(SendfileData data) {
// Initialize fd from data given
try {
data.fdpool = Socket.pool(data.socket);
data.fd = File.open
(data.fileName, File.APR_FOPEN_READ
| File.APR_FOPEN_SENDFILE_ENABLED | File.APR_FOPEN_BINARY,
0, data.fdpool);
data.pos = data.start;
// Set the socket to nonblocking mode
Socket.timeoutSet(data.socket, 0);
while (true) {
long nw = Socket.sendfilen(data.socket, data.fd,
data.pos, data.end - data.pos, 0);
if (nw < 0) {
if (!(-nw == Status.EAGAIN)) {
Pool.destroy(data.fdpool);
data.socket = 0;
return false;
} else {
// Break the loop and add the socket to poller.
break;
}
} else {
data.pos = data.pos + nw;
if (data.pos >= data.end) {
// Entire file has been sent
Pool.destroy(data.fdpool);
// Set back socket to blocking mode
Socket.timeoutSet(
data.socket, getSoTimeout() * 1000);
return true;
}
}
}
} catch (Exception e) {
log.warn(sm.getString("endpoint.sendfile.error"), e);
return false;
}
// Add socket to the list. Newly added sockets will wait
// at most for pollTime before being polled
synchronized (this) {
addS.add(data);
this.notify();
}
return false;
}
示例10: createAprPool
import org.apache.tomcat.jni.Pool; //导入依赖的package包/类
private long createAprPool() {
// Create the pool for the server socket
try {
return Pool.create(0);
} catch (UnsatisfiedLinkError e) {
log.error("Could not create socket pool", e);
return 0;
}
}
示例11: destroyAprSocket
import org.apache.tomcat.jni.Pool; //导入依赖的package包/类
private void destroyAprSocket(long serverSock, long pool) {
if (serverSock != 0) {
Socket.shutdown(serverSock, Socket.APR_SHUTDOWN_READWRITE);
Socket.close(serverSock);
Socket.destroy(serverSock);
}
if (pool != 0) {
Pool.destroy(pool);
pool = 0;
}
}
示例12: unbind
import org.apache.tomcat.jni.Pool; //导入依赖的package包/类
/**
* Deallocate APR memory pools, and close server socket.
*/
@Override
public void unbind() throws Exception {
if (running) {
stop();
}
// Destroy pool if it was initialised
if (serverSockPool != 0) {
Pool.destroy(serverSockPool);
serverSockPool = 0;
}
// Close server socket if it was initialised
if (serverSock != 0) {
Socket.close(serverSock);
serverSock = 0;
}
sslContext = 0;
// Close all APR memory pools and resources if initialised
if (rootPool != 0) {
Pool.destroy(rootPool);
rootPool = 0;
}
handler.recycle();
}
示例13: destroy
import org.apache.tomcat.jni.Pool; //导入依赖的package包/类
/**
* Destroy the poller.
*/
protected void destroy() {
sendfileRunning = false;
// Wait for polltime before doing anything, so that the poller
// threads
// exit, otherwise parallel destruction of sockets which are still
// in the poller can cause problems
try {
synchronized (this) {
this.notify();
this.wait(pollTime / 1000);
}
} catch (InterruptedException e) {
// Ignore
}
// Close any socket remaining in the add queue
for (int i = (addS.size() - 1); i >= 0; i--) {
SendfileData data = addS.get(i);
closeSocket(data.socket);
}
// Close all sockets still in the poller
int rv = Poll.pollset(sendfilePollset, desc);
if (rv > 0) {
for (int n = 0; n < rv; n++) {
closeSocket(desc[n * 2 + 1]);
}
}
Pool.destroy(pool);
sendfileData.clear();
}
示例14: destroy
import org.apache.tomcat.jni.Pool; //导入依赖的package包/类
/**
* Destroy the poller.
*/
@Override
public void destroy() {
// Close all sockets in the add queue
for (int i = 0; i < addCount; i++) {
if (comet) {
processSocket(addSocket[i], SocketStatus.STOP);
} else {
destroySocket(addSocket[i]);
}
}
// Close all sockets still in the pollers
closePollset(connectionPollset);
if (separateKeepAlive) {
closePollset(keepAlivePollset);
}
Pool.destroy(pool);
keepAliveCount = 0;
addCount = 0;
try {
while (this.isAlive()) {
this.interrupt();
this.join(1000);
}
} catch (InterruptedException e) {
// Ignore
}
}