/** * Cluster callback called when a node wants to know our complete list of local replicants * @throws Exception Thrown if a cluster communication exception occurs * @return A java array of size 2 containing the name of our node in this cluster and the serialized representation of our state */ public Object[] lookupLocalReplicants() throws Exception { Object[] rtn = { this.partition.getNodeName(), this.localReplicants }; if (this.log.isTraceEnabled()) { this.log.trace("lookupLocalReplicants called ("+ rtn[0] + "). Return: " + this.localReplicants.size()); } return rtn; }
public void start() throws Exception { this.myNodeName = this.partition.getNodeName(); this.log.debug("HASessionState node name : " + this.myNodeName ); // BES 4/7/06 clean up lifecycle; move this to start, as it can't be // called until startService due to JNDI dependency Context ctx = new InitialContext(); this.bind(this._sessionStateName, this, HASessionStateImpl.class, ctx); }
@Override @SuppressWarnings({"unchecked", "rawtypes"}) public void membershipChanged(Vector deadMembers, Vector newMembers, Vector allMembers) { // Here we only care about deadMembers. Purge all replicant lists of deadMembers // and then notify all listening nodes. // this.log.info("I am (" + this.partition.getNodeName() + ") received membershipChanged event:"); this.log.info("Dead members: " + deadMembers.size() + " (" + deadMembers + ")"); this.log.info("New Members : " + newMembers.size() + " (" + newMembers + ")"); this.log.info("All Members : " + allMembers.size() + " (" + allMembers + ")"); this.purgeDeadMembers(deadMembers, false); // we don't need to merge members anymore }
@SuppressWarnings("unchecked") @Override public void setCurrentState(Serializable newState) { Object[] globalState = (Object[]) newState; Map<String, ConcurrentMap<String, Serializable>> map = (Map<String, ConcurrentMap<String, Serializable>>) globalState[0]; this.replicants.putAll(map); this.intraviewIdCache = (Map<String, Integer>) globalState[1]; if (this.log.isTraceEnabled()) { this.log.trace(this.partition.getNodeName() + ": received new state, will republish local replicants"); } new MembersPublisher().start(); }
@Override public Serializable getCurrentState() { Map<String, ConcurrentMap<String, Serializable>> result = new HashMap<String, ConcurrentMap<String, Serializable>>(); for (String category: this.getAllServices()) { ConcurrentMap<String, Serializable> map = new ConcurrentHashMap<String, Serializable>(); ConcurrentMap<String, Serializable> content = this.replicants.get(category); if (content != null) { map.putAll(content); } Serializable local = this.localReplicants.get(category); if (local != null) { map.put(this.partition.getNodeName(), local); } result.put(category, map); } // we add the intraviewid cache to the global result // return new Object[] { result, this.intraviewIdCache }; }
@Override public void remove(String key) throws Exception { // optimisation: we don't make a costly network call // if there is nothing to remove if (this.localReplicants.containsKey(key)) { Object[] args = { key, this.partition.getNodeName() }; this.partition.callAsynchMethodOnCluster(SERVICE_NAME, "_remove", args, remove_types, true); this.removeLocal(key); } }
protected void sendClusterUpdatesAndRelease(GUID globalTxId, List clusterUpdates) throws Exception { try { Object[] args = {partition.getNodeName(), globalTxId, clusterUpdates}; checkResponses(partition.callMethodOnCluster(domainName, "updateObjects", args, LOCK_TYPES, true)); } catch (Exception ex) { log.error("serious cache problems, data inconsistency is imminent", ex); throw ex; } } protected void acquireRemoteLocks(GUID globalTxId, List guids) throws Exception
result.append("\t\t\t<Name local=\"True\">").append (this.partition.getNodeName()).append ("</Name>\n"); result.append("\t\t</Location>\n");
protected void acquireRemoteLocks(GUID globalTxId, List guids) throws Exception { try { Object[] args = {partition.getNodeName(), globalTxId, guids}; checkResponses(partition.callMethodOnCluster(domainName, "acquireLocks", args, LOCK_TYPES, true)); } catch (Exception ex) { try { Object[] args = {partition.getNodeName()}; partition.callMethodOnCluster(domainName, "releaseHeldLocks", args, STRING_TYPE, true); } catch (Exception ignored) { } throw ex; } }
if (local != null && this.partition.getNodeName().equals(name))
@Override public void add(String key, Serializable replicant) throws Exception { if (this.log.isTraceEnabled()) { this.log.trace("add, key=" + key + ", value=" + replicant); } Object[] args = { key, this.partition.getNodeName(), replicant }; this.partition.callMethodOnCluster(SERVICE_NAME, "_add", args, add_types, true); List<Serializable> replicants = null; synchronized (this.localReplicants) { this.localReplicants.put(key, replicant); replicants = this.getReplicants(key); } this.notifyKeyListeners(key, replicants, false); }
String nodeName = this.partition.getNodeName();
else if (node.equals(this.partition.getNodeName()))
Object[] args = { key, this.partition.getNodeName(), replicant };
@Override public List<ClusterNode> lookupReplicantsNodes(String key) { boolean local = this.localReplicants.containsKey(key); Map<String, Serializable> replicant = this.replicants.get(key); if (replicant == null) { return local ? Collections.singletonList(this.partition.getClusterNode()) : null; } Set<String> keys = replicant.keySet(); ClusterNode[] nodes = this.partition.getClusterNodes(); List<ClusterNode> rtn = new ArrayList<ClusterNode>(nodes.length); for (ClusterNode node : nodes) { String name = node.getName(); if (local && this.partition.getNodeName().equals(name)) { rtn.add(this.partition.getClusterNode()); } else if (keys.contains(name)) { rtn.add(node); } } return rtn; }
@SuppressWarnings("unchecked") protected synchronized void publishLocalInvalidationGroups() throws Exception { this.localGroups = this.invalMgr.getInvalidationGroups(); this.log.debug("Publishing locally available invalidation groups: " + this.localGroups); ArrayList<InvalidationGroup> content = new ArrayList<InvalidationGroup>(this.localGroups); ArrayList<String> result = new ArrayList<String>(content.size()); for (int i = 0; i < content.size(); i++) { String aGroup = content.get(i).getGroupName(); result.add(aGroup); } String nodeName = this.partition.getNodeName(); DistributedState ds = this.partition.getDistributedStateService(); if (result.size() > 0) { NodeInfo info = new NodeInfo(result, nodeName); ds.set(this.RPC_HANDLER_NAME, nodeName, info, true); } else { ds.remove(this.RPC_HANDLER_NAME, nodeName, true); } }
@Override public void stopService() { DistributedReplicantManager drm = this.partition.getDistributedReplicantManager(); DistributedState ds = this.partition.getDistributedStateService(); try { this.partition.unregisterRPCHandler(this.RPC_HANDLER_NAME, this); ds.unregisterDSListenerEx(this.RPC_HANDLER_NAME, this); drm.unregisterListener(this.RPC_HANDLER_NAME, this); drm.remove(this.RPC_HANDLER_NAME); this.invalidationSubscription.unregister(); ds.remove(this.RPC_HANDLER_NAME, this.partition.getNodeName(), true); // this.invalMgr = null; // partition = null; this.invalidationSubscription = null; this.RPC_HANDLER_NAME = null; this.localGroups = null; this.bridgedGroups = new Vector<String>(); } catch (Exception e) { this.log.info("Problem while shuting down invalidation cache bridge", e); } }