use of com.hazelcast.nio.Address in project hazelcast by hazelcast.
the class PartitionTableView method readData.
public static PartitionTableView readData(ObjectDataInput in) throws IOException {
int len = in.readInt();
Address[][] addresses = new Address[len][MAX_REPLICA_COUNT];
for (int i = 0; i < len; i++) {
for (int j = 0; j < MAX_REPLICA_COUNT; j++) {
boolean exists = in.readBoolean();
if (exists) {
Address address = new Address();
addresses[i][j] = address;
address.readData(in);
}
}
}
int version = in.readInt();
return new PartitionTableView(addresses, version);
}
use of com.hazelcast.nio.Address in project hazelcast by hazelcast.
the class InternalPartitionImpl method setReplicaAddress.
void setReplicaAddress(int replicaIndex, Address newAddress) {
Address[] newAddresses = Arrays.copyOf(addresses, MAX_REPLICA_COUNT);
Address oldAddress = newAddresses[replicaIndex];
newAddresses[replicaIndex] = newAddress;
addresses = newAddresses;
callPartitionListener(replicaIndex, oldAddress, newAddress);
}
use of com.hazelcast.nio.Address in project hazelcast by hazelcast.
the class InternalPartitionImpl method toString.
@Override
public String toString() {
StringBuilder sb = new StringBuilder("Partition [").append(partitionId).append("]{\n");
for (int i = 0; i < MAX_REPLICA_COUNT; i++) {
Address address = addresses[i];
if (address != null) {
sb.append('\t');
sb.append(i).append(":").append(address);
sb.append("\n");
}
}
sb.append("}");
return sb.toString();
}
use of com.hazelcast.nio.Address in project hazelcast by hazelcast.
the class InternalPartitionServiceImpl method processPartitionRuntimeState.
public boolean processPartitionRuntimeState(final PartitionRuntimeState partitionState) {
final Address sender = partitionState.getEndpoint();
if (!node.getNodeExtension().isStartCompleted()) {
logger.warning("Ignoring received partition table, startup is not completed yet. Sender: " + sender);
return false;
}
final Address master = node.getMasterAddress();
if (node.isMaster() && !node.getThisAddress().equals(sender)) {
logger.warning("This is the master node and received a PartitionRuntimeState from " + sender + ". Ignoring incoming state! ");
return false;
} else {
if (sender == null || !sender.equals(master)) {
if (node.clusterService.getMember(sender) == null) {
logger.severe("Received a ClusterRuntimeState from an unknown member!" + " => Sender: " + sender + ", Master: " + master + "! ");
return false;
} else {
logger.warning("Received a ClusterRuntimeState, but its sender doesn't seem to be master!" + " => Sender: " + sender + ", Master: " + master + "! " + "(Ignore if master node has changed recently.)");
return false;
}
}
}
return applyNewState(partitionState, sender);
}
use of com.hazelcast.nio.Address in project hazelcast by hazelcast.
the class ReplicaSyncResponse method run.
@Override
public void run() throws Exception {
NodeEngine nodeEngine = getNodeEngine();
InternalPartitionServiceImpl partitionService = getService();
int partitionId = getPartitionId();
int replicaIndex = getReplicaIndex();
PartitionStateManager partitionStateManager = partitionService.getPartitionStateManager();
InternalPartitionImpl partition = partitionStateManager.getPartitionImpl(partitionId);
Address thisAddress = nodeEngine.getThisAddress();
int currentReplicaIndex = partition.getReplicaIndex(thisAddress);
try {
if (replicaIndex == currentReplicaIndex) {
executeTasks();
} else {
nodeNotOwnsBackup(partition);
}
if (tasks != null) {
tasks.clear();
}
} finally {
postProcessReplicaSync(partitionService, currentReplicaIndex);
}
}
Aggregations