public void flush(Object key) { Object[] args = {}; try { partition.callMethodOnCluster(cacheName, "_flush", args, null, false); } catch (Exception ex) { throw new RuntimeException(ex); } }
public void createService() throws Exception { if (this.partition == null) { throw new IllegalStateException("HAPartition property must be set before creating DistributedReplicantManager service"); } this.log.debug("registerRPCHandler"); this.partition.registerRPCHandler(SERVICE_NAME, this); this.log.debug("subscribeToStateTransferEvents"); this.partition.subscribeToStateTransferEvents(SERVICE_NAME, this); this.log.debug("registerMembershipListener"); this.partition.registerMembershipListener(this); }
public String getLocalNodeName() { ClusterNode localNode = this.partition == null ? null : this.partition.getClusterNode(); return localNode == null ? null : localNode.getName(); }
public void init() throws Exception { this.partition.registerRPCHandler(this.sessionStateIdentifier, this); this.partition.subscribeToStateTransferEvents(HA_SESSION_STATE_STATE_TRANSFER, this); }
public void destroy() throws Exception { // Remove ref to ourself from HAPartition this.partition.unregisterRPCHandler(this.sessionStateIdentifier, this); this.partition.unsubscribeFromStateTransferEvents(HA_SESSION_STATE_STATE_TRANSFER, this); }
/** * 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(); }
protected void _do_rpc_invalidates(String invalidationGroupName, Serializable[] keys, boolean asynch) { Object[] params = new Object[] { invalidationGroupName, keys }; try { if (asynch) { this.partition.callAsynchMethodOnCluster(this.RPC_HANDLER_NAME, "_rpc_invalidates", params, rpc_invalidates_types, true); } else { this.partition.callMethodOnCluster(this.RPC_HANDLER_NAME, "_rpc_invalidates", params, rpc_invalidates_types, true); } } catch (Exception e) { this.log.debug("Distributed invalidation (2) has failed for group " + invalidationGroupName + " (Bridge: " + this.bridgeName + ")"); } }
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; } }
List rsps = partition.callMethodOnCluster(getServiceHAName(), "getLocalTimestamp", NULL_ARGS, NULL_TYPES, true); long responseReceived = System.currentTimeMillis(); long mcastTime = responseReceived - requestSent; List<ClusterNode> nodes = partition.getDistributedReplicantManager().lookupReplicantsNodes(getServiceHAName()); for (ClusterNode node : nodes) if (node.equals(this.partition.getClusterNode())) Object rsp = partition.callMethodOnNode(getServiceHAName(), "getLocalTimestamp", NULL_ARGS, NULL_TYPES, mcastTime, node); long singleResponseReceived = System.currentTimeMillis(); long elapsed = singleResponseReceived - singleRequestSent;
@Override public String getPartitionName() { return this.partition.getPartitionName(); }
@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); } }
DistributedReplicantManager drm = partition.getDistributedReplicantManager(); 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) Object rsp = partition.callMethodOnNode(getServiceHAName(), "getDiscrepancies", NULL_ARGS, NULL_TYPES, 60000, coord); if (rsp instanceof RemoteDiscrepancies)
public void create() throws Exception { partition.registerRPCHandler(domainName, this); }
@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); }
/** * 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); } }
protected void pullState() throws Exception { List<Serializable> rsp = partition.callMethodOnCluster(domainName, "getCurrentState", NULL_ARGS, NULL_TYPES, Serializable.class, true, null, partition.getMethodCallTimeout(), false); if (rsp.size() > 0) setCurrentState(rsp.get(0)); }
private void installModifications(List<ContentModification> modifications, RepositoryContentMetadata toInstall) new SynchronizationId<ClusterNode>(this.partition.getClusterNode()); List<?> rsps = this.partition.callMethodOnCluster(getServiceHAName(), "initiateSynchronization", args, INITIATE_SYNCHRONIZATION_TYPES, true); for (Object rsp : rsps) rsps = this.partition.callMethodOnCluster(getServiceHAName(), "prepare", new Object[]{id}, TX_TYPES, true); boolean prepareOK = true; for (Object rsp : rsps) this.partition.callMethodOnCluster(getServiceHAName(), "commit", new Object[]{id}, TX_TYPES, true); handleCommit(id); committed = true; this.partition.callMethodOnCluster(getServiceHAName(), "rollback", new Object[]{id}, TX_TYPES, true);
@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; }
public void destroyService() throws Exception { // we cleanly shutdown. This should be optimized. for (String key: this.localReplicants.keySet()) { this.removeLocal(key); // channel is disconnected, so don't try to notify cluster } if (this.partition != null) { this.partition.unregisterRPCHandler(SERVICE_NAME, this); this.partition.unsubscribeFromStateTransferEvents(SERVICE_NAME, this); this.partition.unregisterMembershipListener(this); } }
public void shutdown() throws Exception { DistributedReplicantManager drm = this.partition.getDistributedReplicantManager(); drm.unregisterListener(getServiceHAName(), drmListener); drm.remove(getServiceHAName()); this.partition.unregisterRPCHandler(getServiceHAName(), rpcTarget); this.lockSupport.stop(); this.contentManager = null; this.initialized = false; }