public Invoker createProxy(ObjectName targetName, LoadBalancePolicy policy, String proxyFamilyName) throws Exception { Integer hash = new Integer(targetName.hashCode()); HATarget target = (HATarget) targetMap.get(hash); if (target == null) { throw new IllegalStateException("The targetName("+targetName + "), hashCode("+hash+") not found"); } Invoker proxy = new HttpInvokerProxyHA(target.getReplicantList(), target.getCurrentViewId (), policy, proxyFamilyName); return proxy; }
public synchronized void replicantsChanged(String key, List<?> newReplicants, int newReplicantsViewId, boolean merge) { try { if (invoker instanceof InvokerProxyHA) ((InvokerProxyHA) invoker).updateClusterInfo(target.getReplicantList(), target.getCurrentViewId()); log.debug ("Rebinding in JNDI... " + key); rebind(); } catch (Exception none) { log.debug(none); } }
public synchronized void replicantsChanged (String key, List newReplicants, int newReplicantsViewId, boolean merge) { try { if (homeInvoker instanceof InvokerProxyHA) { ((InvokerProxyHA)homeInvoker).updateClusterInfo (target.getReplicantList(), target.getCurrentViewId ()); } if (beanInvoker instanceof InvokerProxyHA) { ((InvokerProxyHA)beanInvoker).updateClusterInfo (target.getReplicantList(), target.getCurrentViewId ()); } log.debug ("Rebinding in JNDI... " + key); rebindHomeProxy (); } catch (Exception none) { log.debug (none); } }
if (clientViewId.longValue() != target.getCurrentViewId()) rsp.newReplicants = new ArrayList<Object>(target.getReplicantList()); rsp.currentViewId = target.getCurrentViewId();
public Invoker createProxy(ObjectName beanName, LoadBalancePolicy policy, String proxyFamilyName) throws Exception { Integer hash = new Integer(beanName.hashCode()); HATarget target = (HATarget) beanMap.get(hash); if(target == null) { throw new IllegalStateException("The bean hashCode not found"); } String familyName = proxyFamilyName; if(familyName == null) { familyName = target.getAssociatedPartition().getPartitionName() + "/" + beanName; } return createProxy(getStrictRMIException(), target.getReplicantList(), policy, proxyFamilyName, target.getCurrentViewId()); }
@Override public Object invoke(Invocation invocation) throws Throwable { Object response = invocation.invokeNext(); String clientFamily = (String) invocation.getMetaData(CLUSTERED_REMOTING, CLUSTER_FAMILY); HATarget target = families.get(clientFamily); if (target == null) { return response; } Long clientViewId = (Long) invocation.getMetaData(CLUSTERED_REMOTING, CLUSTER_VIEW_ID); if (clientViewId == null) { // Maybe we're being invoked upon by a non-clustered proxy return response; } if (clientViewId.longValue() != target.getCurrentViewId()) { invocation.addResponseAttachment("replicants", new ArrayList<Object>(target.getReplicantList())); invocation.addResponseAttachment("viewId", new Long(target.getCurrentViewId())); } return response; } }
/** Override the HttpProxyFactory method to create a HttpInvokerProxyHA. * @return an invoker proxy * @throws Exception */ protected Invoker createInvoker() throws Exception { HAPartition partition = HAPartitionLocator.getHAPartitionLocator().getHAPartition(partitionName, null); /* Create a HATarget for the local invoker mbean stub. The name passed to the HATarget must be the wrappedJmxInvokerName so that different more than one HttpProxyFactoryHA may be configured for the same realJmxInvokerName. */ checkInvokerURL(); Serializable invokerStub = super.getInvokerURL(); invokerTarget = new HATarget(partition, wrappedJmxInvokerName.toString(), invokerStub, HATarget.MAKE_INVOCATIONS_WAIT); log.debug("Created invoker: "+invokerTarget); // Create and register the invoker wrapper MBeanServer mbeanServer = super.getServer(); invokerWrapper = new HAInvokerWrapper(mbeanServer, realJmxInvokerName, invokerTarget); mbeanServer.registerMBean(invokerWrapper, wrappedJmxInvokerName); // Create the LoadBalancePolicy instance LoadBalancePolicy policy = (LoadBalancePolicy) policyClass.newInstance(); // Finally, create the invoker proxy, a HttpInvokerProxyHA String clusterFamilyName = partitionName + "/" + wrappedJmxInvokerName.toString(); Invoker delegateInvoker = new HttpInvokerProxyHA(invokerTarget.getReplicantList(), invokerTarget.getCurrentViewId (), policy, clusterFamilyName); return delegateInvoker; }
if (clientViewId != target.getCurrentViewId()) rsp.newReplicants = new ArrayList<Object>(target.getReplicantList()); rsp.currentViewId = target.getCurrentViewId();
haResponse.newReplicants = new ArrayList<Object>(target.getReplicantList()); haResponse.currentViewId = target.getCurrentViewId();
ClusteringTargetsRepository.initTarget(proxyFamilyName, target.getReplicantList()); families.put(proxyFamilyName, target); ClusteringTargetsRepository.initTarget(proxyFamilyName, target.getReplicantList()); families.put(proxyFamilyName, target); advisor.insertInterceptor(0, new ReplicantsManagerInterceptor(families)); new FamilyWrapper(proxyFamilyName, target.getReplicantList()), PayloadKey.AS_IS);