use of org.springframework.web.bind.annotation.RequestMapping in project jstorm by alibaba.
the class TopologyController method show.
@RequestMapping(value = "/topology", method = RequestMethod.GET)
public String show(@RequestParam(value = "cluster", required = true) String cluster, @RequestParam(value = "id") String id, @RequestParam(value = "win", required = false) String win, ModelMap model) {
cluster = StringEscapeUtils.escapeHtml(cluster);
id = StringEscapeUtils.escapeHtml(id);
long start = System.currentTimeMillis();
LOG.info("request topology info for cluster name: " + cluster + " id:" + id);
int window = UIUtils.parseWindow(win);
UIUtils.addWindowAttribute(model, window);
NimbusClient client = null;
try {
client = NimbusClientManager.getNimbusClient(cluster);
TopologyInfo topologyInfo = client.getClient().getTopologyInfo(id);
// System.out.println("topologyinfo worker metric:" + topologyInfo.get_metrics().get_workerMetric());
model.addAttribute("topology", JStormUtils.thriftToMap(topologyInfo.get_topology()));
// model.addAttribute("tasks", getTaskEntities(topologyInfo)); //remove tasks stat
model.addAttribute("supervisorPort", UIUtils.getSupervisorPort(cluster));
MetricInfo topologyMetrics = topologyInfo.get_metrics().get_topologyMetric();
// List<MetricInfo> topologyMetrics = client.getClient().getMetrics(id, MetaType.TOPOLOGY.getT());
// System.out.println("topologyMetrics:" + topologyMetrics);
UISummaryMetric topologyData = UIMetricUtils.getSummaryMetrics(topologyMetrics, window);
model.addAttribute("topologyData", topologyData);
model.addAttribute("topologyHead", UIMetricUtils.sortHead(topologyData, UISummaryMetric.HEAD));
MetricInfo componentMetrics = topologyInfo.get_metrics().get_componentMetric();
// List<MetricInfo> componentMetrics = client.getClient().getMetrics(id, MetaType.COMPONENT.getT());
// System.out.println("componentMetrics:" + componentMetrics);
List<UIUserDefinedMetric> userDefinedMetrics = Lists.newArrayList();
List<UIComponentMetric> componentData = UIMetricUtils.getComponentMetrics(componentMetrics, window, topologyInfo.get_components(), userDefinedMetrics);
model.addAttribute("componentData", componentData);
model.addAttribute("componentHead", UIMetricUtils.sortHead(componentData, UIComponentMetric.HEAD));
model.addAttribute("userDefinedMetrics", userDefinedMetrics);
// System.out.println("componentHead:" + BasicMetric.sortHead(componentData));
MetricInfo workerMetrics = topologyInfo.get_metrics().get_workerMetric();
// List<MetricInfo> workerMetrics = client.getClient().getMetrics(id, MetaType.WORKER.getT());
// System.out.println("workerMetrics:" + workerMetrics);
List<UIWorkerMetric> workerData = UIMetricUtils.getWorkerMetrics(workerMetrics, id, window);
model.addAttribute("workerData", workerData);
model.addAttribute("workerHead", UIMetricUtils.sortHead(workerData, UIWorkerMetric.HEAD));
List<TaskEntity> taskData = UIUtils.getTaskEntities(topologyInfo);
model.addAttribute("taskData", taskData);
} catch (NotAliveException nae) {
model.addAttribute("flush", String.format("The topology: %s is dead.", id));
} catch (Exception e) {
NimbusClientManager.removeClient(cluster);
LOG.error(e.getMessage(), e);
UIUtils.addErrorAttribute(model, e);
}
model.addAttribute("page", "topology");
model.addAttribute("clusterName", cluster);
UIUtils.addTitleAttribute(model, "Topology Summary");
LOG.info("topology page show cost:{}ms", System.currentTimeMillis() - start);
return "topology";
}
use of org.springframework.web.bind.annotation.RequestMapping in project jstorm by alibaba.
the class ZookeeperController method show.
@RequestMapping(value = "/zookeeper", method = RequestMethod.GET)
public String show(@RequestParam(value = "name", required = true) String name, ModelMap model) {
name = StringEscapeUtils.escapeHtml(name);
long start = System.currentTimeMillis();
try {
ClusterConfig config = UIUtils.clusterConfig.get(name);
StringBuilder builder = new StringBuilder("");
for (String ip : config.getZkServers()) {
builder.append(ip).append(",");
}
builder.deleteCharAt(builder.length() - 1);
builder.append(":");
builder.append(config.getZkPort());
model.addAttribute("zkRoot", config.getZkRoot());
model.addAttribute("zkServers", builder.toString());
model.addAttribute("clusterName", name);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
UIUtils.addErrorAttribute(model, e);
}
LOG.info("zookeeper page show cost:{}ms", System.currentTimeMillis() - start);
return "zookeeper";
}
use of org.springframework.web.bind.annotation.RequestMapping in project spring-boot-admin by codecentric.
the class JournalController method getJournalEvents.
@RequestMapping(produces = "text/event-stream")
public SseEmitter getJournalEvents() {
final SseEmitter emitter = new SseEmitter();
emitter.onCompletion(new Runnable() {
@Override
public void run() {
emitters.remove(emitter);
}
});
emitters.add(emitter);
return emitter;
}
use of org.springframework.web.bind.annotation.RequestMapping in project spring-boot-admin by codecentric.
the class NotificationFilterController method addFilter.
@RequestMapping(method = { RequestMethod.POST }, produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
public ResponseEntity<?> addFilter(@RequestParam(name = "id", required = false) String id, @RequestParam(name = "name", required = false) String name, @RequestParam(name = "ttl", required = false, defaultValue = "-1") long ttl) {
if (hasText(id) || hasText(name)) {
NotificationFilter filter = createFilter(id, name, ttl);
String filterId = filteringNotifier.addFilter(filter);
return ResponseEntity.ok(Collections.singletonMap(filterId, filter));
} else {
return ResponseEntity.badRequest().body("Either 'id' or 'name' must be set");
}
}
use of org.springframework.web.bind.annotation.RequestMapping in project spring-boot-admin by codecentric.
the class RegistryController method get.
/**
* Get a single application out of the registry.
*
* @param id The application identifier.
* @return The registered application.
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public ResponseEntity<?> get(@PathVariable String id) {
LOGGER.debug("Deliver registered application with ID '{}'", id);
Application application = registry.getApplication(id);
if (application != null) {
return ResponseEntity.ok(application);
} else {
return ResponseEntity.notFound().build();
}
}
Aggregations