Search in sources :

Example 46 with RequestMapping

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";
}
Also used : NimbusClient(backtype.storm.utils.NimbusClient) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 47 with RequestMapping

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";
}
Also used : ClusterConfig(com.alibaba.jstorm.ui.model.ClusterConfig) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 48 with RequestMapping

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;
}
Also used : SseEmitter(org.springframework.web.servlet.mvc.method.annotation.SseEmitter) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 49 with RequestMapping

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");
    }
}
Also used : NotificationFilter(de.codecentric.boot.admin.notify.filter.NotificationFilter) ApplicationIdNotificationFilter(de.codecentric.boot.admin.notify.filter.ApplicationIdNotificationFilter) ApplicationNameNotificationFilter(de.codecentric.boot.admin.notify.filter.ApplicationNameNotificationFilter) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 50 with RequestMapping

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();
    }
}
Also used : Application(de.codecentric.boot.admin.model.Application) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1964 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)459 ModelAndView (org.springframework.web.servlet.ModelAndView)413 ApiOperation (io.swagger.annotations.ApiOperation)305 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)234 ArrayList (java.util.ArrayList)197 HashMap (java.util.HashMap)155 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)124 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)124 IOException (java.io.IOException)97 ResponseEntity (org.springframework.http.ResponseEntity)92 Date (java.util.Date)83 Aggregation (org.springframework.data.mongodb.core.aggregation.Aggregation)80 DBObject (com.mongodb.DBObject)71 BasicDBObject (com.mongodb.BasicDBObject)67 InputStream (java.io.InputStream)66 Aggregation.newAggregation (org.springframework.data.mongodb.core.aggregation.Aggregation.newAggregation)64 HttpServletResponse (javax.servlet.http.HttpServletResponse)59 User (org.hisp.dhis.user.User)59 List (java.util.List)53