微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

org.apache.hadoop.hbase.rest.Constants的实例源码

项目:LCIndex-HBase-0.94.16    文件RemoteHTable.java   
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");
}
项目:HIndex    文件RemoteHTable.java   
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");
}
项目:IRIndex    文件RemoteHTable.java   
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");
}
项目:hbase    文件TestXmlParsing.java   
@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));
  }
}
项目:c5    文件RemoteHTable.java   
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");
}
项目:HBase-Research    文件RemoteHTable.java   
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");
}
项目:hbase-0.94.8-qod    文件RemoteHTable.java   
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");
}
项目:DominoHBase    文件RemoteHTable.java   
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");
}
项目:hindex    文件RemoteHTable.java   
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");
}
项目:ditb    文件RemoteHTable.java   
@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");
}
项目:ditb    文件RemoteHTable.java   
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");
}
项目:ditb    文件RemoteHTable.java   
@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");
}
项目:ditb    文件RemoteHTable.java   
@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");
}
项目:ditb    文件RemoteHTable.java   
@Override
public boolean checkAndDelete(byte[] row,Delete delete) throws IOException {
  Put put = new Put(row);
  put.setFamilyCellMap(delete.getFamilyCellMap());
  // column to check-the-value
  put.add(new keyvalue(row,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(),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");
}
项目:ditb    文件RemoteAdmin.java   
/**
 * @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");
}
项目:ditb    文件RemoteAdmin.java   
/**
 * @return string representing the cluster's version
 * @throws IOException if the endpoint does not exist,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");
}
项目:ditb    文件RemoteAdmin.java   
/**
 * @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");
}
项目:ditb    文件RemoteAdmin.java   
/**
 * 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(),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");
}
项目:ditb    文件RemoteAdmin.java   
/**
 * @return string representing the cluster's version
 * @throws IOException
 *           if the endpoint does not exist,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");
}
项目:LCIndex-HBase-0.94.16    文件RemoteHTable.java   
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");
}
项目:LCIndex-HBase-0.94.16    文件RemoteHTable.java   
@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");
}
项目:LCIndex-HBase-0.94.16    文件RemoteHTable.java   
public boolean checkAndPut(byte[] row,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");
}
项目:LCIndex-HBase-0.94.16    文件RemoteHTable.java   
public boolean checkAndDelete(byte[] row,Delete delete) throws IOException {
  Put put = new Put(row);
  // column to check-the-value
  put.add(new keyvalue(row,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");
}
项目:LCIndex-HBase-0.94.16    文件RemoteAdmin.java   
/**
 * @return string representing the rest api's version
 * @throws IOEXception
 *           if the endpoint does not exist,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");
}
项目:LCIndex-HBase-0.94.16    文件RemoteAdmin.java   
/**
 * @return string representing the cluster's version
 * @throws IOEXception if the endpoint does not exist,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");
}
项目:LCIndex-HBase-0.94.16    文件RemoteAdmin.java   
/**
 * @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");
}
项目:LCIndex-HBase-0.94.16    文件RemoteAdmin.java   
/**
 * 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(),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");
}
项目:LCIndex-HBase-0.94.16    文件RemoteAdmin.java   
/**
 * @return string representing the cluster's version
 * @throws IOEXception
 *           if the endpoint does not exist,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) {
      }
      break;
    default:
      throw new IOException("get request to " + path.toString()
          + " request returned " + code);
    }
  }
  throw new IOException("get request to " + path.toString()
      + " request timed out");
}
项目:HIndex    文件RemoteHTable.java   
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");
}
项目:HIndex    文件RemoteHTable.java   
@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");
}
项目:HIndex    文件RemoteHTable.java   
public boolean checkAndPut(byte[] row,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");
}
项目:HIndex    文件RemoteHTable.java   
public boolean checkAndDelete(byte[] row,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");
}
项目:HIndex    文件RemoteAdmin.java   
/**
 * @return string representing the rest api's version
 * @throws IOEXception
 *           if the endpoint does not exist,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");
}
项目:HIndex    文件RemoteAdmin.java   
/**
 * @return string representing the cluster's version
 * @throws IOEXception if the endpoint does not exist,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");
}
项目:HIndex    文件RemoteAdmin.java   
/**
 * @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");
}
项目:HIndex    文件RemoteAdmin.java   
/**
 * 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(),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");
}
项目:HIndex    文件RemoteAdmin.java   
/**
 * @return string representing the cluster's version
 * @throws IOEXception
 *           if the endpoint does not exist,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) {
      }
      break;
    default:
      throw new IOException("get request to " + path.toString()
          + " request returned " + code);
    }
  }
  throw new IOException("get request to " + path.toString()
      + " request timed out");
}
项目:IRIndex    文件RemoteHTable.java   
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");
}
项目:IRIndex    文件RemoteHTable.java   
@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");
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。