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

Java OS类代码示例

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

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



OS类属于org.apache.tomcat.jni包,在下文中一共展示了OS类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: init

import org.apache.tomcat.jni.OS; //导入依赖的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>();
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:25,代码来源:AprEndpoint.java


示例2: init

import org.apache.tomcat.jni.OS; //导入依赖的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>();
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:25,代码来源:AprEndpoint.java


示例3: createAprSocket

import org.apache.tomcat.jni.OS; //导入依赖的package包/类
private long createAprSocket(int port, long pool)
             throws Exception {
    /**
     * Server socket "pointer".
     */
    long serverSock = 0;

    String address = InetAddress.getByName("localhost").getHostAddress();

    // Create the APR address that will be bound
    int family = Socket.APR_INET;
    if (Library.APR_HAVE_IPV6) {
        if (!OS.IS_BSD && !OS.IS_WIN32 && !OS.IS_WIN64)
            family = Socket.APR_UNSPEC;
     }

    long inetAddress = 0;
    try {
        inetAddress = Address.info(address, family,
                                   port, 0, pool);
        // Create the APR server socket
        serverSock = Socket.create(Address.getInfo(inetAddress).family,
                                   Socket.SOCK_STREAM,
                                   Socket.APR_PROTO_TCP, pool);
    } catch (Exception ex) {
        log.error("Could not create socket for address '" + address + "'");
        return 0;
    }

    if (OS.IS_UNIX) {
        Socket.optSet(serverSock, Socket.APR_SO_REUSEADDR, 1);
    }
    // Deal with the firewalls that tend to drop the inactive sockets
    Socket.optSet(serverSock, Socket.APR_SO_KEEPALIVE, 1);
    // Bind the server socket
    int ret = Socket.bind(serverSock, inetAddress);
    if (ret != 0) {
        log.error("Could not bind: " + Error.strerror(ret));
        throw (new Exception(Error.strerror(ret)));
    }
    return serverSock;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:43,代码来源:TestXxxEndpoint.java


示例4: doWriteInternal

import org.apache.tomcat.jni.OS; //导入依赖的package包/类
private int doWriteInternal(byte[] b, int off, int len) throws IOException {

        int start = off;
        int left = len;
        int written;

        do {
            if (endpoint.isSSLEnabled()) {
                if (sslOutputBuffer.remaining() == 0) {
                    // Buffer was fully written last time around
                    sslOutputBuffer.clear();
                    if (left < SSL_OUTPUT_BUFFER_SIZE) {
                        sslOutputBuffer.put(b, start, left);
                    } else {
                        sslOutputBuffer.put(b, start, SSL_OUTPUT_BUFFER_SIZE);
                    }
                    sslOutputBuffer.flip();
                } else {
                    // Buffer still has data from previous attempt to write
                    // APR + SSL requires that exactly the same parameters are
                    // passed when re-attempting the write
                }
                written = Socket.sendb(socket, sslOutputBuffer,
                        sslOutputBuffer.position(), sslOutputBuffer.limit());
                if (written > 0) {
                    sslOutputBuffer.position(
                            sslOutputBuffer.position() + written);
                }
            } else {
                written = Socket.send(socket, b, start, left);
            }
            if (Status.APR_STATUS_IS_EAGAIN(-written)) {
                written = 0;
            } else if (-written == Status.APR_EOF) {
                throw new EOFException(sm.getString("apr.clientAbort"));
            } else if ((OS.IS_WIN32 || OS.IS_WIN64) &&
                    (-written == Status.APR_OS_START_SYSERR + 10053)) {
                // 10053 on Windows is connection aborted
                throw new EOFException(sm.getString("apr.clientAbort"));
            } else if (written < 0) {
                throw new IOException(sm.getString("apr.write.error",
                        Integer.valueOf(-written), Long.valueOf(socket), wrapper));
            }
            start += written;
            left -= written;
        } while (written > 0 && left > 0);

        if (left > 0) {
            endpoint.getPoller().add(socket, -1, false, true);
        }
        return len - left;
    }
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:53,代码来源:AprServletOutputStream.java


示例5: doRead

import org.apache.tomcat.jni.OS; //导入依赖的package包/类
@Override
protected int doRead(boolean block, byte[] b, int off, int len)
        throws IOException {

    if (closed) {
        throw new IOException(sm.getString("apr.closed", Long.valueOf(socket)));
    }

    Lock readLock = wrapper.getBlockingStatusReadLock();
    WriteLock writeLock = wrapper.getBlockingStatusWriteLock();

    boolean readDone = false;
    int result = 0;
    try {
        readLock.lock();
        if (wrapper.getBlockingStatus() == block) {
            result = Socket.recv(socket, b, off, len);
            readDone = true;
        }
    } finally {
        readLock.unlock();
    }

    if (!readDone) {
        try {
            writeLock.lock();
            wrapper.setBlockingStatus(block);
            // Set the current settings for this socket
            Socket.optSet(socket, Socket.APR_SO_NONBLOCK, (block ? 0 : 1));
            // Downgrade the lock
            try {
                readLock.lock();
                writeLock.unlock();
                result = Socket.recv(socket, b, off, len);
            } finally {
                readLock.unlock();
            }
        } finally {
            // Should have been released above but may not have been on some
            // exception paths
            if (writeLock.isHeldByCurrentThread()) {
                writeLock.unlock();
            }
        }
    }

    if (result > 0) {
        eagain = false;
        return result;
    } else if (-result == Status.EAGAIN) {
        eagain = true;
        return 0;
    } else if (-result == Status.APR_EGENERAL && wrapper.isSecure()) {
        // Not entirely sure why this is necessary. Testing to date has not
        // identified any issues with this but log it so it can be tracked
        // if it is suspected of causing issues in the future.
        if (log.isDebugEnabled()) {
            log.debug(sm.getString("apr.read.sslGeneralError",
                    Long.valueOf(socket), wrapper));
        }
        eagain = true;
        return 0;
    } else if (-result == Status.APR_EOF) {
        throw new EOFException(sm.getString("apr.clientAbort"));
    } else if ((OS.IS_WIN32 || OS.IS_WIN64) &&
            (-result == Status.APR_OS_START_SYSERR + 10053)) {
        // 10053 on Windows is connection aborted
        throw new EOFException(sm.getString("apr.clientAbort"));
    } else {
        throw new IOException(sm.getString("apr.read.error",
                Integer.valueOf(-result), Long.valueOf(socket), wrapper));
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:74,代码来源:AprServletInputStream.java


示例6: init

import org.apache.tomcat.jni.OS; //导入依赖的package包/类
/**
 * Create the poller. With some versions of APR, the maximum poller size will
 * be 62 (recompiling APR is necessary to remove this limitation).
 */
protected void init() {

    timeouts = new SocketTimeouts(pollerSize);
    
    pool = Pool.create(serverSockPool);
    actualPollerSize = pollerSize;
    if ((OS.IS_WIN32 || OS.IS_WIN64) && (actualPollerSize > 1024)) {
        // The maximum per poller to get reasonable performance is 1024
        // Adjust poller size so that it won't reach the limit
        actualPollerSize = 1024;
    }
    int timeout = keepAliveTimeout;
    if (timeout < 0) {
        timeout = soTimeout;
    }
    
    // At the moment, setting the timeout is useless, but it could get used
    // again as the normal poller could be faster using maintain. It might not
    // be worth bothering though.
    long pollset = allocatePoller(actualPollerSize, pool, -1);
    if (pollset == 0 && actualPollerSize > 1024) {
        actualPollerSize = 1024;
        pollset = allocatePoller(actualPollerSize, pool, -1);
    }
    if (pollset == 0) {
        actualPollerSize = 62;
        pollset = allocatePoller(actualPollerSize, pool, -1);
    }
    
    pollerCount = pollerSize / actualPollerSize;
    pollerTime = pollTime / pollerCount;
    
    pollers = new long[pollerCount];
    pollers[0] = pollset;
    for (int i = 1; i < pollerCount; i++) {
        pollers[i] = allocatePoller(actualPollerSize, pool, -1);
    }
    
    pollerSpace = new int[pollerCount];
    for (int i = 0; i < pollerCount; i++) {
        pollerSpace[i] = actualPollerSize;
    }

    desc = new long[actualPollerSize * 2];
    connectionCount = 0;
    addList = new SocketList(pollerSize);
    localAddList = new SocketList(pollerSize);

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:54,代码来源:AprEndpoint.java


示例7: doWriteInternal

import org.apache.tomcat.jni.OS; //导入依赖的package包/类
private int doWriteInternal(byte[] b, int off, int len) throws IOException {

		int start = off;
		int left = len;
		int written;

		do {
			if (endpoint.isSSLEnabled()) {
				if (sslOutputBuffer.remaining() == 0) {
					// Buffer was fully written last time around
					sslOutputBuffer.clear();
					if (left < SSL_OUTPUT_BUFFER_SIZE) {
						sslOutputBuffer.put(b, start, left);
					} else {
						sslOutputBuffer.put(b, start, SSL_OUTPUT_BUFFER_SIZE);
					}
					sslOutputBuffer.flip();
				} else {
					// Buffer still has data from previous attempt to write
					// APR + SSL requires that exactly the same parameters are
					// passed when re-attempting the write
				}
				written = Socket.sendb(socket, sslOutputBuffer, sslOutputBuffer.position(), sslOutputBuffer.limit());
				if (written > 0) {
					sslOutputBuffer.position(sslOutputBuffer.position() + written);
				}
			} else {
				written = Socket.send(socket, b, start, left);
			}
			if (Status.APR_STATUS_IS_EAGAIN(-written)) {
				written = 0;
			} else if (-written == Status.APR_EOF) {
				throw new EOFException(sm.getString("apr.clientAbort"));
			} else if ((OS.IS_WIN32 || OS.IS_WIN64) && (-written == Status.APR_OS_START_SYSERR + 10053)) {
				// 10053 on Windows is connection aborted
				throw new EOFException(sm.getString("apr.clientAbort"));
			} else if (written < 0) {
				throw new IOException(
						sm.getString("apr.write.error", Integer.valueOf(-written), Long.valueOf(socket), wrapper));
			}
			start += written;
			left -= written;
		} while (written > 0 && left > 0);

		if (left > 0) {
			endpoint.getPoller().add(socket, -1, false, true);
		}
		return len - left;
	}
 
开发者ID:how2j,项目名称:lazycat,代码行数:50,代码来源:AprServletOutputStream.java


示例8: doRead

import org.apache.tomcat.jni.OS; //导入依赖的package包/类
@Override
protected int doRead(boolean block, byte[] b, int off, int len) throws IOException {

	if (closed) {
		throw new IOException(sm.getString("apr.closed", Long.valueOf(socket)));
	}

	Lock readLock = wrapper.getBlockingStatusReadLock();
	WriteLock writeLock = wrapper.getBlockingStatusWriteLock();

	boolean readDone = false;
	int result = 0;
	try {
		readLock.lock();
		if (wrapper.getBlockingStatus() == block) {
			result = Socket.recv(socket, b, off, len);
			readDone = true;
		}
	} finally {
		readLock.unlock();
	}

	if (!readDone) {
		try {
			writeLock.lock();
			wrapper.setBlockingStatus(block);
			// Set the current settings for this socket
			Socket.optSet(socket, Socket.APR_SO_NONBLOCK, (block ? 0 : 1));
			// Downgrade the lock
			try {
				readLock.lock();
				writeLock.unlock();
				result = Socket.recv(socket, b, off, len);
			} finally {
				readLock.unlock();
			}
		} finally {
			// Should have been released above but may not have been on some
			// exception paths
			if (writeLock.isHeldByCurrentThread()) {
				writeLock.unlock();
			}
		}
	}

	if (result > 0) {
		eagain = false;
		return result;
	} else if (-result == Status.EAGAIN) {
		eagain = true;
		return 0;
	} else if (-result == Status.APR_EGENERAL && wrapper.isSecure()) {
		// Not entirely sure why this is necessary. Testing to date has not
		// identified any issues with this but log it so it can be tracked
		// if it is suspected of causing issues in the future.
		if (log.isDebugEnabled()) {
			log.debug(sm.getString("apr.read.sslGeneralError", Long.valueOf(socket), wrapper));
		}
		eagain = true;
		return 0;
	} else if (-result == Status.APR_EOF) {
		throw new EOFException(sm.getString("apr.clientAbort"));
	} else if ((OS.IS_WIN32 || OS.IS_WIN64) && (-result == Status.APR_OS_START_SYSERR + 10053)) {
		// 10053 on Windows is connection aborted
		throw new EOFException(sm.getString("apr.clientAbort"));
	} else {
		throw new IOException(
				sm.getString("apr.read.error", Integer.valueOf(-result), Long.valueOf(socket), wrapper));
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:71,代码来源:AprServletInputStream.java


示例9: createAprSocket

import org.apache.tomcat.jni.OS; //导入依赖的package包/类
private long createAprSocket(int port, long pool) 
             throws Exception {
    /**
     * Server socket "pointer".
     */
    long serverSock = 0;

    String address = null;
    // Create the APR address that will be bound
    int family = Socket.APR_INET;
    if (Library.APR_HAVE_IPV6) {
        if (!OS.IS_BSD && !OS.IS_WIN32 && !OS.IS_WIN64)
            family = Socket.APR_UNSPEC;
     }

    long inetAddress = 0;
    try {
        inetAddress = Address.info(address, family,
                                   port, 0, pool);
        // Create the APR server socket
        serverSock = Socket.create(Address.getInfo(inetAddress).family,
                                   Socket.SOCK_STREAM,
                                   Socket.APR_PROTO_TCP, pool);
    } catch (Exception ex) {
        log.error("Could not create socket for address '" + address + "'");
        return 0;
    }

    if (OS.IS_UNIX) {
        Socket.optSet(serverSock, Socket.APR_SO_REUSEADDR, 1);
    }
    // Deal with the firewalls that tend to drop the inactive sockets
    Socket.optSet(serverSock, Socket.APR_SO_KEEPALIVE, 1);
    // Bind the server socket
    int ret = Socket.bind(serverSock, inetAddress);
    if (ret != 0) {
        log.error("Could not bind: " + Error.strerror(ret));
        throw (new Exception(Error.strerror(ret)));
    }
    return serverSock;
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:42,代码来源:TestXxxEndpoint.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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