Examples of NimbusClient


Examples of backtype.storm.utils.NimbusClient

  }

  @SuppressWarnings("rawtypes")
  public void init(String host) throws Exception {

    NimbusClient client = null;
    try {

      Map conf = UIUtils.readUiConfig();
      if(clusterName != null  && !(clusterName.equals(""))) {
        UIUtils.getClusterInfoByName(conf, clusterName);
      }
      client = NimbusClient.getConfiguredClient(conf);
      SupervisorWorkers supervisorWorkers = client.getClient()
          .getSupervisorWorkers(host);
      ssumm = new ArrayList<SupervisorSumm>();
      SupervisorSumm supervSumm = new SupervisorSumm(supervisorWorkers.get_supervisor());
      ssumm.add(supervSumm);
      ip = supervSumm.getIp();
      generateWorkerSum(supervisorWorkers.get_workers());
      getTopoList();
      getTopoMetrList(client);
      getWorkerMetrData();

    } catch (Exception e) {
      LOG.error("Failed to get cluster information:", e);
      throw e;
    } finally {
      if (client != null) {
        client.close();
      }
    }
  }
View Full Code Here

Examples of backtype.storm.utils.NimbusClient

        String topologyId = null;
        if (ctx.getExternalContext().getRequestParameterMap().get("topologyId") != null) {
            topologyId = ctx.getExternalContext().getRequestParameterMap()
                .get("topologyId");
          }
        NimbusClient client = NimbusClient.getConfiguredClient(conf);
        TopologyInfo summ = client.getClient().getTopologyInfo(topologyId);
        logFileName = JStormUtils.genLogName(summ.get_name(), Integer.valueOf(workerPort));
      }
      return;
    }

    String topologyid = null;
    String taskid = null;
    String clusterName = null;

    // resolve the arguments
    if (ctx.getExternalContext().getRequestParameterMap().get("clusterName") != null) {
      clusterName = (String) ctx.getExternalContext()
          .getRequestParameterMap().get("clusterName");
    }
    if (ctx.getExternalContext().getRequestParameterMap().get("topologyid") != null) {
      topologyid = ctx.getExternalContext().getRequestParameterMap()
          .get("topologyid");
    }
    if (ctx.getExternalContext().getRequestParameterMap().get("taskid") != null) {
      taskid = ctx.getExternalContext().getRequestParameterMap()
          .get("taskid");
    }

    if (topologyid == null) {
      throw new NotAliveException("Input topologyId is null ");
    }
    if (taskid == null) {
      throw new NotAliveException("Input taskId is null ");
    }

    NimbusClient client = null;

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

      TopologyInfo summ = client.getClient().getTopologyInfo(topologyid);

      // find the specified task entity
      TaskSummary taskSummary = null;
      for (TaskSummary _taskSummary : summ.get_tasks()) {
        if (taskid.equals(String.valueOf(_taskSummary.get_task_id()))) {
          taskSummary = _taskSummary;
          break;
        }
      }

      if (taskSummary == null) {
        throw new NotAliveException("topologyid=" + topologyid
            + ", taskid=" + taskid);
      }

      ComponentTask componentTask = UIUtils.getComponentTask(taskSummary,
          topologyid);

      host = componentTask.getHost();

//      logFileName = componentTask.getTopologyid() + "-worker-"
//          + componentTask.getPort() + ".log";
      logFileName = JStormUtils.genLogName(summ.get_name(),
          Integer.valueOf(componentTask.getPort()));

    } 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

Examples of backtype.storm.utils.NimbusClient

      throw new InvalidParameterException("Should input topology name");
    }

    String topologyName = args[0];

    NimbusClient client = null;
    try {

      Map conf = Utils.readStormConfig();
      client = NimbusClient.getConfiguredClient(conf);

      client.getClient().deactivate(topologyName);

      System.out.println("Successfully submit command deactivate "
          + topologyName);
    } catch (Exception e) {
      System.out.println(e.getMessage());
      e.printStackTrace();
      throw new RuntimeException(e);
    } finally {
      if (client != null) {
        client.close();
      }
    }
  }
View Full Code Here

Examples of backtype.storm.utils.NimbusClient

      throw new InvalidParameterException("Should input topology name and enable flag");
    }

    String topologyName = args[0];

    NimbusClient client = null;
    try {

      Map conf = Utils.readStormConfig();
      client = NimbusClient.getConfiguredClient(conf);

      boolean isEnable = Boolean.valueOf(args[1]).booleanValue();

      MonitorOptions options = new MonitorOptions();
      options.set_isEnable(isEnable);

      client.getClient().metricMonitor(topologyName, options);

      String str = (isEnable) ? "enable" : "disable";
      System.out.println("Successfully submit command to " + str
          + " the monitor of " + topologyName);
    } catch (Exception e) {
      System.out.println(e.getMessage());
      e.printStackTrace();
      throw new RuntimeException(e);
    } finally {
      if (client != null) {
        client.close();
      }
    }
  }
View Full Code Here

Examples of backtype.storm.utils.NimbusClient

      throw new InvalidParameterException("Should input topology name");
    }

    String topologyName = args[0];

    NimbusClient client = null;
    try {

      Map conf = Utils.readStormConfig();
      client = NimbusClient.getConfiguredClient(conf);

      if (args.length == 1) {

        client.getClient().killTopology(topologyName);
      } else {
        int delaySeconds = Integer.parseInt(args[1]);

        KillOptions options = new KillOptions();
        options.set_wait_secs(delaySeconds);

        client.getClient().killTopologyWithOpts(topologyName, options);

      }

      System.out.println("Successfully submit command kill "
          + topologyName);
    } catch (Exception e) {
      System.out.println(e.getMessage());
      e.printStackTrace();
      throw new RuntimeException(e);
    } finally {
      if (client != null) {
        client.close();
      }
    }
  }
View Full Code Here

Examples of backtype.storm.utils.NimbusClient

      throw new InvalidParameterException("Should input topology name");
    }

    String topologyName = args[0];

    NimbusClient client = null;
    try {
      Map conf = Utils.readStormConfig();
      client = NimbusClient.getConfiguredClient(conf);

      if (args.length == 1) {
        client.getClient().restart(topologyName, null);
      } else {
        Map loadConf = LoadConf(args[1]);
        String jsonConf = Utils.to_json(loadConf);
        client.getClient().restart(topologyName, jsonConf);
      }

      System.out.println("Successfully submit command restart "
          + topologyName);
    } catch (Exception e) {
      System.out.println(e.getMessage());
      e.printStackTrace();
      throw new RuntimeException(e);
    } finally {
      if (client != null) {
        client.close();
      }
    }
  }
View Full Code Here

Examples of backtype.storm.utils.NimbusClient

      throw new InvalidParameterException("Should input topology name");
    }

    String topologyName = args[0];

    NimbusClient client = null;
    try {

      Map conf = Utils.readStormConfig();
      client = NimbusClient.getConfiguredClient(conf);

      client.getClient().activate(topologyName);

      System.out.println("Successfully submit command activate "
          + topologyName);
    } catch (Exception e) {
      System.out.println(e.getMessage());
      e.printStackTrace();
      throw new RuntimeException(e);
    } finally {
      if (client != null) {
        client.close();
      }
    }
  }
View Full Code Here

Examples of backtype.storm.utils.NimbusClient

      throw new InvalidParameterException("Should input topology name");
    }

    String topologyName = args[0];

    NimbusClient client = null;
    try {

      Map conf = Utils.readStormConfig();
      client = NimbusClient.getConfiguredClient(conf);

      if (args.length == 1) {

        client.getClient().rebalance(topologyName, null);
      } else {
        int delaySeconds = Integer.parseInt(args[1]);

        RebalanceOptions options = new RebalanceOptions();
        options.set_wait_secs(delaySeconds);

        client.getClient().rebalance(topologyName, options);
      }

      System.out.println("Successfully submit command rebalance "
          + topologyName);
    } catch (Exception e) {
      System.out.println(e.getMessage());
      e.printStackTrace();
      throw new RuntimeException(e);
    } finally {
      if (client != null) {
        client.close();
      }
    }
  }
View Full Code Here

Examples of backtype.storm.utils.NimbusClient

  /**
   * @param args
   */
  public static void main(String[] args) {

    NimbusClient client = null;
    try {

      Map conf = Utils.readStormConfig();
      client = NimbusClient.getConfiguredClient(conf);
     
      if (args.length > 0 && StringUtils.isBlank(args[0]) == false) {
        String topologyId = args[0];
        TopologyInfo info = client.getClient().getTopologyInfo(topologyId);
       
        System.out.println("Successfully get topology info \n"
            + info.toString());
      }else {
        ClusterSummary clusterSummary = client.getClient().getClusterInfo();
       

        System.out.println("Successfully get cluster info \n"
            + clusterSummary.toString());
      }

     
    } catch (Exception e) {
      System.out.println(e.getMessage());
      e.printStackTrace();
      throw new RuntimeException(e);
    } finally {
      if (client != null) {
        client.close();
      }
    }
  }
View Full Code Here

Examples of backtype.storm.utils.NimbusClient

    init();
  }

  private void init() throws TException, NotAliveException {

    NimbusClient client = null;

    try {
      Map conf = Utils.readStormConfig();
      client = NimbusClient.getConfiguredClient(conf);

      TopologyInfo summ = client.getClient().getTopologyInfo(topologyid);

      List<TaskSummary> ts = summ.get_tasks();
      if (ts == null) {
        throw new NotAliveException("No TaskSummary");
      }
      TaskSummary t = null;
      if (ts != null) {
        int tssize = ts.size();
        for (int i = 0; i < tssize; i++) {
          if (ts.get(i).get_task_id() == Integer.parseInt(taskid)) {
            t = ts.get(i);
          }
        }
      }

      tsumms = taskSummaryTable(t, summ);
      esumms = taskErrorTable(t);
    } 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.