use of com.hazelcast.internal.management.operation.AddWanConfigOperation in project hazelcast by hazelcast.
the class HttpPostCommandProcessor method handleAddWanConfig.
private void handleAddWanConfig(HttpPostCommand command) throws UnsupportedEncodingException {
String res;
byte[] data = command.getData();
String[] strList = bytesToString(data).split("&");
String wanConfigJson = URLDecoder.decode(strList[0], "UTF-8");
try {
OperationService opService = textCommandService.getNode().getNodeEngine().getOperationService();
final Set<Member> members = textCommandService.getNode().getClusterService().getMembers();
WanReplicationConfig wanReplicationConfig = new WanReplicationConfig();
WanReplicationConfigDTO dto = new WanReplicationConfigDTO(wanReplicationConfig);
dto.fromJson(Json.parse(wanConfigJson).asObject());
List<InternalCompletableFuture> futureList = new ArrayList<InternalCompletableFuture>(members.size());
for (Member member : members) {
InternalCompletableFuture<Object> future = opService.invokeOnTarget(WanReplicationService.SERVICE_NAME, new AddWanConfigOperation(dto.getConfig()), member.getAddress());
futureList.add(future);
}
for (InternalCompletableFuture future : futureList) {
future.get();
}
res = response(ResponseType.SUCCESS, "message", "WAN configuration added.");
} catch (Exception ex) {
logger.warning("Error occurred while adding WAN config", ex);
res = exceptionResponse(ex);
}
command.setResponse(HttpCommand.CONTENT_TYPE_JSON, stringToBytes(res));
}
use of com.hazelcast.internal.management.operation.AddWanConfigOperation in project hazelcast by hazelcast.
the class ManagementDataSerializerHook method createFactory.
@Override
@SuppressWarnings("unchecked")
public DataSerializableFactory createFactory() {
ConstructorFunction<Integer, IdentifiedDataSerializable>[] constructors = new ConstructorFunction[LEN];
constructors[SCRIPT_EXECUTOR] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new ScriptExecutorOperation();
}
};
constructors[UPDATE_MANAGEMENT_CENTER_URL] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new UpdateManagementCenterUrlOperation();
}
};
constructors[UPDATE_MAP_CONFIG] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new UpdateMapConfigOperation();
}
};
constructors[MAP_CONFIG_DTO] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new MapConfigDTO();
}
};
constructors[ADD_WAN_CONFIG] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new AddWanConfigOperation();
}
};
return new ArrayDataSerializableFactory(constructors);
}
Aggregations