Search in sources :

Example 6 with MemberVersion

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

the class ClusterJoinManager method setAsMaster.

public boolean setAsMaster() {
    clusterServiceLock.lock();
    try {
        if (node.joined()) {
            logger.warning("Cannot set as master because node is already joined!");
            return false;
        }
        logger.finest("This node is being set as the master");
        Address thisAddress = node.getThisAddress();
        MemberVersion version = node.getVersion();
        node.setMasterAddress(thisAddress);
        if (clusterService.getClusterVersion().isUnknown()) {
            clusterService.getClusterStateManager().setClusterVersion(version.asVersion());
        }
        clusterService.getClusterClock().setClusterStartTime(Clock.currentTimeMillis());
        clusterService.setClusterId(UuidUtil.createClusterUuid());
        node.setJoined();
        return true;
    } finally {
        clusterServiceLock.unlock();
    }
}
Also used : Address(com.hazelcast.nio.Address) MemberVersion(com.hazelcast.version.MemberVersion)

Example 7 with MemberVersion

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

the class MemberSelectingIteratorTest method before.

@Before
public void before() throws Exception {
    MemberVersion version = new MemberVersion(BuildInfoProvider.BUILD_INFO.getVersion());
    thisMember = new MemberImpl(new Address("localhost", 5701), version, true, true);
    matchingMember = new MemberImpl(new Address("localhost", 5702), version, false, true);
    matchingMember2 = new MemberImpl(new Address("localhost", 5703), version, false, true);
    nonMatchingMember = new MemberImpl(new Address("localhost", 5704), version, false, false);
}
Also used : Address(com.hazelcast.nio.Address) MemberImpl(com.hazelcast.instance.MemberImpl) MemberVersion(com.hazelcast.version.MemberVersion) Before(org.junit.Before)

Example 8 with MemberVersion

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

the class DefaultNodeExtensionTest method test_joinRequestFails_whenOtherMinorVersion.

@Test
public void test_joinRequestFails_whenOtherMinorVersion() throws UnknownHostException {
    MemberVersion otherPatchVersion = MemberVersion.of(node.getVersion().getMajor(), node.getVersion().getMinor() + 1, node.getVersion().getPatch());
    JoinRequest joinRequest = new JoinRequest(Packet.VERSION, BUILD_INFO.getBuildNumber(), otherPatchVersion, new Address("127.0.0.1", 9999), UuidUtil.newUnsecureUuidString(), false, null, null, null, null);
    expected.expect(VersionMismatchException.class);
    nodeExtension.validateJoinRequest(joinRequest);
}
Also used : Address(com.hazelcast.nio.Address) JoinRequest(com.hazelcast.internal.cluster.impl.JoinRequest) MemberVersion(com.hazelcast.version.MemberVersion) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 9 with MemberVersion

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

the class DefaultNodeExtensionTest method test_joinRequestAllowed_whenOtherPatchVersion.

@Test
public void test_joinRequestAllowed_whenOtherPatchVersion() throws UnknownHostException {
    MemberVersion otherPatchVersion = MemberVersion.of(node.getVersion().getMajor(), node.getVersion().getMinor(), node.getVersion().getPatch() + 1);
    JoinRequest joinRequest = new JoinRequest(Packet.VERSION, BUILD_INFO.getBuildNumber(), otherPatchVersion, new Address("127.0.0.1", 9999), UuidUtil.newUnsecureUuidString(), false, null, null, null, null);
    nodeExtension.validateJoinRequest(joinRequest);
}
Also used : Address(com.hazelcast.nio.Address) JoinRequest(com.hazelcast.internal.cluster.impl.JoinRequest) MemberVersion(com.hazelcast.version.MemberVersion) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 10 with MemberVersion

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

the class DefaultNodeExtensionTest method test_joinRequestFails_whenOtherMajorVersion.

@Test
public void test_joinRequestFails_whenOtherMajorVersion() throws UnknownHostException {
    MemberVersion otherPatchVersion = MemberVersion.of(node.getVersion().getMajor() + 1, node.getVersion().getMinor(), node.getVersion().getPatch());
    JoinRequest joinRequest = new JoinRequest(Packet.VERSION, BUILD_INFO.getBuildNumber(), otherPatchVersion, new Address("127.0.0.1", 9999), UuidUtil.newUnsecureUuidString(), false, null, null, null, null);
    expected.expect(VersionMismatchException.class);
    nodeExtension.validateJoinRequest(joinRequest);
}
Also used : Address(com.hazelcast.nio.Address) JoinRequest(com.hazelcast.internal.cluster.impl.JoinRequest) MemberVersion(com.hazelcast.version.MemberVersion) 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