/** * Get a nimbus client as configured by conf. * @param conf the configuration to use. * @return the client, don't forget to close it when done. */ public static NimbusClient getConfiguredClient(Map<String, Object> conf) { return getConfiguredClientAs(conf, null); }
/** * Get a nimbus client as configured by conf. * @param conf the configuration to use. * @param timeout the timeout to use when connecting. * @return the client, don't forget to close it when done. */ public static NimbusClient getConfiguredClient(Map<String, Object> conf, Integer timeout) { return getConfiguredClientAs(conf, null, timeout); }
/** * Get a nimbus client as configured by conf. * @param conf the configuration to use. * @param asUser the user to impersonate (this does not always work). * @return the client, don't forget to close it when done. */ public static NimbusClient getConfiguredClientAs(Map<String, Object> conf, String asUser) { return getConfiguredClientAs(conf, asUser, null); }
public static String submitJarAs(Map<String, Object> conf, String localJar, ProgressListener listener, String asUser) { if (localJar == null) { throw new RuntimeException( "Must submit topologies using the 'storm' client script so that StormSubmitter knows which jar to upload."); } try (NimbusClient client = NimbusClient.getConfiguredClientAs(conf, asUser)) { return submitJarAs(conf, localJar, listener, client); } }
/** * Execute cb with a configured nimbus client that will be closed once cb returns. * @param cb the callback to send to nimbus. * @param conf the conf to use instead of reading the global storm conf. * @throws Exception on any kind of error. */ public static void withConfiguredClient(WithNimbus cb, Map<String, Object> conf) throws Exception { try (NimbusClient client = getConfiguredClientAs(conf, null)) { cb.run(client.getClient()); } }
public static TopologyInfo getTopologyInfo(String name, String asUser, Map<String, Object> topoConf) { try (NimbusClient client = NimbusClient.getConfiguredClientAs(topoConf, asUser)) { String topologyId = getTopologyId(name, client.getClient()); if (null != topologyId) { return client.getClient().getTopologyInfo(topologyId); } return null; } catch (Exception e) { throw new RuntimeException(e); } }
try (NimbusClient client = NimbusClient.getConfiguredClientAs(conf, asUser)) { if (topologyNameExists(name, client)) { throw new RuntimeException("Topology with name `" + name + "` already exists on cluster");
public static NimbusClient getConfiguredClient(Map conf, Integer timeout) { return getConfiguredClientAs(conf, null, timeout); }
public static NimbusClient getConfiguredClient(Map conf) { return getConfiguredClientAs(conf, null); }
public static NimbusClient getConfiguredClientAs(Map conf, String asUser) { return getConfiguredClientAs(conf, asUser, null); }
public static String submitJarAs(Map conf, String localJar, ProgressListener listener, String asUser) { if (localJar == null) { throw new RuntimeException("Must submit topologies using the 'storm' client script so that StormSubmitter knows which jar to upload."); } try (NimbusClient client = NimbusClient.getConfiguredClientAs(conf, asUser)) { return submitJarAs(conf, localJar, listener, client); } }
public static void withConfiguredClient(WithNimbus cb, Map conf) throws Exception { ReqContext context = ReqContext.context(); Principal principal = context.principal(); String user = principal == null ? null : principal.getName(); try (NimbusClient client = getConfiguredClientAs(conf, user);) { cb.run(client.getClient()); } }
public static TopologyInfo getTopologyInfo(String name, String asUser, Map stormConf) { try (NimbusClient client = NimbusClient.getConfiguredClientAs(stormConf, asUser)) { String topologyId = getTopologyId(name, client.getClient()); if (null != topologyId) { return client.getClient().getTopologyInfo(topologyId); } return null; } catch(Exception e) { throw new RuntimeException(e); } }
} else { String serConf = JSONValue.toJSONString(stormConf); try (NimbusClient client = NimbusClient.getConfiguredClientAs(conf, asUser)) { if (topologyNameExists(name, client)) { throw new RuntimeException("Topology with name `" + name + "` already exists on cluster");