Search in sources :

Example 1 with EndpointQualifier

use of com.hazelcast.instance.EndpointQualifier in project hazelcast by hazelcast.

the class MemberImplTest method testSerialization_whenMultiAddress.

@Test
public void testSerialization_whenMultiAddress() throws Exception {
    Map<EndpointQualifier, Address> addressMap = new HashMap<EndpointQualifier, Address>();
    addressMap.put(EndpointQualifier.MEMBER, address);
    addressMap.put(EndpointQualifier.REST, new Address("127.0.0.1", 8080));
    MemberImpl member = new MemberImpl.Builder(addressMap).version(MemberVersion.of("3.12.0")).build();
    testSerialization(member);
}
Also used : Address(com.hazelcast.cluster.Address) HashMap(java.util.HashMap) EndpointQualifier(com.hazelcast.instance.EndpointQualifier) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with EndpointQualifier

use of com.hazelcast.instance.EndpointQualifier in project hazelcast by hazelcast.

the class ConfigTest method testEndpointConfig.

@Test
public void testEndpointConfig() {
    String name = randomName();
    EndpointQualifier qualifier = EndpointQualifier.resolve(WAN, name);
    ServerSocketEndpointConfig endpointConfig = new ServerSocketEndpointConfig();
    endpointConfig.setName(name);
    endpointConfig.setProtocolType(WAN);
    config.getAdvancedNetworkConfig().addWanEndpointConfig(endpointConfig);
    assertEquals(endpointConfig, config.getAdvancedNetworkConfig().getEndpointConfigs().get(qualifier));
}
Also used : EndpointQualifier(com.hazelcast.instance.EndpointQualifier) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with EndpointQualifier

use of com.hazelcast.instance.EndpointQualifier in project hazelcast by hazelcast.

the class ClusterServiceImpl method resetLocalMemberUuid.

private void resetLocalMemberUuid() {
    assert lock.isHeldByCurrentThread() : "Called without holding cluster service lock!";
    assert !isJoined() : "Cannot reset local member UUID when joined.";
    Map<EndpointQualifier, Address> addressMap = localMember.getAddressMap();
    UUID newUuid = UuidUtil.newUnsecureUUID();
    logger.warning("Resetting local member UUID. Previous: " + localMember.getUuid() + ", new: " + newUuid);
    node.setThisUuid(newUuid);
    localMember = new MemberImpl.Builder(addressMap).version(localMember.getVersion()).localMember(true).uuid(newUuid).attributes(localMember.getAttributes()).liteMember(localMember.isLiteMember()).memberListJoinVersion(localMember.getMemberListJoinVersion()).instance(node.hazelcastInstance).build();
    node.loggingService.setThisMember(localMember);
    node.getLocalAddressRegistry().setLocalUuid(newUuid);
}
Also used : Address(com.hazelcast.cluster.Address) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) EndpointQualifier(com.hazelcast.instance.EndpointQualifier) UUID(java.util.UUID)

Example 4 with EndpointQualifier

use of com.hazelcast.instance.EndpointQualifier in project hazelcast by hazelcast.

the class ClusterDataSerializerHook method createFactory.

@Override
public DataSerializableFactory createFactory() {
    ConstructorFunction<Integer, IdentifiedDataSerializable>[] constructors = new ConstructorFunction[LEN];
    constructors[AUTH_FAILURE] = arg -> new AuthenticationFailureOp();
    constructors[ADDRESS] = arg -> new Address();
    constructors[MEMBER] = arg -> new MemberImpl();
    constructors[HEARTBEAT] = arg -> new HeartbeatOp();
    constructors[CONFIG_CHECK] = arg -> new ConfigCheck();
    constructors[MEMBER_HANDSHAKE] = arg -> new MemberHandshake();
    constructors[MEMBER_INFO_UPDATE] = arg -> new MembersUpdateOp();
    constructors[FINALIZE_JOIN] = arg -> new FinalizeJoinOp();
    constructors[BEFORE_JOIN_CHECK_FAILURE] = arg -> new BeforeJoinCheckFailureOp();
    constructors[CHANGE_CLUSTER_STATE] = arg -> new CommitClusterStateOp();
    constructors[CONFIG_MISMATCH] = arg -> new ConfigMismatchOp();
    constructors[CLUSTER_MISMATCH] = arg -> new ClusterMismatchOp();
    constructors[SPLIT_BRAIN_MERGE_VALIDATION] = arg -> new SplitBrainMergeValidationOp();
    constructors[JOIN_REQUEST_OP] = arg -> new JoinRequestOp();
    constructors[LOCK_CLUSTER_STATE] = arg -> new LockClusterStateOp();
    constructors[MASTER_CLAIM] = arg -> new JoinMastershipClaimOp();
    constructors[WHOIS_MASTER] = arg -> new WhoisMasterOp();
    constructors[MERGE_CLUSTERS] = arg -> new MergeClustersOp();
    constructors[POST_JOIN] = arg -> new OnJoinOp();
    constructors[ROLLBACK_CLUSTER_STATE] = arg -> new RollbackClusterStateOp();
    constructors[MASTER_RESPONSE] = arg -> new MasterResponseOp();
    constructors[SHUTDOWN_NODE] = arg -> new ShutdownNodeOp();
    constructors[TRIGGER_MEMBER_LIST_PUBLISH] = arg -> new TriggerMemberListPublishOp();
    constructors[CLUSTER_STATE_TRANSACTION_LOG_RECORD] = arg -> new ClusterStateTransactionLogRecord();
    constructors[MEMBER_INFO] = arg -> new MemberInfo();
    constructors[JOIN_MESSAGE] = arg -> new JoinMessage();
    constructors[JOIN_REQUEST] = arg -> new JoinRequest();
    constructors[MIGRATION_INFO] = arg -> new MigrationInfo();
    constructors[MEMBER_VERSION] = arg -> new MemberVersion();
    constructors[CLUSTER_STATE_CHANGE] = arg -> new ClusterStateChange();
    constructors[SPLIT_BRAIN_JOIN_MESSAGE] = arg -> new SplitBrainJoinMessage();
    constructors[VERSION] = arg -> new Version();
    constructors[FETCH_MEMBER_LIST_STATE] = arg -> new FetchMembersViewOp();
    constructors[EXPLICIT_SUSPICION] = arg -> new ExplicitSuspicionOp();
    constructors[MEMBERS_VIEW] = arg -> new MembersView();
    constructors[TRIGGER_EXPLICIT_SUSPICION] = arg -> new TriggerExplicitSuspicionOp();
    constructors[MEMBERS_VIEW_METADATA] = arg -> new MembersViewMetadata();
    constructors[HEARTBEAT_COMPLAINT] = arg -> new HeartbeatComplaintOp();
    constructors[PROMOTE_LITE_MEMBER] = arg -> new PromoteLiteMemberOp();
    constructors[VECTOR_CLOCK] = arg -> new VectorClock();
    constructors[ENDPOINT_QUALIFIER] = arg -> new EndpointQualifier();
    return new ArrayDataSerializableFactory(constructors);
}
Also used : MigrationInfo(com.hazelcast.internal.partition.MigrationInfo) MergeClustersOp(com.hazelcast.internal.cluster.impl.operations.MergeClustersOp) Address(com.hazelcast.cluster.Address) MembersUpdateOp(com.hazelcast.internal.cluster.impl.operations.MembersUpdateOp) SplitBrainMergeValidationOp(com.hazelcast.internal.cluster.impl.operations.SplitBrainMergeValidationOp) RollbackClusterStateOp(com.hazelcast.internal.cluster.impl.operations.RollbackClusterStateOp) EndpointQualifier(com.hazelcast.instance.EndpointQualifier) TriggerMemberListPublishOp(com.hazelcast.internal.cluster.impl.operations.TriggerMemberListPublishOp) MemberVersion(com.hazelcast.version.MemberVersion) HeartbeatComplaintOp(com.hazelcast.internal.cluster.impl.operations.HeartbeatComplaintOp) MemberInfo(com.hazelcast.internal.cluster.MemberInfo) Version(com.hazelcast.version.Version) MemberVersion(com.hazelcast.version.MemberVersion) ShutdownNodeOp(com.hazelcast.internal.cluster.impl.operations.ShutdownNodeOp) HeartbeatOp(com.hazelcast.internal.cluster.impl.operations.HeartbeatOp) TriggerExplicitSuspicionOp(com.hazelcast.internal.cluster.impl.operations.TriggerExplicitSuspicionOp) BeforeJoinCheckFailureOp(com.hazelcast.internal.cluster.impl.operations.BeforeJoinCheckFailureOp) MasterResponseOp(com.hazelcast.internal.cluster.impl.operations.MasterResponseOp) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) LockClusterStateOp(com.hazelcast.internal.cluster.impl.operations.LockClusterStateOp) ExplicitSuspicionOp(com.hazelcast.internal.cluster.impl.operations.ExplicitSuspicionOp) TriggerExplicitSuspicionOp(com.hazelcast.internal.cluster.impl.operations.TriggerExplicitSuspicionOp) VectorClock(com.hazelcast.cluster.impl.VectorClock) AuthenticationFailureOp(com.hazelcast.internal.cluster.impl.operations.AuthenticationFailureOp) ClusterMismatchOp(com.hazelcast.internal.cluster.impl.operations.ClusterMismatchOp) PromoteLiteMemberOp(com.hazelcast.internal.cluster.impl.operations.PromoteLiteMemberOp) FinalizeJoinOp(com.hazelcast.internal.cluster.impl.operations.FinalizeJoinOp) ConstructorFunction(com.hazelcast.internal.util.ConstructorFunction) ConfigMismatchOp(com.hazelcast.internal.cluster.impl.operations.ConfigMismatchOp) CommitClusterStateOp(com.hazelcast.internal.cluster.impl.operations.CommitClusterStateOp) WhoisMasterOp(com.hazelcast.internal.cluster.impl.operations.WhoisMasterOp) OnJoinOp(com.hazelcast.internal.cluster.impl.operations.OnJoinOp) JoinRequestOp(com.hazelcast.internal.cluster.impl.operations.JoinRequestOp) FetchMembersViewOp(com.hazelcast.internal.cluster.impl.operations.FetchMembersViewOp) ArrayDataSerializableFactory(com.hazelcast.internal.serialization.impl.ArrayDataSerializableFactory) JoinMastershipClaimOp(com.hazelcast.internal.cluster.impl.operations.JoinMastershipClaimOp)

Example 5 with EndpointQualifier

use of com.hazelcast.instance.EndpointQualifier in project hazelcast by hazelcast.

the class MemberStateImpl method fromJson.

@Override
@SuppressWarnings({ "checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity", "checkstyle:methodlength" })
public void fromJson(JsonObject json) {
    address = getString(json, "address");
    String uuidString = getString(json, "uuid", null);
    uuid = uuidString != null ? UUID.fromString(uuidString) : null;
    String cpMemberUuidString = getString(json, "cpMemberUuid", null);
    cpMemberUuid = cpMemberUuidString != null ? UUID.fromString(cpMemberUuidString) : null;
    name = getString(json, "name", null);
    JsonArray jsonEndpoints = getArray(json, "endpoints");
    endpoints = new HashMap<>();
    for (JsonValue obj : jsonEndpoints) {
        JsonObject endpoint = obj.asObject();
        String id = endpoint.getString("id", null);
        ProtocolType type = ProtocolType.valueOf(endpoint.getString("protocol", "MEMBER"));
        JsonValue addr = endpoint.get("address");
        String host = addr.asObject().getString("host", "");
        int port = addr.asObject().getInt("port", 0);
        EndpointQualifier qualifier = EndpointQualifier.resolve(type, id);
        Address address = null;
        try {
            address = new Address(host, port);
        } catch (UnknownHostException e) {
            // ignore
            ignore(e);
        }
        endpoints.put(qualifier, address);
    }
    mapsWithStats = new HashSet<>();
    for (JsonObject.Member next : getObject(json, "mapStats")) {
        mapsWithStats.add(next.getName());
    }
    multiMapsWithStats = new HashSet<>();
    for (JsonObject.Member next : getObject(json, "multiMapStats")) {
        multiMapsWithStats.add(next.getName());
    }
    replicatedMapsWithStats = new HashSet<>();
    for (JsonObject.Member next : getObject(json, "replicatedMapStats")) {
        replicatedMapsWithStats.add(next.getName());
    }
    queuesWithStats = new HashSet<>();
    for (JsonObject.Member next : getObject(json, "queueStats")) {
        queuesWithStats.add(next.getName());
    }
    topicsWithStats = new HashSet<>();
    for (JsonObject.Member next : getObject(json, "topicStats")) {
        topicsWithStats.add(next.getName());
    }
    reliableTopicsWithStats = new HashSet<>();
    for (JsonObject.Member next : getObject(json, "reliableTopicStats")) {
        reliableTopicsWithStats.add(next.getName());
    }
    pnCountersWithStats = new HashSet<>();
    for (JsonObject.Member next : getObject(json, "pnCounterStats")) {
        pnCountersWithStats.add(next.getName());
    }
    executorsWithStats = new HashSet<>();
    for (JsonObject.Member next : getObject(json, "executorStats")) {
        executorsWithStats.add(next.getName());
    }
    scheduledExecutorsWithStats = new HashSet<>();
    for (JsonObject.Member next : getObject(json, "scheduledExecutorStats")) {
        scheduledExecutorsWithStats.add(next.getName());
    }
    durableExecutorsWithStats = new HashSet<>();
    for (JsonObject.Member next : getObject(json, "durableExecutorStats")) {
        durableExecutorsWithStats.add(next.getName());
    }
    cachesWithStats = new HashSet<>();
    for (JsonObject.Member next : getObject(json, "cacheStats")) {
        cachesWithStats.add(next.getName());
    }
    flakeIdGeneratorsWithStats = new HashSet<>();
    for (JsonObject.Member next : getObject(json, "flakeIdStats")) {
        flakeIdGeneratorsWithStats.add(next.getName());
    }
    for (JsonObject.Member next : getObject(json, "wanStats", new JsonObject())) {
        putDeserializedIfSerializable(wanStats, next.getName(), next.getValue().asObject(), new LocalWanStatsImpl());
    }
    JsonArray jsonClients = getArray(json, "clients");
    clients = new ArrayList<>();
    for (JsonValue jsonClient : jsonClients) {
        final ClientEndPointDTO client = new ClientEndPointDTO();
        client.fromJson(jsonClient.asObject());
        clients.add(client);
    }
    JsonObject jsonOperationStats = getObject(json, "operationStats", null);
    if (jsonOperationStats != null) {
        operationStats = readJsonIfDeserializable(jsonOperationStats, operationStats);
    }
    JsonObject jsonMemberPartitionState = getObject(json, "memberPartitionState", null);
    if (jsonMemberPartitionState != null) {
        memberPartitionState = new MemberPartitionStateImpl();
        memberPartitionState.fromJson(jsonMemberPartitionState);
    }
    JsonObject jsonNodeState = getObject(json, "nodeState", null);
    if (jsonNodeState != null) {
        nodeState = new NodeStateImpl();
        nodeState.fromJson(jsonNodeState);
    }
    JsonObject jsonHotRestartState = getObject(json, "hotRestartState", null);
    if (jsonHotRestartState != null) {
        hotRestartState = new HotRestartStateImpl();
        hotRestartState.fromJson(jsonHotRestartState);
    }
    JsonObject jsonClusterHotRestartStatus = getObject(json, "clusterHotRestartStatus", null);
    if (jsonClusterHotRestartStatus != null) {
        clusterHotRestartStatus = new ClusterHotRestartStatusDTO();
        clusterHotRestartStatus.fromJson(jsonClusterHotRestartStatus);
    }
    clientStats = new HashMap<>();
    for (JsonObject.Member next : getObject(json, "clientStats")) {
        clientStats.put(UUID.fromString(next.getName()), next.getValue().asString());
    }
}
Also used : Address(com.hazelcast.cluster.Address) UnknownHostException(java.net.UnknownHostException) ClientEndPointDTO(com.hazelcast.internal.management.dto.ClientEndPointDTO) JsonValue(com.hazelcast.internal.json.JsonValue) JsonObject(com.hazelcast.internal.json.JsonObject) EndpointQualifier(com.hazelcast.instance.EndpointQualifier) JsonUtil.getString(com.hazelcast.internal.util.JsonUtil.getString) JsonArray(com.hazelcast.internal.json.JsonArray) ProtocolType(com.hazelcast.instance.ProtocolType) ClusterHotRestartStatusDTO(com.hazelcast.internal.management.dto.ClusterHotRestartStatusDTO)

Aggregations

EndpointQualifier (com.hazelcast.instance.EndpointQualifier)22 Address (com.hazelcast.cluster.Address)9 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)9 QuickTest (com.hazelcast.test.annotation.QuickTest)9 Test (org.junit.Test)9 EndpointConfig (com.hazelcast.config.EndpointConfig)5 HashMap (java.util.HashMap)5 UUID (java.util.UUID)5 MemberImpl (com.hazelcast.cluster.impl.MemberImpl)3 ProtocolType (com.hazelcast.instance.ProtocolType)3 MemberInfo (com.hazelcast.internal.cluster.MemberInfo)3 ClientEndPointDTO (com.hazelcast.internal.management.dto.ClientEndPointDTO)3 Map (java.util.Map)3 AdvancedNetworkConfig (com.hazelcast.config.AdvancedNetworkConfig)2 ServerSocketEndpointConfig (com.hazelcast.config.ServerSocketEndpointConfig)2 ClusterHotRestartStatusDTO (com.hazelcast.internal.management.dto.ClusterHotRestartStatusDTO)2 MemberVersion (com.hazelcast.version.MemberVersion)2 Version (com.hazelcast.version.Version)2 InetSocketAddress (java.net.InetSocketAddress)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2