示例#1
0
  @Override
  public Response getAvailableNodes(final String clusterName) {
    Set<String> hostsName = Sets.newHashSet();

    HiveConfig hiveConfig = hiveManager.getCluster(clusterName);
    HadoopClusterConfig hadoopConfig = hadoopManager.getCluster(hiveConfig.getHadoopClusterName());

    Set<String> nodes = new HashSet<>(hadoopConfig.getAllNodes());
    nodes.removeAll(hiveConfig.getAllNodes());
    if (!nodes.isEmpty()) {
      Set<EnvironmentContainerHost> hosts;
      try {
        hosts =
            environmentManager
                .loadEnvironment(hadoopConfig.getEnvironmentId())
                .getContainerHostsByIds(nodes);

        for (final EnvironmentContainerHost host : hosts) {
          hostsName.add(host.getHostname());
        }
      } catch (ContainerHostNotFoundException | EnvironmentNotFoundException e) {
        e.printStackTrace();
      }
    } else {
      LOG.info("All nodes in corresponding Hadoop cluster have Nutch installed");
      //            return Response.status( Response.Status.NOT_FOUND ).build();
    }

    String hosts = JsonUtil.GSON.toJson(hostsName);
    return Response.status(Response.Status.OK).entity(hosts).build();
  }
示例#2
0
  private HivePojo parsePojo(HiveConfig config) {
    HivePojo pojo = new HivePojo();
    try {
      Environment env = environmentManager.loadEnvironment(config.getEnvironmentId());

      pojo.setClusterName(config.getClusterName());
      pojo.setEnvironmentId(config.getEnvironmentId());
      pojo.setHadoopClusterName(config.getHadoopClusterName());
      pojo.setServer(new NodePojo(config.getServer(), env));
      UUID uuid = hiveManager.statusCheck(config.getClusterName(), pojo.getServer().getHostname());
      pojo.getServer().setStatus(checkStatus(tracker, uuid));

      Set<NodePojo> clients = new HashSet<>();
      for (String slave : config.getClients()) {
        clients.add(new NodePojo(slave, env));
      }
      pojo.setClients(clients);
    } catch (EnvironmentNotFoundException e) {
      e.printStackTrace();
    }

    return pojo;
  }