use of com.hazelcast.internal.management.dto.WanReplicationConfigDTO 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.dto.WanReplicationConfigDTO in project hazelcast by hazelcast.
the class RestTest method addWanConfig.
@Test
public void addWanConfig() throws Exception {
WanReplicationConfig wanConfig = new WanReplicationConfig();
wanConfig.setName("test");
WanReplicationConfigDTO dto = new WanReplicationConfigDTO(wanConfig);
String result = communicator.addWanConfig(dto.toJson().toString());
assertEquals("{\"status\":\"fail\",\"message\":\"java.lang.UnsupportedOperationException: Adding new WAN config is not supported.\"}", result);
}
Aggregations