@Test public void shouldReturnSameThreadExecutorForSameThreadStrategy() { OncRpcSvcBuilder builder = new OncRpcSvcBuilder(); ExecutorService executorService = builder.getWorkerThreadExecutorService(); final Object[] holder = new Object[1]; final Thread thisThread = Thread.currentThread(); executorService.execute(() -> { holder[0] = Thread.currentThread(); }); assertTrue("Executoed in a different thread", thisThread == holder[0]); }
public ExecutorService getWorkerThreadExecutorService() { if (_ioStrategy == IoStrategy.SAME_THREAD ) { return MoreExecutors.newDirectExecutorService(); } if (_workerThreadExecutionService != null) { return _workerThreadExecutionService; } ThreadFactory threadFactory = new ThreadFactoryBuilder() .setNameFormat(_serviceName + " (%d)") .build(); int threadPoolSize = _workerThreadPoolSize != 0 ? _workerThreadPoolSize : getDefaultWorkerPoolSize(); return Executors.newFixedThreadPool(threadPoolSize, threadFactory); }
OncRpcSvcBuilder { public ExecutorService getWorkerThreadExecutorService() { if (_ioStrategy == IoStrategy.SAME_THREAD ) { return MoreExecutors.newDirectExecutorService(); } if (_workerThreadExecutionService != null) { return _workerThreadExecutionService; } ThreadFactory threadFactory = new ThreadFactoryBuilder() .setNameFormat(_serviceName + " (%d)") .build(); int threadPoolSize = _workerThreadPoolSize != 0 ? _workerThreadPoolSize : getDefaultWorkerPoolSize(); return Executors.newFixedThreadPool(threadPoolSize, threadFactory); } }
OncRpcSvcBuilder { public ExecutorService getWorkerThreadExecutorService() { if (_ioStrategy == IoStrategy.SAME_THREAD ) { return MoreExecutors.newDirectExecutorService(); } if (_workerThreadExecutionService != null) { return _workerThreadExecutionService; } ThreadFactory threadFactory = new ThreadFactoryBuilder() .setNameFormat(_serviceName + " (%d)") .build(); int threadPoolSize = _workerThreadPoolSize != 0 ? _workerThreadPoolSize : getDefaultWorkerPoolSize(); return Executors.newFixedThreadPool(threadPoolSize, threadFactory); }  }
OncRpcSvcBuilder { public ExecutorService getWorkerThreadExecutorService() { if (_ioStrategy == IoStrategy.SAME_THREAD ) { return MoreExecutors.newDirectExecutorService(); } if (_workerThreadExecutionService != null) { return _workerThreadExecutionService; } ThreadFactory threadFactory = new ThreadFactoryBuilder() .setNameFormat(_serviceName + " (%d)") .build(); int threadPoolSize = _workerThreadPoolSize != 0 ? _workerThreadPoolSize : getDefaultWorkerPoolSize(); return Executors.newFixedThreadPool(threadPoolSize, threadFactory); }  OncRpcSvcBuilder withAutoPublish(); @Beta OncRpcSvcBuilder withStartTLS(); @Beta OncRpcSvcBuilder withoutStartTLS(); OncRpcSvcBuilder withoutAutoPublish(); OncRpcSvcBuilder withMaxPort(int maxPort); OncRpcSvcBuilder withMinPort(int minPort); OncRpcSvcBuilder withPort(int port); OncRpcSvcBuilder withTCP(); OncRpcSvcBuilder withUDP(); OncRpcSvcBuilder withIpProtocolType(int protocolType); OncRpcSvcBuilder withSameThreadIoStrategy(); OncRpcSvcBuilder withSelectorThreadPoolSize(int threadPoolSize); OncRpcSvcBuilder withWorkerThreadIoStrategy(); OncRpcSvcBuilder withWorkerThreadPoolSize(int threadPoolSize); OncRpcSvcBuilder withIoStrategy(IoStrategy ioStrategy); OncRpcSvcBuilder withJMX(); OncRpcSvcBuilder withBacklog(int backlog); OncRpcSvcBuilder withBindAddress(String address); OncRpcSvcBuilder withServiceName(String serviceName); OncRpcSvcBuilder withGssSessionManager(GssSessionManager gssSessionManager); OncRpcSvcBuilder withWorkerThreadExecutionService(ExecutorService executorService); OncRpcSvcBuilder withClientMode(); OncRpcSvcBuilder withRpcService(OncRpcProgram program, RpcDispatchable service); OncRpcSvcBuilder withSubjectPropagation(); OncRpcSvcBuilder withoutSubjectPropagation(); OncRpcSvcBuilder withSSLContext(SSLContext sslContext); OncRpcSvcBuilder withSSLParameters(SSLParameters sslParams); boolean getSubjectPropagation(); int getProtocol(); int getMinPort(); int getMaxPort(); boolean isAutoPublish(); @Beta boolean isStartTLS(); IoStrategy getIoStrategy(); boolean isWithJMX(); int getBacklog(); String getBindAddress(); String getServiceName(); GssSessionManager getGssSessionManager(); ExecutorService getWorkerThreadExecutorService(); int getSelectorThreadPoolSize(); int getWorkerThreadPoolSize(); boolean isClient(); Map<OncRpcProgram, RpcDispatchable> getRpcServices(); SSLContext getSSLContext(); SSLParameters getSSLParameters(); OncRpcSvc build(); }
OncRpcSvcBuilder { public ExecutorService getWorkerThreadExecutorService() { if (_ioStrategy == IoStrategy.SAME_THREAD ) { return MoreExecutors.newDirectExecutorService(); } if (_workerThreadExecutionService != null) { return _workerThreadExecutionService; } ThreadFactory threadFactory = new ThreadFactoryBuilder() .setNameFormat(_serviceName + " (%d)") .build(); int threadPoolSize = _workerThreadPoolSize != 0 ? _workerThreadPoolSize : getDefaultWorkerPoolSize(); return Executors.newFixedThreadPool(threadPoolSize, threadFactory); }  OncRpcSvcBuilder withAutoPublish(); @Beta OncRpcSvcBuilder withStartTLS(); @Beta OncRpcSvcBuilder withoutStartTLS(); OncRpcSvcBuilder withoutAutoPublish(); OncRpcSvcBuilder withMaxPort(int maxPort); OncRpcSvcBuilder withMinPort(int minPort); OncRpcSvcBuilder withPort(int port); OncRpcSvcBuilder withTCP(); OncRpcSvcBuilder withUDP(); OncRpcSvcBuilder withIpProtocolType(int protocolType); OncRpcSvcBuilder withSameThreadIoStrategy(); OncRpcSvcBuilder withSelectorThreadPoolSize(int threadPoolSize); OncRpcSvcBuilder withWorkerThreadIoStrategy(); OncRpcSvcBuilder withWorkerThreadPoolSize(int threadPoolSize); OncRpcSvcBuilder withIoStrategy(IoStrategy ioStrategy); OncRpcSvcBuilder withJMX(); OncRpcSvcBuilder withBacklog(int backlog); OncRpcSvcBuilder withBindAddress(String address); OncRpcSvcBuilder withServiceName(String serviceName); OncRpcSvcBuilder withGssSessionManager(GssSessionManager gssSessionManager); OncRpcSvcBuilder withWorkerThreadExecutionService(ExecutorService executorService); OncRpcSvcBuilder withClientMode(); OncRpcSvcBuilder withRpcService(OncRpcProgram program, RpcDispatchable service); OncRpcSvcBuilder withSubjectPropagation(); OncRpcSvcBuilder withoutSubjectPropagation(); OncRpcSvcBuilder withSSLContext(SSLContext sslContext); OncRpcSvcBuilder withSSLParameters(SSLParameters sslParams); boolean getSubjectPropagation(); int getProtocol(); int getMinPort(); int getMaxPort(); boolean isAutoPublish(); @Beta boolean isStartTLS(); IoStrategy getIoStrategy(); boolean isWithJMX(); int getBacklog(); String getBindAddress(); String getServiceName(); GssSessionManager getGssSessionManager(); ExecutorService getWorkerThreadExecutorService(); int getSelectorThreadPoolSize(); int getWorkerThreadPoolSize(); boolean isClient(); Map<OncRpcProgram, RpcDispatchable> getRpcServices(); SSLContext getSSLContext(); SSLParameters getSSLParameters(); OncRpcSvc build();  }