/** * Kill topo on Ctrl-C */ public static void setupShutdownHook(final String topoName) { Map<String, Object> clusterConf = Utils.readStormConfig(); final Nimbus.Iface client = NimbusClient.getConfiguredClient(clusterConf).getClient(); Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { try { System.out.println("Killing..."); Helper.kill(client, topoName); System.out.println("Killed Topology"); } catch (Exception e) { e.printStackTrace(); } } }); }
public HeartbeatSendTask(int taskId, int tryTimes) { this.taskId = taskId; this.tryTimes = tryTimes; this.runtimesBook = new double[tryTimes]; try { client = new NimbusClient(initializedConfig(), NIMBUS_HOST, NIMBUS_PORT, null, null); } catch (TTransportException e) { e.printStackTrace(); } }
@Override public void shutdown() { if (client != null) { client.close(); client = null; } }
/** * 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()); } }
client = NimbusClient.getConfiguredClient(stormConf.createStormConf()); ClusterSummary clusterSummary = client.getClient().getClusterInfo(); List<TopologySummary> topologies = clusterSummary.get_topologies(); return new StormApplicationResults(topologies); client.close();
@Override public boolean isRemoteBlobExists(String blobKey) throws AuthorizationException { try { return client.getClient().isRemoteBlobExists(blobKey); } catch (AuthorizationException aze) { throw aze; } catch (TException e) { throw new RuntimeException(e); } }
public static void tryConnectAs(Map<String, Object> conf, ThriftServer server, Subject subject, String topoId) throws PrivilegedActionException { Subject.doAs(subject, (PrivilegedExceptionAction<Void>) () -> { try (NimbusClient client = new NimbusClient(conf, "localhost", server.getPort(), NIMBUS_TIMEOUT)) { client.getClient().activate(topoId); //Yes this should be a topo name, but it makes this simpler... } return null; }); }
String url = metricServer.getUrl(); NimbusClient client = NimbusClient.getConfiguredClient(sysConf); conf.registerMetricsConsumer(LoggingMetricsConsumer.class); conf.registerMetricsConsumer(HttpForwardingMetricsConsumer.class, url, 1); Map<String, String> workerMetrics = new HashMap<>(); if (!NimbusClient.isLocalOverride()) { try (ScopedTopologySet topologyNames = new ScopedTopologySet(client.getClient())) { StormSubmitter.submitTopology(name, conf, builder.createTopology()); topologyNames.add(name); metricServer.monitorFor(numMins, client.getClient(), topologyNames); exitStatus = 0; } catch (Exception e) {
Nimbus.Iface override = _localOverrideClient; if (override != null) { return new NimbusClient(override); NimbusClient client = null; try { client = new NimbusClient(conf, host, port, timeout, asUser); nimbusSummary = client.getClient().getLeader(); if (nimbusSummary != null) { String leaderNimbus = nimbusSummary.get_host() + ":" + nimbusSummary.get_port(); if (shouldLogLeader(leaderNimbus)) { LOG.info("Found leader nimbus : {}", leaderNimbus); return new NimbusClient(conf, nimbusSummary.get_host(), nimbusSummary.get_port(), timeout, asUser); } catch (TTransportException e) { throw new RuntimeException("Failed to create a nimbus client for the leader " + leaderNimbus, e); } finally { if (client != null) { client.close();
NimbusClient client = null; try { client = new NimbusClient(conf, host, port, timeout, asUser); nimbusSummary = client.getClient().getLeader(); if (nimbusSummary != null) { String leaderNimbus = nimbusSummary.get_host() + ":" + nimbusSummary.get_port(); return new NimbusClient(conf, nimbusSummary.get_host(), nimbusSummary.get_port(), timeout, asUser); } catch (TTransportException e) { throw new RuntimeException("Failed to create a nimbus client for the leader " + leaderNimbus, e); } finally { if (client != null) { client.close();
@Override public void prepare(Map<String, Object> conf) { this.client = NimbusClient.getConfiguredClient(conf); if (conf != null) { this.bufferSize = ObjectReader.getInt(conf.get(Config.STORM_BLOBSTORE_INPUTSTREAM_BUFFER_SIZE_BYTES), bufferSize); } }
/** * 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); }
conf.registerMetricsConsumer(HttpForwardingMetricsConsumer.class, url, 1); Map<String, String> workerMetrics = new HashMap<>(); if (!NimbusClient.isLocalOverride()) {
client = NimbusClient.getConfiguredClient(conf); ClusterSummary clusterInfo = client.getClient().getClusterInfo(); List<TopologySummary> list = clusterInfo.get_topologies(); for (TopologySummary ts : list) client.close();
@Override public void cancel() throws IOException { try { synchronized (client) { client.getClient().cancelBlobUpload(session); } } catch (TException e) { throw new RuntimeException(e); } }
try (NimbusClient client = new NimbusClient(conf, nimbusInfo.getHost(), nimbusInfo.getPort(), null)) { rbm = client.getClient().getBlobMeta(key); remoteBlobStore = new NimbusBlobStore(); remoteBlobStore.setClient(conf, client);
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); } }
/** * 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 void main(String[] args) throws Exception { if (!NimbusClient.isLocalOverride()) { throw new IllegalStateException("This example only works in local mode. " + "Run with storm local not storm jar"); } FeederSpout genderSpout = new FeederSpout(new Fields("id", "gender")); FeederSpout ageSpout = new FeederSpout(new Fields("id", "age")); TopologyBuilder builder = new TopologyBuilder(); builder.setSpout("genderSpout", genderSpout); builder.setSpout("ageSpout", ageSpout); // inner join of 'age' and 'gender' records on 'id' field JoinBolt joiner = new JoinBolt("genderSpout", "id") .join("ageSpout", "id", "genderSpout") .select("genderSpout:id,ageSpout:id,gender,age") .withTumblingWindow(new BaseWindowedBolt.Duration(10, TimeUnit.SECONDS)); builder.setBolt("joiner", joiner) .fieldsGrouping("genderSpout", new Fields("id")) .fieldsGrouping("ageSpout", new Fields("id")); builder.setBolt("printer", new PrinterBolt()).shuffleGrouping("joiner"); Config conf = new Config(); StormSubmitter.submitTopologyWithProgressBar("join-example", conf, builder.createTopology()); generateGenderData(genderSpout); generateAgeData(ageSpout); }
@Override public void processWorkerMetrics(Map<String, Object> conf, WorkerMetrics metrics) throws MetricException { try (NimbusClient client = NimbusClient.getConfiguredClient(conf)) { client.getClient().processWorkerMetrics(metrics); } catch (TException | NimbusLeaderNotFoundException e) { throw new MetricException("Failed to process metrics", e); } }