@Override public SockCreator getSockCreator() { return SocketCreator.getDefaultInstance(); }
/** * Returns the default instance for use in GemFire socket creation after * initializing it using defaults in {@link * com.gemstone.gemfire.distributed.internal.DistributionConfig}. If any * values are specified in the provided properties or in System properties, * those values will be used to override the defaults. * <p> * This will reinitialize the SocketCreator if it was previously initialized. * <p> * Call will synchronize on the DEFAULT_INSTANCE. */ public static SocketCreator getDefaultInstance(Properties props) { return getDefaultInstance(new DistributionConfigImpl(props)); }
public void run( ) { try { Socket s = ss.accept(); SocketCreator.getDefaultInstance().configureServerSSLSocket( s, log ); ObjectInputStream ois = new ObjectInputStream( s.getInputStream() ); receiver[0] = ois.readObject( ); server = s; acceptor = ss; } catch ( Exception e ) { e.printStackTrace(); receiver[0] = e; } } }, name + "-server" );
/** * Returns the default instance for use in GemFire socket creation after * initializing it using defaults in {@link * com.gemstone.gemfire.distributed.internal.DistributionConfig}. If any * values are specified in the provided properties or in System properties, * those values will be used to override the defaults. * <p> * This will reinitialize the SocketCreator if it was previously initialized. * <p> * Call will synchronize on the DEFAULT_INSTANCE. */ public static SocketCreator getDefaultInstance(Properties props) { return getDefaultInstance(new DistributionConfigImpl(props)); }
private Thread startServer( final Object[] receiver ) throws Exception { final ServerSocket ss = SocketCreator.getDefaultInstance().createServerSocket( randport, 0, InetAddress.getByName( "localhost" ), log ); Thread t = new Thread( new Runnable() { public void run( ) { try { Socket s = ss.accept(); SocketCreator.getDefaultInstance().configureServerSSLSocket( s, log ); ObjectInputStream ois = new ObjectInputStream( s.getInputStream() ); receiver[0] = ois.readObject( ); server = s; acceptor = ss; } catch ( Exception e ) { e.printStackTrace(); receiver[0] = e; } } }, name + "-server" ); t.start(); return t; }
/** not actually related to this test class, but this is as good a place as any for this little test of the client-side ability to tell gemfire to use a given socket factory. We just test the connectForClient method to see if it's used */ public void testClientSocketFactory() { System.getProperties().put("gemfire.clientSocketFactory", TSocketFactory.class.getName()); System.getProperties().remove( "gemfire.ssl-enabled"); SocketCreator.getDefaultInstance(new Properties()); factoryInvoked = false; try { try { Socket sock = SocketCreator.getDefaultInstance().connectForClient("localhost", 12345, new LocalLogWriter(LogWriterImpl.ALL_LEVEL, System.out),0); sock.close(); fail("socket factory was not invoked"); } catch (IOException e) { assertTrue("socket factory was not invoked: " + factoryInvoked, factoryInvoked); } } finally { System.getProperties().remove("gemfire.clientSocketFactory"); SocketCreator.getDefaultInstance().initializeClientSocketFactory(); } }
SocketCreator.getDefaultInstance(); synchronized(connectingSockets) { for (Iterator it = connectingSockets.entrySet().iterator(); it.hasNext(); ) {
private void startServerThread() throws IOException { if (srv_sock == null || srv_sock.isClosed()) { if (bind_address == null) { srv_sock = SocketCreator.getDefaultInstance().createServerSocket(port, BACKLOG); srv_sock = SocketCreator.getDefaultInstance().createServerSocket(port, BACKLOG, bind_address);
ServerSocket createServerSocket(InetAddress socketAddress, int[] portRange) { ServerSocket serverSocket = null; try { serverSocket = SocketCreator.getDefaultInstance().createServerSocketUsingPortRange(socketAddress, 50/*backlog*/, true/*isBindAddress*/, false/*useNIO*/, 65536/*tcpBufferSize*/, portRange); socketPort = serverSocket.getLocalPort(); } catch (IOException e) { throw new GemFireConfigException("Unable to allocate a failure detection port in the membership-port range", e); } catch (SystemConnectException e) { throw new GemFireConfigException("Unable to allocate a failure detection port in the membership-port range", e); } return serverSocket; }
assertTrue(SocketCreator.getDefaultInstance().useSSL()); Socket client = SocketCreator.getDefaultInstance().connectForServer( InetAddress.getByName("localhost"), randport, log ); ObjectOutputStream oos = new ObjectOutputStream( client.getOutputStream() ); String expected = new String( "testing " + name );
public TcpServer(int port, InetAddress bind_address, Properties sslConfig, DistributionConfigImpl cfg, TcpHandler handler, PoolStatHelper poolHelper, ThreadGroup threadGroup, String threadName) { this.port = port; this.bind_address = bind_address; this.handler = handler; this.poolHelper = poolHelper; // register DSFID types first; invoked explicitly so that all message type // initializations do not happen in first deserialization on a possibly // "precious" thread DSFIDFactory.registerTypes(); this.executor = createExecutor(poolHelper, threadGroup); this.threadGroup = threadGroup; this.threadName = threadName; if (cfg == null) { if (sslConfig == null) { sslConfig = new Properties(); } cfg = new DistributionConfigImpl(sslConfig); } SocketCreator.getDefaultInstance(cfg); }
public TcpServer(int port, InetAddress bind_address, Properties sslConfig, DistributionConfigImpl cfg, TcpHandler handler, PoolStatHelper poolHelper, ThreadGroup threadGroup, String threadName) { this.port = port; this.bind_address = bind_address; this.handler = handler; this.poolHelper = poolHelper; // register DSFID types first; invoked explicitly so that all message type // initializations do not happen in first deserialization on a possibly // "precious" thread DSFIDFactory.registerTypes(); this.executor = createExecutor(poolHelper, threadGroup); this.threadGroup = threadGroup; this.threadName = threadName; if (cfg == null) { if (sslConfig == null) { sslConfig = new Properties(); } cfg = new DistributionConfigImpl(sslConfig); } SocketCreator.getDefaultInstance(cfg); }
private void startServerThread() throws IOException { if (srv_sock == null || srv_sock.isClosed()) { if (bind_address == null) { srv_sock = SocketCreator.getDefaultInstance().createServerSocket(port, BACKLOG, log.getLogWriter()); srv_sock = SocketCreator.getDefaultInstance().createServerSocket(port, BACKLOG, bind_address, log.getLogWriter());
socket.bind(addr, backlog); } else { socket = SocketCreator.getDefaultInstance().createServerSocket(localPort, backlog, isBindAddress? ba : null, logger, tcpBufferSize);
socket.bind(addr, backlog); } else { socket = SocketCreator.getDefaultInstance().createServerSocket(localPort, backlog, isBindAddress? ba : null, tcpBufferSize);
Socket sock=SocketCreator.getDefaultInstance().connect(ipAddr.getAddress(), ipAddr.getPort(), timeout, null, false); sock.setSoTimeout(timeout);
/** * During final check, establish TCP connection between current member and suspect member. * And exchange PING/PONG message to see if the suspect member is still alive. * * @param suspectMember member that does not respond to HeartbeatRequestMessage * @return true if successfully exchanged PING/PONG with TCP connection, otherwise false. */ private boolean doTCPCheckMember(InternalDistributedMember suspectMember, int port) { Socket clientSocket = null; try { logger.debug("Checking member {} with TCP socket connection {}:{}.", suspectMember, suspectMember.getInetAddress(), port); clientSocket = SocketCreator.getDefaultInstance().connect(suspectMember.getInetAddress(), port, (int)memberTimeout, new ConnectTimeoutTask(services.getTimer(), memberTimeout), false, -1, false); clientSocket.setTcpNoDelay(true); return doTCPCheckMember(suspectMember, clientSocket); } catch (IOException e) { logger.debug("Unexpected exception", e); } finally { try { if (clientSocket != null) { clientSocket.close(); } } catch (IOException e) { logger.trace("Unexpected exception", e); } } return false; }
GemFireTracer.getLog(JmxManagerLocator.class).setSecurityLogWriter( new LocalLogWriter(LogWriterImpl.NONE_LEVEL)); SocketCreator.getDefaultInstance(distConfProps);
int handShakeTimeout, int readTimeout, byte communicationMode, GatewaySender sender) throws IOException { SocketCreator sc = SocketCreator.getDefaultInstance(); if (sender != null && !sender.getGatewayTransportFilters().isEmpty()) { DistributionConfig config = new DistributionConfigImpl(new Properties());
SocketCreator sc = SocketCreator.getDefaultInstance(); if (!sc.isHostReachable(this.theSocket.getInetAddress())) { return;