コード例 #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
  @Override
  public Response getCluster(final String clusterName) {
    HiveConfig config = hiveManager.getCluster(clusterName);
    if (config == null) {
      return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
          .entity(clusterName + "cluster not found")
          .build();
    }

    String cluster = JsonUtil.GSON.toJson(parsePojo(config));
    return Response.status(Response.Status.OK).entity(cluster).build();
  }
コード例 #3
0
 @Override
 public Response uninstallCluster(final String clusterName) {
   Preconditions.checkNotNull(clusterName);
   if (hiveManager.getCluster(clusterName) == null) {
     return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
         .entity(clusterName + " cluster not found.")
         .build();
   }
   UUID uuid = hiveManager.uninstallCluster(clusterName);
   OperationState state = waitUntilOperationFinish(uuid);
   return createResponse(uuid, state);
 }