use of org.apache.storm.generated.SubmitOptions in project storm by apache.
the class Flux method runCli.
private static void runCli(CommandLine cmd) throws Exception {
if (!cmd.hasOption(OPTION_NO_SPLASH)) {
printSplash();
}
boolean dumpYaml = cmd.hasOption("dump-yaml");
TopologyDef topologyDef = null;
String filePath = (String) cmd.getArgList().get(0);
// TODO conditionally load properties from a file our resource
String filterProps = null;
if (cmd.hasOption(OPTION_FILTER)) {
filterProps = cmd.getOptionValue(OPTION_FILTER);
}
boolean envFilter = cmd.hasOption(OPTION_ENV_FILTER);
if (cmd.hasOption(OPTION_RESOURCE)) {
printf("Parsing classpath resource: %s", filePath);
topologyDef = FluxParser.parseResource(filePath, dumpYaml, true, filterProps, envFilter);
} else {
printf("Parsing file: %s", new File(filePath).getAbsolutePath());
topologyDef = FluxParser.parseFile(filePath, dumpYaml, true, filterProps, envFilter);
}
String topologyName = topologyDef.getName();
// merge contents of `config` into topology config
Config conf = FluxBuilder.buildConfig(topologyDef);
ExecutionContext context = new ExecutionContext(topologyDef, conf);
StormTopology topology = FluxBuilder.buildTopology(context);
if (!cmd.hasOption(OPTION_NO_DETAIL)) {
printTopologyInfo(context);
}
if (!cmd.hasOption(OPTION_DRY_RUN)) {
if (cmd.hasOption(OPTION_REMOTE)) {
LOG.info("Running remotely...");
// should the topology be active or inactive
SubmitOptions submitOptions = null;
if (cmd.hasOption(OPTION_INACTIVE)) {
LOG.info("Deploying topology in an INACTIVE state...");
submitOptions = new SubmitOptions(TopologyInitialStatus.INACTIVE);
} else {
LOG.info("Deploying topology in an ACTIVE state...");
submitOptions = new SubmitOptions(TopologyInitialStatus.ACTIVE);
}
StormSubmitter.submitTopology(topologyName, conf, topology, submitOptions, null);
} else {
LOG.info("Running in local mode...");
String sleepStr = cmd.getOptionValue(OPTION_SLEEP);
Long sleepTime = DEFAULT_LOCAL_SLEEP_TIME;
if (sleepStr != null) {
sleepTime = Long.parseLong(sleepStr);
}
LOG.debug("Sleep time: {}", sleepTime);
LocalCluster cluster = null;
// in-process or external zookeeper
if (cmd.hasOption(OPTION_ZOOKEEPER)) {
String zkStr = cmd.getOptionValue(OPTION_ZOOKEEPER);
LOG.info("Using ZooKeeper at '{}' instead of in-process one.", zkStr);
long zkPort = DEFAULT_ZK_PORT;
String zkHost = null;
if (zkStr.contains(":")) {
String[] hostPort = zkStr.split(":");
zkHost = hostPort[0];
zkPort = hostPort.length > 1 ? Long.parseLong(hostPort[1]) : DEFAULT_ZK_PORT;
} else {
zkHost = zkStr;
}
// the following constructor is only available in 0.9.3 and later
try {
cluster = new LocalCluster(zkHost, zkPort);
} catch (NoSuchMethodError e) {
LOG.error("The --zookeeper option can only be used with Apache Storm 0.9.3 and later.");
System.exit(1);
}
} else {
cluster = new LocalCluster();
}
try (LocalTopology topo = cluster.submitTopology(topologyName, conf, topology)) {
Utils.sleep(sleepTime);
} finally {
cluster.shutdown();
}
}
}
}
use of org.apache.storm.generated.SubmitOptions in project storm by apache.
the class StormSqlRunner method main.
public static void main(String[] args) throws Exception {
Options options = buildOptions();
CommandLineParser parser = new DefaultParser();
CommandLine commandLine = parser.parse(options, args);
if (!commandLine.hasOption(OPTION_SQL_FILE_LONG)) {
printUsageAndExit(options, OPTION_SQL_FILE_LONG + " is required");
}
String filePath = commandLine.getOptionValue(OPTION_SQL_FILE_LONG);
List<String> stmts = Files.readAllLines(Paths.get(filePath), StandardCharsets.UTF_8);
StormSql sql = StormSql.construct();
@SuppressWarnings("unchecked") Map<String, ?> conf = Utils.readStormConfig();
if (commandLine.hasOption(OPTION_SQL_EXPLAIN_LONG)) {
sql.explain(stmts);
} else if (commandLine.hasOption(OPTION_SQL_TOPOLOGY_NAME_LONG)) {
String topoName = commandLine.getOptionValue(OPTION_SQL_TOPOLOGY_NAME_LONG);
SubmitOptions submitOptions = new SubmitOptions(TopologyInitialStatus.ACTIVE);
sql.submit(topoName, stmts, conf, submitOptions, null, null);
} else {
printUsageAndExit(options, "Either " + OPTION_SQL_TOPOLOGY_NAME_LONG + " or " + OPTION_SQL_EXPLAIN_LONG + " must be presented");
}
}
use of org.apache.storm.generated.SubmitOptions in project storm by apache.
the class Nimbus method submitTopology.
//THRIFT SERVER METHODS...
@Override
public void submitTopology(String name, String uploadedJarLocation, String jsonConf, StormTopology topology) throws AlreadyAliveException, InvalidTopologyException, AuthorizationException, TException {
submitTopologyCalls.mark();
submitTopologyWithOpts(name, uploadedJarLocation, jsonConf, topology, new SubmitOptions(TopologyInitialStatus.ACTIVE));
}
Aggregations