public JrdsSocketConnection(String host, int port, SocketFactory sf) throws IOException { super(sf.createSocket(host, port)); this.host = host; this.port = port; }
/** * @return the timeout */ public int getTimeout() { return getLevel().getTimeout(); }
public Socket createSocket(String host, int port) throws IOException { if(!isStarted()) return null; Socket s = getSocket(); s.connect(new InetSocketAddress(host, port), getTimeout()); return s; }
public ServerSocket createServerSocket(int port) throws IOException { if(!isStarted()) return null; ServerSocket s = new ServerSocket(port) { /* * (non-Javadoc) * * @see java.net.ServerSocket#accept() */ @Override public Socket accept() throws IOException { Socket accepted = super.accept(); accepted.setTcpNoDelay(true); return accepted; } }; s.setSoTimeout(getTimeout() * 1000); return s; }
try { SocketFactory ss = find(SocketFactory.class); if(!ss.isStarted()) return null; s = ss.createSocket(this, port); } catch (Exception e) { log(Level.ERROR, e, "Connect error %s", e);
@Override public void connect(SocketAddress endpoint, int timeout) throws IOException { super.connect(endpoint, getTimeout() * 1000); } };
private HostStarter addConnection(Starter cnx) throws IOException { String truststore = getClass().getClassLoader().getResource("localhost.jks").getFile(); PropertiesManager pm = Tools.makePm(testFolder, "timeout=1", "collectorThreads=1", "ssl.protocol=TLS", "ssl.strict=true", "ssl.truststore=" + truststore, "ssl.trustpassword=123456"); HostStarter localhost = new HostStarter(new HostInfo("localhost")); Timer t = Tools.getDefaultTimer(); localhost.setParent(t); localhost.getHost().setHostDir(testFolder.getRoot()); t.registerStarter(new SSLStarter()); t.registerStarter(new SocketFactory()); t.configureStarters(pm); localhost.registerStarter(cnx); cnx.configure(pm); return localhost; }
@Override public boolean isStarted(Object key) { return super.isStarted(key) && find(XmlProvider.class).isStarted() && find(SocketFactory.class).isStarted(); }
public void connect(SocketAddress endpoint) throws IOException { super.connect(endpoint, getTimeout() * 1000); }
@SuppressWarnings("unused") private void doTest(String proto, int port) throws Exception { mbi = new JrdsMBeanInfo(proto, "localhost", port); HostStarter host = new HostStarter(new HostInfo("localhost")) { public boolean isCollectRunning() { return true; } }; host.setTimeout(1); JMXConnection cnx = getCnx(proto, port); host.registerStarter(new SocketFactory()); host.registerStarter(new JmxSocketFactory()); host.registerStarter(cnx); host.configureStarters(new PropertiesManager()); host.startCollect(); Assert.assertTrue("JMX Connection failed to start", cnx.isStarted()); Assert.assertNotNull("Failed to read uptime", cnx.setUptime()); if(false) enumerate((NativeJmxSource)cnx.getConnection()); }
public Socket createSocket(StarterNode host, int port) throws IOException { if(!isStarted()) return null; Resolver r = host.find(Resolver.class); if(r == null || !r.isStarted()) return null; Socket s = getSocket(); s.connect(new InetSocketAddress(r.getInetAddress(), port), getTimeout()); return s; }
@Override public Socket createSocket(HttpContext context) throws IOException { return ss.createSocket(); } };
private Socket getSocket() throws SocketException { Socket s = new Socket() { public void connect(SocketAddress endpoint) throws IOException { super.connect(endpoint, getTimeout() * 1000); } @Override public void connect(SocketAddress endpoint, int timeout) throws IOException { super.connect(endpoint, getTimeout() * 1000); } }; s.setSoTimeout(getTimeout() * 1000); s.setTcpNoDelay(true); return s; }
@Override public boolean startConnection() { SocketFactory ss = getLevel().find(SocketFactory.class); channel = new SocketChannels(); try { channel.muninsSocket = ss.createSocket(getHostName(), port); channel.out = new PrintWriter(channel.muninsSocket.getOutputStream(), true); channel.in = new BufferedReader(new InputStreamReader(channel.muninsSocket.getInputStream())); } catch (IOException e) { log(Level.ERROR, e, "Connection error", e.getMessage()); return false; } return true; }
Socket makeSocket(String host, int port) throws IOException { SocketFactory sf = getLevel().find(SocketFactory.class); return sf.createSocket(host, port); }
public Socket connect(String host, int port) throws NoSuchAlgorithmException, KeyManagementException, IOException { SocketFactory ss = getLevel().find(SocketFactory.class); Socket s = ss.createSocket(host, port); SSLSocketFactory ssf = getContext().getSocketFactory(); s = ssf.createSocket(s, host, port, true); log(Level.DEBUG, "done SSL handshake for %s", host); return s; }
private Socket connect() throws NoSuchAlgorithmException, KeyManagementException, IOException { if(port == 23) { SocketFactory ss = find(SocketFactory.class); return ss.createSocket(iloHost, port); } else { return find(SSLStarter.class).connect(iloHost, port); } }
public Socket createSocket(String host, int port) throws IOException { log(Level.DEBUG, "creating a RMI socket to %s:%d", host, port); return getLevel().find(SocketFactory.class).createSocket(host, port); } }
public Socket createSocket(String host, int port) throws IOException { log(Level.DEBUG, "creating a RMI socket to %s:%d", host, port); return getLevel().find(SocketFactory.class).createSocket(host, port); }