/** * Returns a list of String representing a ServerRef for an object with the given name and protocol. * @param objectName a name of object * @param protocolName a name of protocol * @return a list of String representing a ServerRef for an object with the given name and protocol * @throws IllegalArgumentException if none object has the given name */ public List<String> getServerRefs(final String objectName, final String protocolName) throws IllegalArgumentException { Collection<CMIReference> cmiReferences; try { cmiReferences = clusterViewManager.getCMIReferences(objectName, protocolName); } catch (ObjectNotFoundException e) { LOGGER.error("Object not found: {0}", objectName, e); throw new IllegalArgumentException("Object not found: " + objectName + "\n" + e.getMessage()); } List<String> stringOfCMIRefs = new ArrayList<String>(cmiReferences.size()); for(CMIReference cmiReference : cmiReferences) { stringOfCMIRefs.add(cmiReference.getServerRef().getProviderURL()); } return stringOfCMIRefs; }
private Object findStubOrProxy(final String objectName) throws CMIContextException, ObjectNotFoundException, NamingException { // Choose a server to perform the request. Collection<CMIReference> cmiReferences = clusterViewManager.getCMIReferences(objectName, protocol); IPolicy<CMIReference> policy = clusterViewManager.getPolicy(objectName); CMIReference cmiReference; try { cmiReference = policy.choose(cmiReferences); } catch (NoLoadBalanceableException e) { LOGGER.error("Cannot choose a CMIReference in the list {0} with LB policy {1}", cmiReferences, policy, e); throw new CMIContextException( "Cannot choose a CMIReference in the list " + cmiReferences + " with LB policy " + policy, e); } ServerRef serverRef = cmiReference.getServerRef(); String pURL = serverRef.getProviderURL(); LOGGER.debug("Chosen providerURL: {0}", pURL); Context context; context = getRealContext(pURL, initialContextFactoryName); try { return context.lookup(objectName); } finally { try { context.close(); } catch (NamingException e) { LOGGER.debug("Unable to close the context", e); } } }
policy = clusterViewManager.getPolicy(objectName); logger.debug("Object: {0} - Invoke: {1} > Policy: {2}", objectName, methodName, policy); cmiReferences = new ArrayList<CMIReference>(clusterViewManager.getCMIReferences(objectName, protocolName)); logger.debug("Object: {0} - Invoke:{1} > CMIReferences: {2}", objectName, methodName, cmiReferences); } catch (Exception e) { new ArrayList<CMIReference>(clusterViewManager.getCMIReferences(objectName, protocolName)); logger.debug("Object: {0} - Invoke: {1} > onInvokeException=RETRY, CMIReferences is now: {2}", objectName, methodName, cmiReferences);
loadBalanceables = clusterViewManager.getCMIReferences(dummyRegistryName, protocol); } catch (ObjectNotFoundException e) { LOGGER.error("Cannot get node list for {0}", dummyRegistryName, e);
loadBalanceables = clusterViewManager.getCMIReferences(dummyRegistryName, protocol); } catch (ObjectNotFoundException e) { LOGGER.error("Cannot get node list for {0}", dummyRegistryName, e);
loadBalanceables = clusterViewManager.getCMIReferences(dummyRegistryName, protocol); } catch (ObjectNotFoundException e) { LOGGER.error("Cannot get node list for {0}", dummyRegistryName, e);
loadBalanceables = clusterViewManager.getCMIReferences(dummyRegistryName, protocol); } catch (ObjectNotFoundException e) { LOGGER.error("Cannot get node list for {0}", dummyRegistryName, e);