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;
}
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);
}
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;
}
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";
}
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;
}
Aggregations