/** * Create a new endpoint with the given configuration. This method (starting with 3.3) will use the class loader * of XNIO itself to construct the XNIO implementation. * * @param endpointName the name of the endpoint * @param optionMap the options to configure the endpoint * @return the new endpoint * @throws IOException if an error occurs */ public static Endpoint createEndpoint(final String endpointName, final OptionMap optionMap) throws IOException { return createEndpoint(endpointName, Xnio.getInstance(), optionMap); }
public UndertowXhrTransport(OptionMap optionMap) throws IOException { Assert.notNull(optionMap, "OptionMap is required"); this.optionMap = optionMap; this.httpClient = UndertowClient.getInstance(); this.worker = Xnio.getInstance().createWorker(optionMap); this.bufferPool = new DefaultByteBufferPool(false, 1024, -1, 2); }
public ConnectionProviderContextImpl ( OptionMap opts, String endpointName ) throws IllegalArgumentException, IOException { this.instance = Xnio.getInstance(); this.worker = this.instance.createWorker(opts); this.endpoint = Remoting.createEndpoint(endpointName, this.worker, opts); this.executor = Executors.newCachedThreadPool(new ThreadFactory() { public Thread newThread ( Runnable r ) { Thread t = new Thread(r, "Worker"); t.setDaemon(true); return t; } }); }
fileSystemWatcher = Xnio.getInstance().createFileSystemWatcher("Watcher for " + base, OptionMap.EMPTY); fileSystemWatcher.watchPath(new File(base), new FileChangeCallback() { @Override
private Http2Client(final ClassLoader classLoader) { ServiceLoader<ClientProvider> providers = ServiceLoader.load(ClientProvider.class, classLoader); final Map<String, ClientProvider> map = new HashMap<>(); for (ClientProvider provider : providers) { for (String scheme : provider.handlesSchemes()) { map.put(scheme, provider); } } this.clientProviders = Collections.unmodifiableMap(map); try { final Xnio xnio = Xnio.getInstance(); WORKER = xnio.createWorker(null, Http2Client.DEFAULT_OPTIONS); SSL = new UndertowXnioSsl(WORKER.getXnio(), OptionMap.EMPTY, BUFFER_POOL, createSSLContext()); } catch (Exception e) { logger.error("Exception: ", e); } }
private XnioWorker createWorker() throws IOException { Xnio xnio = Xnio.getInstance(Undertow.class.getClassLoader()); return xnio.createWorker( OptionMap.builder().set(Options.THREAD_DAEMON, true).getMap()); }
private XnioWorker createWorker() throws IOException { Xnio xnio = Xnio.getInstance(Undertow.class.getClassLoader()); return xnio.createWorker( OptionMap.builder().set(Options.THREAD_DAEMON, true).getMap()); }
@Parameters(name = "client[{0}] - server [{1}]") public static Object[][] arguments() throws IOException { WebSocketClient[] clients = new WebSocketClient[] { new TomcatWebSocketClient(), new JettyWebSocketClient(), new ReactorNettyWebSocketClient(), new UndertowWebSocketClient(Xnio.getInstance().createWorker(OptionMap.EMPTY)) }; Map<HttpServer, Class<?>> servers = new LinkedHashMap<>(); servers.put(new TomcatHttpServer(TMP_DIR.getAbsolutePath(), WsContextListener.class), TomcatConfig.class); servers.put(new JettyHttpServer(), JettyConfig.class); servers.put(new ReactorHttpServer(), ReactorNettyConfig.class); servers.put(new UndertowHttpServer(), UndertowConfig.class); Flux<WebSocketClient> f1 = Flux.fromArray(clients).concatMap(c -> Flux.just(c).repeat(servers.size())); Flux<HttpServer> f2 = Flux.fromIterable(servers.keySet()).repeat(clients.length); Flux<Class<?>> f3 = Flux.fromIterable(servers.values()).repeat(clients.length); return Flux.zip(f1, f2, f3).map(Tuple3::toArray).collectList().block() .toArray(new Object[clients.length * servers.size()][2]); }
info.setWorker(Xnio.getInstance().createWorker(OptionMap.EMPTY)); info.setBuffers(new org.xnio.ByteBufferSlicePool(1024,1024));
public synchronized void start() { UndertowLogger.ROOT_LOGGER.debugf("starting undertow server %s", this); xnio = Xnio.getInstance(Undertow.class.getClassLoader()); channels = new ArrayList<>(); try {
@Override public void start(StartContext startContext) throws StartException { //todo: this is a bit of a hack, as the proxy handler may be wrapped by a request controller handler for graceful shutdown ProxyHandler proxyHandler = (ProxyHandler) (this.proxyHandler.getValue() instanceof GlobalRequestControllerHandler ? ((GlobalRequestControllerHandler)this.proxyHandler.getValue()).getNext() : this.proxyHandler.getValue()); final LoadBalancingProxyClient client = (LoadBalancingProxyClient) proxyHandler.getProxyClient(); try { SSLContext sslContext = this.sslContext.getOptionalValue(); if (sslContext == null) { SecurityRealm securityRealm = this.securityRealm.getOptionalValue(); if (securityRealm != null) { sslContext = securityRealm.getSSLContext(); } } if (sslContext == null) { client.addHost(getUri(), instanceId, null, OptionMap.create(UndertowOptions.ENABLE_HTTP2, enableHttp2)); } else { OptionMap.Builder builder = OptionMap.builder(); builder.set(Options.USE_DIRECT_BUFFERS, true); OptionMap combined = builder.getMap(); XnioSsl xnioSsl = new UndertowXnioSsl(Xnio.getInstance(), combined, sslContext); client.addHost(getUri(), instanceId, xnioSsl, OptionMap.create(UndertowOptions.ENABLE_HTTP2, enableHttp2)); } } catch (URISyntaxException e) { throw new StartException(e); } }
endpointCreationOptions = OptionMap.builder().addAll(endpointCreationOptions).set(Options.THREAD_DAEMON, true).getMap(); endpointBuilder.buildXnioWorker(Xnio.getInstance()).populateFromOptions(endpointCreationOptions);
@Override public Xnio getXnioInstance() { if(this.xnioInstance == null) { this.xnioInstance = Xnio.getInstance("nio", SpincastHttpClientWithWebsocketUtilsDefault.class.getClassLoader()); } return this.xnioInstance; } }
@Override public XnioSsl getXnioSsl() { final SSLContext sslContext; if (realm == null || (sslContext = realm.getSSLContext()) == null) { return null; } return new JsseXnioSsl(Xnio.getInstance(Remoting.class.getClassLoader()), OptionMap.EMPTY, sslContext); }
static XnioWorker getWorker() { if (worker == null) { try { worker = Xnio.getInstance().createWorker(DEFAULT.getMap()); } catch (Exception e) { throw new RuntimeException("Could not build client worker", e); } } return worker; }
@Override public void start(StartContext startContext) throws StartException { final Xnio xnio = Xnio.getInstance(); try { worker = xnio.createWorker(null, options, this::stopDone); } catch (IOException e) { throw new StartException(e); } }
private ConnectionFactory(URI kubernetesMasterUri) { this.kubernetesMasterUri = kubernetesMasterUri; undertowClient = UndertowClient.getInstance(); Xnio xnio = Xnio.getInstance(Undertow.class.getClassLoader()); try { ssl = new UndertowXnioSsl(xnio, OptionMap.EMPTY); } catch (Exception e) { throw new RuntimeException(e); } byteBufferPool = createByteBufferPool(); }
/** * @deprecated Use {@link #WorkerService(XnioWorker.Builder)} instead to allow setting of full range of options. */ public WorkerService(OptionMap optionMap) { this(Xnio.getInstance().createWorkerBuilder().populateFromOptions(optionMap)); }
/** * Create a new {@link XnioEventLoopGroup} which creates a new {@link XnioWorker} by itself and use it for all * operations. Using the given number of Threads to handle the IO. * * @throws IOException */ public XnioEventLoopGroup(int numThreads) throws IOException { this(Xnio.getInstance().createWorker(OptionMap.create(Options.WORKER_IO_THREADS, numThreads))); }
private UndertowClientWrapper() throws IOException, URISyntaxException { this.worker = Xnio.getInstance().createWorker(OptionMap.EMPTY); this.pool = new DefaultByteBufferPool(true, 17 * 1024); this.client = UndertowClient.getInstance(); }