Search in sources :

Example 26 with Address

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);
}
Also used : Address(com.hazelcast.nio.Address)

Example 27 with Address

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);
}
Also used : Address(com.hazelcast.nio.Address)

Example 28 with Address

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();
}
Also used : Address(com.hazelcast.nio.Address)

Example 29 with Address

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);
}
Also used : Address(com.hazelcast.nio.Address)

Example 30 with Address

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);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) Address(com.hazelcast.nio.Address) InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) InternalPartitionImpl(com.hazelcast.internal.partition.impl.InternalPartitionImpl) PartitionStateManager(com.hazelcast.internal.partition.impl.PartitionStateManager)

Aggregations

Address (com.hazelcast.nio.Address)274 Test (org.junit.Test)44 QuickTest (com.hazelcast.test.annotation.QuickTest)36 HashMap (java.util.HashMap)33 ParallelTest (com.hazelcast.test.annotation.ParallelTest)29 Member (com.hazelcast.core.Member)27 ArrayList (java.util.ArrayList)27 Map (java.util.Map)26 ILogger (com.hazelcast.logging.ILogger)25 InetAddress (java.net.InetAddress)25 MemberImpl (com.hazelcast.instance.MemberImpl)21 List (java.util.List)20 HashSet (java.util.HashSet)18 Connection (com.hazelcast.nio.Connection)17 NodeEngine (com.hazelcast.spi.NodeEngine)16 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)16 IOException (java.io.IOException)16 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)14 HazelcastInstance (com.hazelcast.core.HazelcastInstance)13 IPartitionService (com.hazelcast.spi.partition.IPartitionService)13