Java 类org.apache.hadoop.hbase.rest.model.ScannerModel 实例源码

项目:ditb    文件:TestScannerResource.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf = TEST_UTIL.getConfiguration();
  TEST_UTIL.startMiniCluster();
  REST_TEST_UTIL.startServletContainer(conf);
  client = new Client(new Cluster().add("localhost",
    REST_TEST_UTIL.getServletPort()));
  context = JAXBContext.newInstance(
    CellModel.class,
    CellSetModel.class,
    RowModel.class,
    ScannerModel.class);
  marshaller = context.createMarshaller();
  unmarshaller = context.createUnmarshaller();
  Admin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TABLE);
  htd.addFamily(new HColumnDescriptor(CFA));
  htd.addFamily(new HColumnDescriptor(CFB));
  admin.createTable(htd);
  expectedRows1 = insertData(TEST_UTIL.getConfiguration(), TABLE, COLUMN_1, 1.0);
  expectedRows2 = insertData(TEST_UTIL.getConfiguration(), TABLE, COLUMN_2, 0.5);
}
项目:ditb    文件:TestScannersWithLabels.java   
@Test
public void testSimpleScannerXMLWithLabelsThatReceivesNoData() throws IOException, JAXBException {
  final int BATCH_SIZE = 5;
  // new scanner
  ScannerModel model = new ScannerModel();
  model.setBatch(BATCH_SIZE);
  model.addColumn(Bytes.toBytes(COLUMN_1));
  model.addLabel(PUBLIC);
  StringWriter writer = new StringWriter();
  marshaller.marshal(model, writer);
  byte[] body = Bytes.toBytes(writer.toString());
  // recall previous put operation with read-only off
  conf.set("hbase.rest.readonly", "false");
  Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML, body);
  assertEquals(response.getCode(), 201);
  String scannerURI = response.getLocation();
  assertNotNull(scannerURI);

  // get a cell set
  response = client.get(scannerURI, Constants.MIMETYPE_XML);
  // Respond with 204 as there are no cells to be retrieved
  assertEquals(response.getCode(), 204);
  assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
}
项目:LCIndex-HBase-0.94.16    文件:TestScannerResource.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf = TEST_UTIL.getConfiguration();
  TEST_UTIL.startMiniCluster();
  REST_TEST_UTIL.startServletContainer(conf);
  client = new Client(new Cluster().add("localhost",
    REST_TEST_UTIL.getServletPort()));
  context = JAXBContext.newInstance(
    CellModel.class,
    CellSetModel.class,
    RowModel.class,
    ScannerModel.class);
  marshaller = context.createMarshaller();
  unmarshaller = context.createUnmarshaller();
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TABLE);
  htd.addFamily(new HColumnDescriptor(CFA));
  htd.addFamily(new HColumnDescriptor(CFB));
  admin.createTable(htd);
  expectedRows1 = insertData(TABLE, COLUMN_1, 1.0);
  expectedRows2 = insertData(TABLE, COLUMN_2, 0.5);
}
项目:HIndex    文件:TestScannerResource.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf = TEST_UTIL.getConfiguration();
  TEST_UTIL.startMiniCluster();
  REST_TEST_UTIL.startServletContainer(conf);
  client = new Client(new Cluster().add("localhost",
    REST_TEST_UTIL.getServletPort()));
  context = JAXBContext.newInstance(
    CellModel.class,
    CellSetModel.class,
    RowModel.class,
    ScannerModel.class);
  marshaller = context.createMarshaller();
  unmarshaller = context.createUnmarshaller();
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(TABLE));
  htd.addFamily(new HColumnDescriptor(CFA));
  htd.addFamily(new HColumnDescriptor(CFB));
  admin.createTable(htd);
  expectedRows1 = insertData(TEST_UTIL.getConfiguration(), TABLE, COLUMN_1, 1.0);
  expectedRows2 = insertData(TEST_UTIL.getConfiguration(), TABLE, COLUMN_2, 0.5);
}
项目:HIndex    文件:TestScannersWithLabels.java   
@Test
public void testSimpleScannerXMLWithLabelsThatReceivesNoData() throws IOException, JAXBException {
  final int BATCH_SIZE = 5;
  // new scanner
  ScannerModel model = new ScannerModel();
  model.setBatch(BATCH_SIZE);
  model.addColumn(Bytes.toBytes(COLUMN_1));
  model.addLabel(PUBLIC);
  StringWriter writer = new StringWriter();
  marshaller.marshal(model, writer);
  byte[] body = Bytes.toBytes(writer.toString());
  // recall previous put operation with read-only off
  conf.set("hbase.rest.readonly", "false");
  Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML, body);
  assertEquals(response.getCode(), 201);
  String scannerURI = response.getLocation();
  assertNotNull(scannerURI);

  // get a cell set
  response = client.get(scannerURI, Constants.MIMETYPE_XML);
  // Respond with 204 as there are no cells to be retrieved
  assertEquals(response.getCode(), 204);
  assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
}
项目:IRIndex    文件:TestScannerResource.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf = TEST_UTIL.getConfiguration();
  TEST_UTIL.startMiniCluster();
  REST_TEST_UTIL.startServletContainer(conf);
  client = new Client(new Cluster().add("localhost",
    REST_TEST_UTIL.getServletPort()));
  context = JAXBContext.newInstance(
    CellModel.class,
    CellSetModel.class,
    RowModel.class,
    ScannerModel.class);
  marshaller = context.createMarshaller();
  unmarshaller = context.createUnmarshaller();
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TABLE);
  htd.addFamily(new HColumnDescriptor(CFA));
  htd.addFamily(new HColumnDescriptor(CFB));
  admin.createTable(htd);
  expectedRows1 = insertData(TABLE, COLUMN_1, 1.0);
  expectedRows2 = insertData(TABLE, COLUMN_2, 0.5);
}
项目:hbase    文件:TestScannersWithLabels.java   
@Test
public void testSimpleScannerXMLWithLabelsThatReceivesNoData() throws IOException, JAXBException {
  final int BATCH_SIZE = 5;
  // new scanner
  ScannerModel model = new ScannerModel();
  model.setBatch(BATCH_SIZE);
  model.addColumn(Bytes.toBytes(COLUMN_1));
  model.addLabel(PUBLIC);
  StringWriter writer = new StringWriter();
  marshaller.marshal(model, writer);
  byte[] body = Bytes.toBytes(writer.toString());
  // recall previous put operation with read-only off
  conf.set("hbase.rest.readonly", "false");
  Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML, body);
  assertEquals(201, response.getCode());
  String scannerURI = response.getLocation();
  assertNotNull(scannerURI);

  // get a cell set
  response = client.get(scannerURI, Constants.MIMETYPE_XML);
  // Respond with 204 as there are no cells to be retrieved
  assertEquals(204, response.getCode());
  // With no content in the payload, the 'Content-Type' header is not echo back
}
项目:PyroDB    文件:TestScannerResource.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf = TEST_UTIL.getConfiguration();
  TEST_UTIL.startMiniCluster();
  REST_TEST_UTIL.startServletContainer(conf);
  client = new Client(new Cluster().add("localhost",
    REST_TEST_UTIL.getServletPort()));
  context = JAXBContext.newInstance(
    CellModel.class,
    CellSetModel.class,
    RowModel.class,
    ScannerModel.class);
  marshaller = context.createMarshaller();
  unmarshaller = context.createUnmarshaller();
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(TABLE));
  htd.addFamily(new HColumnDescriptor(CFA));
  htd.addFamily(new HColumnDescriptor(CFB));
  admin.createTable(htd);
  expectedRows1 = insertData(TEST_UTIL.getConfiguration(), TABLE, COLUMN_1, 1.0);
  expectedRows2 = insertData(TEST_UTIL.getConfiguration(), TABLE, COLUMN_2, 0.5);
}
项目:PyroDB    文件:TestScannersWithLabels.java   
@Test
public void testSimpleScannerXMLWithLabelsThatReceivesNoData() throws IOException, JAXBException {
  final int BATCH_SIZE = 5;
  // new scanner
  ScannerModel model = new ScannerModel();
  model.setBatch(BATCH_SIZE);
  model.addColumn(Bytes.toBytes(COLUMN_1));
  model.addLabel(PUBLIC);
  StringWriter writer = new StringWriter();
  marshaller.marshal(model, writer);
  byte[] body = Bytes.toBytes(writer.toString());
  // recall previous put operation with read-only off
  conf.set("hbase.rest.readonly", "false");
  Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML, body);
  assertEquals(response.getCode(), 201);
  String scannerURI = response.getLocation();
  assertNotNull(scannerURI);

  // get a cell set
  response = client.get(scannerURI, Constants.MIMETYPE_XML);
  // Respond with 204 as there are no cells to be retrieved
  assertEquals(response.getCode(), 204);
  assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
}
项目:c5    文件:TestScannerResource.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf = TEST_UTIL.getConfiguration();
  TEST_UTIL.startMiniCluster();
  REST_TEST_UTIL.startServletContainer(conf);
  client = new Client(new Cluster().add("localhost",
    REST_TEST_UTIL.getServletPort()));
  context = JAXBContext.newInstance(
    CellModel.class,
    CellSetModel.class,
    RowModel.class,
    ScannerModel.class);
  marshaller = context.createMarshaller();
  unmarshaller = context.createUnmarshaller();
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(TABLE));
  htd.addFamily(new HColumnDescriptor(CFA));
  htd.addFamily(new HColumnDescriptor(CFB));
  admin.createTable(htd);
  expectedRows1 = insertData(TABLE, COLUMN_1, 1.0);
  expectedRows2 = insertData(TABLE, COLUMN_2, 0.5);
}
项目:HBase-Research    文件:TestScannerResource.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf = TEST_UTIL.getConfiguration();
  TEST_UTIL.startMiniCluster();
  REST_TEST_UTIL.startServletContainer(conf);
  client = new Client(new Cluster().add("localhost",
    REST_TEST_UTIL.getServletPort()));
  context = JAXBContext.newInstance(
    CellModel.class,
    CellSetModel.class,
    RowModel.class,
    ScannerModel.class);
  marshaller = context.createMarshaller();
  unmarshaller = context.createUnmarshaller();
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TABLE);
  htd.addFamily(new HColumnDescriptor(CFA));
  htd.addFamily(new HColumnDescriptor(CFB));
  admin.createTable(htd);
  expectedRows1 = insertData(TABLE, COLUMN_1, 1.0);
  expectedRows2 = insertData(TABLE, COLUMN_2, 0.5);
}
项目:hbase-0.94.8-qod    文件:TestScannerResource.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf = TEST_UTIL.getConfiguration();
  TEST_UTIL.startMiniCluster();
  REST_TEST_UTIL.startServletContainer(conf);
  client = new Client(new Cluster().add("localhost",
    REST_TEST_UTIL.getServletPort()));
  context = JAXBContext.newInstance(
    CellModel.class,
    CellSetModel.class,
    RowModel.class,
    ScannerModel.class);
  marshaller = context.createMarshaller();
  unmarshaller = context.createUnmarshaller();
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TABLE);
  htd.addFamily(new HColumnDescriptor(CFA));
  htd.addFamily(new HColumnDescriptor(CFB));
  admin.createTable(htd);
  expectedRows1 = insertData(TABLE, COLUMN_1, 1.0);
  expectedRows2 = insertData(TABLE, COLUMN_2, 0.5);
}
项目:hbase-0.94.8-qod    文件:TestScannerResource.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf = TEST_UTIL.getConfiguration();
  TEST_UTIL.startMiniCluster();
  REST_TEST_UTIL.startServletContainer(conf);
  client = new Client(new Cluster().add("localhost",
    REST_TEST_UTIL.getServletPort()));
  context = JAXBContext.newInstance(
    CellModel.class,
    CellSetModel.class,
    RowModel.class,
    ScannerModel.class);
  marshaller = context.createMarshaller();
  unmarshaller = context.createUnmarshaller();
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TABLE);
  htd.addFamily(new HColumnDescriptor(CFA));
  htd.addFamily(new HColumnDescriptor(CFB));
  admin.createTable(htd);
  expectedRows1 = insertData(TABLE, COLUMN_1, 1.0);
  expectedRows2 = insertData(TABLE, COLUMN_2, 0.5);
}
项目:DominoHBase    文件:TestScannerResource.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf = TEST_UTIL.getConfiguration();
  TEST_UTIL.startMiniCluster();
  REST_TEST_UTIL.startServletContainer(conf);
  client = new Client(new Cluster().add("localhost",
    REST_TEST_UTIL.getServletPort()));
  context = JAXBContext.newInstance(
    CellModel.class,
    CellSetModel.class,
    RowModel.class,
    ScannerModel.class);
  marshaller = context.createMarshaller();
  unmarshaller = context.createUnmarshaller();
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TABLE);
  htd.addFamily(new HColumnDescriptor(CFA));
  htd.addFamily(new HColumnDescriptor(CFB));
  admin.createTable(htd);
  expectedRows1 = insertData(TABLE, COLUMN_1, 1.0);
  expectedRows2 = insertData(TABLE, COLUMN_2, 0.5);
}
项目:hindex    文件:TestScannerResource.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf = TEST_UTIL.getConfiguration();
  TEST_UTIL.startMiniCluster();
  REST_TEST_UTIL.startServletContainer(conf);
  client = new Client(new Cluster().add("localhost",
    REST_TEST_UTIL.getServletPort()));
  context = JAXBContext.newInstance(
    CellModel.class,
    CellSetModel.class,
    RowModel.class,
    ScannerModel.class);
  marshaller = context.createMarshaller();
  unmarshaller = context.createUnmarshaller();
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TABLE);
  htd.addFamily(new HColumnDescriptor(CFA));
  htd.addFamily(new HColumnDescriptor(CFB));
  admin.createTable(htd);
  expectedRows1 = insertData(TABLE, COLUMN_1, 1.0);
  expectedRows2 = insertData(TABLE, COLUMN_2, 0.5);
}
项目:ditb    文件:ScannerResource.java   
@PUT
@Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
  MIMETYPE_PROTOBUF_IETF})
public Response put(final ScannerModel model, 
    final @Context UriInfo uriInfo) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("PUT " + uriInfo.getAbsolutePath());
  }
  return update(model, true, uriInfo);
}
项目:ditb    文件:ScannerResource.java   
@POST
@Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
  MIMETYPE_PROTOBUF_IETF})
public Response post(final ScannerModel model,
    final @Context UriInfo uriInfo) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("POST " + uriInfo.getAbsolutePath());
  }
  return update(model, false, uriInfo);
}
项目:ditb    文件:ScannerResultGenerator.java   
public static Filter buildFilterFromModel(final ScannerModel model) 
    throws Exception {
  String filter = model.getFilter();
  if (filter == null || filter.length() == 0) {
    return null;
  }
  return buildFilter(filter);
}
项目:ditb    文件:TestScannerResource.java   
private static int fullTableScan(ScannerModel model) throws IOException {
  model.setBatch(100);
  Response response = client.put("/" + TABLE + "/scanner",
    Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput());
  assertEquals(response.getCode(), 201);
  String scannerURI = response.getLocation();
  assertNotNull(scannerURI);
  int count = 0;
  while (true) {
    response = client.get(scannerURI, Constants.MIMETYPE_PROTOBUF);
    assertTrue(response.getCode() == 200 || response.getCode() == 204);
    if (response.getCode() == 200) {
      assertEquals(Constants.MIMETYPE_PROTOBUF, response.getHeader("content-type"));
      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;
}
项目:ditb    文件:TestScannerResource.java   
@Test
public void testTableDoesNotExist() throws IOException, JAXBException {
  ScannerModel model = new ScannerModel();
  StringWriter writer = new StringWriter();
  marshaller.marshal(model, writer);
  byte[] body = Bytes.toBytes(writer.toString());
  Response response = client.put("/" + NONEXISTENT_TABLE +
    "/scanner", Constants.MIMETYPE_XML, body);
  assertEquals(response.getCode(), 404);
}
项目:ditb    文件:TestScannersWithLabels.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  SUPERUSER = User.createUserForTesting(conf, "admin",
      new String[] { "supergroup" });
  conf = TEST_UTIL.getConfiguration();
  conf.setClass(VisibilityUtils.VISIBILITY_LABEL_GENERATOR_CLASS,
      SimpleScanLabelGenerator.class, ScanLabelGenerator.class);
  conf.setInt("hfile.format.version", 3);
  conf.set("hbase.superuser", SUPERUSER.getShortName());
  conf.set("hbase.coprocessor.master.classes", VisibilityController.class.getName());
  conf.set("hbase.coprocessor.region.classes", VisibilityController.class.getName());
  TEST_UTIL.startMiniCluster(1);
  // Wait for the labels table to become available
  TEST_UTIL.waitTableEnabled(VisibilityConstants.LABELS_TABLE_NAME.getName(), 50000);
  createLabels();
  setAuths();
  REST_TEST_UTIL.startServletContainer(conf);
  client = new Client(new Cluster().add("localhost", REST_TEST_UTIL.getServletPort()));
  context = JAXBContext.newInstance(CellModel.class, CellSetModel.class, RowModel.class,
      ScannerModel.class);
  marshaller = context.createMarshaller();
  unmarshaller = context.createUnmarshaller();
  Admin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TABLE);
  htd.addFamily(new HColumnDescriptor(CFA));
  htd.addFamily(new HColumnDescriptor(CFB));
  admin.createTable(htd);
  insertData(TABLE, COLUMN_1, 1.0);
  insertData(TABLE, COLUMN_2, 0.5);
}
项目:ditb    文件:TestScannersWithLabels.java   
@Test
public void testSimpleScannerXMLWithLabelsThatReceivesData() throws IOException, JAXBException {
  // new scanner
  ScannerModel model = new ScannerModel();
  model.setBatch(5);
  model.addColumn(Bytes.toBytes(COLUMN_1));
  model.addLabel(SECRET);
  StringWriter writer = new StringWriter();
  marshaller.marshal(model, writer);
  byte[] body = Bytes.toBytes(writer.toString());

  // recall previous put operation with read-only off
  conf.set("hbase.rest.readonly", "false");
  Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML, body);
  assertEquals(response.getCode(), 201);
  String scannerURI = response.getLocation();
  assertNotNull(scannerURI);

  // get a cell set
  response = client.get(scannerURI, Constants.MIMETYPE_XML);
  // Respond with 204 as there are no cells to be retrieved
  assertEquals(response.getCode(), 200);
  assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
  CellSetModel cellSet = (CellSetModel) unmarshaller.unmarshal(new ByteArrayInputStream(response
      .getBody()));
  assertEquals(countCellSet(cellSet), 5);
}
项目:ditb    文件:TestScannersWithFilters.java   
private static void verifyScan(Scan s, long expectedRows, long expectedKeys) 
    throws Exception {
  ScannerModel model = ScannerModel.fromScan(s);
  model.setBatch(Integer.MAX_VALUE); // fetch it all at once
  StringWriter writer = new StringWriter();
  marshaller.marshal(model, writer);
  LOG.debug(writer.toString());
  byte[] body = Bytes.toBytes(writer.toString());
  Response response = client.put("/" + TABLE + "/scanner",
    Constants.MIMETYPE_XML, body);
  assertEquals(response.getCode(), 201);
  String scannerURI = response.getLocation();
  assertNotNull(scannerURI);

  // get a cell set
  response = client.get(scannerURI, Constants.MIMETYPE_XML);
  assertEquals(response.getCode(), 200);
  assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
  CellSetModel cells = (CellSetModel)
    unmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));

  int rows = cells.getRows().size();
  assertTrue("Scanned too many rows! Only expected " + expectedRows + 
      " total but scanned " + rows, expectedRows == rows);
  for (RowModel row: cells.getRows()) {
    int count = row.getCells().size();
    assertEquals("Expected " + expectedKeys + " keys per row but " +
      "returned " + count, expectedKeys, count);
  }

  // delete the scanner
  response = client.delete(scannerURI);
  assertEquals(response.getCode(), 200);
}
项目:LCIndex-HBase-0.94.16    文件:ScannerResource.java   
@PUT
@Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
  MIMETYPE_PROTOBUF_IETF})
public Response put(final ScannerModel model, 
    final @Context UriInfo uriInfo) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("PUT " + uriInfo.getAbsolutePath());
  }
  return update(model, true, uriInfo);
}
项目:LCIndex-HBase-0.94.16    文件:ScannerResource.java   
@POST
@Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
  MIMETYPE_PROTOBUF_IETF})
public Response post(final ScannerModel model,
    final @Context UriInfo uriInfo) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("POST " + uriInfo.getAbsolutePath());
  }
  return update(model, false, uriInfo);
}
项目:LCIndex-HBase-0.94.16    文件:ScannerResultGenerator.java   
public static Filter buildFilterFromModel(final ScannerModel model) 
    throws Exception {
  String filter = model.getFilter();
  if (filter == null || filter.length() == 0) {
    return null;
  }
  return buildFilter(filter);
}
项目:LCIndex-HBase-0.94.16    文件:TestScannerResource.java   
private static int fullTableScan(ScannerModel model) throws IOException {
  model.setBatch(100);
  Response response = client.put("/" + TABLE + "/scanner",
    Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput());
  assertEquals(response.getCode(), 201);
  String scannerURI = response.getLocation();
  assertNotNull(scannerURI);
  int count = 0;
  while (true) {
    response = client.get(scannerURI, Constants.MIMETYPE_PROTOBUF);
    assertTrue(response.getCode() == 200 || response.getCode() == 204);
    if (response.getCode() == 200) {
      assertEquals(Constants.MIMETYPE_PROTOBUF, response.getHeader("content-type"));
      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;
}
项目:LCIndex-HBase-0.94.16    文件:TestScannerResource.java   
@Test
public void testTableDoesNotExist() throws IOException, JAXBException {
  ScannerModel model = new ScannerModel();
  StringWriter writer = new StringWriter();
  marshaller.marshal(model, writer);
  byte[] body = Bytes.toBytes(writer.toString());
  Response response = client.put("/" + NONEXISTENT_TABLE +
    "/scanner", Constants.MIMETYPE_XML, body);
  assertEquals(response.getCode(), 404);
}
项目:LCIndex-HBase-0.94.16    文件:TestScannersWithFilters.java   
private static void verifyScan(Scan s, long expectedRows, long expectedKeys) 
    throws Exception {
  ScannerModel model = ScannerModel.fromScan(s);
  model.setBatch(Integer.MAX_VALUE); // fetch it all at once
  StringWriter writer = new StringWriter();
  marshaller.marshal(model, writer);
  LOG.debug(writer.toString());
  byte[] body = Bytes.toBytes(writer.toString());
  Response response = client.put("/" + TABLE + "/scanner", 
    Constants.MIMETYPE_XML, body);
  assertEquals(response.getCode(), 201);
  String scannerURI = response.getLocation();
  assertNotNull(scannerURI);

  // get a cell set
  response = client.get(scannerURI, Constants.MIMETYPE_XML);
  assertEquals(response.getCode(), 200);
  assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
  CellSetModel cells = (CellSetModel)
    unmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));

  int rows = cells.getRows().size();
  assertTrue("Scanned too many rows! Only expected " + expectedRows + 
      " total but scanned " + rows, expectedRows == rows);
  for (RowModel row: cells.getRows()) {
    int count = row.getCells().size();
    assertEquals("Expected " + expectedKeys + " keys per row but " +
      "returned " + count, expectedKeys, count);
  }

  // delete the scanner
  response = client.delete(scannerURI);
  assertEquals(response.getCode(), 200);
}
项目:HIndex    文件:ScannerResource.java   
@PUT
@Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
  MIMETYPE_PROTOBUF_IETF})
public Response put(final ScannerModel model, 
    final @Context UriInfo uriInfo) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("PUT " + uriInfo.getAbsolutePath());
  }
  return update(model, true, uriInfo);
}
项目:HIndex    文件:ScannerResource.java   
@POST
@Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
  MIMETYPE_PROTOBUF_IETF})
public Response post(final ScannerModel model,
    final @Context UriInfo uriInfo) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("POST " + uriInfo.getAbsolutePath());
  }
  return update(model, false, uriInfo);
}
项目:HIndex    文件:ScannerResultGenerator.java   
public static Filter buildFilterFromModel(final ScannerModel model) 
    throws Exception {
  String filter = model.getFilter();
  if (filter == null || filter.length() == 0) {
    return null;
  }
  return buildFilter(filter);
}
项目:HIndex    文件:TestScannerResource.java   
private static int fullTableScan(ScannerModel model) throws IOException {
  model.setBatch(100);
  Response response = client.put("/" + TABLE + "/scanner",
    Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput());
  assertEquals(response.getCode(), 201);
  String scannerURI = response.getLocation();
  assertNotNull(scannerURI);
  int count = 0;
  while (true) {
    response = client.get(scannerURI, Constants.MIMETYPE_PROTOBUF);
    assertTrue(response.getCode() == 200 || response.getCode() == 204);
    if (response.getCode() == 200) {
      assertEquals(Constants.MIMETYPE_PROTOBUF, response.getHeader("content-type"));
      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;
}
项目:HIndex    文件:TestScannerResource.java   
@Test
public void testTableDoesNotExist() throws IOException, JAXBException {
  ScannerModel model = new ScannerModel();
  StringWriter writer = new StringWriter();
  marshaller.marshal(model, writer);
  byte[] body = Bytes.toBytes(writer.toString());
  Response response = client.put("/" + NONEXISTENT_TABLE +
    "/scanner", Constants.MIMETYPE_XML, body);
  assertEquals(response.getCode(), 404);
}
项目:HIndex    文件:TestScannersWithLabels.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  SUPERUSER = User.createUserForTesting(conf, "admin",
      new String[] { "supergroup" });
  conf = TEST_UTIL.getConfiguration();
  conf.setClass(VisibilityUtils.VISIBILITY_LABEL_GENERATOR_CLASS,
      SimpleScanLabelGenerator.class, ScanLabelGenerator.class);
  conf.setInt("hfile.format.version", 3);
  conf.set("hbase.superuser", SUPERUSER.getShortName());
  conf.set("hbase.coprocessor.master.classes", VisibilityController.class.getName());
  conf.set("hbase.coprocessor.region.classes", VisibilityController.class.getName());
  TEST_UTIL.startMiniCluster(1);
  // Wait for the labels table to become available
  TEST_UTIL.waitTableEnabled(VisibilityConstants.LABELS_TABLE_NAME.getName(), 50000);
  createLabels();
  setAuths();
  REST_TEST_UTIL.startServletContainer(conf);
  client = new Client(new Cluster().add("localhost", REST_TEST_UTIL.getServletPort()));
  context = JAXBContext.newInstance(CellModel.class, CellSetModel.class, RowModel.class,
      ScannerModel.class);
  marshaller = context.createMarshaller();
  unmarshaller = context.createUnmarshaller();
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(TABLE));
  htd.addFamily(new HColumnDescriptor(CFA));
  htd.addFamily(new HColumnDescriptor(CFB));
  admin.createTable(htd);
  insertData(TABLE, COLUMN_1, 1.0);
  insertData(TABLE, COLUMN_2, 0.5);
}
项目:HIndex    文件:TestScannersWithLabels.java   
@Test
public void testSimpleScannerXMLWithLabelsThatReceivesData() throws IOException, JAXBException {
  // new scanner
  ScannerModel model = new ScannerModel();
  model.setBatch(5);
  model.addColumn(Bytes.toBytes(COLUMN_1));
  model.addLabel(SECRET);
  StringWriter writer = new StringWriter();
  marshaller.marshal(model, writer);
  byte[] body = Bytes.toBytes(writer.toString());

  // recall previous put operation with read-only off
  conf.set("hbase.rest.readonly", "false");
  Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML, body);
  assertEquals(response.getCode(), 201);
  String scannerURI = response.getLocation();
  assertNotNull(scannerURI);

  // get a cell set
  response = client.get(scannerURI, Constants.MIMETYPE_XML);
  // Respond with 204 as there are no cells to be retrieved
  assertEquals(response.getCode(), 200);
  assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
  CellSetModel cellSet = (CellSetModel) unmarshaller.unmarshal(new ByteArrayInputStream(response
      .getBody()));
  assertEquals(countCellSet(cellSet), 5);
}
项目:HIndex    文件:TestScannersWithFilters.java   
private static void verifyScan(Scan s, long expectedRows, long expectedKeys) 
    throws Exception {
  ScannerModel model = ScannerModel.fromScan(s);
  model.setBatch(Integer.MAX_VALUE); // fetch it all at once
  StringWriter writer = new StringWriter();
  marshaller.marshal(model, writer);
  LOG.debug(writer.toString());
  byte[] body = Bytes.toBytes(writer.toString());
  Response response = client.put("/" + TABLE + "/scanner",
    Constants.MIMETYPE_XML, body);
  assertEquals(response.getCode(), 201);
  String scannerURI = response.getLocation();
  assertNotNull(scannerURI);

  // get a cell set
  response = client.get(scannerURI, Constants.MIMETYPE_XML);
  assertEquals(response.getCode(), 200);
  assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
  CellSetModel cells = (CellSetModel)
    unmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));

  int rows = cells.getRows().size();
  assertTrue("Scanned too many rows! Only expected " + expectedRows + 
      " total but scanned " + rows, expectedRows == rows);
  for (RowModel row: cells.getRows()) {
    int count = row.getCells().size();
    assertEquals("Expected " + expectedKeys + " keys per row but " +
      "returned " + count, expectedKeys, count);
  }

  // delete the scanner
  response = client.delete(scannerURI);
  assertEquals(response.getCode(), 200);
}
项目:IRIndex    文件:ScannerResource.java   
@PUT
@Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
  MIMETYPE_PROTOBUF_IETF})
public Response put(final ScannerModel model, 
    final @Context UriInfo uriInfo) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("PUT " + uriInfo.getAbsolutePath());
  }
  return update(model, true, uriInfo);
}
项目:IRIndex    文件:ScannerResource.java   
@POST
@Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
  MIMETYPE_PROTOBUF_IETF})
public Response post(final ScannerModel model,
    final @Context UriInfo uriInfo) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("POST " + uriInfo.getAbsolutePath());
  }
  return update(model, false, uriInfo);
}
项目:IRIndex    文件:ScannerResultGenerator.java   
public static Filter buildFilterFromModel(final ScannerModel model) 
    throws Exception {
  String filter = model.getFilter();
  if (filter == null || filter.length() == 0) {
    return null;
  }
  return buildFilter(filter);
}