use of com.hazelcast.version.Version in project hazelcast by hazelcast.
the class DefaultNodeExtensionTest method test_clusterVersionListener_invokedWithNodeCodebaseVersion_whenClusterVersionIsNull.
@Test
public void test_clusterVersionListener_invokedWithNodeCodebaseVersion_whenClusterVersionIsNull() throws UnknownHostException, NoSuchFieldException, IllegalAccessException {
final CountDownLatch latch = new CountDownLatch(1);
final AtomicBoolean failed = new AtomicBoolean(false);
ClusterVersionListener listener = new ClusterVersionListener() {
@Override
public void onClusterVersionChange(Version newVersion) {
if (!newVersion.equals(node.getVersion().asVersion())) {
failed.set(true);
}
latch.countDown();
}
};
makeClusterVersionUnknownAndVerifyListener(latch, failed, listener);
}
use of com.hazelcast.version.Version in project hazelcast by hazelcast.
the class ClusterStateManager method commitClusterState.
public void commitClusterState(ClusterStateChange stateChange, Address initiator, String txnId, boolean isTransient) {
Preconditions.checkNotNull(stateChange);
stateChange.validate();
clusterServiceLock.lock();
try {
final LockGuard stateLock = getStateLock();
if (!stateLock.allowsUnlock(txnId)) {
throw new TransactionException("Cluster state change [" + state + " -> " + stateChange + "] failed for " + initiator + ", current state: " + stateToString());
}
if (stateChange.isOfType(ClusterState.class)) {
ClusterState newState = (ClusterState) stateChange.getNewState();
doSetClusterState(newState, isTransient);
// if state is changed to ACTIVE, then remove all members which left while not active.
if (newState == ClusterState.ACTIVE) {
node.getClusterService().removeMembersDeadWhileClusterIsNotActive();
}
} else if (stateChange.isOfType(Version.class)) {
// version is validated on cluster-state-lock, thus we can commit without checking compatibility
doSetClusterVersion((Version) stateChange.getNewState());
} else {
throw new IllegalArgumentException("Illegal ClusterStateChange of type " + stateChange.getType() + ".");
}
} finally {
clusterServiceLock.unlock();
}
}
use of com.hazelcast.version.Version in project hazelcast by hazelcast.
the class ArrayDataSerializableFactoryTest method testCreateWithVersion.
@Test
public void testCreateWithVersion() throws Exception {
ConstructorFunction<Integer, IdentifiedDataSerializable>[] constructorFunctions = new ConstructorFunction[1];
VersionAwareConstructorFunction function = mock(VersionAwareConstructorFunction.class);
constructorFunctions[0] = function;
ArrayDataSerializableFactory factory = new ArrayDataSerializableFactory(constructorFunctions);
Version version = MemberVersion.of(3, 6, 0).asVersion();
factory.create(0, version);
verify(function, times(0)).createNew(0);
verify(function, times(1)).createNew(0, version);
}
use of com.hazelcast.version.Version in project hazelcast by hazelcast.
the class VersionedObjectDataInputAndOutputTest method testVersionOnOutput.
@Test
public void testVersionOnOutput() {
ObjectDataOutputStream output = new ObjectDataOutputStream(new ByteArrayOutputStream(16), iss);
Version version = Versions.V3_8;
output.setVersion(version);
assertEquals(version, output.getVersion());
}
use of com.hazelcast.version.Version in project hazelcast by hazelcast.
the class NodeStateImplTest method toJson.
@Test
public void toJson() throws Exception {
ClusterState clusterState = ClusterState.ACTIVE;
com.hazelcast.instance.NodeState nodeState = com.hazelcast.instance.NodeState.PASSIVE;
Version clusterVersion = Version.of("3.8");
MemberVersion memberVersion = MemberVersion.of("3.9.0");
NodeState state = new NodeStateImpl(clusterState, nodeState, clusterVersion, memberVersion);
NodeState deserialized = new NodeStateImpl();
deserialized.fromJson(state.toJson());
assertEquals(clusterState, deserialized.getClusterState());
assertEquals(nodeState, deserialized.getNodeState());
assertEquals(clusterVersion, deserialized.getClusterVersion());
assertEquals(memberVersion, deserialized.getMemberVersion());
}
Aggregations