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);
}
}
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);
}
}
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);
}
}
Aggregations