Search in sources :

Example 1 with MemberVersion

use of com.hazelcast.version.MemberVersion in project hazelcast by hazelcast.

the class ClusterDataSerializerHook method createFactory.

@Override
public DataSerializableFactory createFactory() {
    ConstructorFunction<Integer, IdentifiedDataSerializable>[] constructors = new ConstructorFunction[LEN];
    constructors[AUTH_FAILURE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new AuthenticationFailureOperation();
        }
    };
    constructors[ADDRESS] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new Address();
        }
    };
    constructors[MEMBER] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new MemberImpl();
        }
    };
    constructors[HEARTBEAT] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new HeartbeatOperation();
        }
    };
    constructors[CONFIG_CHECK] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new ConfigCheck();
        }
    };
    constructors[BIND_MESSAGE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new BindMessage();
        }
    };
    constructors[MEMBER_INFO_UPDATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new MemberInfoUpdateOperation();
        }
    };
    constructors[FINALIZE_JOIN] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new FinalizeJoinOperation();
        }
    };
    constructors[AUTHORIZATION] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new AuthorizationOperation();
        }
    };
    constructors[BEFORE_JOIN_CHECK_FAILURE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new BeforeJoinCheckFailureOperation();
        }
    };
    constructors[CHANGE_CLUSTER_STATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new ChangeClusterStateOperation();
        }
    };
    constructors[CONFIG_MISMATCH] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new ConfigMismatchOperation();
        }
    };
    constructors[GROUP_MISMATCH] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new GroupMismatchOperation();
        }
    };
    constructors[SPLIT_BRAIN_MERGE_VALIDATION] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new SplitBrainMergeValidationOperation();
        }
    };
    constructors[JOIN_REQUEST_OP] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new JoinRequestOperation();
        }
    };
    constructors[LOCK_CLUSTER_STATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new LockClusterStateOperation();
        }
    };
    constructors[MASTER_CLAIM] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new MasterClaimOperation();
        }
    };
    constructors[MASTER_CONFIRM] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new MasterConfirmationOperation();
        }
    };
    constructors[MASTER_DISCOVERY] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new MasterDiscoveryOperation();
        }
    };
    constructors[MEMBER_ATTR_CHANGED] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new MemberAttributeChangedOperation();
        }
    };
    constructors[MEMBER_REMOVE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new MemberRemoveOperation();
        }
    };
    constructors[MERGE_CLUSTERS] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new MergeClustersOperation();
        }
    };
    constructors[POST_JOIN] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new PostJoinOperation();
        }
    };
    constructors[ROLLBACK_CLUSTER_STATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new RollbackClusterStateOperation();
        }
    };
    constructors[SET_MASTER] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new SetMasterOperation();
        }
    };
    constructors[SHUTDOWN_NODE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new ShutdownNodeOperation();
        }
    };
    constructors[TRIGGER_MEMBER_LIST_PUBLISH] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new TriggerMemberListPublishOperation();
        }
    };
    constructors[CLUSTER_STATE_TRANSACTION_LOG_RECORD] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new ClusterStateTransactionLogRecord();
        }
    };
    constructors[MEMBER_INFO] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new MemberInfo();
        }
    };
    constructors[JOIN_MESSAGE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new JoinMessage();
        }
    };
    constructors[JOIN_REQUEST] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new JoinRequest();
        }
    };
    constructors[MIGRATION_INFO] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new MigrationInfo();
        }
    };
    constructors[MEMBER_VERSION] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new MemberVersion();
        }
    };
    constructors[CLUSTER_STATE_CHANGE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new ClusterStateChange();
        }
    };
    constructors[SPLIT_BRAIN_JOIN_MESSAGE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new SplitBrainJoinMessage();
        }
    };
    constructors[VERSION] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new Version();
        }
    };
    return new ArrayDataSerializableFactory(constructors);
}
Also used : MemberAttributeChangedOperation(com.hazelcast.internal.cluster.impl.operations.MemberAttributeChangedOperation) MigrationInfo(com.hazelcast.internal.partition.MigrationInfo) Address(com.hazelcast.nio.Address) MergeClustersOperation(com.hazelcast.internal.cluster.impl.operations.MergeClustersOperation) PostJoinOperation(com.hazelcast.internal.cluster.impl.operations.PostJoinOperation) SetMasterOperation(com.hazelcast.internal.cluster.impl.operations.SetMasterOperation) MemberVersion(com.hazelcast.version.MemberVersion) TriggerMemberListPublishOperation(com.hazelcast.internal.cluster.impl.operations.TriggerMemberListPublishOperation) MasterDiscoveryOperation(com.hazelcast.internal.cluster.impl.operations.MasterDiscoveryOperation) ConfigMismatchOperation(com.hazelcast.internal.cluster.impl.operations.ConfigMismatchOperation) MemberInfo(com.hazelcast.internal.cluster.MemberInfo) SplitBrainMergeValidationOperation(com.hazelcast.internal.cluster.impl.operations.SplitBrainMergeValidationOperation) Version(com.hazelcast.version.Version) MemberVersion(com.hazelcast.version.MemberVersion) BeforeJoinCheckFailureOperation(com.hazelcast.internal.cluster.impl.operations.BeforeJoinCheckFailureOperation) ChangeClusterStateOperation(com.hazelcast.internal.cluster.impl.operations.ChangeClusterStateOperation) IdentifiedDataSerializable(com.hazelcast.nio.serialization.IdentifiedDataSerializable) LockClusterStateOperation(com.hazelcast.internal.cluster.impl.operations.LockClusterStateOperation) MemberImpl(com.hazelcast.instance.MemberImpl) MemberRemoveOperation(com.hazelcast.internal.cluster.impl.operations.MemberRemoveOperation) HeartbeatOperation(com.hazelcast.internal.cluster.impl.operations.HeartbeatOperation) MasterClaimOperation(com.hazelcast.internal.cluster.impl.operations.MasterClaimOperation) ShutdownNodeOperation(com.hazelcast.internal.cluster.impl.operations.ShutdownNodeOperation) ConstructorFunction(com.hazelcast.util.ConstructorFunction) MemberInfoUpdateOperation(com.hazelcast.internal.cluster.impl.operations.MemberInfoUpdateOperation) GroupMismatchOperation(com.hazelcast.internal.cluster.impl.operations.GroupMismatchOperation) FinalizeJoinOperation(com.hazelcast.internal.cluster.impl.operations.FinalizeJoinOperation) AuthorizationOperation(com.hazelcast.internal.cluster.impl.operations.AuthorizationOperation) MasterConfirmationOperation(com.hazelcast.internal.cluster.impl.operations.MasterConfirmationOperation) AuthenticationFailureOperation(com.hazelcast.internal.cluster.impl.operations.AuthenticationFailureOperation) JoinRequestOperation(com.hazelcast.internal.cluster.impl.operations.JoinRequestOperation) ArrayDataSerializableFactory(com.hazelcast.internal.serialization.impl.ArrayDataSerializableFactory) RollbackClusterStateOperation(com.hazelcast.internal.cluster.impl.operations.RollbackClusterStateOperation)

Example 2 with MemberVersion

use of com.hazelcast.version.MemberVersion in project hazelcast by hazelcast.

the class DefaultNodeExtensionTest method test_nodeVersionNotCompatibleWith_otherMinorVersion.

@Test
public void test_nodeVersionNotCompatibleWith_otherMinorVersion() {
    MemberVersion currentVersion = getNode(hazelcastInstance).getVersion();
    Version minorMinusOne = Version.of(currentVersion.getMajor(), currentVersion.getMinor() - 1);
    assertFalse(nodeExtension.isNodeVersionCompatibleWith(minorMinusOne));
}
Also used : Version(com.hazelcast.version.Version) MemberVersion(com.hazelcast.version.MemberVersion) MemberVersion(com.hazelcast.version.MemberVersion) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 3 with MemberVersion

use of com.hazelcast.version.MemberVersion in project hazelcast by hazelcast.

the class DefaultNodeExtensionTest method test_nodeVersionCompatibleWith_ownClusterVersion.

@Test
public void test_nodeVersionCompatibleWith_ownClusterVersion() {
    MemberVersion currentVersion = getNode(hazelcastInstance).getVersion();
    assertTrue(nodeExtension.isNodeVersionCompatibleWith(currentVersion.asVersion()));
}
Also used : MemberVersion(com.hazelcast.version.MemberVersion) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 4 with MemberVersion

use of com.hazelcast.version.MemberVersion in project hazelcast by hazelcast.

the class DefaultNodeExtensionTest method test_nodeVersionNotCompatibleWith_otherMajorVersion.

@Test
public void test_nodeVersionNotCompatibleWith_otherMajorVersion() {
    MemberVersion currentVersion = getNode(hazelcastInstance).getVersion();
    Version majorPlusOne = Version.of(currentVersion.getMajor() + 1, currentVersion.getMinor());
    assertFalse(nodeExtension.isNodeVersionCompatibleWith(majorPlusOne));
}
Also used : Version(com.hazelcast.version.Version) MemberVersion(com.hazelcast.version.MemberVersion) MemberVersion(com.hazelcast.version.MemberVersion) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 5 with MemberVersion

use of com.hazelcast.version.MemberVersion in project hazelcast by hazelcast.

the class MemberStateImplTest method testSerialization.

@Test
public void testSerialization() {
    HazelcastInstance hazelcastInstance = createHazelcastInstance();
    LocalReplicatedMapStatsImpl replicatedMapStats = new LocalReplicatedMapStatsImpl();
    replicatedMapStats.incrementPuts(30);
    CacheStatisticsImpl cacheStatistics = new CacheStatisticsImpl(Clock.currentTimeMillis());
    cacheStatistics.increaseCacheHits(5);
    Collection<ClientEndPointDTO> clients = new ArrayList<ClientEndPointDTO>();
    ClientEndPointDTO client = new ClientEndPointDTO();
    client.uuid = "abc123456";
    client.address = "localhost";
    client.clientType = "undefined";
    clients.add(client);
    Map<String, Long> runtimeProps = new HashMap<String, Long>();
    runtimeProps.put("prop1", 598123L);
    ClusterState clusterState = ClusterState.ACTIVE;
    com.hazelcast.instance.NodeState nodeState = com.hazelcast.instance.NodeState.PASSIVE;
    Version clusterVersion = Version.of("3.8.0");
    MemberVersion memberVersion = MemberVersion.of("3.9.0");
    NodeState state = new NodeStateImpl(clusterState, nodeState, clusterVersion, memberVersion);
    final BackupTaskStatus backupTaskStatus = new BackupTaskStatus(BackupTaskState.IN_PROGRESS, 5, 10);
    final HotRestartStateImpl hotRestartState = new HotRestartStateImpl(backupTaskStatus, false);
    final WanSyncState wanSyncState = new WanSyncStateImpl(WanSyncStatus.IN_PROGRESS, 86, "atob", "B");
    TimedMemberStateFactory factory = new TimedMemberStateFactory(getHazelcastInstanceImpl(hazelcastInstance));
    TimedMemberState timedMemberState = factory.createTimedMemberState();
    MemberStateImpl memberState = timedMemberState.getMemberState();
    memberState.setAddress("memberStateAddress:Port");
    memberState.putLocalMapStats("mapStats", new LocalMapStatsImpl());
    memberState.putLocalMultiMapStats("multiMapStats", new LocalMultiMapStatsImpl());
    memberState.putLocalQueueStats("queueStats", new LocalQueueStatsImpl());
    memberState.putLocalTopicStats("topicStats", new LocalTopicStatsImpl());
    memberState.putLocalExecutorStats("executorStats", new LocalExecutorStatsImpl());
    memberState.putLocalReplicatedMapStats("replicatedMapStats", replicatedMapStats);
    memberState.putLocalCacheStats("cacheStats", new LocalCacheStatsImpl(cacheStatistics));
    memberState.setRuntimeProps(runtimeProps);
    memberState.setLocalMemoryStats(new LocalMemoryStatsImpl());
    memberState.setOperationStats(new LocalOperationStatsImpl());
    memberState.setClients(clients);
    memberState.setNodeState(state);
    memberState.setHotRestartState(hotRestartState);
    memberState.setWanSyncState(wanSyncState);
    MemberStateImpl deserialized = new MemberStateImpl();
    deserialized.fromJson(memberState.toJson());
    assertEquals("memberStateAddress:Port", deserialized.getAddress());
    assertNotNull(deserialized.getLocalMapStats("mapStats").toString());
    assertNotNull(deserialized.getLocalMultiMapStats("multiMapStats").toString());
    assertNotNull(deserialized.getLocalQueueStats("queueStats").toString());
    assertNotNull(deserialized.getLocalTopicStats("topicStats").toString());
    assertNotNull(deserialized.getLocalExecutorStats("executorStats").toString());
    assertNotNull(deserialized.getLocalReplicatedMapStats("replicatedMapStats").toString());
    assertEquals(1, deserialized.getLocalReplicatedMapStats("replicatedMapStats").getPutOperationCount());
    assertNotNull(deserialized.getLocalCacheStats("cacheStats").toString());
    assertEquals(5, deserialized.getLocalCacheStats("cacheStats").getCacheHits());
    assertNotNull(deserialized.getRuntimeProps());
    assertEquals(Long.valueOf(598123L), deserialized.getRuntimeProps().get("prop1"));
    assertNotNull(deserialized.getLocalMemoryStats());
    assertNotNull(deserialized.getOperationStats());
    assertNotNull(deserialized.getMXBeans());
    client = deserialized.getClients().iterator().next();
    assertEquals("abc123456", client.uuid);
    assertEquals("localhost", client.address);
    assertEquals("undefined", client.clientType);
    NodeState deserializedState = deserialized.getNodeState();
    assertEquals(clusterState, deserializedState.getClusterState());
    assertEquals(nodeState, deserializedState.getNodeState());
    assertEquals(clusterVersion, deserializedState.getClusterVersion());
    assertEquals(memberVersion, deserializedState.getMemberVersion());
    final HotRestartState deserializedHotRestartState = deserialized.getHotRestartState();
    assertEquals(backupTaskStatus, deserializedHotRestartState.getBackupTaskStatus());
    final WanSyncState deserializedWanSyncState = deserialized.getWanSyncState();
    assertEquals(WanSyncStatus.IN_PROGRESS, deserializedWanSyncState.getStatus());
    assertEquals(86, deserializedWanSyncState.getSyncedPartitionCount());
    assertEquals("atob", deserializedWanSyncState.getActiveWanConfigName());
    assertEquals("B", deserializedWanSyncState.getActivePublisherName());
    ClusterHotRestartStatusDTO clusterHotRestartStatus = deserialized.getClusterHotRestartStatus();
    assertEquals(FULL_RECOVERY_ONLY, clusterHotRestartStatus.getDataRecoveryPolicy());
    assertEquals(ClusterHotRestartStatusDTO.ClusterHotRestartStatus.UNKNOWN, clusterHotRestartStatus.getHotRestartStatus());
    assertEquals(-1, clusterHotRestartStatus.getRemainingValidationTimeMillis());
    assertEquals(-1, clusterHotRestartStatus.getRemainingDataLoadTimeMillis());
    assertTrue(clusterHotRestartStatus.getMemberHotRestartStatusMap().isEmpty());
}
Also used : NodeState(com.hazelcast.monitor.NodeState) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) WanSyncState(com.hazelcast.monitor.WanSyncState) MemberVersion(com.hazelcast.version.MemberVersion) Version(com.hazelcast.version.Version) MemberVersion(com.hazelcast.version.MemberVersion) ClusterHotRestartStatusDTO(com.hazelcast.internal.management.dto.ClusterHotRestartStatusDTO) TimedMemberState(com.hazelcast.monitor.TimedMemberState) ClusterState(com.hazelcast.cluster.ClusterState) TimedMemberStateFactory(com.hazelcast.internal.management.TimedMemberStateFactory) ClientEndPointDTO(com.hazelcast.internal.management.dto.ClientEndPointDTO) CacheStatisticsImpl(com.hazelcast.cache.impl.CacheStatisticsImpl) HazelcastInstance(com.hazelcast.core.HazelcastInstance) BackupTaskStatus(com.hazelcast.hotrestart.BackupTaskStatus) HotRestartState(com.hazelcast.monitor.HotRestartState) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

MemberVersion (com.hazelcast.version.MemberVersion)12 ParallelTest (com.hazelcast.test.annotation.ParallelTest)8 QuickTest (com.hazelcast.test.annotation.QuickTest)8 Test (org.junit.Test)8 Address (com.hazelcast.nio.Address)6 Version (com.hazelcast.version.Version)5 MemberImpl (com.hazelcast.instance.MemberImpl)3 JoinRequest (com.hazelcast.internal.cluster.impl.JoinRequest)3 ClusterState (com.hazelcast.cluster.ClusterState)2 CacheStatisticsImpl (com.hazelcast.cache.impl.CacheStatisticsImpl)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 BackupTaskStatus (com.hazelcast.hotrestart.BackupTaskStatus)1 MemberInfo (com.hazelcast.internal.cluster.MemberInfo)1 AuthenticationFailureOperation (com.hazelcast.internal.cluster.impl.operations.AuthenticationFailureOperation)1 AuthorizationOperation (com.hazelcast.internal.cluster.impl.operations.AuthorizationOperation)1 BeforeJoinCheckFailureOperation (com.hazelcast.internal.cluster.impl.operations.BeforeJoinCheckFailureOperation)1 ChangeClusterStateOperation (com.hazelcast.internal.cluster.impl.operations.ChangeClusterStateOperation)1 ConfigMismatchOperation (com.hazelcast.internal.cluster.impl.operations.ConfigMismatchOperation)1 FinalizeJoinOperation (com.hazelcast.internal.cluster.impl.operations.FinalizeJoinOperation)1 GroupMismatchOperation (com.hazelcast.internal.cluster.impl.operations.GroupMismatchOperation)1