Search in sources :

Example 1 with AddWanConfigOperation

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));
}
Also used : WanReplicationConfig(com.hazelcast.config.WanReplicationConfig) WanReplicationConfigDTO(com.hazelcast.internal.management.dto.WanReplicationConfigDTO) InternalCompletableFuture(com.hazelcast.spi.InternalCompletableFuture) ArrayList(java.util.ArrayList) StringUtil.bytesToString(com.hazelcast.util.StringUtil.bytesToString) UnsupportedEncodingException(java.io.UnsupportedEncodingException) AddWanConfigOperation(com.hazelcast.internal.management.operation.AddWanConfigOperation) OperationService(com.hazelcast.spi.OperationService) Member(com.hazelcast.core.Member)

Example 2 with AddWanConfigOperation

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);
}
Also used : IdentifiedDataSerializable(com.hazelcast.nio.serialization.IdentifiedDataSerializable) ScriptExecutorOperation(com.hazelcast.internal.management.operation.ScriptExecutorOperation) UpdateManagementCenterUrlOperation(com.hazelcast.internal.management.operation.UpdateManagementCenterUrlOperation) MapConfigDTO(com.hazelcast.internal.management.dto.MapConfigDTO) UpdateMapConfigOperation(com.hazelcast.internal.management.operation.UpdateMapConfigOperation) ArrayDataSerializableFactory(com.hazelcast.internal.serialization.impl.ArrayDataSerializableFactory) ConstructorFunction(com.hazelcast.util.ConstructorFunction) AddWanConfigOperation(com.hazelcast.internal.management.operation.AddWanConfigOperation)

Aggregations

AddWanConfigOperation (com.hazelcast.internal.management.operation.AddWanConfigOperation)2 WanReplicationConfig (com.hazelcast.config.WanReplicationConfig)1 Member (com.hazelcast.core.Member)1 MapConfigDTO (com.hazelcast.internal.management.dto.MapConfigDTO)1 WanReplicationConfigDTO (com.hazelcast.internal.management.dto.WanReplicationConfigDTO)1 ScriptExecutorOperation (com.hazelcast.internal.management.operation.ScriptExecutorOperation)1 UpdateManagementCenterUrlOperation (com.hazelcast.internal.management.operation.UpdateManagementCenterUrlOperation)1 UpdateMapConfigOperation (com.hazelcast.internal.management.operation.UpdateMapConfigOperation)1 ArrayDataSerializableFactory (com.hazelcast.internal.serialization.impl.ArrayDataSerializableFactory)1 IdentifiedDataSerializable (com.hazelcast.nio.serialization.IdentifiedDataSerializable)1 InternalCompletableFuture (com.hazelcast.spi.InternalCompletableFuture)1 OperationService (com.hazelcast.spi.OperationService)1 ConstructorFunction (com.hazelcast.util.ConstructorFunction)1 StringUtil.bytesToString (com.hazelcast.util.StringUtil.bytesToString)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ArrayList (java.util.ArrayList)1