public Acceptor(InetAddress bind, int port) throws Exception { this.bind=bind; this.port=port; runner=new Runner(new DefaultThreadFactory("tcp", true, true), "acceptor", this, null); }
public CENTRAL_LOCK2() { req_handler=new Runner(new DefaultThreadFactory("lock-handler", true, true), "lock-handler", this::processQueue, req_queue::clear); }
@Override public void init() throws Exception { global_thread_factory = new DefaultThreadFactory("Geode ", true); timer_thread_factory = new LazyThreadFactory(THREAD_POOL_NAME_PREFIX + " Timer", true, true); default_thread_factory = new DefaultThreadFactory(THREAD_POOL_NAME_PREFIX + " Incoming", true, true); oob_thread_factory = new DefaultThreadFactory(THREAD_POOL_NAME_PREFIX + " OOB", true, true); internal_thread_factory = new DefaultThreadFactory(THREAD_POOL_NAME_PREFIX + " INT", true, true); super.init(); }
public AsyncNoBundler() { thread_pool=new ThreadPoolExecutor(0, max_threads, 30000, TimeUnit.MICROSECONDS, new SynchronousQueue<>(), new DefaultThreadFactory("async-bundler", true, true), new ThreadPoolExecutor.CallerRunsPolicy()); thread_pool.allowCoreThreadTimeOut(true); }
/** * Creates an instance of {@link NioServer} that opens a server channel and listens for connections. * Needs to be started next. * @param bind_addr The local address to bind to. If null, the address will be picked by the OS * @param port The local port to bind to * @throws Exception Thrown if the creation failed */ public NioServer(InetAddress bind_addr, int port) throws Exception { this(new DefaultThreadFactory("nio", false), new DefaultSocketFactory(), bind_addr, port, port+50, null, 0); }
/** * Creates an instance of {@link TcpServer} that creates a server socket and listens for connections. * The end port defaults to (port + 50). Needs to be started next. * @param bind_addr The local address to bind to. If null, the address will be picked by the OS * @param port The local port to bind to. If 0, the port will be picked by the OS. * @throws Exception Thrown if the creation failed */ public TcpServer(InetAddress bind_addr, int port) throws Exception { this(new DefaultThreadFactory("tcp", false), new DefaultSocketFactory(), bind_addr, port, port+50, null, 0); }
public Connection(Socket sock) throws Exception { this.sock=sock; peer_addr=new IpAddress((InetSocketAddress)sock.getRemoteSocketAddress()); in=new DataInputStream(createBufferedInputStream(sock.getInputStream())); out=new DataOutputStream(createBufferedOutputStream(sock.getOutputStream())); runner=new Runner(new DefaultThreadFactory("tcp", false, true), "conn-" + sock.getLocalPort(), this, null); }
public void init(TP transport) { super.init(transport); rb=new RingBuffer(Message.class, transport.getBundlerCapacity()); remove_queue=new Message[queue_size]; runner=new Runner(new DefaultThreadFactory("aqb", true, true), "runner", this::run, null); }
@Override public void accept(T protocol) { InetSocketAddress socketAddress = this.getSocketBinding().getSocketAddress(); protocol.setBindAddress(socketAddress.getAddress()); protocol.setBindPort(socketAddress.getPort()); protocol.setThreadFactory(new ClassLoaderThreadFactory(new DefaultThreadFactory("jgroups", false, true), JChannelFactory.class.getClassLoader())); protocol.setThreadPool(this.threadPoolFactory.get().apply(protocol.getThreadFactory())); protocol.setInternalThreadPoolThreadFactory(new ClassLoaderThreadFactory(new DefaultThreadFactory("jgroups-int", false, false), JChannelFactory.class.getClassLoader())); // Because we provide the transport with a thread pool, TP.init() won't auto-create the internal thread pool // So create one explicitly matching the logic in TP.init() but with our thread factory QueuelessThreadPoolFactory factory = new QueuelessThreadPoolFactory() .setMaxThreads(Math.max(4, Runtime.getRuntime().availableProcessors())) .setKeepAliveTime(30000) ; protocol.setInternalThreadPool(factory.apply(protocol.getInternalThreadPoolThreadFactory())); protocol.setValue("enable_diagnostics", this.diagnosticsSocketBinding != null); if (this.diagnosticsSocketBinding != null) { InetSocketAddress address = this.diagnosticsSocketBinding.get().getSocketAddress(); protocol.setValue("diagnostics_addr", address.getAddress()); protocol.setValue("diagnostics_port", address.getPort()); } }
/** * Creates an instance of an {@link NioClient} that acts as a <em>client</em>: no server channel is created and * no acceptor is started to listen for incoming connections. Instead, a channel is created * (bound to bind_addr/bind_port) and connected to server_addr/server_port. This is used to send messages to the * remote server and receive messages from it. Note that there is only a single TCP connection established between * the client and server. * @param bind_addr The address to which the local channel should bind to. Can be null, then the OS picks the address * @param bind_port The local port. Can be 0, then the OS picks the port. * @param server_addr The address of the server to connect to * @param server_port The port of the server to connect to. * @throws Exception If the creation failed */ public NioClient(InetAddress bind_addr, int bind_port, InetAddress server_addr, int server_port) { this(new DefaultThreadFactory("nio", false), new DefaultSocketFactory()); clientBindAddress(bind_addr).clientBindPort(bind_port); this.remote_addr=new IpAddress(server_addr, server_port); }
/** * Creates an instance of an {@link TcpClient} that acts as a <em>client</em>: no server socket is created and * no acceptor is started to listen for incoming connections. Instead, a client socket is created * (bound to bind_addr/bind_port) and connected to server_addr/server_port. This is used to send messages to the * remote server and receive messages from it. Note that there is only a single TCP connection established between * the client and server. * @param bind_addr The address to which the local socket should bind to. Can be null, then the OS picks the address * @param bind_port The local port. Can be 0, then the OS picks the port. * @param server_addr The address of the server to connect to * @param server_port The port of the server to connect to. * @throws Exception If the creation failed */ public TcpClient(InetAddress bind_addr, int bind_port, InetAddress server_addr, int server_port) { this(new DefaultThreadFactory("tcp", false), new DefaultSocketFactory()); clientBindAddress(bind_addr).clientBindPort(bind_port); this.remote_addr=new IpAddress(server_addr, server_port); }
@Override public void init() throws Exception { global_thread_factory=new DefaultThreadFactory("Geode ", true); timer_thread_factory=new LazyThreadFactory(THREAD_POOL_NAME_PREFIX + " Timer", true, true); default_thread_factory=new DefaultThreadFactory(THREAD_POOL_NAME_PREFIX + " Incoming", true, true); oob_thread_factory=new DefaultThreadFactory(THREAD_POOL_NAME_PREFIX + " OOB", true, true); internal_thread_factory=new DefaultThreadFactory(THREAD_POOL_NAME_PREFIX + " INT", true, true); super.init(); }
public Acceptor(InetAddress bind, int port) throws Exception { this.bind=bind; this.port=port; runner=new Runner(new DefaultThreadFactory("tcp", true, true), "acceptor", this, null); }
public AsyncNoBundler() { thread_pool=new ThreadPoolExecutor(0, max_threads, 30000, TimeUnit.MICROSECONDS, new SynchronousQueue<>(), new DefaultThreadFactory("async-bundler", true, true), new ThreadPoolExecutor.CallerRunsPolicy()); thread_pool.allowCoreThreadTimeOut(true); }
public CENTRAL_LOCK2() { req_handler=new Runner(new DefaultThreadFactory("lock-handler", true, true), "lock-handler", this::processQueue, req_queue::clear); }
/** * Creates an instance of {@link TcpServer} that creates a server socket and listens for connections. * The end port defaults to (port + 50). Needs to be started next. * @param bind_addr The local address to bind to. If null, the address will be picked by the OS * @param port The local port to bind to. If 0, the port will be picked by the OS. * @throws Exception Thrown if the creation failed */ public TcpServer(InetAddress bind_addr, int port) throws Exception { this(new DefaultThreadFactory("tcp", false), new DefaultSocketFactory(), bind_addr, port, port+50, null, 0); }
/** * Creates an instance of {@link NioServer} that opens a server channel and listens for connections. * Needs to be started next. * @param bind_addr The local address to bind to. If null, the address will be picked by the OS * @param port The local port to bind to * @throws Exception Thrown if the creation failed */ public NioServer(InetAddress bind_addr, int port) throws Exception { this(new DefaultThreadFactory("nio", false), new DefaultSocketFactory(), bind_addr, port, port+50, null, 0); }
public Connection(Socket sock) throws Exception { this.sock=sock; peer_addr=new IpAddress((InetSocketAddress)sock.getRemoteSocketAddress()); in=new DataInputStream(createBufferedInputStream(sock.getInputStream())); out=new DataOutputStream(createBufferedOutputStream(sock.getOutputStream())); runner=new Runner(new DefaultThreadFactory("tcp", false, true), "conn-" + sock.getLocalPort(), this, null); }
public void init(TP transport) { super.init(transport); rb=new RingBuffer(Message.class, transport.getBundlerCapacity()); remove_queue=new Message[queue_size]; runner=new Runner(new DefaultThreadFactory("aqb", true, true), "runner", this::run, null); }
/** * Creates an instance of an {@link TcpClient} that acts as a <em>client</em>: no server socket is created and * no acceptor is started to listen for incoming connections. Instead, a client socket is created * (bound to bind_addr/bind_port) and connected to server_addr/server_port. This is used to send messages to the * remote server and receive messages from it. Note that there is only a single TCP connection established between * the client and server. * @param bind_addr The address to which the local socket should bind to. Can be null, then the OS picks the address * @param bind_port The local port. Can be 0, then the OS picks the port. * @param server_addr The address of the server to connect to * @param server_port The port of the server to connect to. * @throws Exception If the creation failed */ public TcpClient(InetAddress bind_addr, int bind_port, InetAddress server_addr, int server_port) { this(new DefaultThreadFactory("tcp", false), new DefaultSocketFactory()); clientBindAddress(bind_addr).clientBindPort(bind_port); this.remote_addr=new IpAddress(server_addr, server_port); }