当前位置: 首页>>代码示例>>Java>>正文


Java Options类代码示例

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


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

示例1: getPeerCertificates

import org.xnio.Options; //导入依赖的package包/类
@Override
public Certificate[] getPeerCertificates() throws SSLPeerUnverifiedException, RenegotiationRequiredException {
    try {
        return channel.getSslSession().getPeerCertificates();
    } catch (SSLPeerUnverifiedException e) {
        try {
            SslClientAuthMode sslClientAuthMode = channel.getOption(Options.SSL_CLIENT_AUTH_MODE);
            if (sslClientAuthMode == SslClientAuthMode.NOT_REQUESTED) {
                throw new RenegotiationRequiredException();
            }
        } catch (IOException e1) {
            //ignore, will not actually happen
        }
        throw e;
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:SpdySslSessionInfo.java

示例2: getPeerCertificateChain

import org.xnio.Options; //导入依赖的package包/类
@Override
public X509Certificate[] getPeerCertificateChain() throws SSLPeerUnverifiedException, RenegotiationRequiredException {
    try {
        return channel.getSslSession().getPeerCertificateChain();
    } catch (SSLPeerUnverifiedException e) {
        try {
            SslClientAuthMode sslClientAuthMode = channel.getOption(Options.SSL_CLIENT_AUTH_MODE);
            if (sslClientAuthMode == SslClientAuthMode.NOT_REQUESTED) {
                throw new RenegotiationRequiredException();
            }
        } catch (IOException e1) {
            //ignore, will not actually happen
        }
        throw e;
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:SpdySslSessionInfo.java

示例3: optimizeWorkerOptions

import org.xnio.Options; //导入依赖的package包/类
private static void optimizeWorkerOptions(Builder builder, Config undertowConf, Logger logger) {
    if (Environment.isProd()) {
        Config workerOptions = undertowConf.getConfig(KEY_WORKER_OPTIONS);
        // defaults to 64
        int cfgCoreTaskThreads = workerOptions.getInt(KEY_WORKER_TASK_CORE_THREADS);
        int calcCoreTaskThreads = Runtime.getRuntime().availableProcessors() * WORKER_TASK_THREAD_MULTIPLIER;
        builder.setWorkerOption(Options.WORKER_TASK_CORE_THREADS, calcCoreTaskThreads > cfgCoreTaskThreads
                ? calcCoreTaskThreads : cfgCoreTaskThreads);
        // defaults to double of [worker-task-core-threads] i.e 128
        int cfgMaxTaskThreads = workerOptions.getInt(KEY_WORKER_TASK_MAX_THREADS);
        int calcMaxTaskThreads = calcCoreTaskThreads * SYS_TASK_THREAD_MULTIPLIER;
        builder.setWorkerOption(Options.WORKER_TASK_MAX_THREADS, calcMaxTaskThreads > cfgMaxTaskThreads
                ? calcMaxTaskThreads : cfgMaxTaskThreads);
        // For a 16 core system, number of worker task core and max threads will be.
        // 1. core task thread: 128 (16[cores] * 8)
        // 2. max task thread: 128 * 2 = 256
        // Default settings would have set the following.
        // 1. core task thread: 128 (16[cores] * 8)
        // 2. max task thread: 128 (Same as core task thread)
        logger.info("Undertow Worker Options optimized for AdeptJ Runtime [PROD] mode.");
    }
}
 
开发者ID:AdeptJ,项目名称:adeptj-runtime,代码行数:23,代码来源:Server.java

示例4: configureSaslMechanisms

import org.xnio.Options; //导入依赖的package包/类
private static AuthenticationConfiguration configureSaslMechanisms(Map<String, String> saslOptions, boolean isLocal, AuthenticationConfiguration authenticationConfiguration) {
    String[] mechanisms = null;
    String listed;
    if (saslOptions != null && (listed = saslOptions.get(Options.SASL_DISALLOWED_MECHANISMS.getName())) != null) {
        // Disallowed mechanisms were passed via the saslOptions map; need to convert to an XNIO option
        String[] split = listed.split(" ");
        if (isLocal) {
            mechanisms = new String[split.length + 1];
            mechanisms[0] = JBOSS_LOCAL_USER;
            System.arraycopy(split, 0, mechanisms, 1, split.length);
        } else {
            mechanisms = split;
        }
    } else if (!isLocal) {
        mechanisms = new String[]{ JBOSS_LOCAL_USER };
    }

    return (mechanisms != null && mechanisms.length > 0) ? authenticationConfiguration.setSaslMechanismSelector(SaslMechanismSelector.DEFAULT.forbidMechanisms(mechanisms)) : authenticationConfiguration;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:20,代码来源:ProtocolConnectionUtils.java

示例5: startChannels

import org.xnio.Options; //导入依赖的package包/类
public void startChannels() throws IOException, URISyntaxException {

        ProtocolConnectionConfiguration configuration = ProtocolConnectionConfiguration.create(channelServer.getEndpoint(),
                new URI("" + URI_SCHEME + "://127.0.0.1:" + PORT + ""),
                OptionMap.create(Options.SASL_POLICY_NOANONYMOUS, Boolean.FALSE, Options.SSL_ENABLED, Boolean.FALSE));
        configuration.setClientBindAddress("127.0.0.1"); // we set this to exercise this code path in ProtocolConnectionUtils.connectSync
                                                         // The path with no client bind address gets used all the time

        connection = ProtocolConnectionUtils.connectSync(configuration);
        clientChannel = connection.openChannel(TEST_CHANNEL, OptionMap.EMPTY).get();
        try {
            clientConnectedLatch.await();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:17,代码来源:RemoteChannelPairSetup.java

示例6: getFullOptions

import org.xnio.Options; //导入依赖的package包/类
protected static OptionMap getFullOptions(OperationContext context, ModelNode fullModel) throws OperationFailedException {
    OptionMap.Builder builder = OptionMap.builder();
    builder.set(Options.TCP_NODELAY, true);
    builder.set(Options.REUSE_ADDRESSES, true);

    builder.set(RemotingOptions.SASL_PROTOCOL, ConnectorCommon.SASL_PROTOCOL.resolveModelAttribute(context, fullModel).asString());
    ModelNode serverName = ConnectorCommon.SERVER_NAME.resolveModelAttribute(context, fullModel);
    if (serverName.isDefined()) {
        builder.set(RemotingOptions.SERVER_NAME, serverName.asString());
    }

    ModelNode properties = fullModel.get(PROPERTY);
    if (properties.isDefined() && properties.asInt() > 0) {
        addOptions(context, properties, builder);
    }
    if (fullModel.hasDefined(SECURITY)) {
        ModelNode security = fullModel.require(SECURITY);
        if (security.hasDefined(SASL)) {
            ModelNode sasl = security.require(SASL);
            addSasl(context, sasl, builder);
        }
    }
    return builder.getMap();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:25,代码来源:ConnectorUtils.java

示例7: start

import org.xnio.Options; //导入依赖的package包/类
public void start() {
    try {

        OptionMap.Builder serverOptionsBuilder = OptionMap.builder()
                .set(Options.TCP_NODELAY, true)
                .set(Options.REUSE_ADDRESSES, true);
        ChannelListener acceptListener = ChannelListeners.openListenerAdapter(openListener);
        if (httpAddress != null) {
            normalServer = worker.createStreamConnectionServer(httpAddress, acceptListener, serverOptionsBuilder.getMap());
            normalServer.resumeAccepts();
        }
        if (secureAddress != null) {
            if (sslClientAuthMode != null) {
                serverOptionsBuilder.set(SSL_CLIENT_AUTH_MODE, sslClientAuthMode);
            }
            OptionMap secureOptions = serverOptionsBuilder.getMap();
            XnioSsl xnioSsl = new UndertowXnioSsl(worker.getXnio(), secureOptions, sslContext);
            secureServer = xnioSsl.createSslConnectionServer(worker, secureAddress, acceptListener, secureOptions);
            secureServer.resumeAccepts();
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:25,代码来源:ManagementHttpServer.java

示例8: installService

import org.xnio.Options; //导入依赖的package包/类
public static void installService(ServiceTarget serviceTarget){
    //todo make configurable
    ManagementWorkerService service = new ManagementWorkerService(OptionMap.builder()
                        .set(Options.WORKER_IO_THREADS, 2)
                        .set(Options.WORKER_TASK_CORE_THREADS, 5)
                        .set(Options.WORKER_TASK_MAX_THREADS, 10)
                        .set(Options.TCP_NODELAY, true)
                        .set(Options.CORK, true)
                        .set(Options.WORKER_NAME, "management")
                        .getMap());

    serviceTarget.addService(SERVICE_NAME, service)
            .setInitialMode(ServiceController.Mode.ON_DEMAND) //have it on demand as it might not be needed in certain scenarios
            .install();

}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:17,代码来源:ManagementWorkerService.java

示例9: testRuntime

import org.xnio.Options; //导入依赖的package包/类
@Test
public void testRuntime() throws Exception {
    KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization())
            .setSubsystemXml(getSubsystemXml());
    KernelServices mainServices = builder.build();
    if (!mainServices.isSuccessfulBoot()) {
        Assert.fail(String.valueOf(mainServices.getBootError()));
    }
    ServiceController<XnioWorker> workerServiceController = (ServiceController<XnioWorker>) mainServices.getContainer().getService(IOServices.WORKER.append("default"));
    workerServiceController.setMode(ServiceController.Mode.ACTIVE);
    workerServiceController.awaitValue();
    XnioWorker worker = workerServiceController.getService().getValue();
    Assert.assertEquals(ProcessorInfo.availableProcessors() * 2, worker.getIoThreadCount());
    Assert.assertEquals(ProcessorInfo.availableProcessors() * 16, worker.getOption(Options.WORKER_TASK_MAX_THREADS).intValue());
    PathAddress addr = PathAddress.parseCLIStyleAddress("/subsystem=io/worker=default");
    ModelNode op = Util.createOperation("read-resource", addr);
    op.get("include-runtime").set(true);
    mainServices.executeOperation(op);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:20,代码来源:IOSubsystemTestCase.java

示例10: testRuntime

import org.xnio.Options; //导入依赖的package包/类
@Test
public void testRuntime() throws Exception {
    KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization())
            .setSubsystemXml(getSubsystemXml());
    KernelServices mainServices = builder.build();
    if (!mainServices.isSuccessfulBoot()) {
        Assert.fail(mainServices.getBootError().toString());
    }
    ServiceController<XnioWorker> workerServiceController = (ServiceController<XnioWorker>) mainServices.getContainer().getService(IOServices.WORKER.append("default"));
    workerServiceController.setMode(ServiceController.Mode.ACTIVE);
    workerServiceController.awaitValue();
    XnioWorker worker = workerServiceController.getService().getValue();
    Assert.assertEquals(ProcessorInfo.availableProcessors() * 2, worker.getIoThreadCount());
    Assert.assertEquals(ProcessorInfo.availableProcessors() * 16, worker.getOption(Options.WORKER_TASK_MAX_THREADS).intValue());
    PathAddress addr = PathAddress.parseCLIStyleAddress("/subsystem=io/worker=default");
    ModelNode op = Util.createOperation("read-resource", addr);
    op.get("include-runtime").set(true);
    mainServices.executeOperation(op);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:20,代码来源:IOSubsystem11TestCase.java

示例11: createServer

import org.xnio.Options; //导入依赖的package包/类
private AcceptingChannel<? extends StreamConnection> createServer(int sourcePort, int targetPort)
    throws IllegalArgumentException, IOException {
    OptionMap socketOptions = OptionMap.builder()
        .set(Options.WORKER_IO_THREADS, 16)
        .set(Options.TCP_NODELAY, true)
        .set(Options.REUSE_ADDRESSES, true)
        .getMap();

    ChannelListener<AcceptingChannel<StreamConnection>> acceptListener = ChannelListeners.openListenerAdapter(
        new PortForwardOpenListener(connection, portForwardURI.getPath(), targetPort, requestId, bufferPoolSlice,
            OptionMap.EMPTY));
    AcceptingChannel<? extends StreamConnection> server =
        xnioWorker.createStreamConnectionServer(new InetSocketAddress(portForwardBindAddress, sourcePort),
            acceptListener, socketOptions);
    server.resumeAccepts();
    return server;
}
 
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:18,代码来源:PortForwarder.java

示例12: doRun

import org.xnio.Options; //导入依赖的package包/类
private static void doRun ( URI u, final Object payloadObject, String username, String password ) {
    ConnectionProvider instance = null;
    ConnectionProviderContextImpl context = null;
    ConnectionHandler ch = null;
    Channel c = null;
    VersionedConnection vc = null;
    try {
        Logger logger = LogManager.getLogManager().getLogger("");
        logger.addHandler(new ConsoleLogHandler());
        logger.setLevel(Level.INFO);
        OptionMap options = OptionMap.builder().set(Options.SSL_ENABLED, u.getScheme().equals("https")).getMap();
        context = new ConnectionProviderContextImpl(options, "endpoint");
        instance = new HttpUpgradeConnectionProviderFactory().createInstance(context, options);
        String host = u.getHost();
        int port = u.getPort() > 0 ? u.getPort() : 9990;
        SocketAddress destination = new InetSocketAddress(host, port);
        ConnectionHandlerFactory chf = getConnection(destination, username, password, context, instance, options);
        ch = chf.createInstance(new ConnectionHandlerContextImpl(context));
        c = getChannel(context, ch, options);
        System.err.println("Connected");
        vc = makeVersionedConnection(c);
        MBeanServerConnection mbc = vc.getMBeanServerConnection(null);
        doExploit(payloadObject, mbc);
        System.err.println("DONE");
    }
    catch ( Throwable e ) {
        e.printStackTrace(System.err);
    }
    finally {
        cleanup(instance, context, ch, c, vc);
    }
}
 
开发者ID:hucheat,项目名称:APacheSynapseSimplePOC,代码行数:33,代码来源:JBoss.java

示例13: handleEvent

import org.xnio.Options; //导入依赖的package包/类
@Override
public void handleEvent(final StreamConnection channel) {
    if (UndertowLogger.REQUEST_LOGGER.isTraceEnabled()) {
        UndertowLogger.REQUEST_LOGGER.tracef("Opened connection with %s", channel.getPeerAddress());
    }

    //set read and write timeouts
    try {
        Integer readTimeout = channel.getOption(Options.READ_TIMEOUT);
        Integer idleTimeout = undertowOptions.get(UndertowOptions.IDLE_TIMEOUT);
        if ((readTimeout == null || readTimeout <= 0) && idleTimeout != null) {
            readTimeout = idleTimeout;
        } else if (readTimeout != null && idleTimeout != null && idleTimeout > 0) {
            readTimeout = Math.min(readTimeout, idleTimeout);
        }
        if (readTimeout != null && readTimeout > 0) {
            channel.getSourceChannel().setConduit(new ReadTimeoutStreamSourceConduit(channel.getSourceChannel().getConduit(), channel, this));
        }
        Integer writeTimeout = channel.getOption(Options.WRITE_TIMEOUT);
        if ((writeTimeout == null || writeTimeout <= 0) && idleTimeout != null) {
            writeTimeout = idleTimeout;
        } else if (writeTimeout != null && idleTimeout != null && idleTimeout > 0) {
            writeTimeout = Math.min(writeTimeout, idleTimeout);
        }
        if (writeTimeout != null && writeTimeout > 0) {
            channel.getSinkChannel().setConduit(new WriteTimeoutStreamSinkConduit(channel.getSinkChannel().getConduit(), channel, this));
        }
    } catch (IOException e) {
        IoUtils.safeClose(channel);
        UndertowLogger.REQUEST_IO_LOGGER.ioException(e);
    }

    AjpServerConnection connection = new AjpServerConnection(channel, bufferPool, rootHandler, undertowOptions, bufferSize);
    AjpReadListener readListener = new AjpReadListener(connection, scheme, parser);
    connection.setAjpReadListener(readListener);
    readListener.startRequest();
    channel.getSourceChannel().setReadListener(readListener);
    readListener.handleEvent(channel.getSourceChannel());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:40,代码来源:AjpOpenListener.java

示例14: renegotiateNoRequest

import org.xnio.Options; //导入依赖的package包/类
public void renegotiateNoRequest(HttpServerExchange exchange, SslClientAuthMode newAuthMode) throws IOException {
    AbstractServerConnection.ConduitState oldState = serverConnection.resetChannel();
    try {
        SslClientAuthMode sslClientAuthMode = channel.getOption(Options.SSL_CLIENT_AUTH_MODE);
        if (sslClientAuthMode == SslClientAuthMode.NOT_REQUESTED) {
            SslHandshakeWaiter waiter = new SslHandshakeWaiter();
            channel.getHandshakeSetter().set(waiter);
            //we use requested, to place nicely with other auth modes
            channel.setOption(Options.SSL_CLIENT_AUTH_MODE, newAuthMode);
            channel.getSslSession().invalidate();
            channel.startHandshake();
            ByteBuffer buff = ByteBuffer.wrap(new byte[1]);
            while (!waiter.isDone() && serverConnection.isOpen()) {
                int read = serverConnection.getSourceChannel().read(buff);
                if (read != 0) {
                    throw new SSLPeerUnverifiedException("");
                }
                if (!waiter.isDone()) {
                    serverConnection.getSourceChannel().awaitReadable();
                }
            }
        }
    } finally {
        if (oldState != null) {
            serverConnection.restoreChannel(oldState);
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:ConnectionSSLSessionInfo.java

示例15: getTimeout

import org.xnio.Options; //导入依赖的package包/类
private Integer getTimeout() throws IOException {
    Integer timeout = connection.getSourceChannel().getOption(Options.WRITE_TIMEOUT);
    Integer idleTimeout = openListener.getUndertowOptions().get(UndertowOptions.IDLE_TIMEOUT);
    if ((timeout == null || timeout <= 0) && idleTimeout != null) {
        timeout = idleTimeout;
    } else if (timeout != null && idleTimeout != null && idleTimeout > 0) {
        timeout = Math.min(timeout, idleTimeout);
    }
    return timeout;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:WriteTimeoutStreamSinkConduit.java


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