/** * @see org.jboss.ha.framework.interfaces.EventListener#handleEvent(java.util.EventObject) */ @Override public void handleEvent(E event) throws Exception { this.callAsyncMethodOnPartition("handleEvent", new Object[] { event }, HANDLE_EVENT_TYPES); }
/** * @see org.jboss.ha.framework.interfaces.HAService#start() */ @Override public void start() throws Exception { this.registerRPCHandler(); this.registerDRMListener(); }
/** * @see org.jboss.ha.framework.interfaces.HAService#stop() */ @Override public void stop() { try { this.unregisterDRMListener(); this.unregisterRPCHandler(); } catch (Exception e) { this.log.error("Failed to stop service.", e); } }
protected void registerRPCHandler() { String key = this.getHAServiceKey(); if (this.isRegisterThreadContextClassLoader()) { this.partition.registerRPCHandler(key, this.getRpcHandler(), Thread.currentThread().getContextClassLoader()); } else { this.partition.registerRPCHandler(key, this.getRpcHandler()); } }
/** * @see org.jboss.ha.framework.interfaces.DistributedReplicantManager.ReplicantListener#replicantsChanged(java.lang.String, java.util.List, int, boolean) */ @Override public void replicantsChanged(String key, List<?> newReplicants, int newReplicantsViewId, boolean merge) { if (key.equals(this.getHAServiceKey())) { // This synchronized block was added when the internal behavior of // DistributedReplicantManagerImpl was changed so that concurrent // replicantsChanged notifications are possible. Synchronization // ensures that this change won't break non-thread-safe // subclasses of HAServiceMBeanSupport. synchronized (this) { // change in the topology callback this.partitionTopologyChanged(newReplicants, newReplicantsViewId, merge); } } }
protected void unregisterRPCHandler() { this.partition.unregisterRPCHandler(this.getHAServiceKey(), this.getRpcHandler()); }
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()); }
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); }