Package org.apache.hadoop.hbase.stargate.model

Examples of org.apache.hadoop.hbase.stargate.model.TableSchemaModel


      return Response.status(509).build();
    }
    servlet.getMetrics().incrementRequests(1);
    try {
      ResponseBuilder response =
        Response.ok(new TableSchemaModel(getTableSchema()));
      response.cacheControl(cacheControl);
      return response.build();
    } catch (TableNotFoundException e) {
      throw new WebApplicationException(Response.Status.NOT_FOUND);
    } catch (IOException e) {
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
View Full Code Here

    assertFalse(admin.tableExists(TABLE1));
  }

  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

    if (LOG.isDebugEnabled()) {
      LOG.debug("GET " + uriInfo.getAbsolutePath());
    }
    try {
      HTableDescriptor htd = getTableSchema();
      TableSchemaModel model = new TableSchemaModel();
      model.setName(htd.getNameAsString());
      for (Map.Entry<ImmutableBytesWritable, ImmutableBytesWritable> e:
          htd.getValues().entrySet()) {
        model.addAttribute(Bytes.toString(e.getKey().get()),
            Bytes.toString(e.getValue().get()));
      }
      for (HColumnDescriptor hcd: htd.getFamilies()) {
        ColumnSchemaModel columnModel = new ColumnSchemaModel();
        columnModel.setName(hcd.getNameAsString());
        for (Map.Entry<ImmutableBytesWritable, ImmutableBytesWritable> e:
          hcd.getValues().entrySet()) {
        columnModel.addAttribute(Bytes.toString(e.getKey().get()),
          Bytes.toString(e.getValue().get()));
      }
        model.addColumnFamily(columnModel);
      }
      ResponseBuilder response = Response.ok(model);
      response.cacheControl(cacheControl);
      return response.build();
    } catch (TableNotFoundException e) {
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
View Full Code Here

    assertFalse(admin.tableExists(TABLE1));
  }

  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

  }

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

    assertFalse(admin.tableExists(TABLE1));

    // create the table
View Full Code Here

    assertFalse(admin.tableExists(TABLE1));
  }

  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

   * @param desc table descriptor for table
   * @throws IOException if a remote or network exception occurs
   */
  public void createTable(HTableDescriptor desc)
      throws IOException {
    TableSchemaModel model = new TableSchemaModel(desc);
    StringBuilder sb = new StringBuilder();
    sb.append('/');
    if (accessToken != null) {
      sb.append(accessToken);
      sb.append('/');
    }
    sb.append(Bytes.toStringBinary(desc.getName()));
    sb.append('/');
    sb.append("schema");
    int code = 0;
    for (int i = 0; i < maxRetries; i++) {
      Response response = client.put(sb.toString(), Constants.MIMETYPE_PROTOBUF,
        model.createProtobufOutput());
      code = response.getCode();
      switch (code) {
      case 201:
        return;
      case 509:
View Full Code Here

      LOG.debug("GET " + uriInfo.getAbsolutePath());
    }
    servlet.getMetrics().incrementRequests(1);
    try {
      ResponseBuilder response =
        Response.ok(new TableSchemaModel(getTableSchema()));
      response.cacheControl(cacheControl);
      return response.build();
    } catch (TableNotFoundException e) {
      throw new WebApplicationException(Response.Status.NOT_FOUND);
    } catch (IOException e) {
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.stargate.model.TableSchemaModel

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.