/** Initializes the cache for use. Prior to this the cache has no store. */ public void create() { // Lookup the parition HAPartition partition = HAPartitionLocator.getHAPartitionLocator().getHAPartition(this.partitionName, null); this.entryMap = partition.getDistributedStateService(); log.debug("Obtained DistributedState from partition=" + this.partitionName); this.now = System.currentTimeMillis(); }
protected void updatedBridgedInvalidationGroupsInfo() Collection<NodeInfo> bridgedByNode = (Collection<NodeInfo>) this.partition.getDistributedStateService().getAllValues(this.RPC_HANDLER_NAME);
@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); } }
/** * * Convenience method for sharing state across a cluster partition. * Delegates to the DistributedStateService * * @param key key for the distributed object * @return Serializable the distributed object * */ public Serializable getDistributedState(String key) { DistributedState ds = this.getHAPartition().getDistributedStateService(); return ds.get(this.getHAServiceKey(), key); }
/** * * * Convenience method for sharing state across a cluster partition. * Delegates to the DistributedStateService * * @param key key for the distributed object * @param value the distributed object * */ public void setDistributedState(String key, Serializable value) throws Exception { DistributedState ds = this.getHAPartition().getDistributedStateService(); ds.set(this.getHAServiceKey(), key, value); }
DistributedState ds = this.partition.getDistributedStateService();
@Override public void startService() throws Exception { if (this.partition == null) throw new IllegalStateException("HAPartition property must be set before starting InvalidationBridge service"); this.RPC_HANDLER_NAME = "DCacheBridge-" + this.bridgeName; DistributedReplicantManager drm = this.partition.getDistributedReplicantManager(); DistributedState ds = this.partition.getDistributedStateService(); drm.add(this.RPC_HANDLER_NAME, ""); drm.registerListener(this.RPC_HANDLER_NAME, this); ds.registerDSListenerEx(this.RPC_HANDLER_NAME, this); this.partition.registerRPCHandler(this.RPC_HANDLER_NAME, this); // we now publish the list of caches we have access to if (this.invalMgr == null) { throw new IllegalStateException("Failed to find an InvalidationManagerMBean, ensure one is injected"); } this.publishLocalInvalidationGroups(); this.updatedBridgedInvalidationGroupsInfo(); this.invalidationSubscription = this.invalMgr.registerBridgeListener(this); }
@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); } }