/** * Bring the service into active operation. * * @throws Exception */ public void start() throws Exception { partition.registerRPCHandler(getServiceHAName(), rpcTarget); DistributedReplicantManager drm = partition.getDistributedReplicantManager(); drm.add(getServiceHAName(), partition.getClusterNode()); coordinator = drm.isMasterReplica(getServiceHAName()); drm.registerListener(getServiceHAName(), drmListener); statusCheck(); }
/** * Unregister's with the partition's {@link DistributedReplicantManager}. */ protected void cleanExistenceInCurrentHAPartition() { if (this.partition != null) { try { DistributedReplicantManager drm = partition.getDistributedReplicantManager(); drm.unregisterListener(this.replicantName, this); drm.remove(this.replicantName); } catch (Exception e) { log.error("failed to clean existence in current ha partition", e); } } }
List<ModClusterServiceDRMEntry> lookupDRMEntries() { DistributedReplicantManager drm = this.getHAPartition().getDistributedReplicantManager(); @SuppressWarnings("unchecked") List<CachableMarshalledValue> values = (List<CachableMarshalledValue>) drm.lookupReplicants(this.getHAServiceKey()); if (values == null) return null; List<ModClusterServiceDRMEntry> entries = new ArrayList<ModClusterServiceDRMEntry>(values.size()); for (CachableMarshalledValue value: values) { entries.add(this.extractDRMEntry(value)); } return entries; }
/** * 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); }
drm.add(getServiceHAName(), this.partition.getClusterNode()); this.serviceView = drm.lookupReplicantsNodes(getServiceHAName()); drm.registerListener(getServiceHAName(), drmListener);
drm.registerListener(key, listener); drm.add(key, this.getReplicant()); drm.registerListener(key, this); drm.unregisterListener(key, listener);
protected List<ClusterNode> getElectionCandidates() { return this.getHAPartition().getDistributedReplicantManager().lookupReplicantsNodes(this.getHAServiceKey()); }
if (key.equals(this.RPC_HANDLER_NAME) && drm.isMasterReplica(this.RPC_HANDLER_NAME)) List<String> newReplicantsNodeNames = drm.lookupReplicantsNodeNames(this.RPC_HANDLER_NAME);
void updateLocalDRM(ModClusterServiceDRMEntry entry) { DistributedReplicantManager drm = this.getHAPartition().getDistributedReplicantManager(); try { drm.add(this.getHAServiceKey(), this.createReplicant(entry)); } catch (Exception e) { throw Utils.convertToUnchecked(e); } }
protected boolean isDRMMasterReplica() { DistributedReplicantManager drm = this.getHAPartition().getDistributedReplicantManager(); return drm.isMasterReplica(this.getHAServiceKey()); }
drm.unregisterListener (replicantName, this);
drm.registerListener (replicantName, this);
/** * Removes the local node from the distributed registry of nodes providing * the service. After this call, the HATarget can still be queried for * view change, etc. but the local node's instance of the service is no * longer registered with the cluster. * <p> * <strong>NOTE:</strong> Calling this method does not cause * {@link #invocationsAllowed()} to return <code>false</code>. Use * {@link #destroy()} unless your application needs to separately control * the two aspects of shutting down a clustered service. */ public void disable() { try { if (this.partition != null) { log.debug ("Disabled called on HATarget"); this.partition.getDistributedReplicantManager().remove (this.replicantName); } } catch (Exception e) { log.error("failed to disable", e); } }
ModClusterServiceDRMEntry lookupLocalDRMEntry() { DistributedReplicantManager drm = this.getHAPartition().getDistributedReplicantManager(); return this.extractDRMEntry((CachableMarshalledValue) drm.lookupLocalReplicant(this.getHAServiceKey())); }
protected void registerDRMListener() throws Exception { if (log.isDebugEnabled()) { log.debug("HAServiceImpl.registerDRMListener for service=" + getHAServiceKey()); } DistributedReplicantManager drm = this.partition.getDistributedReplicantManager(); String key = this.getHAServiceKey(); drm.registerListener(key, this); // this ensures that the DRM knows that this node has the MBean deployed drm.add(key, this.getReplicant()); }
List<ClusterNode> nodes = drm.lookupReplicantsNodes(getServiceHAName()); ClusterNode coord = (nodes != null && nodes.size() > 0 ? nodes.get(0) : null); if (coord != null && coord.equals(partition.getClusterNode()) == false)
this.coordinator = drm.isMasterReplica(getServiceHAName());
public void stopService() throws Exception { super.stopService(); // JBAS-5164. Unregister the listener first, or when we destroy // the target we will get a callback and rebind the proxy if (drm != null) drm.unregisterListener(replicantName, this); try { invokerHA.unregisterBean(getServiceName()); target.destroy(); } catch (Exception ignored) { // ignore. } }
drm.registerListener (replicantName, this);
protected void unregisterDRMListener() throws Exception { DistributedReplicantManager drm = this.partition.getDistributedReplicantManager(); String key = this.getHAServiceKey(); // remove replicant node drm.remove(key); // unregister drm.unregisterListener(key, this); }