本文整理汇总了Java中org.apache.hadoop.hbase.rest.Constants类的典型用法代码示例。如果您正苦于以下问题:Java Constants类的具体用法?Java Constants怎么用?Java Constants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Constants类属于org.apache.hadoop.hbase.rest包,在下文中一共展示了Constants类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getTableDescriptor
import org.apache.hadoop.hbase.rest.Constants; //导入依赖的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");
}
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:26,代码来源:RemoteHTable.java
示例2: getTableDescriptor
import org.apache.hadoop.hbase.rest.Constants; //导入依赖的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");
}
开发者ID:tenggyut,项目名称:HIndex,代码行数:26,代码来源:RemoteHTable.java
示例3: testFailOnExternalEntities
import org.apache.hadoop.hbase.rest.Constants; //导入依赖的package包/类
@Test
public void testFailOnExternalEntities() throws Exception {
final String externalEntitiesXml =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ " <!DOCTYPE foo [ <!ENTITY xxe SYSTEM \"/tmp/foo\"> ] >"
+ " <ClusterVersion>&xee;</ClusterVersion>";
Client client = mock(Client.class);
RemoteAdmin admin = new RemoteAdmin(client, HBaseConfiguration.create(), null);
Response resp = new Response(200, null, Bytes.toBytes(externalEntitiesXml));
when(client.get("/version/cluster", Constants.MIMETYPE_XML)).thenReturn(resp);
try {
admin.getClusterVersion();
fail("Expected getClusterVersion() to throw an exception");
} catch (IOException e) {
assertEquals("Cause of exception ought to be a failure to parse the stream due to our " +
"invalid external entity. Make sure this isn't just a false positive due to " +
"implementation. see HBASE-19020.", UnmarshalException.class, e.getCause().getClass());
final String exceptionText = StringUtils.stringifyException(e);
final String expectedText = "\"xee\"";
LOG.debug("exception text: '" + exceptionText + "'", e);
assertTrue("Exception does not contain expected text", exceptionText.contains(expectedText));
}
}
开发者ID:apache,项目名称:hbase,代码行数:26,代码来源:TestXmlParsing.java
示例4: getTableDescriptor
import org.apache.hadoop.hbase.rest.Constants; //导入依赖的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");
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:29,代码来源:RemoteHTable.java
示例5: getResults
import org.apache.hadoop.hbase.rest.Constants; //导入依赖的package包/类
private Result[] getResults(String spec) throws IOException {
for (int i = 0; i < maxRetries; i++) {
Response response = client.get(spec, Constants.MIMETYPE_PROTOBUF);
int code = response.getCode();
switch (code) {
case 200:
CellSetModel model = new CellSetModel();
model.getObjectFromMessage(response.getBody());
Result[] results = buildResultFromModel(model);
if ( results.length > 0) {
return results;
}
// fall through
case 404:
return new Result[0];
case 509:
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
throw (InterruptedIOException)new InterruptedIOException().initCause(e);
}
break;
default:
throw new IOException("get request returned " + code);
}
}
throw new IOException("get request timed out");
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:30,代码来源:RemoteHTable.java
示例6: next
import org.apache.hadoop.hbase.rest.Constants; //导入依赖的package包/类
@Override
public Result[] next(int nbRows) throws IOException {
StringBuilder sb = new StringBuilder(uri);
sb.append("?n=");
sb.append(nbRows);
for (int i = 0; i < maxRetries; i++) {
Response response = client.get(sb.toString(),
Constants.MIMETYPE_PROTOBUF);
int code = response.getCode();
switch (code) {
case 200:
CellSetModel model = new CellSetModel();
model.getObjectFromMessage(response.getBody());
return buildResultFromModel(model);
case 204:
case 206:
return null;
case 509:
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
throw (InterruptedIOException)new InterruptedIOException().initCause(e);
}
break;
default:
throw new IOException("scanner.next request failed with " + code);
}
}
throw new IOException("scanner.next request timed out");
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:31,代码来源:RemoteHTable.java
示例7: checkAndPut
import org.apache.hadoop.hbase.rest.Constants; //导入依赖的package包/类
@Override
public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier,
byte[] value, Put put) throws IOException {
// column to check-the-value
put.add(new KeyValue(row, family, qualifier, value));
CellSetModel model = buildModelFromPut(put);
StringBuilder sb = new StringBuilder();
sb.append('/');
sb.append(Bytes.toStringBinary(name));
sb.append('/');
sb.append(Bytes.toStringBinary(put.getRow()));
sb.append("?check=put");
for (int i = 0; i < maxRetries; i++) {
Response response = client.put(sb.toString(),
Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput());
int code = response.getCode();
switch (code) {
case 200:
return true;
case 304: // NOT-MODIFIED
return false;
case 509:
try {
Thread.sleep(sleepTime);
} catch (final InterruptedException e) {
throw (InterruptedIOException)new InterruptedIOException().initCause(e);
}
break;
default:
throw new IOException("checkAndPut request failed with " + code);
}
}
throw new IOException("checkAndPut request timed out");
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:37,代码来源:RemoteHTable.java
示例8: checkAndDelete
import org.apache.hadoop.hbase.rest.Constants; //导入依赖的package包/类
@Override
public boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier,
byte[] value, Delete delete) throws IOException {
Put put = new Put(row);
put.setFamilyCellMap(delete.getFamilyCellMap());
// column to check-the-value
put.add(new KeyValue(row, family, qualifier, value));
CellSetModel model = buildModelFromPut(put);
StringBuilder sb = new StringBuilder();
sb.append('/');
sb.append(Bytes.toStringBinary(name));
sb.append('/');
sb.append(Bytes.toStringBinary(row));
sb.append("?check=delete");
for (int i = 0; i < maxRetries; i++) {
Response response = client.put(sb.toString(),
Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput());
int code = response.getCode();
switch (code) {
case 200:
return true;
case 304: // NOT-MODIFIED
return false;
case 509:
try {
Thread.sleep(sleepTime);
} catch (final InterruptedException e) {
throw (InterruptedIOException)new InterruptedIOException().initCause(e);
}
break;
default:
throw new IOException("checkAndDelete request failed with " + code);
}
}
throw new IOException("checkAndDelete request timed out");
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:38,代码来源:RemoteHTable.java
示例9: getRestVersion
import org.apache.hadoop.hbase.rest.Constants; //导入依赖的package包/类
/**
* @return string representing the rest api's version
* @throws IOException
* if the endpoint does not exist, there is a timeout, or some other
* general failure mode
*/
public VersionModel getRestVersion() throws IOException {
StringBuilder path = new StringBuilder();
path.append('/');
if (accessToken != null) {
path.append(accessToken);
path.append('/');
}
path.append("version/rest");
int code = 0;
for (int i = 0; i < maxRetries; i++) {
Response response = client.get(path.toString(),
Constants.MIMETYPE_PROTOBUF);
code = response.getCode();
switch (code) {
case 200:
VersionModel v = new VersionModel();
return (VersionModel) v.getObjectFromMessage(response.getBody());
case 404:
throw new IOException("REST version not found");
case 509:
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
throw (InterruptedIOException)new InterruptedIOException().initCause(e);
}
break;
default:
throw new IOException("get request to " + path.toString()
+ " returned " + code);
}
}
throw new IOException("get request to " + path.toString() + " timed out");
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:44,代码来源:RemoteAdmin.java
示例10: getClusterStatus
import org.apache.hadoop.hbase.rest.Constants; //导入依赖的package包/类
/**
* @return string representing the cluster's version
* @throws IOException if the endpoint does not exist, there is a timeout, or some other general failure mode
*/
public StorageClusterStatusModel getClusterStatus() throws IOException {
StringBuilder path = new StringBuilder();
path.append('/');
if (accessToken !=null) {
path.append(accessToken);
path.append('/');
}
path.append("status/cluster");
int code = 0;
for (int i = 0; i < maxRetries; i++) {
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 {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
throw (InterruptedIOException)new InterruptedIOException().initCause(e);
}
break;
default:
throw new IOException("get request to " + path + " returned " + code);
}
}
throw new IOException("get request to " + path + " timed out");
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:41,代码来源:RemoteAdmin.java
示例11: isTableAvailable
import org.apache.hadoop.hbase.rest.Constants; //导入依赖的package包/类
/**
* @param tableName name of table to check
* @return true if all regions of the table are available
* @throws IOException if a remote or network exception occurs
*/
public boolean isTableAvailable(byte[] tableName) throws IOException {
StringBuilder path = new StringBuilder();
path.append('/');
if (accessToken != null) {
path.append(accessToken);
path.append('/');
}
path.append(Bytes.toStringBinary(tableName));
path.append('/');
path.append("exists");
int code = 0;
for (int i = 0; i < maxRetries; i++) {
Response response = client.get(path.toString(), Constants.MIMETYPE_PROTOBUF);
code = response.getCode();
switch (code) {
case 200:
return true;
case 404:
return false;
case 509:
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
throw (InterruptedIOException)new InterruptedIOException().initCause(e);
}
break;
default:
throw new IOException("get request to " + path.toString() + " returned " + code);
}
}
throw new IOException("get request to " + path.toString() + " timed out");
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:38,代码来源:RemoteAdmin.java
示例12: createTable
import org.apache.hadoop.hbase.rest.Constants; //导入依赖的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");
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:39,代码来源:RemoteAdmin.java
示例13: getTableList
import org.apache.hadoop.hbase.rest.Constants; //导入依赖的package包/类
/**
* @return string representing the cluster's version
* @throws IOException
* if the endpoint does not exist, there is a timeout, or some other
* general failure mode
*/
public TableListModel getTableList() throws IOException {
StringBuilder path = new StringBuilder();
path.append('/');
if (accessToken != null) {
path.append(accessToken);
path.append('/');
}
int code = 0;
for (int i = 0; i < maxRetries; i++) {
// Response response = client.get(path.toString(),
// Constants.MIMETYPE_XML);
Response response = client.get(path.toString(),
Constants.MIMETYPE_PROTOBUF);
code = response.getCode();
switch (code) {
case 200:
TableListModel t = new TableListModel();
return (TableListModel) t.getObjectFromMessage(response.getBody());
case 404:
throw new IOException("Table list not found");
case 509:
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
throw (InterruptedIOException)new InterruptedIOException().initCause(e);
}
break;
default:
throw new IOException("get request to " + path.toString()
+ " request returned " + code);
}
}
throw new IOException("get request to " + path.toString()
+ " request timed out");
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:44,代码来源:RemoteAdmin.java
示例14: getResults
import org.apache.hadoop.hbase.rest.Constants; //导入依赖的package包/类
private Result[] getResults(String spec) throws IOException {
for (int i = 0; i < maxRetries; i++) {
Response response = client.get(spec, Constants.MIMETYPE_PROTOBUF);
int code = response.getCode();
switch (code) {
case 200:
CellSetModel model = new CellSetModel();
model.getObjectFromMessage(response.getBody());
Result[] results = buildResultFromModel(model);
if (results.length > 0) {
return results;
}
// fall through
case 404:
return new Result[0];
case 509:
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
}
break;
default:
throw new IOException("get request returned " + code);
}
}
throw new IOException("get request timed out");
}
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:29,代码来源:RemoteHTable.java
示例15: next
import org.apache.hadoop.hbase.rest.Constants; //导入依赖的package包/类
@Override
public Result[] next(int nbRows) throws IOException {
StringBuilder sb = new StringBuilder(uri);
sb.append("?n=");
sb.append(nbRows);
for (int i = 0; i < maxRetries; i++) {
Response response = client.get(sb.toString(),
Constants.MIMETYPE_PROTOBUF);
int code = response.getCode();
switch (code) {
case 200:
CellSetModel model = new CellSetModel();
model.getObjectFromMessage(response.getBody());
return buildResultFromModel(model);
case 204:
case 206:
return null;
case 509:
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) { }
break;
default:
throw new IOException("scanner.next request failed with " + code);
}
}
throw new IOException("scanner.next request timed out");
}
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:29,代码来源:RemoteHTable.java
示例16: checkAndPut
import org.apache.hadoop.hbase.rest.Constants; //导入依赖的package包/类
public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier,
byte[] value, Put put) throws IOException {
// column to check-the-value
put.add(new KeyValue(row, family, qualifier, value));
CellSetModel model = buildModelFromPut(put);
StringBuilder sb = new StringBuilder();
sb.append('/');
sb.append(Bytes.toStringBinary(name));
sb.append('/');
sb.append(Bytes.toStringBinary(put.getRow()));
sb.append("?check=put");
for (int i = 0; i < maxRetries; i++) {
Response response = client.put(sb.toString(),
Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput());
int code = response.getCode();
switch (code) {
case 200:
return true;
case 304: // NOT-MODIFIED
return false;
case 509:
try {
Thread.sleep(sleepTime);
} catch (final InterruptedException e) {
}
break;
default:
throw new IOException("checkAndPut request failed with " + code);
}
}
throw new IOException("checkAndPut request timed out");
}
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:35,代码来源:RemoteHTable.java
示例17: checkAndDelete
import org.apache.hadoop.hbase.rest.Constants; //导入依赖的package包/类
public boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier,
byte[] value, Delete delete) throws IOException {
Put put = new Put(row);
// column to check-the-value
put.add(new KeyValue(row, family, qualifier, value));
CellSetModel model = buildModelFromPut(put);
StringBuilder sb = new StringBuilder();
sb.append('/');
sb.append(Bytes.toStringBinary(name));
sb.append('/');
sb.append(Bytes.toStringBinary(row));
sb.append("?check=delete");
for (int i = 0; i < maxRetries; i++) {
Response response = client.put(sb.toString(),
Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput());
int code = response.getCode();
switch (code) {
case 200:
return true;
case 304: // NOT-MODIFIED
return false;
case 509:
try {
Thread.sleep(sleepTime);
} catch (final InterruptedException e) {
}
break;
default:
throw new IOException("checkAndDelete request failed with " + code);
}
}
throw new IOException("checkAndDelete request timed out");
}
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:35,代码来源:RemoteHTable.java
示例18: getRestVersion
import org.apache.hadoop.hbase.rest.Constants; //导入依赖的package包/类
/**
* @return string representing the rest api's version
* @throws IOEXception
* if the endpoint does not exist, there is a timeout, or some other
* general failure mode
*/
public VersionModel getRestVersion() throws IOException {
StringBuilder path = new StringBuilder();
path.append('/');
if (accessToken != null) {
path.append(accessToken);
path.append('/');
}
path.append("version/rest");
int code = 0;
for (int i = 0; i < maxRetries; i++) {
Response response = client.get(path.toString(),
Constants.MIMETYPE_PROTOBUF);
code = response.getCode();
switch (code) {
case 200:
VersionModel v = new VersionModel();
return (VersionModel) v.getObjectFromMessage(response.getBody());
case 404:
throw new IOException("REST version not found");
case 509:
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
}
break;
default:
throw new IOException("get request to " + path.toString()
+ " returned " + code);
}
}
throw new IOException("get request to " + path.toString() + " timed out");
}
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:43,代码来源:RemoteAdmin.java
示例19: getClusterStatus
import org.apache.hadoop.hbase.rest.Constants; //导入依赖的package包/类
/**
* @return string representing the cluster's version
* @throws IOEXception if the endpoint does not exist, there is a timeout, or some other general failure mode
*/
public StorageClusterStatusModel getClusterStatus() throws IOException {
StringBuilder path = new StringBuilder();
path.append('/');
if (accessToken !=null) {
path.append(accessToken);
path.append('/');
}
path.append("status/cluster");
int code = 0;
for (int i = 0; i < maxRetries; i++) {
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 {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
}
break;
default:
throw new IOException("get request to " + path + " returned " + code);
}
}
throw new IOException("get request to " + path + " timed out");
}
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:40,代码来源:RemoteAdmin.java
示例20: isTableAvailable
import org.apache.hadoop.hbase.rest.Constants; //导入依赖的package包/类
/**
* @param tableName name of table to check
* @return true if all regions of the table are available
* @throws IOException if a remote or network exception occurs
*/
public boolean isTableAvailable(byte[] tableName) throws IOException {
StringBuilder path = new StringBuilder();
path.append('/');
if (accessToken != null) {
path.append(accessToken);
path.append('/');
}
path.append(Bytes.toStringBinary(tableName));
path.append('/');
path.append("exists");
int code = 0;
for (int i = 0; i < maxRetries; i++) {
Response response = client.get(path.toString(), Constants.MIMETYPE_PROTOBUF);
code = response.getCode();
switch (code) {
case 200:
return true;
case 404:
return false;
case 509:
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) { }
break;
default:
throw new IOException("get request to " + path.toString() + " returned " + code);
}
}
throw new IOException("get request to " + path.toString() + " timed out");
}
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:36,代码来源:RemoteAdmin.java
注:本文中的org.apache.hadoop.hbase.rest.Constants类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论