Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package org.infinispan.topology;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.infinispan.commands.ReplicableCommand;
import org.infinispan.commons.CacheException;
import org.infinispan.commons.marshall.MarshallUtil;
import org.infinispan.distribution.ch.ConsistentHash;
import org.infinispan.factories.annotations.Inject;
import org.infinispan.partitionhandling.AvailabilityMode;
import org.infinispan.remoting.responses.ExceptionResponse;
import org.infinispan.remoting.responses.SuccessfulResponse;
import org.infinispan.remoting.responses.UnsuccessfulResponse;
import org.infinispan.remoting.transport.Address;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;
/**
* A control command for all cache membership/rebalance operations.
* It is not a {@code CacheRpcCommand} because it needs to run on the coordinator even when
* the coordinator doesn't have a certain cache running.
*
* @author Dan Berindei
* @since 5.2
*/
public class CacheTopologyControlCommand implements ReplicableCommand {
public enum Type {
// Member to coordinator:
// A node is requesting to join the cluster.
JOIN,
// A member is signaling that it wants to leave the cluster.
LEAVE,
/**
* A member is confirming that it has finished a topology change during rebalance.
* This confirmation is sent after topologies with {@link CacheTopology.Phase#READ_OLD_WRITE_ALL},
* {@link CacheTopology.Phase#READ_ALL_WRITE_ALL} and {@link CacheTopology.Phase#READ_NEW_WRITE_ALL}
* rebalance phases are installed, but not after a topology change with {@link CacheTopology.Phase#NO_REBALANCE} phase.
*/
REBALANCE_PHASE_CONFIRM,
// A member is requesting a cache shutdown
SHUTDOWN_REQUEST,
// Coordinator to member:
// The coordinator is updating the consistent hash.
// Used to signal the end of rebalancing as well.
CH_UPDATE,
// The coordinator is starting a rebalance operation.
REBALANCE_START,
// The coordinator is requesting information about the running caches.
GET_STATUS,
// Update the stable topology
STABLE_TOPOLOGY_UPDATE,
// Tell members to shutdown cache
SHUTDOWN_PERFORM,
// Member to coordinator:
// Enable/disable rebalancing, check whether rebalancing is enabled
POLICY_DISABLE,
POLICY_ENABLE,
POLICY_GET_STATUS,
// Change the availability
AVAILABILITY_MODE_CHANGE,
// Query the rebalancing progress
REBALANCING_GET_STATUS;
private static final Type[] CACHED_VALUES = values();
}
private static final Log log = LogFactory.getLog(CacheTopologyControlCommand.class);
public static final byte COMMAND_ID = 17;
@Inject private transient LocalTopologyManager localTopologyManager;
@Inject private transient ClusterTopologyManager clusterTopologyManager;
private String cacheName;
private Type type;
private Address sender;
private CacheJoinInfo joinInfo;
private int topologyId;
private int rebalanceId;
private ConsistentHash currentCH;
private ConsistentHash pendingCH;
private CacheTopology.Phase phase;
private AvailabilityMode availabilityMode;
private List actualMembers;
private List persistentUUIDs;
private Throwable throwable;
private int viewId;
// For CommandIdUniquenessTest only
public CacheTopologyControlCommand() {
this.cacheName = null;
}
public CacheTopologyControlCommand(String cacheName, Type type, Address sender, int viewId) {
this.cacheName = cacheName;
this.type = type;
this.sender = sender;
this.viewId = viewId;
}
public CacheTopologyControlCommand(String cacheName, Type type, Address sender, CacheJoinInfo joinInfo, int viewId) {
this.cacheName = cacheName;
this.type = type;
this.sender = sender;
this.joinInfo = joinInfo;
this.viewId = viewId;
}
public CacheTopologyControlCommand(String cacheName, Type type, Address sender, int topologyId, int rebalanceId,
Throwable throwable, int viewId) {
this.cacheName = cacheName;
this.type = type;
this.sender = sender;
this.topologyId = topologyId;
this.rebalanceId = rebalanceId;
this.throwable = throwable;
this.viewId = viewId;
}
public CacheTopologyControlCommand(String cacheName, Type type, Address sender, AvailabilityMode availabilityMode,
int viewId) {
this.cacheName = cacheName;
this.type = type;
this.sender = sender;
this.availabilityMode = availabilityMode;
this.viewId = viewId;
}
public CacheTopologyControlCommand(String cacheName, Type type, Address sender, CacheTopology cacheTopology,
AvailabilityMode availabilityMode, int viewId) {
this.cacheName = cacheName;
this.type = type;
this.sender = sender;
this.topologyId = cacheTopology.getTopologyId();
this.rebalanceId = cacheTopology.getRebalanceId();
this.currentCH = cacheTopology.getCurrentCH();
this.pendingCH = cacheTopology.getPendingCH();
this.phase = cacheTopology.getPhase();
this.availabilityMode = availabilityMode;
this.actualMembers = cacheTopology.getActualMembers();
this.persistentUUIDs = cacheTopology.getMembersPersistentUUIDs();
this.viewId = viewId;
}
@Override
public CompletableFuture