List of usage examples for java.rmi Naming lookup
public static Remote lookup(String name) throws NotBoundException, java.net.MalformedURLException, RemoteException
name
. From source file:net.sf.mpaxs.spi.computeHost.Host.java
/** * Meldet diesen Host beim Masterserver an. Nach erfolgreicher Anmeldung * kann der Masterserver Jobs an diesen Host vergeben. *//* w w w. j a v a 2 s . c o m*/ private void connectToMasterServer() { final ScheduledExecutorService ses = Executors.newSingleThreadScheduledExecutor(); final long startUpAt = System.currentTimeMillis(); final long failAfter = 5000; ses.scheduleAtFixedRate(new Runnable() { @Override public void run() { Logger.getLogger(Host.class.getName()).log(Level.FINE, "Trying to connect to MasterServer from IP " + settings.getLocalIp()); long currentTime = System.currentTimeMillis(); if (currentTime - startUpAt >= failAfter) { Logger.getLogger(Host.class.getName()).log(Level.WARNING, "Waited {0} seconds for MasterServer, shutting down ComputeHost", (failAfter / 1000)); System.exit(1); } try { Logger.getLogger(Host.class.getName()).log(Level.FINE, "Trying to bind to MasterServer at " + settings.getMasterServerIP() + ":" + settings.getMasterServerPort() + " with name: " + settings.getMasterServerName()); IRemoteServer remRef = (IRemoteServer) Naming.lookup("//" + settings.getMasterServerIP() + ":" + settings.getMasterServerPort() + "/" + settings.getMasterServerName()); settings.setRemoteReference(remRef); UUID hostID = remRef.addHost(authToken, settings.getName(), settings.getLocalIp(), settings.getCores()); settings.setHostID(hostID); Logger.getLogger(Host.class.getName()).log(Level.FINE, "Connection to server established!"); ses.shutdown(); try { ses.awaitTermination(5, TimeUnit.SECONDS); } catch (InterruptedException ex) { Logger.getLogger(Host.class.getName()).log(Level.SEVERE, null, ex); } } catch (NotBoundException ex) { Logger.getLogger(Host.class.getName()).log(Level.INFO, "Master server not found, waiting for connection!"); //Logger.getLogger(Host.class.getName()).log(Level.SEVERE, null, ex); } catch (MalformedURLException ex) { Logger.getLogger(Host.class.getName()).log(Level.SEVERE, null, ex); System.exit(1); } catch (RemoteException ex) { Logger.getLogger(Host.class.getName()).log(Level.SEVERE, null, ex); System.exit(1); } } }, 1, settings.getMasterServerTimeout(), TimeUnit.SECONDS); }
From source file:org.speechforge.cairo.server.resource.ReceiverResource.java
public static void main(String[] args) throws Exception { CommandLineParser parser = new GnuParser(); Options options = getOptions();/* w w w . j av a2 s.co m*/ CommandLine line = parser.parse(options, args, true); args = line.getArgs(); if (args.length != 2 || line.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("ReceiverResource [options] <cairo-config-URL> <resource-name>", options); return; } URL configURL = CairoUtil.argToURL(args[0]); String resourceName = args[1]; CairoConfig config = new CairoConfig(configURL); ReceiverConfig resourceConfig = config.getReceiverConfig(resourceName); StringBuilder rmiUrl = new StringBuilder("rmi://"); if (line.hasOption(RSERVERHOST_OPTION)) { rmiUrl.append(line.getOptionValue(RSERVERHOST_OPTION)); } else { rmiUrl.append(CairoUtil.getLocalHost().getHostName()); } rmiUrl.append('/').append(ResourceRegistry.NAME); _logger.info("looking up: " + rmiUrl); ResourceRegistry resourceRegistry = (ResourceRegistry) Naming.lookup(rmiUrl.toString()); ReceiverResource impl = new ReceiverResource(resourceConfig); _logger.info("binding receiver resource..."); resourceRegistry.register(impl, RESOURCE_TYPE); _logger.info("Resource bound and waiting..."); }
From source file:edu.clemson.cs.nestbed.client.gui.NetworkMonitorFrame.java
private final void lookupRemoteManagers() throws RemoteException, NotBoundException, MalformedURLException { programManager = (ProgramManager) Naming.lookup(RMI_BASE_URL + "ProgramManager"); moteManager = (MoteManager) Naming.lookup(RMI_BASE_URL + "MoteManager"); moteTypeManager = (MoteTypeManager) Naming.lookup(RMI_BASE_URL + "MoteTypeManager"); mtbaManager = (MoteTestbedAssignmentManager) Naming.lookup(RMI_BASE_URL + "MoteTestbedAssignmentManager"); moteDepConfMgr = (MoteDeploymentConfigurationManager) Naming .lookup(RMI_BASE_URL + "MoteDeploymentConfigurationManager"); configManager = (ProjectDeploymentConfigurationManager) Naming .lookup(RMI_BASE_URL + "ProjectDeploymentConfigurationManager"); progDeployMgr = (ProgramDeploymentManager) Naming.lookup(RMI_BASE_URL + "ProgramDeploymentManager"); programProbeManager = (ProgramProbeManager) Naming.lookup(RMI_BASE_URL + "ProgramProbeManager"); }
From source file:edu.clemson.cs.nestbed.client.gui.TestbedManagerFrame.java
private final void lookupRemoteManagers() throws RemoteException, NotBoundException, MalformedURLException { testbedManager = (TestbedManager) Naming.lookup(RMI_BASE_URL + "TestbedManager"); projectManager = (ProjectManager) Naming.lookup(RMI_BASE_URL + "ProjectManager"); configManager = (ProjectDeploymentConfigurationManager) Naming .lookup(RMI_BASE_URL + "ProjectDeploymentConfigurationManager"); }
From source file:edu.clemson.cs.nestbed.client.gui.MoteManagementPanel.java
private final void lookupRemoteManagers() throws NotBoundException, MalformedURLException, RemoteException { messageManager = (MessageManager) Naming.lookup(RMI_BASE_URL + "MessageManager"); progDeployMgr = (ProgramDeploymentManager) Naming.lookup(RMI_BASE_URL + "ProgramDeploymentManager"); sfManager = (SerialForwarderManager) Naming.lookup(RMI_BASE_URL + "SerialForwarderManager"); motePowerManager = (MotePowerManager) Naming.lookup(RMI_BASE_URL + "MotePowerManager"); programProbeManager = (ProgramProbeManager) Naming.lookup(RMI_BASE_URL + "ProgramProbeManager"); }
From source file:edu.clemson.cs.nestbed.client.gui.MoteDetailFrame.java
private final void lookupRemoteManagers() throws RemoteException, NotBoundException, MalformedURLException { profSymManager = (ProgramProfilingSymbolManager) Naming .lookup(RMI_BASE_URL + "ProgramProfilingSymbolManager"); programSymbolManager = (ProgramSymbolManager) Naming.lookup(RMI_BASE_URL + "ProgramSymbolManager"); progMsgSymManager = (ProgramMessageSymbolManager) Naming .lookup(RMI_BASE_URL + "ProgramMessageSymbolManager"); progProfMsgSymManager = (ProgramProfilingMessageSymbolManager) Naming .lookup(RMI_BASE_URL + "ProgramProfilingMessageSymbolManager"); nucleusManager = (NucleusManager) Naming.lookup(RMI_BASE_URL + "NucleusManager"); }
From source file:org.red5.server.war.RootContextLoaderServlet.java
/** * Main entry point for the Red5 Server as a war */// ww w . java2 s . co m // Notification that the web application is ready to process requests @Override public void contextInitialized(ServletContextEvent sce) { if (null != servletContext) { return; } instance = this; System.setProperty("red5.deployment.type", "war"); myClassloader = getClass().getClassLoader(); servletContext = sce.getServletContext(); String prefix = servletContext.getRealPath("/"); servletContext.setAttribute("root.classloader", myClassloader); initRegistry(servletContext); long time = System.currentTimeMillis(); logger.info("RED5 Server (http://www.osflash.org/red5)"); logger.info("Root context loader"); logger.debug("Path: " + prefix); try { // instance the context loader ContextLoader loader = createContextLoader(); applicationContext = (ConfigurableWebApplicationContext) loader .initWebApplicationContext(servletContext); logger.debug("Root context path: " + applicationContext.getServletContext().getContextPath()); ConfigurableBeanFactory factory = applicationContext.getBeanFactory(); // register default factory.registerSingleton("default.context", applicationContext); // get the main factory parentFactory = (DefaultListableBeanFactory) factory.getParentBeanFactory(); // create a wrapper around our primary context BeanFactoryReference beanfactoryRef = new ContextBeanFactoryReference(applicationContext); // set it in the root servlet context servletContext.setAttribute("bean.factory.ref", beanfactoryRef); // set a remoting codec factory for AMF use servletContext.setAttribute("remoting.codec.factory", parentFactory.getBean("remotingCodecFactory")); server = (Server) parentFactory.getBean("red5.server"); clientRegistry = (ClientRegistry) factory.getBean("global.clientRegistry"); globalInvoker = (ServiceInvoker) factory.getBean("global.serviceInvoker"); globalStrategy = (MappingStrategy) factory.getBean("global.mappingStrategy"); global = (GlobalScope) factory.getBean("global.scope"); logger.debug("GlobalScope: " + global); global.setServer(server); global.register(); global.start(); globalResolver = new ScopeResolver(); globalResolver.setGlobalScope(global); logger.debug("About to grab Webcontext bean for Global"); Context globalContext = (Context) factory.getBean("global.context"); globalContext.setCoreBeanFactory(parentFactory); globalContext.setClientRegistry(clientRegistry); globalContext.setServiceInvoker(globalInvoker); globalContext.setScopeResolver(globalResolver); globalContext.setMappingStrategy(globalStrategy); logger.debug("About to grab Webcontext bean for ROOT"); Context webContext = (Context) factory.getBean("web.context"); webContext.setCoreBeanFactory(parentFactory); webContext.setClientRegistry(clientRegistry); webContext.setServiceInvoker(globalInvoker); webContext.setScopeResolver(globalResolver); webContext.setMappingStrategy(globalStrategy); WebScope scope = (WebScope) factory.getBean("web.scope"); scope.setServer(server); scope.setParent(global); scope.register(); scope.start(); // grab the scope list (other war/webapps) IRemotableList remote = (IRemotableList) Naming .lookup("rmi://localhost:" + rmiPort + "/subContextList"); logger.debug("Children: " + remote.numChildren()); if (remote.hasChildren()) { logger.debug("Children were detected"); for (int i = 0; i < remote.numChildren(); i++) { logger.debug("Enumerating children"); WebSettings settings = remote.getAt(i); registerSubContext(settings.getWebAppKey()); } logger.debug("End of children..."); } } catch (Throwable t) { logger.error(t); } finally { timer = new Timer(); checkScopeList = new CheckScopeListTask(); timer.scheduleAtFixedRate(checkScopeList, 1000, 30000); } long startupIn = System.currentTimeMillis() - time; logger.info("Startup done in: " + startupIn + " ms"); }
From source file:com.symbian.driver.remoting.client.TestClient.java
/** * Checks wether a connection is possible with the master and sets master * variable./*from w w w .j a v a 2 s . c om*/ * * @return boolean : true = connected, false = a coneaction error happened. * */ public boolean connectToMaster() { LOGGER.info("Client: Connecting to Master."); String lLookupName = null; try { lLookupName = (serverAddress != null) ? serverAddress : TDConfig.getInstance().getPreference(TDConfig.SERVER); master = (MasterRemote) Naming.lookup(lLookupName); } catch (NotBoundException lNBE) { LOGGER.log(Level.SEVERE, "Client: The remote service " + lLookupName + " is not available. ", lNBE); return false; } catch (AccessException lAE) { LOGGER.log(Level.SEVERE, "Client: Could not connect to Master. Server address supplied: " + lLookupName, lAE); return false; } catch (RemoteException lRE) { LOGGER.log(Level.SEVERE, "Client: Unable to connect to Master. Master may not be running. ", lRE); return false; } catch (MalformedURLException lMUE) { LOGGER.log(Level.SEVERE, "Client: The RMI Registry lookup name " + lLookupName + " is not appropriately formatted. ", lMUE); return false; } catch (ParseException lParseException) { LOGGER.log(Level.SEVERE, "Client: The RMI Registry lookup name " + lLookupName + " is not appropriately formatted. ", lParseException); return false; } LOGGER.info("Client: Connected to Master."); return true; }
From source file:edu.clemson.cs.nestbed.client.gui.ConfigManagerFrame.java
private final void lookupRemoteManagers() throws RemoteException, NotBoundException, MalformedURLException { programManager = (ProgramManager) Naming.lookup(RMI_BASE_URL + "ProgramManager"); mtbaManager = (MoteTestbedAssignmentManager) Naming.lookup(RMI_BASE_URL + "MoteTestbedAssignmentManager"); moteManager = (MoteManager) Naming.lookup(RMI_BASE_URL + "MoteManager"); moteTypeManager = (MoteTypeManager) Naming.lookup(RMI_BASE_URL + "MoteTypeManager"); progProfManager = (ProgramProfilingSymbolManager) Naming .lookup(RMI_BASE_URL + "ProgramProfilingSymbolManager"); programSymbolManager = (ProgramSymbolManager) Naming.lookup(RMI_BASE_URL + "ProgramSymbolManager"); progMsgSymManager = (ProgramMessageSymbolManager) Naming .lookup(RMI_BASE_URL + "ProgramMessageSymbolManager"); progProfMsgSymManager = (ProgramProfilingMessageSymbolManager) Naming .lookup(RMI_BASE_URL + "ProgramProfilingMessageSymbolManager"); moteDepConfMgr = (MoteDeploymentConfigurationManager) Naming .lookup(RMI_BASE_URL + "MoteDeploymentConfigurationManager"); programCompileManager = (ProgramCompileManager) Naming.lookup(RMI_BASE_URL + "ProgramCompileManager"); programWeaverManager = (ProgramWeaverManager) Naming.lookup(RMI_BASE_URL + "ProgramWeaverManager"); programProbeManager = (ProgramProbeManager) Naming.lookup(RMI_BASE_URL + "ProgramProbeManager"); }
From source file:org.act.index.server.MetaService.java
@Override public int replicateCore(Address dst, int coreId) { String url = "rmi://" + dst.getAddr().getAddress().getHostAddress() + ":" + dst.getAddr().getPort() + "/meta@server" + dst.getServerId(); try {//from w ww . j av a 2s . c o m System.out.println("core:" + coreId + "@server:" + dst.getServerId() + " begin replicating."); IMetaService metaService = (IMetaService) Naming.lookup(url); metaService.createCoreWithNoSegment(coreId); //String path = ServerParam.SOLR_HOME + "/core" + coreId + "/data/index/"; //FileSelection dir = new FileSelection(path, coreId); //dir.doBackup(dst.getAddr().getAddress(), dst.getAddr().getPort() - 1); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NotBoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } return GlobalMessage.ISS_SUCCESS; }