Ejemplo n.º 1
0
 private Response createResponse(UUID uuid, OperationState state) {
   TrackerOperationView po = tracker.getTrackerOperation(HiveConfig.PRODUCT_KEY, uuid);
   if (state == OperationState.FAILED) {
     return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
         .entity(JsonUtil.GSON.toJson(po.getLog()))
         .build();
   } else if (state == OperationState.SUCCEEDED) {
     return Response.status(Response.Status.OK).entity(JsonUtil.GSON.toJson(po.getLog())).build();
   } else {
     return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
         .entity(JsonUtil.GSON.toJson("Timeout"))
         .build();
   }
 }
Ejemplo n.º 2
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();
  }
Ejemplo n.º 3
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();
  }
Ejemplo n.º 4
0
  @Override
  public Response getClusters() {
    List<HiveConfig> configs = hiveManager.getClusters();
    ArrayList<String> clusterNames = Lists.newArrayList();

    for (HiveConfig config : configs) {
      clusterNames.add(config.getClusterName());
    }

    String clusters = JsonUtil.GSON.toJson(clusterNames);
    return Response.status(Response.Status.OK).entity(clusters).build();
  }
Ejemplo n.º 5
0
  @Override
  public Response getPluginInfo() {
    Properties prop = new Properties();
    VersionPojo pojo = new VersionPojo();
    InputStream input = null;
    try {
      input = getClass().getResourceAsStream("/git.properties");

      prop.load(input);
      pojo.setGitCommitId(prop.getProperty("git.commit.id"));
      pojo.setGitCommitTime(prop.getProperty("git.commit.time"));
      pojo.setGitBranch(prop.getProperty("git.branch"));
      pojo.setGitCommitUserName(prop.getProperty("git.commit.user.name"));
      pojo.setGitCommitUserEmail(prop.getProperty("git.commit.user.email"));
      pojo.setProjectVersion(prop.getProperty("git.build.version"));

      pojo.setGitBuildUserName(prop.getProperty("git.build.user.name"));
      pojo.setGitBuildUserEmail(prop.getProperty("git.build.user.email"));
      pojo.setGitBuildHost(prop.getProperty("git.build.host"));
      pojo.setGitBuildTime(prop.getProperty("git.build.time"));

      pojo.setGitClosestTagName(prop.getProperty("git.closest.tag.name"));
      pojo.setGitCommitIdDescribeShort(prop.getProperty("git.commit.id.describe-short"));
      pojo.setGitClosestTagCommitCount(prop.getProperty("git.closest.tag.commit.count"));
      pojo.setGitCommitIdDescribe(prop.getProperty("git.commit.id.describe"));
    } catch (IOException ex) {
      ex.printStackTrace();
    } finally {
      if (input != null) {
        try {
          input.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }

    String projectInfo = JsonUtil.GSON.toJson(pojo);

    return Response.status(Response.Status.OK).entity(projectInfo).build();
  }