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; }
public ArrayList<KeyValueServerInterface> getServersList() throws RemoteException { // ArrayList<KeyValueServerInterface> res = new ArrayList(); try { Registry registry = LocateRegistry.getRegistry(); String[] name = registry.list(); for (String str : name) { // if( str.equals(server_name) ) continue; KeyValueServerInterface obj = (KeyValueServerInterface) registry.lookup(str); res.add(obj); } } catch (Exception e) { System.out.println(e.getMessage()); } return res; }