Examples of NimbusClient


Examples of backtype.storm.utils.NimbusClient

            String serConf = JSONValue.toJSONString(stormConf);
            if(localNimbus!=null) {
                LOG.info("Submitting topology " + name + " in local mode");
                localNimbus.submitTopology(name, null, serConf, topology);
            } else {
                NimbusClient client = NimbusClient.getConfiguredClient(conf);
                if(topologyNameExists(conf, name)) {
                    throw new RuntimeException("Topology with name `" + name + "` already exists on cluster");
                }
                submitJar(conf, progressListener);
                try {
                    LOG.info("Submitting topology " +  name + " in distributed mode with conf " + serConf);
                    if(opts!=null) {
                        client.getClient().submitTopologyWithOpts(name, submittedJar, serConf, topology, opts);
                    } else {
                        // this is for backwards compatibility
                        client.getClient().submitTopology(name, submittedJar, serConf, topology);
                    }
                } catch(InvalidTopologyException e) {
                    LOG.warn("Topology submission exception: "+e.get_msg());
                    throw e;
                } catch(AlreadyAliveException e) {
                    LOG.warn("Topology already alive exception", e);
                    throw e;
                } finally {
                    client.close();
                }
            }
            LOG.info("Finished submitting topology: " +  name);
        } catch(TException e) {
            throw new RuntimeException(e);
View Full Code Here

Examples of backtype.storm.utils.NimbusClient

            }
        });
    }

    private static boolean topologyNameExists(Map conf, String name) {
        NimbusClient client = NimbusClient.getConfiguredClient(conf);
        try {
            ClusterSummary summary = client.getClient().getClusterInfo();
            for(TopologySummary s : summary.get_topologies()) {
                if(s.get_name().equals(name)) { 
                    return true;
                }
            } 
            return false;

        } catch(Exception e) {
            throw new RuntimeException(e);
        } finally {
            client.close();
        }
    }
View Full Code Here

Examples of backtype.storm.utils.NimbusClient

    public static String submitJar(Map conf, String localJar, ProgressListener listener) {
        if (localJar == null) {
            throw new RuntimeException("Must submit topologies using the 'storm' client script so that StormSubmitter knows which jar to upload.");
        }

        NimbusClient client = NimbusClient.getConfiguredClient(conf);
        try {
            String uploadLocation = client.getClient().beginFileUpload();
            LOG.info("Uploading topology jar " + localJar + " to assigned location: " + uploadLocation);
            BufferFileInputStream is = new BufferFileInputStream(localJar, THRIFT_CHUNK_SIZE_BYTES);

            long totalSize = new File(localJar).length();
            if (listener != null) {
                listener.onStart(localJar, uploadLocation, totalSize);
            }

            long bytesUploaded = 0;
            while(true) {
                byte[] toSubmit = is.read();
                bytesUploaded += toSubmit.length;
                if (listener != null) {
                    listener.onProgress(localJar, uploadLocation, bytesUploaded, totalSize);
                }

                if(toSubmit.length==0) break;
                client.getClient().uploadChunk(uploadLocation, ByteBuffer.wrap(toSubmit));
            }
            client.getClient().finishFileUpload(uploadLocation);

            if (listener != null) {
                listener.onCompleted(localJar, uploadLocation, totalSize);
            }

            LOG.info("Successfully uploaded topology jar to assigned location: " + uploadLocation);
            return uploadLocation;
        } catch(Exception e) {
            throw new RuntimeException(e);           
        } finally {
            client.close();
        }
    }
View Full Code Here

Examples of backtype.storm.utils.NimbusClient

            String serConf = JSONValue.toJSONString(stormConf);
            if(localNimbus!=null) {
                LOG.info("Submitting topology " + name + " in local mode");
                localNimbus.submitTopology(name, null, serConf, topology);
            } else {
                NimbusClient client = NimbusClient.getConfiguredClient(conf);
                if(topologyNameExists(conf, name)) {
                    throw new RuntimeException("Topology with name `" + name + "` already exists on cluster");
                }
                submitJar(conf);
                try {
                    LOG.info("Submitting topology " +  name + " in distributed mode with conf " + serConf);
                    if(opts!=null) {
                        client.getClient().submitTopologyWithOpts(name, submittedJar, serConf, topology, opts);                   
                    } else {
                        // this is for backwards compatibility
                        client.getClient().submitTopology(name, submittedJar, serConf, topology);                                           
                    }
                } catch(InvalidTopologyException e) {
                    LOG.warn("Topology submission exception", e);
                    throw e;
                } catch(AlreadyAliveException e) {
                    LOG.warn("Topology already alive exception", e);
                    throw e;
                } finally {
                    client.close();
                }
            }
            LOG.info("Finished submitting topology: " +  name);
        } catch(TException e) {
            throw new RuntimeException(e);
View Full Code Here

Examples of backtype.storm.utils.NimbusClient

            throw new RuntimeException(e);
        }
    }
   
    private static boolean topologyNameExists(Map conf, String name) {
        NimbusClient client = NimbusClient.getConfiguredClient(conf);
        try {
            ClusterSummary summary = client.getClient().getClusterInfo();
            for(TopologySummary s : summary.get_topologies()) {
                if(s.get_name().equals(name)) { 
                    return true;
                }
            } 
            return false;

        } catch(Exception e) {
            throw new RuntimeException(e);
        } finally {
            client.close();
        }
    }
View Full Code Here

Examples of backtype.storm.utils.NimbusClient

   
    public static String submitJar(Map conf, String localJar) {
        if(localJar==null) {
            throw new RuntimeException("Must submit topologies using the 'storm' client script so that StormSubmitter knows which jar to upload.");
        }
        NimbusClient client = NimbusClient.getConfiguredClient(conf);
        try {
            String uploadLocation = client.getClient().beginFileUpload();
            LOG.info("Uploading topology jar " + localJar + " to assigned location: " + uploadLocation);
            BufferFileInputStream is = new BufferFileInputStream(localJar);
            while(true) {
                byte[] toSubmit = is.read();
                if(toSubmit.length==0) break;
                client.getClient().uploadChunk(uploadLocation, ByteBuffer.wrap(toSubmit));
            }
            client.getClient().finishFileUpload(uploadLocation);
            LOG.info("Successfully uploaded topology jar to assigned location: " + uploadLocation);
            return uploadLocation;
        } catch(Exception e) {
            throw new RuntimeException(e);           
        } finally {
            client.close();
        }
    }
View Full Code Here

Examples of backtype.storm.utils.NimbusClient

      String serConf = Utils.to_json(stormConf);
      if (localNimbus != null) {
        LOG.info("Submitting topology " + name + " in local mode");
        localNimbus.submitTopology(name, null, serConf, topology);
      } else {
        NimbusClient client = NimbusClient.getConfiguredClient(conf);
        if (topologyNameExists(conf, name)) {
          throw new RuntimeException("Topology with name `" + name
              + "` already exists on cluster");
        }
        submitJar(conf);
        try {
          LOG.info("Submitting topology " + name
              + " in distributed mode with conf " + serConf);
          if (opts != null) {
            client.getClient().submitTopologyWithOpts(name, path,
                serConf, topology, opts);
          } else {
            // this is for backwards compatibility
            client.getClient().submitTopology(name, path, serConf,
                topology);
          }
        } finally {
          client.close();
        }
      }
      LOG.info("Finished submitting topology: " + name);
    } catch (InvalidTopologyException e) {
      LOG.warn("Topology submission exception", e);
View Full Code Here

Examples of backtype.storm.utils.NimbusClient

     */
    submitTopology(name, stormConf, topology, opts);
  }

  private static boolean topologyNameExists(Map conf, String name) {
    NimbusClient client = NimbusClient.getConfiguredClient(conf);
    try {
      ClusterSummary summary = client.getClient().getClusterInfo();
      for (TopologySummary s : summary.get_topologies()) {
        if (s.get_name().equals(name)) {
          return true;
        }
      }
      return false;

    } catch (Exception e) {
      throw new RuntimeException(e);
    } finally {
      client.close();
    }
  }
View Full Code Here

Examples of backtype.storm.utils.NimbusClient

  private static String submittedJar = null;
  private static String path = null;

  private static void submitJar(Map conf) {
    if (submittedJar == null) {
      NimbusClient client = NimbusClient.getConfiguredClient(conf);
      try {
        LOG.info("Jar not uploaded to master yet. Submitting jar...");
        String localJar = System.getProperty("storm.jar");
        path = client.getClient().beginFileUpload();
        String[] pathCache = path.split("/");
        String uploadLocation = path + "/stormjar-"
            + pathCache[pathCache.length - 1] + ".jar";
        submittedJar = submitJar(conf, localJar, uploadLocation, client);
        List<String> lib = (List<String>) conf
            .get(GenericOptionsParser.TOPOLOGY_LIB_NAME);
        Map<String, String> libPath = (Map<String, String>) conf
            .get(GenericOptionsParser.TOPOLOGY_LIB_PATH);
        if (lib != null) {
          for (String libName : lib) {
            String jarPath = path + "/" + libName;
            client.getClient().beginLibUpload(jarPath);
            submitJar(conf, libPath.get(libName), jarPath, client);
          }
        }
      } catch (Exception e) {
        throw new RuntimeException(e);
      } finally {
        client.close();
      }
    } else {
      LOG.info("Jar already uploaded to master. Not submitting jar.");
    }
  }
View Full Code Here

Examples of backtype.storm.utils.NimbusClient

  }

  @SuppressWarnings("rawtypes")
  private void init() throws TException, NotAliveException {

    NimbusClient client = null;

    try {
      Map conf = UIUtils.readUiConfig();
      if(clusterName != null  && !(clusterName.equals(""))) {
        UIUtils.getClusterInfoByName(conf, clusterName);
      }
      client = NimbusClient.getConfiguredClient(conf);

      TopologyInfo summ = client.getClient().getTopologyInfo(topologyid);
      StormTopology topology = client.getClient().getTopology(topologyid);
      TopologyMetricInfo topologyMetricInfo = client.getClient().getTopologyMetric(topologyid);

      String type = UIUtils.componentType(topology, componentid);

      List<TaskSummary> ts = UIUtils.getTaskList(summ.get_tasks(),
          componentid);

      coms = getComponentSummaries(summ, ts);

      cts = getComponentTasks(ts, window);

      comstats = getWinComponentStats(ts, window);

      getOutputSummary(ts, window);
      List<TaskMetricData> totoaltaskmetrics = topologyMetricInfo.get_task_metric_list();
      taskmetrics = getTaskMetricsList(totoaltaskmetrics);

    } catch (TException e) {
      LOG.error(e.getCause(), e);
      throw e;
    } catch (NotAliveException e) {
      LOG.error(e.getCause(), e);
      throw e;
    } finally {
      if (client != null) {
        client.close();
      }
    }

  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.