static boolean isAlreadyRunning(InvokerLocator serverLocator) { Map<String, String> metadata = new HashMap<>(); metadata.put(SocketWrapper.WRITE_TIMEOUT, String.valueOf(ConfigSettings.instance.getSocketWriteTimeout())); metadata.put("generalizeSocketException", "true"); try { MageServer testServer = (MageServer) TransporterClient.createTransporterClient(serverLocator.getLocatorURI(), MageServer.class, metadata); if (testServer != null) { testServer.getServerState(); return true; } } catch (Throwable t) { // assume server is not running } return false; }
server = (MageServer) TransporterClient.createTransporterClient(clientLocator.getLocatorURI(), MageServer.class, metadata);
/** * Creates Connector with specified locator. * * @param locator */ public Connector(InvokerLocator locator) { if (locator != null) { this.locatorURI = locator.getLocatorURI(); } }
@Override public String toString() { return "remoting endpoint [" + ((m_invokerLocator != null) ? m_invokerLocator.getLocatorURI() : "?") + ']'; }
public String getRemoteEndpoint() { return (m_invokerLocator != null) ? m_invokerLocator.getLocatorURI() : "<null>"; }
@Override public String toString() { return "remoting endpoint [" + ((m_invokerLocator != null) ? m_invokerLocator.getLocatorURI() : "?") + ']'; }
public String getRemoteEndpoint() { return (m_invokerLocator != null) ? m_invokerLocator.getLocatorURI() : "<null>"; }
/** * Compares to see if Object passed is of type InvokerLocator and * it's internal locator uri hashcode is same as this one. Note, this * means is testing to see if not only the host, protocol, and port are the * same, but the path and parameters as well. Therefore 'socket://localhost:9000' * and 'socket://localhost:9000/foobar' would NOT be considered equal. * @param obj * @return */ public boolean equals(Object obj) { return obj != null && obj instanceof InvokerLocator && uri.equals(((InvokerLocator)obj).getLocatorURI()); }
/** * Constructs connector for given locator and configuration. * * @param locator * @param configuration */ public Connector(InvokerLocator locator, Map configuration) { if (locator != null) { this.locatorURI = locator.getLocatorURI(); } if (configuration != null) { this.configuration.putAll(configuration); } }
public StreamServer(InputStream stream, InvokerLocator locator) throws Exception { this.streamSource = stream; setupServer(locator.getLocatorURI()); }
/** * Gets the invoker locator string for this server * * @return */ public String getInvokerLocator() { if(serverInvoker != null) { return serverInvoker.getLocator().getLocatorURI(); } else { return null; } }
private MBeanServerClientInvokerProxy(ClassLoader cl, InvokerLocator invoker, String localJmxId, String id) throws Exception { this.localJmxId = localJmxId; this.serverId = id; if(this.serverId == null) { throw new IllegalArgumentException("MBeanServer ID not found - make sure the NetworkRegistry MBean is running"); } this.client = new Client(cl, invoker, Subsystem.JMX, null); this.locator = new InvokerLocator(invoker.getLocatorURI()); this.proxies.put(id, this); setupPollingTimer(); }
/** * Sets up the callback server that the target remoting server can call on * with the callbacks that it generates. * * @param locator * @throws Exception */ public void setupServer(InvokerLocator locator) throws Exception { System.out.println("Starting remoting server with locator uri of: " + locator); callbackServerConnector = new Connector(); callbackServerConnector.setInvokerLocator(locator.getLocatorURI()); callbackServerConnector.start(); }
/** * This will create the Client. */ public void init() { try { String locatorURI = "multiplex://localhost:9090/?multiplexBindHost=localhost&multiplexBindPort=8080"; InvokerLocator locator = new InvokerLocator(locatorURI); client = new Client(locator, "sample"); client.connect(); System.out.println("Connected client to server at: " + client.getInvoker().getLocator().getLocatorURI()); } catch(Exception e) { e.printStackTrace(); } }
public void setUp() throws Exception { init(); locator = initServer(); client.connect(); System.out.println("Connected client to server at: " + client.getInvoker().getLocator().getLocatorURI()); }
/** * This will be used to create callback server * * @param port * @return * @throws Exception */ private InvokerLocator initServer() throws Exception { String locatorURI = "multiplex://localhost:8080"; InvokerLocator locator = new InvokerLocator(locatorURI); Map configuration = new HashMap(); configuration.put(Multiplex.SERVER_MULTIPLEX_ID, "client2server2"); connector = new Connector(locator.getLocatorURI(), configuration); connector.create(); connector.start(); System.out.println("Started callback server at: " + connector.getInvokerLocator()); return connector.getLocator(); }
public void setupServer() throws Exception { InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Starting remoting server with locator uri of: " + locatorURI); connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); TestStreamInvocationHandler invocationHandler = new TestStreamInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("test_stream", invocationHandler); connector.start(true); }
/** * This will be used to create callback server * * @param port * @return * @throws Exception */ private InvokerLocator initServer() throws Exception { String parameters = "/?serverMultiplexId=server2client1"; String locatorURI = "multiplex://localhost:8080" + parameters; InvokerLocator locator = new InvokerLocator(locatorURI); connector = new Connector(locator.getLocatorURI()); connector.create(); connector.start(); System.out.println("Started callback server at: " + connector.getInvokerLocator()); return connector.getLocator(); }
public void init() throws Exception { connector = new Connector(); InvokerLocator locator = new InvokerLocator("multiplex://localhost:9090"); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); handler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", handler); connector.start(); System.out.println("Started server at: " + connector.getInvokerLocator()); }
public void setupServer(String locatorURI) throws Exception { InvokerLocator locator = new InvokerLocator(locatorURI); connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); ServerInvocationHandler invocationHandler = new Handler(connector); connector.addInvocationHandler("stream", invocationHandler); connector.start(); }