本文整理了Java中com.sun.grizzly.util.Utils
类的一些代码示例,展示了Utils
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils
类的具体详情如下:
包路径:com.sun.grizzly.util.Utils
类名称:Utils
[英]Class contains set of useful operations commonly used in the framework
[中]类包含框架中常用的一组有用操作
代码示例来源:origin: com.sun.grizzly/grizzly-utils
protected int doClearRead() throws IOException{
Utils.Result r = Utils.readWithTemporarySelector(key.channel(),
byteBuffer, readTimeout);
byteBuffer.flip();
isClosed = r.isClosed;
return r.bytesRead;
}
代码示例来源:origin: com.sun.grizzly/grizzly-http
/**
* Introspect the request and determine if the target url can
* execute under {@link AsyncHandler} or not.
* @param bb The current byteBuffer.
* @param handlerCode - no used.
* @return An {@link Interceptor} value determining if an {@link AsyncHandler}
* should be allowed to execute or not.
* @throws java.io.IOException
*/
public int handle(ByteBuffer bb, int handlerCode) throws IOException {
int pos = bb.position();
int limit = bb.limit();
try{
// TODO: Add patten matching.
for (byte[] b: allowed){
if (Utils.findBytes(bb,b) > -1){
return Interceptor.CONTINUE;
}
}
} finally {
bb.position(pos);
bb.limit(limit);
}
return Interceptor.BREAK;
}
代码示例来源:origin: com.sun.grizzly/grizzly-utils
public static List<String> toHexStrings(byte[] bytes) {
return toHexStrings(bytes, 0, bytes.length);
}
代码示例来源:origin: com.sun.grizzly/grizzly-utils
/**
* Please ensure to use try finally around get and return of selector so avoid leaks.
* Get a exclusive {@link Selector}
* @return {@link Selector}
*/
public static Selector getSelector() {
Selector selector = selectors.poll();
if (selector != null) {
poolSize.decrementAndGet();
} else {
try {
selector = Utils.openSelector();
} catch (IOException e) {
LoggerUtils.getLogger().log(Level.WARNING,
"SelectorFactory. Can not create a selector", e);
}
final int missesCount = missesCounter.incrementAndGet();
if (missesCount % MISS_THRESHOLD == 0) {
LoggerUtils.getLogger().log(Level.WARNING,
"SelectorFactory. Pool encounters a lot of misses {0}. "
+ "Increase default {1} pool size",
new Object[] {missesCount, maxSelectors});
}
}
return selector;
}
代码示例来源:origin: com.sun.grizzly/grizzly-config
/**
* Configures an HTTP grizzlyListener with the given request-processing config.
*/
private void configureThreadPool(NetworkListener networkListener, ThreadPool threadPool,
final String transactionTimeoutSec) {
if (threadPool == null) {
return;
}
try {
final int maxQueueSize = Integer.parseInt(threadPool.getMaxQueueSize());
final int minThreads = Integer.parseInt(threadPool.getMinThreadPoolSize());
final int maxThreads = Integer.parseInt(threadPool.getMaxThreadPoolSize());
final int keepAlive = Integer.parseInt(threadPool.getIdleThreadTimeoutSeconds());
final int ttSec = Integer.parseInt(transactionTimeoutSec);
final String name = Utils.composeThreadPoolName(networkListener);
setThreadPool(newThreadPool(name, minThreads, maxThreads, maxQueueSize,
keepAlive < 0 ? Long.MAX_VALUE : keepAlive * 1000, TimeUnit.MILLISECONDS));
setCoreThreads(minThreads);
setMaxThreads(maxThreads);
if (!com.sun.grizzly.util.Utils.isDebugVM() && ttSec > 0) {
// Idle Threads cannot be alive more than 15 minutes by default
setTransactionTimeout(ttSec * 1000);
} else {
// Disable the mechanism
setTransactionTimeout(-1);
}
} catch (NumberFormatException ex) {
logger.log(Level.WARNING, " Invalid thread-pool attribute", ex);
}
}
代码示例来源:origin: com.sun.grizzly/grizzly-http-utils
protected int doClearRead() throws IOException{
int bytesRead = Utils.readWithTemporarySelector(key.channel(),
byteBuffer, readTimeout);
byteBuffer.flip();
return bytesRead;
}
代码示例来源:origin: com.sun.grizzly/grizzly-websockets
private List<String> getByteList(final int start, final int end) {
return Utils.toHexStrings(chunk.getBytes(), start, end);
}
代码示例来源:origin: org.glassfish.external/grizzly-module
while(iterator.hasNext()){
matchBytes = iterator.next();
if (Utils.findBytes(bb,matchBytes) > -1){
log("Find match: " + (new String(matchBytes))
+ " Suspending: " + ctx.getSelectionKey());
代码示例来源:origin: org.glassfish.external/grizzly-module
protected int doClearRead() throws IOException{
int bytesRead = Utils.readWithTemporarySelector(key.channel(),
byteBuffer, readTimeout);
byteBuffer.flip();
return bytesRead;
}
代码示例来源:origin: org.glassfish.external/grizzly-module
int bytesRead = Utils.readWithTemporarySelector(channel,
inputBB, timeout);
代码示例来源:origin: com.sun.grizzly/grizzly-http-utils
int bytesRead = Utils.readWithTemporarySelector(channel,
inputBB, timeout);
代码示例来源:origin: com.sun.grizzly/grizzly-utils
r = Utils.readWithTemporarySelector(channel,
inputBB, timeout);
代码示例来源:origin: com.sun.grizzly/grizzly-http
int count = Utils.readWithTemporarySelector(
protocolRequest.getChannel(), tmpBuffer, 20).bytesRead;
if (count == -1) {
代码示例来源:origin: com.sun.grizzly/grizzly-config
return Utils.readWithTemporarySelector(key.channel(),
thread.getByteBuffer(), timeout).bytesRead;
} else {
代码示例来源:origin: org.glassfish.external/grizzly-module
int count = Utils.readWithTemporarySelector(
protocolRequest.getChannel(), tmpBuffer, 2);
if (count == -1) {
代码示例来源:origin: com.sun.grizzly/grizzly-config
Utils.Result result = null;
try {
result = Utils.readWithTemporarySelector(channel, bb, 20);
} catch (Exception ignored) {
代码示例来源:origin: org.glassfish.external/grizzly-module
int bytesRead = Utils.readWithTemporarySelector(
selectionKey.channel(),
protocolRequest.getByteBuffer(), readTimeout);
代码示例来源:origin: com.sun.grizzly/grizzly-portunif
bytesRead = Utils.readWithTemporarySelector(
selectionKey.channel(),
protocolRequest.getByteBuffer(), readTimeout).bytesRead;
代码示例来源:origin: com.sun.grizzly/portunif
int bytesRead = Utils.readWithTemporarySelector(
selectionKey.channel(),
protocolRequest.getByteBuffer(), readTimeout);
内容来源于网络,如有侵权,请联系作者删除!