Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2008-2017, Hazelcast, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hazelcast.internal.management.request;
import com.hazelcast.com.eclipsesource.json.JsonArray;
import com.hazelcast.com.eclipsesource.json.JsonObject;
import com.hazelcast.com.eclipsesource.json.JsonValue;
import com.hazelcast.core.Member;
import com.hazelcast.internal.management.ManagementCenterService;
import com.hazelcast.internal.management.operation.ScriptExecutorOperation;
import com.hazelcast.nio.Address;
import com.hazelcast.util.AddressUtil;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static com.hazelcast.util.JsonUtil.getArray;
import static com.hazelcast.util.JsonUtil.getBoolean;
import static com.hazelcast.util.JsonUtil.getString;
/**
* Request for executing scripts on the nodes from Management Center.
*/
public class ExecuteScriptRequest implements ConsoleRequest {
private String script;
private String engine;
private Set targets;
private boolean targetAllMembers;
private Map bindings;
public ExecuteScriptRequest() {
}
public ExecuteScriptRequest(String script, String engine, boolean targetAllMembers, Map bindings) {
this.script = script;
this.engine = engine;
this.targets = new HashSet(0);
this.targetAllMembers = targetAllMembers;
this.bindings = bindings;
}
public ExecuteScriptRequest(String script, String engine, Set targets, Map bindings) {
this.script = script;
this.targets = targets;
this.engine = engine;
this.targetAllMembers = false;
this.bindings = bindings;
}
@Override
public int getType() {
return ConsoleRequestConstants.REQUEST_TYPE_EXECUTE_SCRIPT;
}
@Override
public void writeResponse(ManagementCenterService mcs, JsonObject root) throws Exception {
JsonObject jsonResult = new JsonObject();
ArrayList results;
if (targetAllMembers) {
Set members = mcs.getHazelcastInstance().getCluster().getMembers();
ArrayList