private MplsnmsRmiServiceAccessPoint connectRemote(CoreConfiguration config) throws NotBoundException, MalformedURLException, RemoteException { if (this.ap != null) { try { this.ap.getServiceFacade(); return this.ap; } catch (RemoteException e) { log.warn("got error from existing remote [MplsnmsRmiServiceAccessPoint].", e); this.ap = null; } } MplsnmsRmiServiceAccessPoint newAccessPoint = (MplsnmsRmiServiceAccessPoint) Naming.lookup(config.getDbServerUrl()); if (newAccessPoint == null) { throw new IllegalStateException("inventory server not found on " + config.getDbServerUrl()); } this.ap = newAccessPoint; registTriggers(); return ap; }
public static void main(String[] args) { if (args.length == 0) { System.err.println("usage: RegistryInspector [registry url]"); System.exit(-1); } String registry = args[0]; try { String[] names = Naming.list(registry); for (String name : names) { Remote remoteObject = Naming.lookup(name); if (remoteObject != null) { System.out.println("name[" + name + "] class=" + remoteObject.getClass().getCanonicalName()); } else { System.out.println("name[" + name + "] is null."); } } } catch (Exception e) { e.printStackTrace(); } }
/** * Register the sample company for remote invocation. */ public Server() { try { InetAddress addr = InetAddress.getLocalHost(); hostname = addr.getHostName(); } catch (UnknownHostException unknownHostException) { System.err.println("Failure during host name resolution: " + unknownHostException); } try { Naming.rebind("//" + hostname + "/meganalysis", mkSampleCompany()); } catch (RemoteException remoteException) { System.err.println("Failure during name registration: " + remoteException); } catch (MalformedURLException malformedException) { System.err.println("Failure during name registration: " + malformedException); } }
public static void main(String[] args) throws Throwable { try { int namingPort = Integer.getInteger(DUnitLauncher.RMI_PORT_PARAM).intValue(); int vmNum = Integer.getInteger(DUnitLauncher.VM_NUM_PARAM).intValue(); int pid = OSProcess.getId(); //logger.info("VM" + vmNum + " is launching" + (pid > 0? " with PID " + pid : "")); DUnitLauncher.MasterRemote holder = (DUnitLauncher.MasterRemote) Naming.lookup("//localhost:" + namingPort + "/" + DUnitLauncher.MASTER_PARAM); DUnitLauncher.init(holder); DUnitLauncher.locatorPort = holder.getLocatorPort(); Naming.rebind("//localhost:" + namingPort + "/vm" + vmNum, new RemoteDUnitVM()); holder.signalVMReady(); //This loop is here so this VM will die even if the master is mean killed. while(true) { holder.ping(); Thread.sleep(1000); } } catch (Throwable t) { t.printStackTrace(); System.exit(1); } }
public ClusterImpl(ActorSystem system, String host, String seedHost) throws RemoteException { super(); this.system = (AbsActorSystem) system; this.members = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>()); this.seed = seedHost; if (!host.equals(seedHost)) this.uuid = host + "/" + UUID.randomUUID().toString().replaceAll("-", ""); else this.uuid = host + "/master"; try { Naming.bind("rmi://" + this.uuid, this); join(this.uuid); if (!host.equals(seedHost)) updateMembers(seedHost, this.uuid); } catch (AlreadyBoundException | MalformedURLException e) { e.printStackTrace(); } }
/** * Create an instance of {@code actor} returning a {@link ActorRef reference} * to it using the given {@code mode} and a unique name inside the cluster. * * @param actor The type of actor that has to be created * @param mode The mode of the actor requested * @param name The name of the actor inside the cluster, must be unique * * @return A reference to the actor */ @Override public ActorRef<? extends Message> actorOf(Class<? extends Actor> actor, ActorMode mode, String name) throws RemoteException { ActorRef<? extends Message> ref = null; switch (mode) { case LOCAL: ref = system.actorOf(actor, mode, name); synchronized(this) { updateRemoteActors(name, ref); } break; case REMOTE: String addr = name.split("/")[0]; String memberName = (String) members.stream().filter(x -> x.startsWith(addr)).toArray()[0]; try { Cluster remoteMember = (Cluster) Naming.lookup("rmi://" + memberName); ref = remoteMember.actorOf(actor, ActorMode.LOCAL, name); } catch (NotBoundException | MalformedURLException | RemoteException e) { e.printStackTrace(); } break; } return ref; }
/** * Update new members' remote actors map so they can access to the actors * located on other {@code ActorSystem}. * * @param newMember The identifier name of the new member, in order to be * located across the cluster and be updated with remote actors table. */ @Override public void updateRemoteActors(String newMember) throws RemoteException { system.getRemoteActors() .entrySet() .stream() .forEach(x -> { try { final Cluster cluster = (Cluster) Naming.lookup("rmi://" + newMember); cluster.addRemoteRef(x.getKey(), x.getValue()); } catch (RemoteException | MalformedURLException | NotBoundException e) { e. printStackTrace(); } }); }
/** * Stops {@code actor} inside the cluster. * * @param actor The actor to be stopped */ @Override public synchronized void stop(ActorRef<? extends Message> actorRef) throws RemoteException { AbsActorSystem abSystem = (AbsActorSystem) system; if (!abSystem.contains(actorRef)) { String destName = actorRef.getName(); if (abSystem.containsRemote(destName)) { try { String addr = destName.split("/")[0]; String memberName = (String) members.stream().filter(x -> x.startsWith(addr)).toArray()[0]; Cluster clusterMember = (Cluster) Naming.lookup("rmi://" + memberName); clusterMember.stop(actorRef); } catch (NotBoundException | MalformedURLException e) { e.printStackTrace(); } } else throw new NoSuchActorException(); } else { system.stop(actorRef); } }
public static void main(String[] args) throws Throwable { try { int namingPort = Integer.getInteger(DUnitLauncher.RMI_PORT_PARAM).intValue(); int vmNum = Integer.getInteger(DUnitLauncher.VM_NUM_PARAM).intValue(); LogWriter log = Log.createLogWriter("dunit-vm-" + vmNum, DUnitLauncher.LOG_LEVEL); System.out.println("VM" + vmNum + " is launching"); DUnitLauncher.initSystemProperties(log); MasterRemote holder = (MasterRemote) Naming.lookup("//localhost:" + namingPort + "/" + DUnitLauncher.MASTER_PARAM); RemoteTestModule.Master = new FakeMaster(); DUnitLauncher.locatorPort = holder.getLocatorPort(); Naming.bind("//localhost:" + namingPort + "/vm" + vmNum, new FakeRemoteTestModule(log)); holder.signalVMReady(); //This loop is here so this VM will die even if the master is mean killed. while(true) { holder.ping(); Thread.sleep(1000); } } catch (Throwable t) { t.printStackTrace(); System.exit(1); } }
public final synchronized static Pi2GoLite getPi2GoLiteLocat(String rmiServerUrl) throws NotBoundException, MalformedURLException, RemoteException { // Assign security manager if (System.getSecurityManager() == null) { System.setSecurityManager (new SecurityManager()); } // Call registry for PowerService Pi2GoLiteRemote piRemote = (Pi2GoLiteRemote) Naming.lookup ("rmi://" + rmiServerUrl + "/Pi2GoLiteRemoteImpl"); //("rmi://" +"raspi-pi2go.homenet.telecomitalia.it" + "/Pi2GoLiteRemote"); Pi2GoLite piLocal = new Pi2GoLiteLocal (piRemote); return piLocal; }
public static String create(final Service svc, final int port) { String svcUri = null; try { synchronized(SVC_MAP) { //ensureRmiUseFixedPort(port); ensureRmiRegistryIsAvailableAt(port); UnicastRemoteObject.exportObject(svc, port); final String svcName = svc.getName(); svcUri = getLocalSvcUri(svcName, port).toString(); if(!SVC_MAP.containsKey(svcName + ":" + port)) { Naming.rebind(svcUri, svc); SVC_MAP.put(svcName + ":" + port, svc); } else { throw new AssertionError("Service already registered"); } } } catch(final IOException | URISyntaxException e) { e.printStackTrace(System.err); } return svcUri; }
public static String close(final Service svc) throws RemoteException, MalformedURLException { final String svcName = svc.getName(); String svcUri = null; try { UnicastRemoteObject.unexportObject(svc, true); } finally { try { svcUri = getLocalSvcUri(svcName, svc.getRegistryPort()).toString(); Naming.unbind(svcUri); synchronized(SVC_MAP) { if(null == SVC_MAP.remove(svcName + ":" + svc.getRegistryPort())) { System.err.println( "Failed to remove the service \"" + svcName + "\"" ); } } } catch(final NotBoundException | URISyntaxException e) { e.printStackTrace(System.err); } } return svcUri; }
public static void main(String[] args) { String location [] = { "rmi://127.0.0.1/seattle.mig.com/gumballmachine" }; GumballMonitor [] monitors = new GumballMonitor[location.length]; for(int i = 0 ; i < location.length ; i ++){ try{ GumballMachineRemote remote = (GumballMachineRemote) Naming.lookup(location[i]); monitors[i] = new GumballMonitor(remote); System.out.println(monitors[i]); }catch(Exception e){ e.printStackTrace(); } } for(int i = 0 ; i < location.length ; i ++){ monitors[i].report(); } }
public static void main(String[] args) { GumballMachineRemote remote = null; int count = 0; if(args.length < 2){ System.out.println("GumballMachine <name> <inventory>"); System.exit(1); } count = Integer.parseInt(args[1]); try { remote = new GumballMachine(args[0], count); System.out.println("/"+args[0]+"/gumballmachine"); Naming.rebind("/"+args[0]+"/gumballmachine", remote); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public SKAdminShell(SKGridConfiguration gc, InputStream in, PrintStream out, PrintStream err, String server, int port) throws NotBoundException, KeeperException, IOException { this.gc = gc; zkConfig = gc.getClientDHTConfiguration().getZKConfig(); zk = new ZooKeeperExtended(zkConfig, zkTimeout, this); this.in = new BufferedReader(new InputStreamReader(in)); this.out = out; this.err = err; rmc = (RingMasterControl)Naming.lookup("rmi://"+ server +":"+ port +"/"+ RingMasterControl.getRegistryName(gc)); sw = new SimpleStopwatch(); rings = ImmutableList.of(); com.ms.silverking.cloud.dht.meta.MetaClient dhtMC; com.ms.silverking.cloud.dht.meta.MetaPaths dhtMP; long latestConfigVersion; DHTConfiguration dhtConfig; dhtMC = new com.ms.silverking.cloud.dht.meta.MetaClient(gc); dhtMP = dhtMC.getMetaPaths(); latestConfigVersion = dhtMC.getZooKeeper().getLatestVersion(dhtMP.getInstanceConfigPath()); dhtConfig = new DHTConfigurationZK(dhtMC).readFromZK(latestConfigVersion, null); curTargetZK = new DHTRingCurTargetZK(dhtMC, dhtConfig); }
public static void main(String[] args) { // You may want a SecurityManager for downloading of classes: // System.setSecurityManager(new RMISecurityManager()); try { // Create an instance of the server object RemoteDateImpl im = new RemoteDateImpl(); System.out.println("DateServer starting..."); // Publish it in the RMI registry. // Of course you have to have rmiregistry or equivalent running! Naming.rebind(RemoteDate.LOOKUPNAME, im); System.out.println("DateServer ready."); } catch (Exception e) { System.err.println(e); System.exit(1); } }
public void init() { try { netConn = (RemoteDate)Naming.lookup(RemoteDate.LOOKUPNAME); } catch (Exception e) { System.err.println("RemoteDate exception: " + e.getMessage()); e.printStackTrace(); } add(b = new Button("Get Date")); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (netConn == null) { showStatus("Connection failed, bye"); return; } try { Date today = netConn.getRemoteDate(); showStatus(today.toString()); // XX use a DateFormat... } catch (Exception ex) { System.err.println("RemoteDate exception: " + ex.getMessage()); showStatus("RemoteDate failed, see Java Console"); } } }); }
/** * Returns a Collection of DBConnectionSpec objects which * represent all database entries known to the named RMI host. * * @return a Collection of databases the user can try to connect * to. All elements will be of type * ca.sqlpower.sql.DBConnectionSpec. The Collection will be empty * if no databases could be found. * @throws DatabaseListReadException if anything goes wrong on the * remote end or with the RMI communication itself. */ public static Collection getListUsingRMI(String host) throws DatabaseListReadException { Collection databases = null; DBConnectionSpecServer obj = null; try { obj = (DBConnectionSpecServer) Naming.lookup ("//"+host+"/DBConnectionSpecServer"); databases = obj.getAvailableDatabases(); } catch (Exception e) { // something bad happened getting the list of databases. throw new DatabaseListReadException(e); } return databases; }
public static void main(String[] args) { Collection message = null; DBConnectionSpecServer obj = null; try { obj = (DBConnectionSpecServer)Naming.lookup("//arthur/DBConnectionSpecServer"); message = obj.getAvailableDatabases(); Iterator messageIt = message.iterator(); while (messageIt.hasNext()) { System.out.println(messageIt.next()); } System.out.println("passcheck: "+obj.checkPassword("mo")); obj.setAvailableDatabases(message,"cow","cow"); } catch (Exception e) { System.out.println("exception: " + e.getMessage()); e.printStackTrace(); } }
public static void main(String[] args) throws UnknownHostException, RemoteException, MalformedURLException{ // System.setProperty("java.rmi.server.hostname", InetAddress.getLocalHost().toString()); // System.setProperty("java.rmi.server.hostname", "172.26.210.111"); // PaymentReceiptDataService data=new PaymentReceiptData(); AccountDataService accountData=new AccountData(); CollectionReceiptDataService collectionData=new CollectionReceiptData(); CostIncomeReceiptDataService costIncomeData=new CostIncomeReceiptData(); InitialStockDataService initData=new InitialStockData(); PaymentReceiptDataService paymentData=new PaymentReceiptData(); LocateRegistry.createRegistry(8800); //// //绑定RMI名称进行发布 Naming.rebind("rmi://localhost:8800/AccountDataService", accountData); Naming.rebind("rmi://localhost:8800/CollectionReceiptDataService", collectionData); Naming.rebind("rmi://localhost:8800/CostIncomeReceiptDataService", costIncomeData); Naming.rebind("rmi://localhost:8800/InitialStockDataService", initData); Naming.rebind("rmi://localhost:8800/PaymentReceiptDataService", paymentData); System.out.println("Service start at 8800 !"); }
public static void main(String[] args) throws Throwable { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.print("login: "); String login = br.readLine(); System.out.println(); System.out.print("password: "); String password = br.readLine(); System.out.println(); AuthRMIClientSocketFactory.setHostAuthData("127.0.0.1", new AuthData(login, password)); // Create and install a security manager if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } TestController test = (TestController) Naming.lookup(TestController.RMI_BINDING_NAME); System.out.println(test.f()); }
public static void main(String[] args){ try{ System.setProperty("java.rmi.server.hostname", "172.25.132.40"); CostDataService costData = new CostData(); LocateRegistry.createRegistry(6004); //绑定RMI名称进行发布 Naming.rebind("rmi://172.25.132.40:6004/CostDataService", costData); System.out.println("Cost Service start!"); ArrayList<CostPO> costList0 = costData.showAllCosts(); for(CostPO cost:costList0) System.out.println("ExpressType: "+cost.getExpressType()+", Cost: "+cost.getCost()); CostPO costpo = costData.findCost(ExpressType.FAST); System.out.println("ExpressType: "+costpo.getExpressType()+", Cost: "+costpo.getCost()); }catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public static void main(String[] args){ try{ System.setProperty("java.rmi.server.hostname", "172.25.132.40"); BasicSalaryDataService basicSalaryData = new BasicSalaryData(); LocateRegistry.createRegistry(6003); //绑定RMI名称进行发布 Naming.rebind("rmi://172.25.132.40:6003/BasicSalaryDataService", basicSalaryData); System.out.println("BasicSalary Service start!"); ArrayList<BasicSalaryPO> basicSalaryList0 = basicSalaryData.showAllBasicSalarys(); for(BasicSalaryPO basicSalary:basicSalaryList0) System.out.println("Profession: "+basicSalary.getProfession()+", BasicSalary: "+basicSalary.getBasicSalary()); BasicSalaryPO basicSalarypo = basicSalaryData.findBasicSalary(ProfessionType.manager); System.out.println("Profession: "+basicSalarypo.getProfession()+", BasicSalary: "+basicSalarypo.getBasicSalary()); }catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public static void main(String[] args) { try { System.setProperty("java.rmi.server.hostname", "172.25.132.40"); CityDistanceDataService cityDistanceData = new CityDistanceData(); LocateRegistry.createRegistry(6005); // ������RMI������������������ Naming.rebind("rmi://172.25.132.40:6005/CityDistanceDataService", cityDistanceData); System.out.println("CityDistance Service start!"); ArrayList<CityDistancePO> cityDistanceList0 = cityDistanceData.showAllCityDistances(); for (CityDistancePO cityDistance : cityDistanceList0) System.out.println("CityA: " + cityDistance.getCityA() + ", CityB: " + cityDistance.getCityB() + ", CityDistance: " + cityDistance.getDistance()); CityDistancePO cityDistancepo = cityDistanceData.findCityDistanceByBoth("������", "������"); System.out.println("CityA: " + cityDistancepo.getCityA() + ", CityB: " + cityDistancepo.getCityB() + ", CityDistance: " + cityDistancepo.getDistance()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public static void main(String[] args) { try { System.setProperty("java.rmi.server.hostname", "172.25.132.40"); OrganizationDataService organizationData = new OrganizationData(); LocateRegistry.createRegistry(6006); // 绑定RMI名称进行发布 Naming.rebind("rmi://172.25.132.40:6006/OrganizationDataService", organizationData); System.out.println("Organization Service start!"); ArrayList<OrganizationPO> organizationList0 = organizationData.showAllOrganizations(); for (OrganizationPO organization : organizationList0) System.out.println("ID: " + organization.getOrganizationID() + ", Name: " + organization.getName()); OrganizationPO organizationpo = organizationData.findOrganization("025000"); System.out.println("ID: " + organizationpo.getOrganizationID() + ", Name: " + organizationpo.getName()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public synchronized static void init() throws ServerInitException { if (inited) { return; } try { LocateRegistry.createRegistry(PORT); for (Entry<String, Class<? extends UnicastRemoteObject>> entry : NAMING_MAP.entrySet()) { String name = entry.getKey(); Class<? extends UnicastRemoteObject> clazz = entry.getValue(); UnicastRemoteObject proxy = clazz.newInstance(); Naming.rebind(name, proxy); } inited = true; } catch (Exception e) { throw new ServerInitException(e); } }
public Service() { File file = FileGetter.getFile("address"); try { if (!file.exists()) { JOptionPane.showMessageDialog(null, "IP地址文件不存在,将使用本地地址,请检查Info目录下的address是否丢失"); address = "localhost"; } else { Scanner in = new Scanner(file); address = in.nextLine(); in.close(); } System.setProperty("java.rmi.server.hostname", address); reg = LocateRegistry.createRegistry(8888); test = new Test(); Naming.bind("rmi://" + address + ":8888/TestConnection", test); } catch (Exception e) { JOptionPane.showMessageDialog(null, "请勿重复启动服务器", "", JOptionPane.ERROR_MESSAGE); System.exit(0); e.printStackTrace(); } }
public boolean testConnection() { Scanner in = null; try { in = new Scanner(FileGetter.getFile("address")); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } String address = in.next(); in.close(); try { return ((TestConnection) Naming.lookup("//" + address + "/TestConnection")).getConnectionInfo(); } catch (Exception e) { return false; } }
public Statement createStatement() throws RemoteException { try { if (statement == null) { //init connection ConnectionConf connectionConf = sdbConf.getConnectionConf(); //create sdbStatement LOG.info("Creating sdb statement"); SdbStatement sdbStatement = new SdbStatement(metaStore, serverConnection, serverDB, sdbConf.getServerConf()); serviceUrl = connectionConf.getSdbAddress() + ":" + connectionConf.getSdbPort() + "/" + SERVICE_NAME; Naming.rebind(serviceUrl, sdbStatement); } statement = (Statement) Naming.lookup(serviceUrl); } catch (RemoteException | NotBoundException | MalformedURLException e) { e.printStackTrace(); } return statement; }
public Connection getConnection() { Connection connection = null; //TODO enable multiple connection synchronized (this) { if (availableConnectionNumber > 0) { if (sdbConnection == null) { createConnection(); } try { connection = (Connection) Naming.lookup(serviceUrl); } catch (NotBoundException | MalformedURLException | RemoteException e) { e.printStackTrace(); } availableConnectionNumber--; return connection; } else return null; } }
public static void main(String[] args) { if(args.length != 1) usage("Wrong number of arguments."); NumberCruncherServer ncs; PropertyConfigurator.configure(args[0]); try { ncs = new NumberCruncherServer(); Naming.rebind("Factor", ncs); logger.info("NumberCruncherServer bound and ready to serve."); } catch(Exception e) { logger.error("Could not bind NumberCruncherServer.", e); return; } NumberCruncherClient.loop(ncs); }
/** * @param args the command line arguments */ public static void main(String[] args) { Contador c = null; try { Caja caja = (Caja) Naming.lookup("rmi://localhost:1099/CajaRemota"); c = (Contador) caja.lee(); if (null != c) { System.out.println("valor de la caja: "+c.lee()); caja.quita(); System.out.println("Caja vaciada."); } else System.out.println("La caja estaba vacía."); } catch (Exception e) { e.printStackTrace(System.err); } }
/** * @param args the command line arguments */ public static void main(String[] args) { try { FileSearch fSearch = (FileSearch) Naming.lookup("rmi://localhost:1099/MasterIndex"); FileServer fServer = new FileServerImpl(); String clave = fSearch.registra("SergioGarciaPrado", fServer); System.out.println("Servidor local registrado con nombre: "+clave); } catch (Exception e) { System.err.println("<Cliente: Excepcion: "+e); e.printStackTrace(); } }
public static void main(String [ ] args) { String nombre = (args.length < 1) ? "anonimo" : args[0]; try { Object obj = Naming.lookup("ObjetoHola"); Hola oHola = (Hola) obj; HolaRegistro oHolaRegistro = (HolaRegistro) obj; String respuesta = oHola.saluda(nombre); System.out.println("[Respuesta: "+respuesta+"]"); Map<String,String> listado; listado = oHolaRegistro.lista(); for (String clave : listado.keySet()) { String valor = listado.get(clave); System.out.println("< "+clave+" , "+valor+" >"); } } catch (Exception e) { System.err.println("<Cliente: Excepcion: "+e); e.printStackTrace(); } }
public Client(String server) throws Exception { try { sampleCompany = (Company) Naming.lookup("//" + server + "/meganalysis"); } catch (MalformedURLException malformedException) { System.err.println("Bad URL: " + malformedException); } catch (NotBoundException notBoundException) { System.err.println("Not Bound: " + notBoundException); } catch (RemoteException remoteException) { System.err.println("Remote Exception: " + remoteException); } demo(); }
/** * Start the Server and wait for user termination by keyboard. * * @param args * This program does not accept command line parameters. */ public static void main(String args[]) { // Override the default security manager System.setSecurityManager(new SecurityManager()); try { LocateRegistry.createRegistry(Registry.REGISTRY_PORT); } catch (RemoteException remoteException) { remoteException.printStackTrace(); } Server server = new Server(); System.out.println("Server started."); System.out.println("Enter <CR> to end."); try { System.in.read(); // Wait for Enter ... } catch (IOException ioException) { ioException.printStackTrace(); } try { Naming.unbind("//" + server.hostname + "/meganalysis"); } catch (Exception e) { e.printStackTrace(); } finally { System.exit(0); } }
public static void main(String[] args) throws RemoteException, MalformedURLException { try { Server server = new Server(); String location = "//localhost/service"; Naming.rebind(location, server); } catch (MalformedURLException e) { System.out.println("Error - Malformed URL: " + e.getMessage()); } catch (RemoteException ex) { System.out.println("Error: " + ex.getMessage()); } }