Search in sources :

Example 96 with InvalidParameterException

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();
        }
    }
}
Also used : InvalidParameterException(java.security.InvalidParameterException) NimbusClient(backtype.storm.utils.NimbusClient) Map(java.util.Map) InvalidParameterException(java.security.InvalidParameterException)

Example 97 with InvalidParameterException

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();
        }
    }
}
Also used : InvalidParameterException(java.security.InvalidParameterException) NimbusClient(backtype.storm.utils.NimbusClient) Map(java.util.Map) InvalidParameterException(java.security.InvalidParameterException)

Example 98 with InvalidParameterException

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;
}
Also used : ComponentCommon(backtype.storm.generated.ComponentCommon) HashMap(java.util.HashMap) StormTopology(backtype.storm.generated.StormTopology) Bolt(backtype.storm.generated.Bolt) InvalidParameterException(java.security.InvalidParameterException) StateSpoutSpec(backtype.storm.generated.StateSpoutSpec) SpoutSpec(backtype.storm.generated.SpoutSpec) StateSpoutSpec(backtype.storm.generated.StateSpoutSpec) HashMap(java.util.HashMap) Map(java.util.Map)

Example 99 with InvalidParameterException

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);
}
Also used : InvalidParameterException(java.security.InvalidParameterException) SunRefreshView(com.yalantis.phoenix.refresh_view.SunRefreshView)

Example 100 with InvalidParameterException

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));
}
Also used : InvalidParameterException(java.security.InvalidParameterException) GetVMPasswordResponse(com.cloud.api.response.GetVMPasswordResponse)

Aggregations

InvalidParameterException (java.security.InvalidParameterException)135 SecureRandom (java.security.SecureRandom)15 ActionEvent (com.cloud.event.ActionEvent)11 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)11 IOException (java.io.IOException)10 ArrayList (java.util.ArrayList)10 Map (java.util.Map)10 LoadBalancerVO (com.cloud.network.dao.LoadBalancerVO)9 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)8 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)8 Paint (android.graphics.Paint)7 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)7 DB (com.cloud.utils.db.DB)7 File (java.io.File)7 Properties (java.util.Properties)7 NimbusClient (backtype.storm.utils.NimbusClient)6 FirewallRule (com.cloud.network.rules.FirewallRule)6 InvalidKeyException (java.security.InvalidKeyException)6 Time (android.text.format.Time)4 FileNotFoundException (java.io.FileNotFoundException)4