use of com.hazelcast.version.Version 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);
}
use of com.hazelcast.version.Version in project hazelcast by hazelcast.
the class HttpPostCommandProcessor method handleChangeClusterVersion.
private void handleChangeClusterVersion(HttpPostCommand command) throws UnsupportedEncodingException {
byte[] data = command.getData();
String[] strList = bytesToString(data).split("&");
String groupName = URLDecoder.decode(strList[0], "UTF-8");
String groupPass = URLDecoder.decode(strList[1], "UTF-8");
String versionParam = URLDecoder.decode(strList[2], "UTF-8");
String res;
try {
Node node = textCommandService.getNode();
ClusterService clusterService = node.getClusterService();
GroupConfig groupConfig = node.getConfig().getGroupConfig();
if (!(groupConfig.getName().equals(groupName) && groupConfig.getPassword().equals(groupPass))) {
res = response(ResponseType.FORBIDDEN);
} else {
Version version;
try {
version = Version.of(versionParam);
clusterService.changeClusterVersion(version);
res = response(ResponseType.SUCCESS, "version", clusterService.getClusterVersion().toString());
} catch (Exception ex) {
res = response(ResponseType.FAIL, "version", clusterService.getClusterVersion().toString());
}
}
} catch (Throwable throwable) {
logger.warning("Error occurred while changing cluster version", throwable);
res = exceptionResponse(throwable);
}
command.setResponse(HttpCommand.CONTENT_TYPE_JSON, stringToBytes(res));
}
use of com.hazelcast.version.Version 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));
}
use of com.hazelcast.version.Version in project hazelcast by hazelcast.
the class DefaultNodeExtensionTest method test_clusterVersionListener_invokedWithOverriddenPropertyValue_whenClusterVersionIsNull.
@Test
public void test_clusterVersionListener_invokedWithOverriddenPropertyValue_whenClusterVersionIsNull() throws UnknownHostException, NoSuchFieldException, IllegalAccessException {
// override initial cluster version
System.setProperty(GroupProperty.INIT_CLUSTER_VERSION.getName(), "2.1.7");
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(Version.of("2.1.7"))) {
failed.set(true);
}
latch.countDown();
}
};
makeClusterVersionUnknownAndVerifyListener(latch, failed, listener);
System.clearProperty(GroupProperty.INIT_CLUSTER_VERSION.getName());
}
use of com.hazelcast.version.Version 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));
}
Aggregations