/** * Unbind the RMI service from the registry on bean factory shutdown. */ @Override public void destroy() throws RemoteException { if (logger.isInfoEnabled()) { logger.info("Unbinding RMI service '" + this.serviceName + "' from registry" + (this.createdRegistry ? (" at port '" + this.registryPort + "'") : "")); } try { this.registry.unbind(this.serviceName); } catch (NotBoundException ex) { if (logger.isWarnEnabled()) { logger.warn("RMI service '" + this.serviceName + "' is not bound to registry" + (this.createdRegistry ? (" at port '" + this.registryPort + "' anymore") : ""), ex); } } finally { unexportObjectSilently(); } }
protected boolean setUp(){ try{ setUpEV3(); setUpPorts(); setUpShooter(); return true; } catch(RemoteException | MalformedURLException | NotBoundException e){ logger.error("Could not open ports " + e.getMessage()); try{ closePorts(); } catch(RemoteException e1){ logger.error("Error closing ports " + e1.getMessage()); } return false; } }
private static void startLocator(Registry registry) throws IOException, NotBoundException { RemoteDUnitVMIF remote = (RemoteDUnitVMIF) registry.lookup("vm" + LOCATOR_VM_NUM); final File locatorLogFile = LOCATOR_LOG_TO_DISK ? new File("locator-" + locatorPort + ".log") : new File(""); MethExecutorResult result = remote.executeMethodOnObject(new SerializableCallable() { public Object call() throws IOException { Properties p = getDistributedSystemProperties(); // I never want this locator to end up starting a jmx manager // since it is part of the unit test framework p.setProperty("jmx-manager", "false"); //Disable the shared configuration on this locator. //Shared configuration tests create their own locator p.setProperty("enable-cluster-configuration", "false"); Locator.startLocatorAndDS(locatorPort, locatorLogFile, p); return null; } }, "call"); if(result.getException() != null) { RuntimeException ex = new RuntimeException("Failed to start locator", result.getException()); ex.printStackTrace(); throw ex; } }
public synchronized Channel inheritedChannel() throws IOException { System.err.println("SP.inheritedChannel"); if (channel == null) { channel = SocketChannel.open(); Socket socket = channel.socket(); System.err.println("socket = " + socket); /* * Notify test that inherited channel was created. */ try { System.err.println("notify test..."); Registry registry = LocateRegistry.getRegistry(TestLibrary.INHERITEDCHANNELNOTSERVERSOCKET_REGISTRY_PORT); Callback obj = (Callback) registry.lookup("Callback"); obj.notifyTest(); } catch (NotBoundException nbe) { throw (IOException) new IOException("callback object not bound"). initCause(nbe); } } return channel; }
@Override public List<? extends IModel> refresh() throws RemoteException, ExternalServiceException, IOException, AuthenticationException, NotBoundException, InstantiationException, IllegalAccessException { List<Vrf> result = new ArrayList<Vrf>(); List<String> inventoryIds = new ArrayList<String>(); for (IModel target : getTargets()) { inventoryIds.add(target.getId()); } for (String inventoryId : inventoryIds) { Vrf vrfModel = VrfModelCreator.createModel(VrfHandler.getVrfIfDto(inventoryId), inventoryId); result.add((Vrf) new VplsModelDisplayNameConverter().convertModel(vrfModel)); } return result; }
@Override public TableInput makeListView() throws RemoteException, AuthenticationException, InventoryException, ExternalServiceException, IOException, NotBoundException, InstantiationException, IllegalAccessException, ParseException { List<? extends IModel> vlanLinkList = new ArrayList<IModel>(); for (String str : getQuery().keySet()) { log.debug(str + " : " + getQuery().getMatcher(str).hashCode()); } if (hasMvoIdAsKeyInQuery()) { String mvoId = getMvoIdFromQuery(); vlanLinkList = VlanLinkHandler.getList(mvoId); } return getConverter().convertList(vlanLinkList); }
@Override public TableInput makeListView() throws RemoteException, AuthenticationException, InventoryException, ExternalServiceException, IOException, NotBoundException, InstantiationException, IllegalAccessException, ParseException { List<? extends IModel> subnetList = new ArrayList<IModel>(); if (hasInventoryIdAsKeyInQuery()) { String mvoId = getInventoryIdFromQuery(); subnetList = SubnetIpHandler.getList(getQuery(), mvoId); } else { subnetList = SubnetIpHandler.getList(getQuery()); } return getConverter().convertList(subnetList); }
public IDiagram build() throws RemoteException, InventoryException, ExternalServiceException, IOException, AuthenticationException, NotBoundException { IDiagram diagram = new Diagram(); List<String> iRefs = new ArrayList<String>(); diagram.setPropertyValue(IPropertyConstants.PROPERTY_INVENTORY_REFS, iRefs); diagram.setText("Whole LSP Topology"); MplsNmsInventoryConnector conn = MplsNmsInventoryConnector.getInstance(); for (RsvpLspIdPoolDto pool : conn.getRsvpLspIdPool()) { for (RsvpLspDto lsp : pool.getUsers()) { if (lsp.getHopSeries1() != null) { setModelsOnHopSeries(diagram, lsp.getHopSeries1().getHops(), true); } if (lsp.getHopSeries2() != null) { setModelsOnHopSeries(diagram, lsp.getHopSeries2().getHops(), false); } } } for (PhysicalLink link : this.linkCache.values()) { setPathStyle(link); } return diagram; }
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(); }
public static ItfUsoAgenteReactivo getItfAgteReactRemoto(String host, String nombreAgente) throws RemoteException, NotBoundException { // Registry regCliente = LocateRegistry.getRegistry(ip, 1099); // ItfUsoAgenteReactivo agenteRemoto = null; // if (regCliente == null) return null; // else { // agenteRemoto = (ItfUsoAgenteReactivo) regCliente.lookup(nombreAgente); // return agenteRemoto; // } return getItfAgteReactRemoto (host, 1099, nombreAgente); }
public static List<Vrf> get(String inventoryId) throws NotBoundException, AuthenticationException, IOException, ExternalServiceException { List<Vrf> vrfList = new ArrayList<Vrf>(); for (VrfIfDto vrf : VrfExtUtil.getVrfIfDtos()) { if (InventoryIdUtil.getInventoryId(vrf).equals(inventoryId)) { vrfList.add(VrfModelCreator.createModel(vrf, InventoryIdUtil.getInventoryId(vrf))); } } return vrfList; }
public static Remote getItfUsoRecursoRemoto(String identHost, String nombreRecurso) throws RemoteException, NotBoundException { Registry regCliente = LocateRegistry.getRegistry(identHost); InterfazGestion agenteRemoto = null; if (regCliente == null) return null; else // agenteRemoto = (ItfUsoAgenteReactivo) regCliente.lookup(nombreAgente); // return agenteRemoto; // } return regCliente.lookup(NombresPredefinidos.ITF_USO+nombreRecurso); }
public static List<PhysicalLink> getList(ObjectFilterQuery query) throws NotBoundException, AuthenticationException, IOException, ExternalServiceException { List<PhysicalLink> linkList = new ArrayList<PhysicalLink>(); for (IpSubnetDto link : filterLinks(query, MplsNmsInventoryConnector.getInstance().getActiveIpSubnets())) { linkList.add(LinkModelCreator.createModel(link, InventoryIdUtil.getInventoryId(link))); } return linkList; }
public static List<LabelSwitchedPath> getListUnderPseudoWire(String pwInventoryId) throws AuthenticationException, NotBoundException, IOException, ExternalServiceException { List<LabelSwitchedPath> lspList = new ArrayList<LabelSwitchedPath>(); for (PseudowireDto pw : MplsNmsInventoryConnector.getInstance().getDtoFacade().getPseudowires()) { if (PseudoWireRenderer.getPseudoWireID(pw).equals(PseudoWireHandler.parseVcId(pwInventoryId))) { appendLSPList(lspList, pw.getRsvpLsps()); } } return lspList; }
public static List<PseudoWire> getListUpperLsp(String lspInventoryId) throws AuthenticationException, NotBoundException, IOException, ExternalServiceException { List<PseudoWire> pwList = new ArrayList<PseudoWire>(); for (RsvpLspDto lsp : MplsNmsInventoryConnector.getInstance().getDtoFacade().getRsvpLsps()) { if (InventoryIdUtil.getInventoryId(lsp).equals(lspInventoryId)) { appendPwList(pwList, getPseudoWiresOn(lsp)); } } return pwList; }
public static List<SubnetIp> getList(ObjectFilterQuery query) throws NotBoundException, AuthenticationException, IOException, InventoryException, ExternalServiceException { List<SubnetIp> subnetIpList = new ArrayList<SubnetIp>(); if (!(query.containsKey("TargetNodeName") || query.containsKey("TargetIfName"))) { IMatcher subnetMatcher = query.get("SubnetIP"); for (IpSubnetNamespaceDto ipSubnetNameSpace : SubnetRenderer.getAllIpSubnetNamespace()) { Set<IpSubnetDto> ipSubnets = ipSubnetNameSpace.getUsers(); if (ipSubnets == null) { continue; } for (IpSubnetDto ipSubnet : ipSubnets) { subnetIpList.addAll(createIpList(ipSubnet, subnetMatcher)); } } } List<PortDto> ipIfList = new ArrayList<PortDto>(); for (NodeDto node : MplsNmsInventoryConnector.getInstance().getActiveNodes()) { for (PortDto port : node.getPorts()) { if (isTargetPort(port)) { ipIfList.add((IpIfDto) port); } } } for (PortDto ipif : filter(query, ipIfList)) { SubnetIp model = SubnetIpModelCreator.createModel(ipif, InventoryIdCalculator.getId(ipif)); int i = ipContains(subnetIpList, model); if (i < 0) { subnetIpList.add(model); } else { subnetIpList.set(i, model); } } return subnetIpList; }
public IDiagram build(String inventoryId) throws RemoteException, ExternalServiceException, IOException, AuthenticationException, NotBoundException { IDiagram diagram = new Diagram(); FakePseudoWire fpw = PseudoWireHandler.getPseudowireDto(inventoryId); RsvpLspDto lsp = null; PortDto ingress = null; PortDto egress = null; if (fpw.isPipe()) { lsp = null; ingress = fpw.getAc1(); egress = fpw.getAc2(); } else { lsp = PseudoWireHandler.getLspOnSrc(inventoryId); ingress = PseudoWireHandler.getAcOnIngress(fpw.getPseudowireDto(), lsp); egress = PseudoWireHandler.getAcOnEgress(fpw.getPseudowireDto(), lsp); } List<String> iRefs = new ArrayList<String>(); iRefs.add(inventoryId); diagram.setPropertyValue(IPropertyConstants.PROPERTY_INVENTORY_REFS, iRefs); diagram.setPropertyValue(IPropertyConstants.PROPERTY_DIAGRAM_SORUCE, PseudoWireModelCreator.createModel(fpw, lsp, inventoryId, ingress, egress)); diagram.setText(InventoryIdUtil.unEscape(inventoryId)); if (fpw.isPseudoWire()) { attachLsp(diagram, fpw.getPseudowireDto()); } else { drawPipe(diagram, fpw); } return diagram; }
@Test(expected = IllegalArgumentException.class) public void testRemoteException() throws NotBoundException, RemoteException { when(testService.getString(any())).thenAnswer(i -> { System.out.println("Got request to server mock"); throw new IllegalArgumentException("Illegal argument"); }); TestService srv = client.getInstance(); srv.getString("string"); }
@Test public void testRemoteRequestSerialTiming() throws NotBoundException, RemoteException { int count = 100; TestService srv = client.getInstance(); long start = System.currentTimeMillis(); for (int i = 0; i < count; i++) { srv.getString("str" + i); } long end = System.currentTimeMillis(); long time = end - start; System.out.println(String.format("Executed %d invocations in %d ms (%.2f ms/req)", count, time, ((double) time) / count)); }
public static List<LabelSwitchedPath> getList(ObjectFilterQuery query) throws NotBoundException, AuthenticationException, IOException, ExternalServiceException { List<LabelSwitchedPath> lspList = new ArrayList<LabelSwitchedPath>(); List<RsvpLspDto> lsps = new ArrayList<RsvpLspDto>(); for (RsvpLspDto lsp : MplsNmsInventoryConnector.getInstance().getRegularRsvpLspPool().getUsers()) { lsps.add(lsp); } appendLSPList(lspList, filterLSPs(query, lsps)); return lspList; }
public void init(Registry registry, int numVMs) throws AccessException, RemoteException, NotBoundException, InterruptedException { for(int i = 0; i < numVMs; i++) { RemoteDUnitVMIF remote = processManager.getStub(i); addVM(i, remote); } addLocator(LOCATOR_VM_NUM, processManager.getStub(LOCATOR_VM_NUM)); addHost(this); }
@Override public VM getVM(int n) { if(n == DEBUGGING_VM_NUM) { //for ease of debugging, pass -1 to get the local VM return debuggingVM; } int oldVMCount = getVMCount(); if(n >= oldVMCount) { //If we don't have a VM with that number, dynamically create it. try { for(int i = oldVMCount; i <= n; i++) { processManager.launchVM(i); } processManager.waitForVMs(STARTUP_TIMEOUT); for(int i = oldVMCount; i <= n; i++) { addVM(i, processManager.getStub(i)); } } catch (IOException | InterruptedException | NotBoundException e) { throw new RuntimeException("Could not dynamically launch vm + " + n, e); } } return super.getVM(n); }
/** * Removes the binding for the specified <code>name</code> in the rmiregistry * * @see java.rmi.registry.Registry#unbind(String) */ public void unbind(String name) throws RemoteException, NotBoundException { if (!isRunning()) { throw new IllegalStateException("RMIRegistryService is not running"); } registry.unbind(name); }
static void initializeLocalSide(String transactionCoordinatorServiceUrl) throws RemoteException, NotBoundException, MalformedURLException { distributedTransactionService__ = (DistributedTransactionService) Naming .lookup(transactionCoordinatorServiceUrl); TefServiceProxy tefServiceProxy = new TefServiceProxy.Impl(); UnicastRemoteObject.exportObject(tefServiceProxy); distributedTransactionService__.enlist(tefServiceProxy); }
private static int startLocator(Registry registry) throws IOException, NotBoundException { RemoteDUnitVMIF remote = (RemoteDUnitVMIF) registry.lookup("vm" + LOCATOR_VM_NUM); final File locatorLogFile = LOCATOR_LOG_TO_DISK ? new File("locator-" + locatorPort + ".log") : new File(""); MethExecutorResult result = remote.executeMethodOnObject(new SerializableCallable() { public Object call() throws IOException { Properties p = getDistributedSystemProperties(); // I never want this locator to end up starting a jmx manager // since it is part of the unit test framework p.setProperty(JMX_MANAGER, "false"); // Disable the shared configuration on this locator. // Shared configuration tests create their own locator p.setProperty(ENABLE_CLUSTER_CONFIGURATION, "false"); // Tell the locator it's the first in the system for // faster boot-up System.setProperty(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY, "true"); // disable auto-reconnect - tests fly by so fast that it will never be // able to do so successfully anyway p.setProperty(DISABLE_AUTO_RECONNECT, "true"); try { Locator.startLocatorAndDS(0, locatorLogFile, p); InternalLocator internalLocator = (InternalLocator) Locator.getLocator(); locatorPort = internalLocator.getPort(); internalLocator.resetInternalLocatorFileNamesWithCorrectPortNumber(locatorPort); } finally { System.getProperties().remove(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY); } return locatorPort; } }, "call"); if (result.getException() != null) { RuntimeException ex = new RuntimeException("Failed to start locator", result.getException()); ex.printStackTrace(); throw ex; } return (Integer) result.getResult(); }
public void init(Registry registry, int numVMs) throws AccessException, RemoteException, NotBoundException, InterruptedException { for (int i = 0; i < numVMs; i++) { RemoteDUnitVMIF remote = processManager.getStub(i); addVM(i, remote); } addLocator(LOCATOR_VM_NUM, processManager.getStub(LOCATOR_VM_NUM)); addHost(this); }
private static synchronized void initialize() throws Exception { if (blackboard == null) { System.out.println( DUnitLauncher.RMI_PORT_PARAM + "=" + System.getProperty(DUnitLauncher.RMI_PORT_PARAM)); int namingPort = Integer.getInteger(DUnitLauncher.RMI_PORT_PARAM).intValue(); String name = "//localhost:" + namingPort + "/" + "InternalBlackboard"; try { blackboard = (InternalBlackboard) Naming.lookup(name); } catch (NotBoundException e) { // create the master blackboard in this VM blackboard = new InternalBlackboardImpl(); Naming.bind(name, blackboard); } } }
private JournalMirroringServer connectMasterServer() throws RemoteException, NotBoundException, MalformedURLException { String distributorUrl = tefService_.getTefServiceConfig().getMasterServerConfig().distributorUrl; logMessage("connecting master, " + distributorUrl); return (JournalMirroringServer) Naming.lookup(distributorUrl); }
/** * Returns the activation system stub if the specified name * matches the activation system's class name, otherwise * returns the result of invoking super.lookup with the specified * name. */ public Remote lookup(String name) throws RemoteException, NotBoundException { if (name.equals(NAME)) { return systemStub; } else { return super.lookup(name); } }
public void unbind(String name) throws RemoteException, NotBoundException, AccessException { if (name.equals(NAME)) { throw new AccessException( "unbinding ActivationSystem is disallowed"); } else { super.unbind(name); } }
public synchronized Channel inheritedChannel() throws IOException { System.err.println("RmidSelectorProvider.inheritedChannel"); if (channel == null) { /* * Create server socket channel and bind server socket. */ channel = ServerSocketChannel.open(); ServerSocket serverSocket = channel.socket(); serverSocket.bind( new InetSocketAddress(InetAddress.getLocalHost(), TestLibrary.RMIDVIAINHERITEDCHANNEL_ACTIVATION_PORT)); System.err.println("serverSocket = " + serverSocket); /* * Notify test that inherited channel was created. */ try { System.err.println("notify test..."); Registry registry = LocateRegistry.getRegistry(TestLibrary.RMIDVIAINHERITEDCHANNEL_REGISTRY_PORT); Callback obj = (Callback) registry.lookup("Callback"); obj.notifyTest(); } catch (NotBoundException nbe) { throw (IOException) new IOException("callback object not bound"). initCause(nbe); } } return channel; }
public static List<PhysicalEthernetPort> get(String inventoryId) throws NotBoundException, AuthenticationException, IOException, InventoryException, ExternalServiceException { List<PhysicalEthernetPort> portList = new ArrayList<PhysicalEthernetPort>(); for (PortDto port : getActivePorts()) { if (InventoryIdUtil.getInventoryId(port).equals(inventoryId)) { portList.add(PortModelCreator.createModel(port, InventoryIdUtil.getInventoryId(port))); break; } } return portList; }
@Test public void simpleRejectableClass() throws RemoteException, AlreadyBoundException, NotBoundException { RejectableClass r1 = null; try { String name = "reject1"; r1 = new RejectableClass(); registry.bind(name, r1); registry.unbind(name); Assert.assertNull(registryFilter, "Registry filter should not have rejected"); } catch (Exception rex) { Assert.assertNotNull(registryFilter, "Registry filter should have rejected"); } }
/** * Returns the activation system stub if the specified name * matches the activation system's class name, otherwise * returns the result of invoking super.lookup with the specified * name. */ public Remote lookup(String name) throws RemoteException, NotBoundException { if (name.equals(NAME)) { return getSystemStub(); } else { return super.lookup(name); } }
public void unbind(String name) throws RemoteException, NotBoundException, AccessException { if (name.equals(NAME)) { throw new AccessException( "unbinding ActivationSystem is disallowed"); } else { RegistryImpl.checkAccess("ActivationSystem.unbind"); super.unbind(name); } }
public static List<PhysicalEthernetPort> getListOwnedByNode(String nodeInventoryId) throws NotBoundException, AuthenticationException, IOException, InventoryException, ExternalServiceException { List<PhysicalEthernetPort> portList = new ArrayList<PhysicalEthernetPort>(); try { String nodeID = InventoryIdDecoder.getNode(nodeInventoryId); appendPortList(portList, getTargetPorts(MplsNmsInventoryConnector.getInstance().getNodeDto(nodeID))); return portList; } catch (ParseException e) { throw new InventoryException("illegal inventory-id.", e); } }
@Test(dataProvider="bindData") public void simpleBind(String name, Remote obj, boolean blacklisted) throws RemoteException, AlreadyBoundException, NotBoundException { try { registry.bind(name, obj); Assert.assertFalse(blacklisted, "Registry filter did not reject (but should have) "); registry.unbind(name); } catch (Exception rex) { Assert.assertTrue(blacklisted, "Registry filter should not have rejected"); } }
@Test public void simpleRejectableClass() throws RemoteException, AlreadyBoundException, NotBoundException { RejectableClass r1 = null; try { String name = "reject1"; r1 = new RejectableClass(); registry.bind(name, r1); registry.unbind(name); Assert.assertNull(registryFilter, "Registry filter should have rejected"); } catch (Exception rex) { Assert.assertNotNull(registryFilter, "Registry filter should not have rejected"); } }
@Test public void simpleDepthRejectable() throws RemoteException, AlreadyBoundException, NotBoundException { int depthOverride = Integer.getInteger("test.maxdepth", REGISTRY_MAX_DEPTH); depthOverride = Math.min(depthOverride, REGISTRY_MAX_DEPTH); System.out.printf("overrideDepth: %d, filter: %s%n", depthOverride, registryFilter); try { String name = "reject3"; DepthRejectableClass r1 = DepthRejectableClass.create(depthOverride + 1); registry.bind(name, r1); Assert.fail("Registry filter should have rejected depth: " + depthOverride + 1); } catch (Exception rex) { // Rejection expected } }
public static List<Vrf> getList(ObjectFilterQuery query) throws NotBoundException, AuthenticationException, IOException, ExternalServiceException { List<Vrf> vrfList = new ArrayList<Vrf>(); for (VrfIfDto vrf : filterVrfs(query, VrfExtUtil.getVrfIfDtos())) { vrfList.add(VrfModelCreator.createModel(vrf, InventoryIdUtil.getInventoryId(vrf))); } return vrfList; }