Package org.apache.hadoop.hbase.stargate.client

Examples of org.apache.hadoop.hbase.stargate.client.Response


  public void testSimpleScannerBinary() throws IOException {
    // new scanner
    ScannerModel model = new ScannerModel();
    model.setBatch(1);
    model.addColumn(Bytes.toBytes(COLUMN_1));
    Response response = client.put("/" + TABLE + "/scanner",
      MIMETYPE_PROTOBUF, model.createProtobufOutput());
    assertEquals(response.getCode(), 201);
    String scannerURI = response.getLocation();
    assertNotNull(scannerURI);

    // get a cell
    response = client.get(scannerURI, MIMETYPE_BINARY);
    assertEquals(response.getCode(), 200);
    // verify that data was returned
    assertTrue(response.getBody().length > 0);
    // verify that the expected X-headers are present
    boolean foundRowHeader = false, foundColumnHeader = false,
      foundTimestampHeader = false;
    for (Header header: response.getHeaders()) {
      if (header.getName().equals("X-Row")) {
        foundRowHeader = true;
      } else if (header.getName().equals("X-Column")) {
        foundColumnHeader = true;
      } else if (header.getName().equals("X-Timestamp")) {
        foundTimestampHeader = true;
      }
    }
    assertTrue(foundRowHeader);
    assertTrue(foundColumnHeader);
    assertTrue(foundTimestampHeader);

    // delete the scanner
    response = client.delete(scannerURI);
    assertEquals(response.getCode(), 200);
  }
View Full Code Here


    assertEquals(response.getCode(), 200);
  }

  private int fullTableScan(ScannerModel model) throws IOException {
    model.setBatch(100);
    Response response = client.put("/" + TABLE + "/scanner",
        MIMETYPE_PROTOBUF, model.createProtobufOutput());
    assertEquals(response.getCode(), 201);
    String scannerURI = response.getLocation();
    assertNotNull(scannerURI);
    int count = 0;
    while (true) {
      response = client.get(scannerURI, MIMETYPE_PROTOBUF);
      assertTrue(response.getCode() == 200 || response.getCode() == 204);
      if (response.getCode() == 200) {
        CellSetModel cellSet = new CellSetModel();
        cellSet.getObjectFromMessage(response.getBody());
        Iterator<RowModel> rows = cellSet.getRows().iterator();
        while (rows.hasNext()) {
          RowModel row = rows.next();
          Iterator<CellModel> cells = row.getCells().iterator();
          while (cells.hasNext()) {
            cells.next();
            count++;
          }
        }
      } else {
        break;
      }
    }
    // delete the scanner
    response = client.delete(scannerURI);
    assertEquals(response.getCode(), 200);
    return count;
  }
View Full Code Here

  public void testTableCreateAndDeleteXML()
      throws IOException, JAXBException {
    String schemaPath = "/" + TABLE1 + "/schema";
    TableSchemaModel model;
    Response response;

    assertFalse(admin.tableExists(TABLE1));

    // create the table
    model = TestTableSchemaModel.buildTestModel(TABLE1);
    TestTableSchemaModel.checkModel(model, TABLE1);
    response = client.put(schemaPath, MIMETYPE_XML, toXML(model));
    assertEquals(response.getCode(), 201);

    // make sure HBase concurs, and wait for the table to come online
    admin.enableTable(TABLE1);

    // retrieve the schema and validate it
    response = client.get(schemaPath, MIMETYPE_XML);
    assertEquals(response.getCode(), 200);
    model = fromXML(response.getBody());
    TestTableSchemaModel.checkModel(model, TABLE1);

    // delete the table
    client.delete(schemaPath);
View Full Code Here

  }

  public void testTableCreateAndDeletePB() throws IOException, JAXBException {
    String schemaPath = "/" + TABLE2 + "/schema";
    TableSchemaModel model;
    Response response;

    assertFalse(admin.tableExists(TABLE2));

    // create the table
    model = TestTableSchemaModel.buildTestModel(TABLE2);
    TestTableSchemaModel.checkModel(model, TABLE2);
    response = client.put(schemaPath, Constants.MIMETYPE_PROTOBUF,
      model.createProtobufOutput());
    assertEquals(response.getCode(), 201);

    // make sure HBase concurs, and wait for the table to come online
    admin.enableTable(TABLE2);

    // retrieve the schema and validate it
    response = client.get(schemaPath, Constants.MIMETYPE_PROTOBUF);
    assertEquals(response.getCode(), 200);
    model = new TableSchemaModel();
    model.getObjectFromMessage(response.getBody());
    TestTableSchemaModel.checkModel(model, TABLE2);

    // delete the table
    client.delete(schemaPath);
View Full Code Here

    }
    assertTrue(found);
  }

  public void testTableListText() throws IOException {
    Response response = client.get("/", MIMETYPE_PLAIN);
    assertEquals(response.getCode(), 200);
  }
View Full Code Here

    Response response = client.get("/", MIMETYPE_PLAIN);
    assertEquals(response.getCode(), 200);
  }

  public void testTableListXML() throws IOException, JAXBException {
    Response response = client.get("/", MIMETYPE_XML);
    assertEquals(response.getCode(), 200);
    TableListModel model = (TableListModel)
      context.createUnmarshaller()
        .unmarshal(new ByteArrayInputStream(response.getBody()));
    checkTableList(model);
  }
View Full Code Here

        .unmarshal(new ByteArrayInputStream(response.getBody()));
    checkTableList(model);
  }

  public void testTableListJSON() throws IOException {
    Response response = client.get("/", MIMETYPE_JSON);
    assertEquals(response.getCode(), 200);
  }
View Full Code Here

    Response response = client.get("/", MIMETYPE_JSON);
    assertEquals(response.getCode(), 200);
  }

  public void testTableListPB() throws IOException, JAXBException {
    Response response = client.get("/", MIMETYPE_PROTOBUF);
    assertEquals(response.getCode(), 200);
    TableListModel model = new TableListModel();
    model.getObjectFromMessage(response.getBody());
    checkTableList(model);
  }
View Full Code Here

      assertTrue(found);
    }
  }

  public void testTableInfoText() throws IOException {
    Response response = client.get("/" + TABLE + "/regions", MIMETYPE_PLAIN);
    assertEquals(response.getCode(), 200);
  }
View Full Code Here

    Response response = client.get("/" + TABLE + "/regions", MIMETYPE_PLAIN);
    assertEquals(response.getCode(), 200);
  }

  public void testTableInfoXML() throws IOException, JAXBException {
    Response response = client.get("/" + TABLE + "/regions", MIMETYPE_XML);
    assertEquals(response.getCode(), 200);
    TableInfoModel model = (TableInfoModel)
      context.createUnmarshaller()
        .unmarshal(new ByteArrayInputStream(response.getBody()));
    checkTableInfo(model);
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.stargate.client.Response

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.