@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); } }
/** * /api/v1/cluster/configuration -> nimbus configuration. */ @GET @Path("/cluster/configuration") @Produces("application/json") public Response getClusterConfiguration(@QueryParam(callbackParameterName) String callback) throws TException { clusterConfigurationRequestMeter.mark(); try (NimbusClient nimbusClient = NimbusClient.getConfiguredClient(config)) { return UIHelpers.makeStandardResponse( nimbusClient.getClient().getNimbusConf(), callback, false, Response.Status.OK ); } }
/** * 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(); } } }); }
/** * /api/v1/topology/:id/profiling/start/:host-port/:timeout -> profiling start. */ @GET @Path("/topology/{id}/profiling/start/{host-port}/{timeout}") @AuthNimbusOp(value = "setWorkerProfiler", needsTopoId = true) @Produces("application/json") public Response getTopologyProfilingStart(@PathParam("id") String id, @PathParam("host-port") String hostPort, @PathParam("timeout") String timeout, @QueryParam(callbackParameterName) String callback) throws TException { try (NimbusClient nimbusClient = NimbusClient.getConfiguredClient(config)) { return UIHelpers.makeStandardResponse( UIHelpers.getTopologyProfilingStart(nimbusClient.getClient(), id, hostPort, timeout, config), callback ); } }
/** * /api/v1/topology/:id/activate -> topology activate. */ @POST @Path("/topology/{id}/activate") @AuthNimbusOp(value = "activate", needsTopoId = true) @Produces("application/json") public Response putTopologyActivate(@PathParam("id") String id, @QueryParam(callbackParameterName) String callback) throws TException { activateTopologyRequestMeter.mark(); try (NimbusClient nimbusClient = NimbusClient.getConfiguredClient(config)) { return UIHelpers.makeStandardResponse( UIHelpers.putTopologyActivate(nimbusClient.getClient(), id), callback ); } }
/** * /api/v1/topology/:id/profiling/stop/:host-port -> profiling stop. */ @GET @Path("/topology/{id}/profiling/stop/{host-port}") @AuthNimbusOp(value = "setWorkerProfiler", needsTopoId = true) @Produces("application/json") public Response getTopologyProfilingStop(@PathParam("id") String id, @PathParam("host-port") String hostPort, @QueryParam(callbackParameterName) String callback) throws TException { try (NimbusClient nimbusClient = NimbusClient.getConfiguredClient(config)) { return UIHelpers.makeStandardResponse( UIHelpers.getTopologyProfilingStop(nimbusClient.getClient(), id, hostPort, config), callback ); } }
/** * /api/v1/topology/:id/deactivate -> topology deactivate. */ @POST @Path("/topology/{id}/deactivate") @AuthNimbusOp(value = "deactivate", needsTopoId = true) @Produces("application/json") public Response putTopologyDeactivate(@PathParam("id") String id, @QueryParam(callbackParameterName) String callback) throws TException { deactivateTopologyRequestMeter.mark(); try (NimbusClient nimbusClient = NimbusClient.getConfiguredClient(config)) { return UIHelpers.makeStandardResponse( UIHelpers.putTopologyDeactivate(nimbusClient.getClient(), id), callback ); } }
/** * /api/v1/topology/:id/profiling/dumpprofile/:host-port -> dump profile. */ @GET @Path("/topology/{id}/profiling/dumpprofile/{host-port}") @AuthNimbusOp(value = "setWorkerProfiler", needsTopoId = true) @Produces("application/json") public Response getTopologyProfilingDumpProfile(@PathParam("id") String id, @PathParam("host-port") String hostPort, @QueryParam(callbackParameterName) String callback) throws TException { try (NimbusClient nimbusClient = NimbusClient.getConfiguredClient(config)) { return UIHelpers.makeStandardResponse( UIHelpers.getTopologyProfilingDump(nimbusClient.getClient(), id, hostPort, config), callback ); } }
/** * /api/v1/history/summary -> topo history. */ @GET @Path("/history/summary") @Produces("application/json") public Response getHistorySummary(@QueryParam(callbackParameterName) String callback) throws TException { try (NimbusClient nimbusClient = NimbusClient.getConfiguredClient(config)) { String user = servletRequest.getRemoteUser(); return UIHelpers.makeStandardResponse( UIHelpers.getTopologyHistoryInfo( nimbusClient.getClient().getTopologyHistory(user)), callback ); } }
/** * /api/v1/topology/:id/kill/:wait-time -> topology kill. */ @POST @Path("/topology/{id}/kill/{wait-time}") @AuthNimbusOp(value = "killTopology", needsTopoId = true) @Produces("application/json") public Response putTopologyKill( @PathParam("id") String id, @PathParam("wait-time") String waitTime, @QueryParam(callbackParameterName) String callback) throws TException { topologyOpResponseMeter.mark(); try (NimbusClient nimbusClient = NimbusClient.getConfiguredClient(config)) { return UIHelpers.makeStandardResponse( UIHelpers.putTopologyKill(nimbusClient.getClient(), id, waitTime), callback ); } }
/** * /api/v1/topology/:id/profiling/restartworker/:host-port -> restart worker. */ @GET @Path("/topology/{id}/profiling/restartworker/{host-port}") @AuthNimbusOp(value = "setWorkerProfiler", needsTopoId = true) @Produces("application/json") public Response getTopologyProfilingRestartWorker(@PathParam("id") String id, @PathParam("host-port") String hostPort, @QueryParam(callbackParameterName) String callback) throws TException { try (NimbusClient nimbusClient = NimbusClient.getConfiguredClient(config)) { return UIHelpers.makeStandardResponse( UIHelpers.getTopologyProfilingRestartWorker( nimbusClient.getClient(), id, hostPort, config ), callback ); } }
/** * /api/v1/topology/:id/logconfig -> logconfig. */ @POST @Path("/topology/{id}/logconfig") @AuthNimbusOp(value = "setLogConfig", needsTopoId = true) @Produces("application/json") @Consumes("application/json") public Response putTopologyLogconfig(@PathParam("id") String id, String body, @QueryParam(callbackParameterName) String callback) throws TException { topologyOpResponseMeter.mark(); try (NimbusClient nimbusClient = NimbusClient.getConfiguredClient(config)) { return UIHelpers.makeStandardResponse( UIHelpers.putTopologyLogLevel(nimbusClient.getClient(), ((Map<String, Map>) JSONValue.parse(body)).get("namedLoggerLevels"), id), callback ); } }
/** * /api/v1/topology/:id/lag -> lag. */ @GET @Path("/topology/{id}/lag") @AuthNimbusOp(value = "getTopology", needsTopoId = true) @Produces("application/json") public Response getTopologyLag(@PathParam("id") String id, @QueryParam(callbackParameterName) String callback) throws TException { topologyLagRequestMeter.mark(); try (NimbusClient nimbusClient = NimbusClient.getConfiguredClient(config)) { return UIHelpers.makeStandardResponse( UIHelpers.getTopologyLag(nimbusClient.getClient().getTopology(id), config), callback ); } }
/** * /api/v1/topology/:id/logconfig -> logconfig. */ @GET @Path("/topology/{id}/logconfig") @AuthNimbusOp(value = "getTopology", needsTopoId = true) @Produces("application/json") public Response getTopologyLogconfig(@PathParam("id") String id, @QueryParam(callbackParameterName) String callback) throws TException { logConfigRequestMeter.mark(); try (NimbusClient nimbusClient = NimbusClient.getConfiguredClient(config)) { return UIHelpers.makeStandardResponse( UIHelpers.getTopolgoyLogConfig(nimbusClient.getClient().getLogConfig(id)), callback ); } }
/** * /api/v1/cluster/summary -> cluster summary. */ @GET @Path("/cluster/summary") @AuthNimbusOp("getClusterInfo") @Produces("application/json") public Response getClusterSummary(@QueryParam(callbackParameterName) String callback) throws TException { clusterSummaryRequestMeter.mark(); try (NimbusClient nimbusClient = NimbusClient.getConfiguredClient(config)) { String user = servletRequest.getRemoteUser(); return UIHelpers.makeStandardResponse( UIHelpers.getClusterSummary( nimbusClient.getClient().getClusterInfo(), user, config), callback ); } }
/** * /api/v1/nimbus/summary -> nimbus summary. */ @GET @Path("/nimbus/summary") @AuthNimbusOp("getClusterInfo") @Produces("application/json") public Response getNimbusSummary(@QueryParam(callbackParameterName) String callback) throws TException { nimbusSummaryRequestMeter.mark(); try (NimbusClient nimbusClient = NimbusClient.getConfiguredClient(config)) { return UIHelpers.makeStandardResponse( UIHelpers.getNimbusSummary( nimbusClient.getClient().getClusterInfo(), config), callback ); } }
/** * /api/v1/owner-resources -> owner resources. */ @GET @Path("/owner-resources") @AuthNimbusOp("getOwnerResourceSummaries") @Produces("application/json") public Response getOwnerResources(@QueryParam(callbackParameterName) String callback) throws TException { getOwnerResourceSummariesMeter.mark(); try (NimbusClient nimbusClient = NimbusClient.getConfiguredClient(config)) { return UIHelpers.makeStandardResponse( UIHelpers.getOwnerResourceSummaries( nimbusClient.getClient().getOwnerResourceSummaries(null), config), callback ); } }
/** * /api/v1/owner-resources/:id -> owner resources. */ @GET @Path("/owner-resources/{id}") @AuthNimbusOp(value = "getOwnerResourceSummaries") @Produces("application/json") public Response getOwnerResource(@PathParam("id") String id, @QueryParam(callbackParameterName) String callback) throws TException { getOwnerResourceSummariesMeter.mark(); try (NimbusClient nimbusClient = NimbusClient.getConfiguredClient(config)) { return UIHelpers.makeStandardResponse( UIHelpers.getOwnerResourceSummary( nimbusClient.getClient().getOwnerResourceSummaries(id), nimbusClient.getClient(), id, config), callback ); } }
@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); } }
public static void main(String[] args) throws Exception { if (args.length <= 1) { LOG.error("Arguments should be of the form: <path_to_jar> [argument...]"); System.exit(-1); } Map<String,Object> conf = ConfigUtils.readStormConfig(); try (NimbusClient client = NimbusClient.getConfiguredClient(conf)) { NimbusSummary ns = client.getClient().getLeader(); String host = ns.get_host(); int port = ns.get_port(); String jarPath = StormSubmitter.submitJar(conf, args[0]); String[] newArgs = (String[]) ArrayUtils.addAll(Arrays.copyOfRange(args, 1, args.length), new String[]{host, String.valueOf(port), jarPath}); ServerUtils.execCommand(newArgs); } } }