本文整理汇总了Java中org.apache.hadoop.hbase.rest.model.TableSchemaModel类的典型用法代码示例。如果您正苦于以下问题:Java TableSchemaModel类的具体用法?Java TableSchemaModel怎么用?Java TableSchemaModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TableSchemaModel类属于org.apache.hadoop.hbase.rest.model包,在下文中一共展示了TableSchemaModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import org.apache.hadoop.hbase.rest.model.TableSchemaModel; //导入依赖的package包/类
@GET
@Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
MIMETYPE_PROTOBUF_IETF})
public Response get(final @Context UriInfo uriInfo) {
if (LOG.isDebugEnabled()) {
LOG.debug("GET " + uriInfo.getAbsolutePath());
}
servlet.getMetrics().incrementRequests(1);
try {
ResponseBuilder response =
Response.ok(new TableSchemaModel(getTableSchema()));
response.cacheControl(cacheControl);
servlet.getMetrics().incrementSucessfulGetRequests(1);
return response.build();
} catch (Exception e) {
servlet.getMetrics().incrementFailedGetRequests(1);
return processException(e);
}
}
示例2: update
import org.apache.hadoop.hbase.rest.model.TableSchemaModel; //导入依赖的package包/类
private Response update(final TableSchemaModel model, final boolean replace,
final UriInfo uriInfo) {
try {
byte[] name = Bytes.toBytes(tableResource.getName());
HBaseAdmin admin = servlet.getAdmin();
if (replace || !admin.tableExists(name)) {
return replace(name, model, uriInfo, admin);
} else {
return update(name, model, uriInfo, admin);
}
} catch (IOException e) {
servlet.getMetrics().incrementFailedPutRequests(1);
return Response.status(Response.Status.SERVICE_UNAVAILABLE)
.type(MIMETYPE_TEXT).entity("Unavailable" + CRLF)
.build();
}
}
示例3: getTableDescriptor
import org.apache.hadoop.hbase.rest.model.TableSchemaModel; //导入依赖的package包/类
public HTableDescriptor getTableDescriptor() throws IOException {
StringBuilder sb = new StringBuilder();
sb.append('/');
sb.append(Bytes.toStringBinary(name));
sb.append('/');
sb.append("schema");
for (int i = 0; i < maxRetries; i++) {
Response response = client.get(sb.toString(), Constants.MIMETYPE_PROTOBUF);
int code = response.getCode();
switch (code) {
case 200:
TableSchemaModel schema = new TableSchemaModel();
schema.getObjectFromMessage(response.getBody());
return schema.getTableDescriptor();
case 509:
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) { }
break;
default:
throw new IOException("schema request returned " + code);
}
}
throw new IOException("schema request timed out");
}
示例4: getTableDescriptor
import org.apache.hadoop.hbase.rest.model.TableSchemaModel; //导入依赖的package包/类
public HTableDescriptor getTableDescriptor() throws IOException {
StringBuilder sb = new StringBuilder();
sb.append('/');
sb.append(Bytes.toStringBinary(name));
sb.append('/');
sb.append("schema");
for (int i = 0; i < maxRetries; i++) {
Response response = client.get(sb.toString(), Constants.MIMETYPE_PROTOBUF);
int code = response.getCode();
switch (code) {
case 200:
TableSchemaModel schema = new TableSchemaModel();
schema.getObjectFromMessage(response.getBody());
return schema.getTableDescriptor();
case 509:
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) { }
break;
default:
throw new IOException("schema request returned " + code);
}
}
throw new IOException("schema request timed out");
}
示例5: TestTableSchemaModel
import org.apache.hadoop.hbase.rest.model.TableSchemaModel; //导入依赖的package包/类
public TestTableSchemaModel() throws Exception {
super(TableSchemaModel.class);
testColumnSchemaModel = new TestColumnSchemaModel();
AS_XML =
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" +
"<TableSchema name=\"testTable\" IS_META=\"false\" IS_ROOT=\"false\" READONLY=\"false\">" +
"<ColumnSchema name=\"testcolumn\" BLOCKSIZE=\"16384\" BLOOMFILTER=\"NONE\" " +
"BLOCKCACHE=\"true\" COMPRESSION=\"GZ\" VERSIONS=\"1\" TTL=\"86400\" IN_MEMORY=\"false\"/>" +
"</TableSchema>";
AS_PB =
"Cgl0ZXN0VGFibGUSEAoHSVNfTUVUQRIFZmFsc2USEAoHSVNfUk9PVBIFZmFsc2USEQoIUkVBRE9O" +
"TFkSBWZhbHNlGpcBCgp0ZXN0Y29sdW1uEhIKCUJMT0NLU0laRRIFMTYzODQSEwoLQkxPT01GSUxU" +
"RVISBE5PTkUSEgoKQkxPQ0tDQUNIRRIEdHJ1ZRIRCgtDT01QUkVTU0lPThICR1oSDQoIVkVSU0lP" +
"TlMSATESDAoDVFRMEgU4NjQwMBISCglJTl9NRU1PUlkSBWZhbHNlGICjBSABKgJHWigA";
AS_JSON =
"{\"name\":\"testTable\",\"IS_META\":\"false\",\"IS_ROOT\":\"false\"," +
"\"READONLY\":\"false\",\"ColumnSchema\":[{\"name\":\"testcolumn\"," +
"\"BLOCKSIZE\":\"16384\",\"BLOOMFILTER\":\"NONE\",\"BLOCKCACHE\":\"true\"," +
"\"COMPRESSION\":\"GZ\",\"VERSIONS\":\"1\",\"TTL\":\"86400\",\"IN_MEMORY\":\"false\"}]}";
}
示例6: get
import org.apache.hadoop.hbase.rest.model.TableSchemaModel; //导入依赖的package包/类
@GET
@Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
MIMETYPE_PROTOBUF_IETF})
public Response get(final @Context UriInfo uriInfo) {
if (LOG.isTraceEnabled()) {
LOG.trace("GET " + uriInfo.getAbsolutePath());
}
servlet.getMetrics().incrementRequests(1);
try {
ResponseBuilder response =
Response.ok(new TableSchemaModel(getTableSchema()));
response.cacheControl(cacheControl);
servlet.getMetrics().incrementSucessfulGetRequests(1);
return response.build();
} catch (Exception e) {
servlet.getMetrics().incrementFailedGetRequests(1);
return processException(e);
}
}
示例7: update
import org.apache.hadoop.hbase.rest.model.TableSchemaModel; //导入依赖的package包/类
private Response update(final TableSchemaModel model, final boolean replace,
final UriInfo uriInfo) {
try {
TableName name = TableName.valueOf(tableResource.getName());
Admin admin = servlet.getAdmin();
if (replace || !admin.tableExists(name)) {
return replace(name, model, uriInfo, admin);
} else {
return update(name, model, uriInfo, admin);
}
} catch (Exception e) {
servlet.getMetrics().incrementFailedPutRequests(1);
return processException(e);
}
}
示例8: put
import org.apache.hadoop.hbase.rest.model.TableSchemaModel; //导入依赖的package包/类
@PUT
@Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
MIMETYPE_PROTOBUF_IETF})
public Response put(final TableSchemaModel model,
final @Context UriInfo uriInfo) {
if (LOG.isDebugEnabled()) {
LOG.debug("PUT " + uriInfo.getAbsolutePath());
}
servlet.getMetrics().incrementRequests(1);
return update(model, true, uriInfo);
}
示例9: post
import org.apache.hadoop.hbase.rest.model.TableSchemaModel; //导入依赖的package包/类
@POST
@Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
MIMETYPE_PROTOBUF_IETF})
public Response post(final TableSchemaModel model,
final @Context UriInfo uriInfo) {
if (LOG.isDebugEnabled()) {
LOG.debug("PUT " + uriInfo.getAbsolutePath());
}
servlet.getMetrics().incrementRequests(1);
return update(model, false, uriInfo);
}
示例10: getTableDescriptor
import org.apache.hadoop.hbase.rest.model.TableSchemaModel; //导入依赖的package包/类
@Override
public HTableDescriptor getTableDescriptor() throws IOException {
StringBuilder sb = new StringBuilder();
sb.append('/');
sb.append(Bytes.toStringBinary(name));
sb.append('/');
sb.append("schema");
for (int i = 0; i < maxRetries; i++) {
Response response = client.get(sb.toString(), Constants.MIMETYPE_PROTOBUF);
int code = response.getCode();
switch (code) {
case 200:
TableSchemaModel schema = new TableSchemaModel();
schema.getObjectFromMessage(response.getBody());
return schema.getTableDescriptor();
case 509:
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
throw (InterruptedIOException)new InterruptedIOException().initCause(e);
}
break;
default:
throw new IOException("schema request returned " + code);
}
}
throw new IOException("schema request timed out");
}
示例11: createTable
import org.apache.hadoop.hbase.rest.model.TableSchemaModel; //导入依赖的package包/类
/**
* Creates a new table.
* @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 path = new StringBuilder();
path.append('/');
if (accessToken != null) {
path.append(accessToken);
path.append('/');
}
path.append(desc.getTableName());
path.append('/');
path.append("schema");
int code = 0;
for (int i = 0; i < maxRetries; i++) {
Response response = client.put(path.toString(), Constants.MIMETYPE_PROTOBUF,
model.createProtobufOutput());
code = response.getCode();
switch (code) {
case 201:
return;
case 509:
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
throw (InterruptedIOException)new InterruptedIOException().initCause(e);
}
break;
default:
throw new IOException("create request to " + path.toString() + " returned " + code);
}
}
throw new IOException("create request to " + path.toString() + " timed out");
}
示例12: setUpBeforeClass
import org.apache.hadoop.hbase.rest.model.TableSchemaModel; //导入依赖的package包/类
@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()));
testTableSchemaModel = new TestTableSchemaModel();
context = JAXBContext.newInstance(
ColumnSchemaModel.class,
TableSchemaModel.class);
}
示例13: createTable
import org.apache.hadoop.hbase.rest.model.TableSchemaModel; //导入依赖的package包/类
/**
* Creates a new table.
* @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 path = new StringBuilder();
path.append('/');
if (accessToken != null) {
path.append(accessToken);
path.append('/');
}
path.append(Bytes.toStringBinary(desc.getName()));
path.append('/');
path.append("schema");
int code = 0;
for (int i = 0; i < maxRetries; i++) {
Response response = client.put(path.toString(), Constants.MIMETYPE_PROTOBUF,
model.createProtobufOutput());
code = response.getCode();
switch (code) {
case 201:
return;
case 509:
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) { }
break;
default:
throw new IOException("create request to " + path.toString() + " returned " + code);
}
}
throw new IOException("create request to " + path.toString() + " timed out");
}
示例14: setUpBeforeClass
import org.apache.hadoop.hbase.rest.model.TableSchemaModel; //导入依赖的package包/类
@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(
ColumnSchemaModel.class,
TableSchemaModel.class);
}
示例15: testTableCreateAndDeleteXML
import org.apache.hadoop.hbase.rest.model.TableSchemaModel; //导入依赖的package包/类
@Test
public void testTableCreateAndDeleteXML() throws IOException, JAXBException {
String schemaPath = "/" + TABLE1 + "/schema";
TableSchemaModel model;
Response response;
HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
assertFalse(admin.tableExists(TABLE1));
// create the table
model = TestTableSchemaModel.buildTestModel(TABLE1);
TestTableSchemaModel.checkModel(model, TABLE1);
response = client.put(schemaPath, Constants.MIMETYPE_XML, toXML(model));
assertEquals(response.getCode(), 201);
// recall the same put operation but in read-only mode
conf.set("hbase.rest.readonly", "true");
response = client.put(schemaPath, Constants.MIMETYPE_XML, toXML(model));
assertEquals(response.getCode(), 403);
// retrieve the schema and validate it
response = client.get(schemaPath, Constants.MIMETYPE_XML);
assertEquals(response.getCode(), 200);
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
model = fromXML(response.getBody());
TestTableSchemaModel.checkModel(model, TABLE1);
// test delete schema operation is forbidden in read-only mode
response = client.delete(schemaPath);
assertEquals(response.getCode(), 403);
// return read-only setting back to default
conf.set("hbase.rest.readonly", "false");
// delete the table and make sure HBase concurs
response = client.delete(schemaPath);
assertEquals(response.getCode(), 200);
assertFalse(admin.tableExists(TABLE1));
}