@Override public void stopping() { refreshed = false; providerServerRefs = null; clientClusterViewCache.clear(); clientClusterViewProvider = null; }
/** * Pulls and updates the load-factors of the server known by this client. * @throws RemoteException */ private void pullAndUpdateLoadFactors() throws RemoteException { for(ServerRef address : clientClusterViewCache.getAddressesOfServer()) { try { int loadFactor = clientClusterViewProvider.getLoadFactor(address); clientClusterViewCache.setLoadFactor(address, loadFactor); } catch (ServerNotFoundException e) { LOGGER.debug("server not found: {0}", address, e); clientClusterViewCache.removeLoadFactor(address); } } }
private void pullAddUpdateReplicationInfos(final String objectName) throws RemoteException, ObjectNotFoundException { clientClusterViewCache.getClusteredObject(objectName).setReplicated( clientClusterViewProvider.isReplicated(objectName)); }
private void pullAndUpdateMissingLoadFactor(final ServerRef serverRef) throws RemoteException { try { clientClusterViewCache.getLoadFactor(serverRef); } catch(NullPointerException npe) { int loadFactor; try { loadFactor = clientClusterViewProvider.getLoadFactor(serverRef); clientClusterViewCache.setLoadFactor(serverRef, loadFactor); } catch (ServerNotFoundException e) { LOGGER.warn("Server not found: {0}", serverRef, e); } } }
clientClusterViewCache.addClusteredObject( clusteredObjectInfo.getClusterName(), clusteredObjectInfo.isProxyEnabled(), providerName, itfClass.getName(), new PolicyData(policyClassname, strategyClassname, clusteredObjectInfo.getProperties()); clusteredObjectView.setPolicyData(policyDataForProvider); clientClusterViewCache.setPolicyClass(policyClassname, policyClass); clientClusterViewCache.setStrategyClass(strategyClassname, strategyClass);
/** * Returns the class that defines the strategy for an object with the given name. * @param objectName a name of object * @return the class that defines the strategy for an object with the given name * @throws ObjectNotFoundException if none object has the given name * @throws ClientClusterViewManagerException if the class of strategy of the object with the given name cannot be downloaded */ public Class<? extends IStrategy<?>> getStrategyClass(final String objectName) throws ObjectNotFoundException, ClientClusterViewManagerException { synchronized (clientClusterViewCache) { String classname = getStrategyClassName(objectName); Class<? extends IStrategy<?>> strategy = clientClusterViewCache.getStrategyClass(classname); if(strategy == null) { try { strategy = pullStrategyClass(objectName); } catch (Exception e) { LOGGER.error("Cannot set the class of strategy for {0}", objectName, e); throw new ClientClusterViewManagerException("Cannot set the class of strategy for " + objectName, e); } clientClusterViewCache.setStrategyClass(classname, strategy); } return strategy; } }
/** * Returns the class that defines the policy for an object with the given name. * @param objectName a name of object * @return the class that defines the policy for an object with the given name * @throws ObjectNotFoundException if none object has the given name * @throws ClientClusterViewManagerException if the class of policy of the object with the given name cannot be downloaded */ public Class<? extends IPolicy<?>> getPolicyClass(final String objectName) throws ObjectNotFoundException, ClientClusterViewManagerException { synchronized (clientClusterViewCache) { String classname = getPolicyClassName(objectName); Class<? extends IPolicy<?>> policy = clientClusterViewCache.getPolicyClass(classname); if(policy == null) { try { policy = pullPolicyClass(objectName); } catch (Exception e) { LOGGER.error("Cannot set the class of policy for {0}", objectName, e); throw new ClientClusterViewManagerException("Cannot set the class of policy for " + objectName, e); } clientClusterViewCache.setPolicyClass(classname, policy); } return policy; } }
public ClientClusteredObjectView addClusteredObject(final String clusterName, final boolean proxyEnabled, final String objectName, final String itfName, final String businessName, final boolean stateful, final Set<String> applicationExceptionNames ) { ClientClusteredObjectView clusteredObjectView = objects.get(objectName); if(clusteredObjectView == null) { clusteredObjectView = new ClientClusteredObjectView(clusterName, proxyEnabled, objectName, itfName, businessName, stateful, applicationExceptionNames); objects.put(objectName, clusteredObjectView); } return clusteredObjectView; }
/** * @return the set of clustered object names */ public Set<String> getObjectNames() { return clientClusterViewCache.getObjectNames(); }
/** * Returns the load-factor for the server with the given address. * @param serverRef a reference on a server * @return the load-factor for the server with the given address */ public int getLoadFactor(final ServerRef serverRef) { return clientClusterViewCache.getLoadFactor(serverRef); }
clientClusterViewCache.addClusteredObject(immutableInfos);
public boolean isProxyEnabled(final String objectName) throws ObjectNotFoundException { try { return clientClusterViewCache.getClusteredObject(objectName).isProxyEnabled(); } catch (NullPointerException e) { LOGGER.error("Object is unknown: {0}", objectName); throw new ObjectNotFoundException("Object is unknown: " + objectName); } }
/** * Registers the dummy registry as an object to watch. * @throws ClientClusterViewManagerException */ private void initDataOfDummyRegistry() throws ClientClusterViewManagerException { String dummyName = getConfig().getDummyRegistryName(); ClusteredObjectInfo clusteredObjectInfo; // Extracts informations on clustering of dummy context try { clusteredObjectInfo = CMIInfoExtractor.extractClusteringInfoFromAnnotatedPOJO( dummyName, null, ClusteredDummyRegistry.class, false, null); } catch (CMIInfoExtractorException e) { LOGGER.error("Cannot get infos for dummy registry", e); throw new ClientClusterViewManagerException("Cannot get infos for dummy registry", e); } clientClusterViewCache.addClusteredObject( clusteredObjectInfo.getClusterName(), clusteredObjectInfo.isProxyEnabled(), dummyName, null, null, clusteredObjectInfo.hasState(), clusteredObjectInfo.getApplicationExceptionNames()); watch(dummyName); }
/** * Return classnames of the application exceptions. * @param objectName a name of object * @return classnames of the application exceptions * @throws ObjectNotFoundException if none object has the given name */ public Set<String> getApplicationExceptionNames(final String objectName) throws ObjectNotFoundException{ try { return clientClusterViewCache.getClusteredObject(objectName).getApplicationExceptionNames(); } catch (NullPointerException e) { LOGGER.error("Object is unknown: {0}", objectName); throw new ObjectNotFoundException("Object is unknown: " + objectName); } }
/** * Returns the name of cluster for the object with the given name. * @param objectName a name of object * @return the name of cluster for a object with the given name * @throws ObjectNotFoundException if none object has the given name */ public String getClusterName(final String objectName) throws ObjectNotFoundException { try { return clientClusterViewCache.getClusteredObject(objectName).getClusterName(); } catch (NullPointerException e) { LOGGER.error("Object is unknown: {0}", objectName); throw new ObjectNotFoundException("Object is unknown: " + objectName); } }
/** * Returns the interface of an object bound with the given name. * @param objectName a name of object * @return the interface of an object bound with the given name * @throws ObjectNotFoundException if none object has the given name */ public Class<?> getInterface(final String objectName) throws ObjectNotFoundException { try { return clientClusterViewCache.getClusteredObject(objectName).getItfClass(); } catch (NullPointerException e) { LOGGER.error("Object is unknown: {0}", objectName); throw new ObjectNotFoundException("Object is unknown: " + objectName); } }
/** * Returns the interface of an object bound with the given name. * @param objectName a name of object * @return the interface of an object bound with the given name * @throws ObjectNotFoundException if none object has the given name */ public Class<? extends EJBObject> getRemoteClass(final String objectName) throws ObjectNotFoundException { try { return clientClusterViewCache.getClusteredObject(objectName).getBusinessClass(); } catch (NullPointerException e) { LOGGER.error("Object is unknown: {0}", objectName); throw new ObjectNotFoundException("Object is unknown: " + objectName); } }
/** * Return true if the object with the given name is stateful. * @param objectName a name of object * @return true if the object with the given name is stateful * @throws ObjectNotFoundException if none object has the given name */ public boolean hasState(final String objectName) throws ObjectNotFoundException { try { return clientClusterViewCache.getClusteredObject(objectName).isStateful(); } catch (NullPointerException e) { LOGGER.error("Object is unknown: {0}", objectName); throw new ObjectNotFoundException("Object is unknown: " + objectName); } }
/** * Returns a value property of the policy for an object with the given name. * @param objectName a name of object * @param propertyName a name of property * @return a value property of the policy for an object with the given name * @throws ObjectNotFoundException if none object has the given name */ public Object getPropertyForPolicy(final String objectName, final String propertyName) throws ObjectNotFoundException { try { return clientClusterViewCache.getClusteredObject(objectName).getPolicyData().getProperties().get(propertyName); } catch (NullPointerException e) { LOGGER.error("Object is unknown: {0}", objectName); throw new ObjectNotFoundException("Object is unknown: " + objectName); } }
/** * Return true if the object with the given name is replicated for high-availability. * @param objectName a name of object * @return true if the object with the given name is replicated for high-availability * @throws ObjectNotFoundException if none object has the given name */ public boolean isReplicated(final String objectName) throws ObjectNotFoundException { try { return clientClusterViewCache.getClusteredObject(objectName).isReplicated(); } catch (NullPointerException e) { LOGGER.error("Object is unknown: {0}", objectName); throw new ObjectNotFoundException("Object is unknown: " + objectName); } }