use of java.security.InvalidParameterException in project jstorm by alibaba.
the class restart method main.
public static void main(String[] args) {
if (args == null || args.length == 0) {
throw new InvalidParameterException("Should input topology name");
}
String topologyName = args[0];
NimbusClient client = null;
try {
Map conf = Utils.readStormConfig();
client = NimbusClient.getConfiguredClient(conf);
System.out.println("It will take 15 ~ 100 seconds to restart, please wait patiently\n");
if (args.length == 1) {
client.getClient().restart(topologyName, null);
} else {
Map loadConf = Utils.loadConf(args[1]);
String jsonConf = Utils.to_json(loadConf);
System.out.println("New configuration:\n" + jsonConf);
client.getClient().restart(topologyName, jsonConf);
}
System.out.println("Successfully submit command restart " + topologyName);
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
throw new RuntimeException(e);
} finally {
if (client != null) {
client.close();
}
}
}
use of java.security.InvalidParameterException in project jstorm by alibaba.
the class deactivate method main.
public static void main(String[] args) {
if (args == null || args.length == 0) {
throw new InvalidParameterException("Should input topology name");
}
String topologyName = args[0];
NimbusClient client = null;
try {
Map conf = Utils.readStormConfig();
client = NimbusClient.getConfiguredClient(conf);
client.getClient().deactivate(topologyName);
System.out.println("Successfully submit command deactivate " + topologyName);
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
throw new RuntimeException(e);
} finally {
if (client != null) {
client.close();
}
}
}
use of java.security.InvalidParameterException in project jstorm by alibaba.
the class NimbusUtils method normalizeTopology.
/**
* finalize component's task parallism
*
* @param stormConf storm conf
* @param topology storm topology
* @param fromConf means if the paralism is read from conf file instead of reading from topology code
* @return normalized topology
*/
public static StormTopology normalizeTopology(Map stormConf, StormTopology topology, boolean fromConf) {
StormTopology ret = topology.deepCopy();
Map<String, Object> rawComponents = ThriftTopologyUtils.getComponents(topology);
Map<String, Object> components = ThriftTopologyUtils.getComponents(ret);
if (!rawComponents.keySet().equals(components.keySet())) {
String errMsg = "Failed to normalize topology binary, maybe due to wrong dependency";
LOG.info(errMsg + " raw components:" + rawComponents.keySet() + ", normalized " + components.keySet());
throw new InvalidParameterException(errMsg);
}
for (Entry<String, Object> entry : components.entrySet()) {
Object component = entry.getValue();
String componentName = entry.getKey();
ComponentCommon common = null;
if (component instanceof Bolt) {
common = ((Bolt) component).get_common();
if (fromConf) {
Integer paraNum = ConfigExtension.getBoltParallelism(stormConf, componentName);
if (paraNum != null) {
LOG.info("Set " + componentName + " as " + paraNum);
common.set_parallelism_hint(paraNum);
}
}
}
if (component instanceof SpoutSpec) {
common = ((SpoutSpec) component).get_common();
if (fromConf) {
Integer paraNum = ConfigExtension.getSpoutParallelism(stormConf, componentName);
if (paraNum != null) {
LOG.info("Set " + componentName + " as " + paraNum);
common.set_parallelism_hint(paraNum);
}
}
}
if (component instanceof StateSpoutSpec) {
common = ((StateSpoutSpec) component).get_common();
if (fromConf) {
Integer paraNum = ConfigExtension.getSpoutParallelism(stormConf, componentName);
if (paraNum != null) {
LOG.info("Set " + componentName + " as " + paraNum);
common.set_parallelism_hint(paraNum);
}
}
}
Map componentMap = new HashMap();
String jsonConfString = common.get_json_conf();
if (jsonConfString != null) {
componentMap.putAll((Map) JStormUtils.from_json(jsonConfString));
}
Integer taskNum = componentParalism(stormConf, common);
componentMap.put(Config.TOPOLOGY_TASKS, taskNum);
// change the executor's task number
common.set_parallelism_hint(taskNum);
LOG.info("Set " + componentName + " parallelism " + taskNum);
common.set_json_conf(JStormUtils.to_json(componentMap));
}
return ret;
}
use of java.security.InvalidParameterException in project Phoenix by Yalantis.
the class PullToRefreshView method setRefreshStyle.
public void setRefreshStyle(int type) {
setRefreshing(false);
switch(type) {
case STYLE_SUN:
mBaseRefreshView = new SunRefreshView(getContext(), this);
break;
default:
throw new InvalidParameterException("Type does not exist");
}
mRefreshView.setImageDrawable(mBaseRefreshView);
}
use of java.security.InvalidParameterException in project CloudStack-archive by CloudStack-extras.
the class GetVMPasswordCmd method execute.
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() {
String passwd = _mgr.getVMPassword(this);
if (passwd == null || passwd.equals(""))
throw new InvalidParameterException("No password for VM with id '" + getId() + "' found.");
this.setResponseObject(new GetVMPasswordResponse(getCommandName(), passwd));
}
Aggregations