Search in sources :

Example 1 with AddWanConfigResult

use of com.hazelcast.wan.impl.AddWanConfigResult in project hazelcast by hazelcast.

the class HttpPostCommandProcessor method handleAddWanConfig.

/**
 * Broadcasts a new {@link WanReplicationConfig} to all members. The config is defined
 * by an encoded JSON as a first parameter of the HTTP command.
 *
 * @param cmd the HTTP command
 */
private void handleAddWanConfig(HttpPostCommand cmd) throws Throwable {
    String[] params = decodeParamsAndAuthenticate(cmd, 3);
    String wanConfigJson = params[2];
    WanReplicationConfigDTO dto = new WanReplicationConfigDTO(new WanReplicationConfig());
    dto.fromJson(Json.parse(wanConfigJson).asObject());
    AddWanConfigResult result = getNode().getNodeEngine().getWanReplicationService().addWanReplicationConfig(dto.getConfig());
    JsonObject res = response(SUCCESS, "message", "WAN configuration added.");
    res.add("addedPublisherIds", Json.array(result.getAddedPublisherIds().toArray(new String[] {})));
    res.add("ignoredPublisherIds", Json.array(result.getIgnoredPublisherIds().toArray(new String[] {})));
    prepareResponse(cmd, res);
}
Also used : WanReplicationConfig(com.hazelcast.config.WanReplicationConfig) WanReplicationConfigDTO(com.hazelcast.internal.management.dto.WanReplicationConfigDTO) AddWanConfigResult(com.hazelcast.wan.impl.AddWanConfigResult) JsonObject(com.hazelcast.internal.json.JsonObject)

Aggregations

WanReplicationConfig (com.hazelcast.config.WanReplicationConfig)1 JsonObject (com.hazelcast.internal.json.JsonObject)1 WanReplicationConfigDTO (com.hazelcast.internal.management.dto.WanReplicationConfigDTO)1 AddWanConfigResult (com.hazelcast.wan.impl.AddWanConfigResult)1