public SetupDataClient() throws RemoteException { try { // get the registry registry = LocateRegistry.getRegistry(serverAddress, (new Integer(serverPort)).intValue()); // look up the remote object rmiServer = (databaseinter) registry.lookup("Database"); rmiServer.receiveMessage("abc"); // starting time long time1 = System.currentTimeMillis(); // call the remote method System.out.println("sending " + text + " to " + serverAddress + ":" + serverPort); // receiving time long time2 = System.currentTimeMillis(); long timedelay = time2 - time1; System.out.println("RMI delay time: " + timedelay); // converting process // finish converting long time3 = System.currentTimeMillis(); long timefinish = time3 - time1; System.out.println("Total time: " + timefinish); } catch (NotBoundException e) { e.printStackTrace(); } catch (IOException e) { System.out.println("File not found"); System.out.println(e.getMessage()); e.printStackTrace(); } }
private void checkSslConfig() throws IOException { // Get the reference to the RMI Registry and lookup RMIServer stub // Registry registry; try { registry = LocateRegistry.getRegistry(registryHostName, registryPort, sslRMIClientSocketFactory); try { stub = (RMIServer) registry.lookup("jmxrmi"); } catch (NotBoundException nbe) { throw (IOException) new IOException(nbe.getMessage()).initCause(nbe); } sslRegistry = true; } catch (IOException e) { registry = LocateRegistry.getRegistry(registryHostName, registryPort); try { stub = (RMIServer) registry.lookup("jmxrmi"); } catch (NotBoundException nbe) { throw (IOException) new IOException(nbe.getMessage()).initCause(nbe); } sslRegistry = false; } // Perform the checks for secure stub // try { checkStub(stub, rmiServerImplStubClass); sslStub = true; } catch (SecurityException e) { sslStub = false; } }
/** * *************************************************************** * * @param ip * @param port * @return */ public ChordMessageInterface rmiChord(String ip, int port) { ChordMessageInterface chord = null; try { Registry registry = LocateRegistry.getRegistry(ip, port); chord = (ChordMessageInterface) (registry.lookup("Chord")); return chord; } catch (RemoteException e) { e.printStackTrace(); } catch (NotBoundException e) { e.printStackTrace(); } return null; }