Java 类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");
}
项目: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, 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");
}
项目: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, 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");
}
项目: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(), 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");
}
项目:ditb    文件:RemoteAdmin.java   
/**
 * @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");
}
项目: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, 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");
}
项目:LCIndex-HBase-0.94.16    文件:RemoteHTable.java   
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");
}
项目:LCIndex-HBase-0.94.16    文件: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) {
      }
      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, 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");
}
项目: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(), 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");
}
项目:LCIndex-HBase-0.94.16    文件:RemoteAdmin.java   
/**
 * @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) {
      }
      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, 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");
}
项目:HIndex    文件:RemoteHTable.java   
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");
}
项目:HIndex    文件: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) {
      }
      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, 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");
}
项目: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(), 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");
}
项目:HIndex    文件:RemoteAdmin.java   
/**
 * @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) {
      }
      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");
}