Package org.apache.hadoop.hbase.rest.model

Examples of org.apache.hadoop.hbase.rest.model.StorageClusterStatusModel$Node


    return getLiteral(n, false);
  }

  public static Literal getLiteral(final Node node, final boolean allowLazyLiteral) {
    Literal literal = null;
    Node n = node;

    if (n instanceof ASTNIL) {
      try {
        literal = (allowLazyLiteral) ? LiteralFactory
            .createURILiteral("<http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>")
            : LiteralFactory
                .createURILiteralWithoutLazyLiteral("<http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>");
      } catch (final URISyntaxException e1) {
        e1.printStackTrace();
      }
    } else if (n instanceof ASTBlankNode) {
      final ASTBlankNode blankNode = (ASTBlankNode) n;
      final String name = blankNode.getIdentifier();
      literal = (allowLazyLiteral) ? LiteralFactory
          .createAnonymousLiteral(name) : LiteralFactory
          .createAnonymousLiteralWithoutLazyLiteral(name);
    } else if (n instanceof ASTQuotedURIRef) {
      final ASTQuotedURIRef uri = (ASTQuotedURIRef) n;
      final String name = uri.getQRef();

      if (URILiteral.isURI("<" + name + ">")) {
        try {
          literal = (allowLazyLiteral) ? LiteralFactory
              .createURILiteral("<" + name + ">")
              : LiteralFactory
                  .createURILiteralWithoutLazyLiteral("<"
                      + name + ">");
        } catch (final Exception e) {
          literal = (allowLazyLiteral) ? LiteralFactory
              .createLiteral("<" + name + ">") : LiteralFactory
              .createLiteralWithoutLazyLiteral("<" + name + ">");
        }
      } else {
        literal = (allowLazyLiteral) ? LiteralFactory.createLiteral("<"
            + name + ">") : LiteralFactory
            .createLiteralWithoutLazyLiteral("<" + name + ">");
      }
    } else if (n instanceof ASTRDFLiteral) {
      n = n.jjtGetChild(0);
    }

    if (literal != null) {
      return literal;
    }

    if (n instanceof ASTStringLiteral) {
      final ASTStringLiteral lit = (ASTStringLiteral) n;
      final String quotedContent = lit.getStringLiteral();

      literal = (allowLazyLiteral) ?
          LiteralFactory.createLiteral(quotedContent)
          : LiteralFactory.createLiteralWithoutLazyLiteral(quotedContent);
    } else if (n instanceof ASTInteger) {
      final ASTInteger lit = (ASTInteger) n;
      final String content = String.valueOf(lit.getValue());

      try {
        literal = (allowLazyLiteral) ? LiteralFactory
            .createTypedLiteral("\"" + content + "\"",
                "<http://www.w3.org/2001/XMLSchema#integer>")
            : TypedLiteralOriginalContent.createTypedLiteral("\""
                + content + "\"",
                "<http://www.w3.org/2001/XMLSchema#integer>");
      } catch (final URISyntaxException e) {
        literal = (allowLazyLiteral) ? LiteralFactory
            .createLiteral(content) : LiteralFactory
            .createLiteralWithoutLazyLiteral(content);
      }
    } else if (n instanceof ASTFloatingPoint) {
      final ASTFloatingPoint lit = (ASTFloatingPoint) n;
      final String content = lit.getValue();

      try {
        if (content.contains("e") || content.contains("E")) {
          literal = (allowLazyLiteral) ? LiteralFactory
              .createTypedLiteral("\"" + content + "\"",
                  "<http://www.w3.org/2001/XMLSchema#double>")
              : TypedLiteralOriginalContent
                  .createTypedLiteral("\"" + content + "\"",
                      "<http://www.w3.org/2001/XMLSchema#double>");
        } else {
          literal = (allowLazyLiteral) ? LiteralFactory
              .createTypedLiteral("\"" + content + "\"",
                  "<http://www.w3.org/2001/XMLSchema#decimal>")
              : TypedLiteralOriginalContent
                  .createTypedLiteral("\"" + content + "\"",
                      "<http://www.w3.org/2001/XMLSchema#decimal>");
        }
      } catch (final URISyntaxException e) {
        literal = (allowLazyLiteral) ? LiteralFactory
            .createLiteral(content) : LiteralFactory
            .createLiteralWithoutLazyLiteral(content);
      }
    } else if (n instanceof ASTBooleanLiteral) {
      final String content = ((ASTBooleanLiteral) n).getState() + "";

      try {
        literal = (allowLazyLiteral) ? LiteralFactory
            .createTypedLiteral("\"" + content + "\"",
                "<http://www.w3.org/2001/XMLSchema#boolean>")
            : TypedLiteralOriginalContent.createTypedLiteral("\""
                + content + "\"",
                "<http://www.w3.org/2001/XMLSchema#boolean>");
      } catch (final URISyntaxException e) {
        literal = (allowLazyLiteral) ? LiteralFactory
            .createLiteral(content) : LiteralFactory
            .createLiteralWithoutLazyLiteral(content);
      }
    } else if (n instanceof ASTDoubleCircumflex) {
      if (n.jjtGetNumChildren() != 2) {
        System.err.println(n + " is expected to have 2 children!");
      } else {
        final String content = getLiteral(n.jjtGetChild(0), false).toString();
        final String type = getLiteral(n.jjtGetChild(1), false).toString();

        try {
          literal = (allowLazyLiteral) ? LiteralFactory
              .createTypedLiteral(content, type)
              : TypedLiteralOriginalContent.createTypedLiteral(
                  content, type);
        } catch (final Exception e) {
          literal = (allowLazyLiteral) ? LiteralFactory
              .createLiteral(content + "^^" + type)
              : LiteralFactory
                  .createLiteralWithoutLazyLiteral(content
                      + "^^" + type);
        }
      }
    } else if (n instanceof ASTLangTag) {
      final String content = getLiteral(n.jjtGetChild(0), false).toString();
      final String lang = ((ASTLangTag) n).getLangTag();
      literal = (allowLazyLiteral) ? LiteralFactory
          .createLanguageTaggedLiteral(content, lang)
          : LanguageTaggedLiteralOriginalLanguage
              .createLanguageTaggedLiteral(content, lang);
    } else if (n instanceof ASTQName) {
      final ASTQName uri = (ASTQName) n;
      final String namespace = uri.getNameSpace();
      final String localName = uri.getLocalName();

      final String name = namespace + localName;

      if (URILiteral.isURI("<" + name + ">")) {
        try {
          literal = (allowLazyLiteral) ? LiteralFactory
              .createURILiteral("<" + name + ">")
              : LiteralFactory
                  .createURILiteralWithoutLazyLiteral("<"
                      + name + ">");
        } catch (final Exception e) {
          literal = (allowLazyLiteral) ? LiteralFactory
              .createLiteral("<" + name + ">") : LiteralFactory
              .createLiteralWithoutLazyLiteral("<" + name + ">");
        }
      } else {
        literal = (allowLazyLiteral) ? LiteralFactory.createLiteral("<"
            + name + ">") : LiteralFactory
            .createLiteralWithoutLazyLiteral("<" + name + ">");
      }
    } else if(n instanceof ASTObjectList){
      literal = getLiteral(n.jjtGetChild(0), allowLazyLiteral);
    } else {
      System.err.println("Unexpected type! "
          + n.getClass().getSimpleName());
    }

    return literal;
  }
View Full Code Here


  @Test
  public void testClusterStatus() throws Exception {

    ClusterStatus status = TEST_UTIL.getHBaseClusterInterface()
        .getClusterStatus();
    StorageClusterStatusModel returnedStatus = remoteAdmin.getClusterStatus();
    assertEquals(
        "Region count from cluster status and returned status did not match up. ",
        status.getRegionsCount(), returnedStatus.getRegions());
    assertEquals(
        "Dead server count from cluster status and returned status did not match up. ",
        status.getDeadServers(), returnedStatus.getDeadNodes().size());
  }
View Full Code Here

      Response response = client.get(path.toString(),
          Constants.MIMETYPE_PROTOBUF);
      code = response.getCode();
      switch (code) {
      case 200:
        StorageClusterStatusModel s = new StorageClusterStatusModel();
        return (StorageClusterStatusModel) s.getObjectFromMessage(response
            .getBody());
      case 404:
        throw new IOException("Cluster version not found");
      case 509:
        try {
View Full Code Here

  @Test
  public void testGetClusterStatusXML() throws IOException, JAXBException {
    Response response = client.get("/status/cluster", Constants.MIMETYPE_XML);
    assertEquals(response.getCode(), 200);
    assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
    StorageClusterStatusModel model = (StorageClusterStatusModel)
      context.createUnmarshaller().unmarshal(
        new ByteArrayInputStream(response.getBody()));
    validate(model);
  }
View Full Code Here

  @Test
  public void testGetClusterStatusPB() throws IOException {
    Response response = client.get("/status/cluster", Constants.MIMETYPE_PROTOBUF);
    assertEquals(response.getCode(), 200);
    assertEquals(Constants.MIMETYPE_PROTOBUF, response.getHeader("content-type"));
    StorageClusterStatusModel model = new StorageClusterStatusModel();
    model.getObjectFromMessage(response.getBody());
    validate(model);
    response = client.get("/status/cluster", Constants.MIMETYPE_PROTOBUF_IETF);
    assertEquals(response.getCode(), 200);
    assertEquals(Constants.MIMETYPE_PROTOBUF_IETF, response.getHeader("content-type"));
    model = new StorageClusterStatusModel();
    model.getObjectFromMessage(response.getBody());
    validate(model);
  }
View Full Code Here

      LOG.debug("GET " + uriInfo.getAbsolutePath());
    }
    servlet.getMetrics().incrementRequests(1);
    try {
      ClusterStatus status = servlet.getAdmin().getClusterStatus();
      StorageClusterStatusModel model = new StorageClusterStatusModel();
      model.setRegions(status.getRegionsCount());
      model.setRequests(status.getRequestsCount());
      model.setAverageLoad(status.getAverageLoad());
      for (ServerName info: status.getServers()) {
        HServerLoad load = status.getLoad(info);
        StorageClusterStatusModel.Node node =
          model.addLiveNode(
            info.getHostname() + ":" +
            Integer.toString(info.getPort()),
            info.getStartcode(), load.getUsedHeapMB(),
            load.getMaxHeapMB());
        node.setRequests(load.getNumberOfRequests());
        for (HServerLoad.RegionLoad region: load.getRegionsLoad().values()) {
          node.addRegion(region.getName(), region.getStores(),
            region.getStorefiles(), region.getStorefileSizeMB(),
            region.getMemStoreSizeMB(), region.getStorefileIndexSizeMB(),
            region.getReadRequestsCount(), region.getWriteRequestsCount(),
            region.getRootIndexSizeKB(), region.getTotalStaticIndexSizeKB(),
            region.getTotalStaticBloomSizeKB(), region.getTotalCompactingKVs(),
            region.getCurrentCompactedKVs());
        }
      }
      for (ServerName name: status.getDeadServerNames()) {
        model.addDeadNode(name.toString());
      }
      ResponseBuilder response = Response.ok(model);
      response.cacheControl(cacheControl);
      servlet.getMetrics().incrementSucessfulGetRequests(1);
      return response.build();
View Full Code Here

  @Test
  public void testClusterStatus() throws Exception {

    ClusterStatus status = TEST_UTIL.getHBaseClusterInterface()
        .getClusterStatus();
    StorageClusterStatusModel returnedStatus = remoteAdmin.getClusterStatus();
    assertEquals(
        "Region count from cluster status and returned status did not match up. ",
        status.getRegionsCount(), returnedStatus.getRegions());
    assertEquals(
        "Dead server count from cluster status and returned status did not match up. ",
        status.getDeadServers(), returnedStatus.getDeadNodes().size());
    assertEquals(
        "Number of requests from cluster status and returned status did not match up. ",
        status.getRequestsCount(), returnedStatus.getRequests());
  }
View Full Code Here

      LOG.debug("GET " + uriInfo.getAbsolutePath());
    }
    servlet.getMetrics().incrementRequests(1);
    try {
      ClusterStatus status = servlet.getAdmin().getClusterStatus();
      StorageClusterStatusModel model = new StorageClusterStatusModel();
      model.setRegions(status.getRegionsCount());
      model.setRequests(status.getRequestsCount());
      model.setAverageLoad(status.getAverageLoad());
      for (HServerInfo info: status.getServerInfo()) {
        HServerLoad load = info.getLoad();
        StorageClusterStatusModel.Node node =
          model.addLiveNode(
            info.getServerAddress().getHostname() + ":" +
            Integer.toString(info.getServerAddress().getPort()),
            info.getStartCode(), load.getUsedHeapMB(),
            load.getMaxHeapMB());
        node.setRequests(load.getNumberOfRequests());
        for (HServerLoad.RegionLoad region: load.getRegionsLoad()) {
          node.addRegion(region.getName(), region.getStores(),
            region.getStorefiles(), region.getStorefileSizeMB(),
            region.getMemStoreSizeMB(), region.getStorefileIndexSizeMB());
        }
      }
      for (String name: status.getDeadServerNames()) {
        model.addDeadNode(name);
      }
      ResponseBuilder response = Response.ok(model);
      response.cacheControl(cacheControl);
      return response.build();
    } catch (IOException e) {
View Full Code Here

    }
    servlet.getMetrics().incrementRequests(1);
    try {
      HBaseAdmin admin = new HBaseAdmin(servlet.getConfiguration());
      ClusterStatus status = admin.getClusterStatus();
      StorageClusterStatusModel model = new StorageClusterStatusModel();
      model.setRegions(status.getRegionsCount());
      model.setRequests(status.getRequestsCount());
      model.setAverageLoad(status.getAverageLoad());
      for (ServerName info: status.getServers()) {
        HServerLoad load = status.getLoad(info);
        StorageClusterStatusModel.Node node =
          model.addLiveNode(
            info.getHostname() + ":" +
            Integer.toString(info.getPort()),
            info.getStartcode(), load.getUsedHeapMB(),
            load.getMaxHeapMB());
        node.setRequests(load.getNumberOfRequests());
        for (HServerLoad.RegionLoad region: load.getRegionsLoad().values()) {
          node.addRegion(region.getName(), region.getStores(),
            region.getStorefiles(), region.getStorefileSizeMB(),
            region.getMemStoreSizeMB(), region.getStorefileIndexSizeMB());
        }
      }
      for (ServerName name: status.getDeadServerNames()) {
        model.addDeadNode(name.toString());
      }
      ResponseBuilder response = Response.ok(model);
      response.cacheControl(cacheControl);
      return response.build();
    } catch (IOException e) {
View Full Code Here

  @Test
  public void testGetClusterStatusXML() throws IOException, JAXBException {
    Response response = client.get("/status/cluster", Constants.MIMETYPE_XML);
    assertEquals(response.getCode(), 200);
    StorageClusterStatusModel model = (StorageClusterStatusModel)
      context.createUnmarshaller().unmarshal(
        new ByteArrayInputStream(response.getBody()));
    validate(model);
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.rest.model.StorageClusterStatusModel$Node

Copyright © 2018 www.massapicom. 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.