Search in sources :

Example 1 with SubmitterHookException

use of org.apache.storm.hooks.SubmitterHookException in project storm by apache.

the class StormSubmitter method invokeSubmitterHook.

/**
     *
     * @param name
     * @param asUser
     * @param stormConf
     * @param topology
     *
     * @thorws SubmitterHookException This is thrown when any Exception occurs during initialization or invocation of registered {@link ISubmitterHook}
     */
private static void invokeSubmitterHook(String name, String asUser, Map stormConf, StormTopology topology) {
    String submissionNotifierClassName = null;
    try {
        if (stormConf.containsKey(Config.STORM_TOPOLOGY_SUBMISSION_NOTIFIER_PLUGIN)) {
            submissionNotifierClassName = stormConf.get(Config.STORM_TOPOLOGY_SUBMISSION_NOTIFIER_PLUGIN).toString();
            LOG.info("Initializing the registered ISubmitterHook [{}]", submissionNotifierClassName);
            if (submissionNotifierClassName == null || submissionNotifierClassName.isEmpty()) {
                throw new IllegalArgumentException(Config.STORM_TOPOLOGY_SUBMISSION_NOTIFIER_PLUGIN + " property must be a non empty string.");
            }
            ISubmitterHook submitterHook = (ISubmitterHook) Class.forName(submissionNotifierClassName).newInstance();
            TopologyInfo topologyInfo = Utils.getTopologyInfo(name, asUser, stormConf);
            LOG.info("Invoking the registered ISubmitterHook [{}]", submissionNotifierClassName);
            submitterHook.notify(topologyInfo, stormConf, topology);
        }
    } catch (Exception e) {
        LOG.warn("Error occurred in invoking submitter hook:[{}] ", submissionNotifierClassName, e);
        throw new SubmitterHookException(e);
    }
}
Also used : SubmitterHookException(org.apache.storm.hooks.SubmitterHookException) TException(org.apache.thrift.TException) SubmitterHookException(org.apache.storm.hooks.SubmitterHookException)

Example 2 with SubmitterHookException

use of org.apache.storm.hooks.SubmitterHookException in project storm by apache.

the class TridentHiveTopology method main.

public static void main(String[] args) throws Exception {
    String metaStoreUri = args[0];
    String dbName = args[1];
    String tblName = args[2];
    Config conf = new Config();
    conf.setMaxSpoutPending(5);
    String topoName = "tridentHiveTopology";
    String keytab = null;
    String principal = null;
    if (args.length > 3) {
        topoName = args[3];
    }
    if (args.length == 6) {
        keytab = args[4];
        principal = args[5];
    } else if (args.length != 3 && args.length != 4) {
        LOG.info("Usage: TridentHiveTopology metastoreURI dbName tableName [topologyName] [keytab principal]");
        return;
    }
    try {
        StormSubmitter.submitTopology(args[3], conf, buildTopology(metaStoreUri, dbName, tblName, null, null));
    } catch (SubmitterHookException e) {
        LOG.warn("Topology is submitted but invoking ISubmitterHook failed", e);
    } catch (Exception e) {
        LOG.warn("Failed to submit topology ", e);
    }
}
Also used : Config(org.apache.storm.Config) SubmitterHookException(org.apache.storm.hooks.SubmitterHookException) SubmitterHookException(org.apache.storm.hooks.SubmitterHookException)

Example 3 with SubmitterHookException

use of org.apache.storm.hooks.SubmitterHookException in project storm by apache.

the class StormSubmitter method invokeSubmitterHook.

/**
 * Invoke submitter hook.
 * @throws SubmitterHookException This is thrown when any Exception occurs during initialization or invocation of registered {@link
 *     ISubmitterHook}
 */
private static void invokeSubmitterHook(String name, String asUser, Map<String, Object> topoConf, StormTopology topology) {
    String submissionNotifierClassName = null;
    try {
        if (topoConf.containsKey(Config.STORM_TOPOLOGY_SUBMISSION_NOTIFIER_PLUGIN)) {
            submissionNotifierClassName = topoConf.get(Config.STORM_TOPOLOGY_SUBMISSION_NOTIFIER_PLUGIN).toString();
            LOG.info("Initializing the registered ISubmitterHook [{}]", submissionNotifierClassName);
            if (submissionNotifierClassName == null || submissionNotifierClassName.isEmpty()) {
                throw new IllegalArgumentException(Config.STORM_TOPOLOGY_SUBMISSION_NOTIFIER_PLUGIN + " property must be a non empty string.");
            }
            ISubmitterHook submitterHook = (ISubmitterHook) Class.forName(submissionNotifierClassName).newInstance();
            TopologyInfo topologyInfo = Utils.getTopologyInfo(name, asUser, topoConf);
            LOG.info("Invoking the registered ISubmitterHook [{}]", submissionNotifierClassName);
            submitterHook.notify(topologyInfo, topoConf, topology);
        }
    } catch (Exception e) {
        LOG.warn("Error occurred in invoking submitter hook:[{}] ", submissionNotifierClassName, e);
        throw new SubmitterHookException(e);
    }
}
Also used : TopologyInfo(org.apache.storm.generated.TopologyInfo) SubmitterHookException(org.apache.storm.hooks.SubmitterHookException) AlreadyAliveException(org.apache.storm.generated.AlreadyAliveException) TException(org.apache.storm.thrift.TException) AuthorizationException(org.apache.storm.generated.AuthorizationException) NotAliveException(org.apache.storm.generated.NotAliveException) WrappedInvalidTopologyException(org.apache.storm.utils.WrappedInvalidTopologyException) InvalidTopologyException(org.apache.storm.generated.InvalidTopologyException) SubmitterHookException(org.apache.storm.hooks.SubmitterHookException)

Aggregations

SubmitterHookException (org.apache.storm.hooks.SubmitterHookException)3 Config (org.apache.storm.Config)1 AlreadyAliveException (org.apache.storm.generated.AlreadyAliveException)1 AuthorizationException (org.apache.storm.generated.AuthorizationException)1 InvalidTopologyException (org.apache.storm.generated.InvalidTopologyException)1 NotAliveException (org.apache.storm.generated.NotAliveException)1 TopologyInfo (org.apache.storm.generated.TopologyInfo)1 TException (org.apache.storm.thrift.TException)1 WrappedInvalidTopologyException (org.apache.storm.utils.WrappedInvalidTopologyException)1 TException (org.apache.thrift.TException)1