Search in sources :

Example 26 with NimbusClient

use of backtype.storm.utils.NimbusClient in project jstorm by alibaba.

the class BlobStoreUtils method downloadUpdatedBlob.

// Download updated blobs from potential nimbodes
public static boolean downloadUpdatedBlob(Map conf, BlobStore blobStore, String key, Set<NimbusInfo> nimbusInfos) throws TTransportException {
    NimbusClient client;
    ClientBlobStore remoteBlobStore;
    InputStreamWithMeta in;
    AtomicOutputStream out;
    boolean isSuccess = false;
    LOG.debug("Download blob NimbusInfos {}", nimbusInfos);
    for (NimbusInfo nimbusInfo : nimbusInfos) {
        if (isSuccess) {
            break;
        }
        try {
            client = new NimbusClient(conf, nimbusInfo.getHost(), nimbusInfo.getPort(), null);
            remoteBlobStore = new NimbusBlobStore();
            remoteBlobStore.setClient(conf, client);
            isSuccess = updateBlob(blobStore, key, remoteBlobStore.getBlob(key));
        } catch (IOException exception) {
            throw new RuntimeException(exception);
        } catch (KeyNotFoundException knf) {
            // Catching and logging KeyNotFoundException because, if
            // there is a subsequent update and delete, the non-leader
            // nimbodes might throw an exception.
            LOG.info("KeyNotFoundException {}", knf);
        } catch (Exception exp) {
            // Logging an exception while client is connecting
            LOG.error("Exception {}", exp);
        }
    }
    if (!isSuccess) {
        LOG.error("Could not update the blob with key" + key);
    }
    return isSuccess;
}
Also used : NimbusClient(backtype.storm.utils.NimbusClient) IOException(java.io.IOException) KeyNotFoundException(backtype.storm.generated.KeyNotFoundException) KeyNotFoundException(backtype.storm.generated.KeyNotFoundException) TTransportException(org.apache.thrift.transport.TTransportException) TException(org.apache.thrift.TException) IOException(java.io.IOException) KeyAlreadyExistsException(backtype.storm.generated.KeyAlreadyExistsException) NimbusInfo(backtype.storm.nimbus.NimbusInfo)

Example 27 with NimbusClient

use of backtype.storm.utils.NimbusClient in project jstorm by alibaba.

the class BlobStoreUtils method createStateInZookeeper.

public static void createStateInZookeeper(Map conf, String key, NimbusInfo nimbusInfo) throws TTransportException {
    ClientBlobStore cb = new NimbusBlobStore();
    cb.setClient(conf, new NimbusClient(conf, nimbusInfo.getHost(), nimbusInfo.getPort(), null));
    cb.createStateInZookeeper(key);
}
Also used : NimbusClient(backtype.storm.utils.NimbusClient)

Example 28 with NimbusClient

use of backtype.storm.utils.NimbusClient in project jstorm by alibaba.

the class BlobStoreUtils method downloadMissingBlob.

// Download missing blobs from potential nimbodes
public static boolean downloadMissingBlob(Map conf, BlobStore blobStore, String key, Set<NimbusInfo> nimbusInfos) throws TTransportException {
    NimbusClient client;
    ReadableBlobMeta rbm;
    ClientBlobStore remoteBlobStore;
    InputStreamWithMeta in;
    boolean isSuccess = false;
    LOG.debug("Download blob NimbusInfos {}", nimbusInfos);
    for (NimbusInfo nimbusInfo : nimbusInfos) {
        if (isSuccess) {
            break;
        }
        try {
            client = new NimbusClient(conf, nimbusInfo.getHost(), nimbusInfo.getPort(), null);
            rbm = client.getClient().getBlobMeta(key);
            remoteBlobStore = new NimbusBlobStore();
            remoteBlobStore.setClient(conf, client);
            in = remoteBlobStore.getBlob(key);
            blobStore.createBlob(key, in, rbm.get_settable());
            // if key already exists while creating the blob else update it
            Iterator<String> keyIterator = blobStore.listKeys();
            while (keyIterator.hasNext()) {
                if (keyIterator.next().equals(key)) {
                    LOG.debug("Success creating key, {}", key);
                    isSuccess = true;
                    break;
                }
            }
        } catch (IOException exception) {
            throw new RuntimeException(exception);
        } catch (KeyAlreadyExistsException kae) {
            LOG.info("KeyAlreadyExistsException Key: {} {}", key, kae);
        } catch (KeyNotFoundException knf) {
            // Catching and logging KeyNotFoundException because, if
            // there is a subsequent update and delete, the non-leader
            // nimbodes might throw an exception.
            LOG.info("KeyNotFoundException Key: {} {}", key, knf);
        } catch (Exception exp) {
            // Logging an exception while client is connecting
            LOG.error("Exception ", exp);
        }
    }
    if (!isSuccess) {
        LOG.error("Could not download blob with key" + key);
    }
    return isSuccess;
}
Also used : ReadableBlobMeta(backtype.storm.generated.ReadableBlobMeta) NimbusClient(backtype.storm.utils.NimbusClient) IOException(java.io.IOException) KeyAlreadyExistsException(backtype.storm.generated.KeyAlreadyExistsException) KeyNotFoundException(backtype.storm.generated.KeyNotFoundException) TTransportException(org.apache.thrift.transport.TTransportException) TException(org.apache.thrift.TException) IOException(java.io.IOException) KeyAlreadyExistsException(backtype.storm.generated.KeyAlreadyExistsException) NimbusInfo(backtype.storm.nimbus.NimbusInfo) KeyNotFoundException(backtype.storm.generated.KeyNotFoundException)

Example 29 with NimbusClient

use of backtype.storm.utils.NimbusClient in project jstorm by alibaba.

the class ComponentController method show.

@RequestMapping(value = "/component", method = RequestMethod.GET)
public String show(@RequestParam(value = "cluster", required = true) String clusterName, @RequestParam(value = "topology", required = true) String topology_id, @RequestParam(value = "component", required = true) String component, @RequestParam(value = "win", required = false) String win, ModelMap model) {
    clusterName = StringEscapeUtils.escapeHtml(clusterName);
    topology_id = StringEscapeUtils.escapeHtml(topology_id);
    long start = System.currentTimeMillis();
    int window = UIUtils.parseWindow(win);
    UIUtils.addWindowAttribute(model, window);
    NimbusClient client = null;
    try {
        client = NimbusClientManager.getNimbusClient(clusterName);
        //get Component Metric
        TopologyInfo topologyInfo = client.getClient().getTopologyInfo(topology_id);
        MetricInfo componentMetrics = topologyInfo.get_metrics().get_componentMetric();
        //            List<MetricInfo> componentMetrics = client.getClient().getMetrics(topology_id, MetaType.COMPONENT.getT());
        UIComponentMetric componentMetric = UIMetricUtils.getComponentMetric(componentMetrics, window, component, topologyInfo.get_components());
        model.addAttribute("comp", componentMetric);
        model.addAttribute("compHead", UIMetricUtils.sortHead(componentMetric, UIComponentMetric.HEAD));
        //get Task Stat
        model.addAttribute("tasks", UIUtils.getTaskEntities(topologyInfo, component));
        //get Task metrics
        //            MetricInfo taskMetrics = topologyInfo.get_metrics().get_taskMetric();
        MetricInfo taskMetrics = client.getClient().getTaskMetrics(topology_id, component);
        //            System.out.println("taskMetrics:" + taskMetrics);
        List<UITaskMetric> taskData = UIMetricUtils.getTaskMetrics(taskMetrics, component, window);
        model.addAttribute("taskData", taskData);
        model.addAttribute("taskHead", UIMetricUtils.sortHead(taskData, UITaskMetric.HEAD));
    } catch (NotAliveException nae) {
        model.addAttribute("flush", String.format("The topology: %s is dead.", topology_id));
    } catch (Exception e) {
        NimbusClientManager.removeClient(clusterName);
        LOG.error(e.getMessage(), e);
        UIUtils.addErrorAttribute(model, e);
    }
    // page information
    model.addAttribute("clusterName", clusterName);
    model.addAttribute("topologyId", topology_id);
    model.addAttribute("compName", component);
    model.addAttribute("page", "component");
    model.addAttribute("supervisorPort", UIUtils.getSupervisorPort(clusterName));
    UIUtils.addTitleAttribute(model, "Component Summary");
    try {
        String topologyName = Common.topologyIdToName(topology_id);
        model.addAttribute("topologyName", topologyName);
    } catch (InvalidTopologyException e) {
        e.printStackTrace();
    }
    LOG.info("component page show cost:{}ms", System.currentTimeMillis() - start);
    return "component";
}
Also used : UIComponentMetric(com.alibaba.jstorm.ui.model.UIComponentMetric) NimbusClient(backtype.storm.utils.NimbusClient) UITaskMetric(com.alibaba.jstorm.ui.model.UITaskMetric) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 30 with NimbusClient

use of backtype.storm.utils.NimbusClient in project jstorm by alibaba.

the class ClusterAPIController method nimbus.

@RequestMapping("/nimbus/summary")
public Map nimbus(@PathVariable String clusterName) {
    Map ret;
    NimbusClient client = null;
    try {
        client = NimbusClientManager.getNimbusClient(clusterName);
        ClusterSummary clusterSummary = client.getClient().getClusterInfo();
        ret = new HashMap<>();
        ret.put("nimbus", UIUtils.getNimbusEntities(clusterSummary));
    } catch (Exception e) {
        NimbusClientManager.removeClient(clusterName);
        ret = UIUtils.exceptionJson(e);
        LOG.error(e.getMessage(), e);
    }
    return ret;
}
Also used : NimbusClient(backtype.storm.utils.NimbusClient) HashMap(java.util.HashMap) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

NimbusClient (backtype.storm.utils.NimbusClient)38 Map (java.util.Map)17 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)16 HashMap (java.util.HashMap)9 InvalidParameterException (java.security.InvalidParameterException)6 IOException (java.io.IOException)4 TException (org.apache.thrift.TException)4 ModelMap (org.springframework.ui.ModelMap)4 ClusterSummary (backtype.storm.generated.ClusterSummary)3 KeyAlreadyExistsException (backtype.storm.generated.KeyAlreadyExistsException)3 KeyNotFoundException (backtype.storm.generated.KeyNotFoundException)3 NimbusInfo (backtype.storm.nimbus.NimbusInfo)3 FileNotFoundException (java.io.FileNotFoundException)3 TTransportException (org.apache.thrift.transport.TTransportException)3 KillOptions (backtype.storm.generated.KillOptions)2 MetricInfo (backtype.storm.generated.MetricInfo)2 TopologyInfo (backtype.storm.generated.TopologyInfo)2 UITaskMetric (com.alibaba.jstorm.ui.model.UITaskMetric)2 UIWorkerMetric (com.alibaba.jstorm.ui.model.UIWorkerMetric)2 ChartSeries (com.alibaba.jstorm.ui.model.graph.ChartSeries)2