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; }
/** Destroys the HATarget */ public void destroy() { super.destroy(); try { invokerTarget.destroy(); } catch(Exception ignore) { } }
protected void containerIsAboutToStop() { if (target != null) { target.setInvocationsAuthorization(HATarget.DISABLE_INVOCATIONS); target.disable(); } }
/** * Creates a new HATarget. * * @param partition the {@link HAPartition} for the service's cluster * @param replicantName the name of the service * @param target the service's {@link #getReplicantList() replicant} * @param allowInvocations <code>true</code> if {@link #invocationsAllowed()} * should return <code>true</code> immediately; * <code>false</code> if not * @throws Exception */ public HATarget(HAPartition partition, String replicantName, Serializable target, int allowInvocations) throws Exception { this.replicantName = replicantName; this.target = target; setInvocationsAuthorization (allowInvocations); updateHAPartition(partition); }
/** * Removes the local node from the distributed registry of nodes providing * the service and causes {@link #invocationsAllowed()} to return * <code>false</code>. */ public void destroy() { try { this.cleanExistenceInCurrentHAPartition(); // maybe some threads are blocked: we let them go here: // setInvocationsAuthorization (HATarget.DISABLE_INVOCATIONS); } catch (Exception e) { log.error("failed to destroy", e); } }
if (!target.invocationsAllowed ()) throw new GenericClusteringException(GenericClusteringException.COMPLETED_NO, "invocations are currently not allowed on this target"); if (clientViewId != target.getCurrentViewId()) rsp.newReplicants = new ArrayList<Object>(target.getReplicantList()); rsp.currentViewId = target.getCurrentViewId();
/** 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; }
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()); }
if (target == null) target = new HATarget(partition, proxyFamilyName, locator, HATarget.ENABLE_INVOCATIONS); ClusteringTargetsRepository.initTarget(proxyFamilyName, target.getReplicantList()); families.put(proxyFamilyName, target); target = new HATarget(partition, proxyFamilyName, locator, HATarget.ENABLE_INVOCATIONS); ClusteringTargetsRepository.initTarget(proxyFamilyName, target.getReplicantList()); families.put(proxyFamilyName, target); advisor.insertInterceptor(0, new ReplicantsManagerInterceptor(families)); new FamilyWrapper(proxyFamilyName, target.getReplicantList()), PayloadKey.AS_IS);
protected void containerIsFullyStarted () { if( target != null ) target.setInvocationsAuthorization (HATarget.ENABLE_INVOCATIONS); }
if (state == ServiceMBean.STARTED) mode = HATarget.ENABLE_INVOCATIONS; target = new HATarget(partition, replicantName, invokerHA.getStub(), mode); invokerHA.registerBean(getServiceName(), target);
/** * Associates this target with the given partition, registering * with the partition's {@link DistributedReplicantManager}. * * @param partition the partition * @throws Exception */ protected void updateHAPartition(HAPartition partition) throws Exception { cleanExistenceInCurrentHAPartition(); this.partition = partition; DistributedReplicantManager drm = partition.getDistributedReplicantManager(); drm.registerListener(this.replicantName, this); drm.add(this.replicantName, this.target); }
if(!target.invocationsAllowed()) if(clientViewId != target.getCurrentViewId()) haResponse.newReplicants = new ArrayList<Object>(target.getReplicantList()); haResponse.currentViewId = target.getCurrentViewId();
protected void containerIsFullyStarted () { if (target != null) target.setInvocationsAuthorization(HATarget.ENABLE_INVOCATIONS); }
target = new HATarget(partition, replicantName, jrmp.getStub (), HATarget.MAKE_INVOCATIONS_WAIT); jrmp.registerBean(jmxName, target);
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); } }
protected void containerIsAboutToStop () { if( target != null ) { target.setInvocationsAuthorization (HATarget.DISABLE_INVOCATIONS); target.disable (); } this.ejbModuleStopping = true; }
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); } }
public static void unregisterClusteredObject(Object object) { try { ClassProxy proxy = (ClassProxy) object; InstanceAdvisor advisor = proxy._getInstanceAdvisor(); String oid = (String) advisor.getMetaData().getMetaData(Dispatcher.DISPATCHER, Dispatcher.OID); InstanceAdvised registeredObject = (InstanceAdvised) Dispatcher.singleton.getRegistered(oid); if (registeredObject == null) throw new NotRegisteredException(oid.toString() + " is not registered"); Dispatcher.singleton.unregisterTarget(oid); advisor = registeredObject._getInstanceAdvisor(); Map families = (Map) advisor.getMetaData().getMetaData(CLUSTERED_REMOTING, CLUSTER_FAMILIES); Iterator it = families.values().iterator(); while (it.hasNext()) { HATarget target = (HATarget) it.next(); target.destroy(); } } catch (Exception ignored) { log.trace("Ignored exception unregistering a clustered object", ignored); } } }