Search in sources :

Example 21 with Address

use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.

the class ClusterServiceImpl method getMasterMember.

private MemberImpl getMasterMember() {
    MemberImpl master;
    lock.lock();
    try {
        Address masterAddress = getMasterAddress();
        if (masterAddress == null) {
            throw new IllegalStateException("Master is not known yet!");
        }
        master = getMember(masterAddress);
    } finally {
        lock.unlock();
    }
    return master;
}
Also used : Address(com.hazelcast.cluster.Address) MemberImpl(com.hazelcast.cluster.impl.MemberImpl)

Example 22 with Address

use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.

the class JoinMessage method readData.

@Override
public void readData(ObjectDataInput in) throws IOException {
    packetVersion = in.readByte();
    buildNumber = in.readInt();
    memberVersion = in.readObject();
    address = in.readObject();
    uuid = UUIDSerializationUtil.readUUID(in);
    configCheck = in.readObject();
    liteMember = in.readBoolean();
    int memberCount = in.readInt();
    memberAddresses = new ArrayList<>(memberCount);
    for (int i = 0; i < memberCount; i++) {
        Address address = in.readObject();
        memberAddresses.add(address);
    }
    dataMemberCount = in.readInt();
}
Also used : Address(com.hazelcast.cluster.Address)

Example 23 with Address

use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.

the class JoinMessage method writeData.

@Override
public void writeData(ObjectDataOutput out) throws IOException {
    out.writeByte(packetVersion);
    out.writeInt(buildNumber);
    out.writeObject(memberVersion);
    out.writeObject(address);
    UUIDSerializationUtil.writeUUID(out, uuid);
    out.writeObject(configCheck);
    out.writeBoolean(liteMember);
    int memberCount = getMemberCount();
    out.writeInt(memberCount);
    if (memberCount > 0) {
        for (Address address : memberAddresses) {
            out.writeObject(address);
        }
    }
    out.writeInt(dataMemberCount);
}
Also used : Address(com.hazelcast.cluster.Address)

Example 24 with Address

use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.

the class MemberHandshake method readData.

@Override
public void readData(ObjectDataInput in) throws IOException {
    schemaVersion = in.readByte();
    targetAddress = in.readObject();
    reply = in.readBoolean();
    uuid = readUUID(in);
    int size = in.readInt();
    if (size == 0) {
        localAddresses = Collections.emptyMap();
    } else {
        Map<ProtocolType, Collection<Address>> addressesPerProtocolType = new EnumMap<>(ProtocolType.class);
        for (int i = 0; i < size; i++) {
            ProtocolType protocolType = ProtocolType.valueOf(in.readInt());
            Collection<Address> addresses = readCollection(in);
            addressesPerProtocolType.put(protocolType, addresses);
        }
        this.localAddresses = addressesPerProtocolType;
    }
    if (schemaVersion > SCHEMA_VERSION_1) {
        int optionsSize = in.readInt();
        for (int k = 0; k < optionsSize; k++) {
            options.put(in.readString(), in.readString());
        }
    }
}
Also used : Address(com.hazelcast.cluster.Address) ProtocolType(com.hazelcast.instance.ProtocolType) SerializationUtil.readCollection(com.hazelcast.internal.serialization.impl.SerializationUtil.readCollection) Collection(java.util.Collection) SerializationUtil.writeCollection(com.hazelcast.internal.serialization.impl.SerializationUtil.writeCollection) EnumMap(java.util.EnumMap)

Example 25 with Address

use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.

the class MulticastJoiner method joinMaster.

private void joinMaster() {
    long maxMasterJoinTime = getMaxJoinTimeToMasterNode();
    long start = Clock.currentTimeMillis();
    while (shouldRetry() && Clock.currentTimeMillis() - start < maxMasterJoinTime) {
        Address master = clusterService.getMasterAddress();
        if (master != null) {
            if (logger.isFineEnabled()) {
                logger.fine("Joining to master " + master);
            }
            clusterJoinManager.sendJoinRequest(master);
        } else {
            break;
        }
        try {
            clusterService.blockOnJoin(JOIN_RETRY_INTERVAL);
        } catch (InterruptedException e) {
            currentThread().interrupt();
        }
        if (isBlacklisted(master)) {
            clusterService.setMasterAddressToJoin(null);
            return;
        }
    }
}
Also used : Address(com.hazelcast.cluster.Address)

Aggregations

Address (com.hazelcast.cluster.Address)540 Test (org.junit.Test)211 QuickTest (com.hazelcast.test.annotation.QuickTest)191 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)178 HazelcastInstance (com.hazelcast.core.HazelcastInstance)92 InetAddress (java.net.InetAddress)75 ArrayList (java.util.ArrayList)66 Member (com.hazelcast.cluster.Member)63 Accessors.getAddress (com.hazelcast.test.Accessors.getAddress)54 MemberImpl (com.hazelcast.cluster.impl.MemberImpl)48 Config (com.hazelcast.config.Config)43 PartitionReplica (com.hazelcast.internal.partition.PartitionReplica)43 UUID (java.util.UUID)43 ILogger (com.hazelcast.logging.ILogger)37 HashMap (java.util.HashMap)36 Operation (com.hazelcast.spi.impl.operationservice.Operation)35 List (java.util.List)35 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)34 Map (java.util.Map)33 InetSocketAddress (java.net.InetSocketAddress)32