org.apache.hadoop.hbase.HConstants.OperationStatusCode Java Examples

The following examples show how to use org.apache.hadoop.hbase.HConstants.OperationStatusCode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultVisibilityLabelServiceImpl.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Adds the mutations to labels region and set the results to the finalOpStatus. finalOpStatus
 * might have some entries in it where the OpStatus is FAILURE. We will leave those and set in
 * others in the order.
 * @param mutations
 * @param finalOpStatus
 * @return whether we need a ZK update or not.
 */
private boolean mutateLabelsRegion(List<Mutation> mutations, OperationStatus[] finalOpStatus)
    throws IOException {
  OperationStatus[] opStatus = this.labelsRegion.batchMutate(mutations
    .toArray(new Mutation[mutations.size()]));
  int i = 0;
  boolean updateZk = false;
  for (OperationStatus status : opStatus) {
    // Update the zk when atleast one of the mutation was added successfully.
    updateZk = updateZk || (status.getOperationStatusCode() == OperationStatusCode.SUCCESS);
    for (; i < finalOpStatus.length; i++) {
      if (finalOpStatus[i] == null) {
        finalOpStatus[i] = status;
        break;
      }
    }
  }
  return updateZk;
}
 
Example #2
Source File: TestParallelPut.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
  byte[] value = new byte[100];
  Put[]  in = new Put[1];

  // iterate for the specified number of operations
  for (int i=0; i<numOps; i++) {
    // generate random bytes
    rand.nextBytes(value);

    // put the randombytes and verify that we can read it. This is one
    // way of ensuring that rwcc manipulation in HRegion.put() is fine.
    Put put = new Put(rowkey);
    put.addColumn(fam1, qual1, value);
    in[0] = put;
    try {
      OperationStatus[] ret = region.batchMutate(in);
      assertEquals(1, ret.length);
      assertEquals(OperationStatusCode.SUCCESS, ret[0].getOperationStatusCode());
      assertGet(this.region, rowkey, fam1, qual1, value);
    } catch (IOException e) {
      assertTrue("Thread id " + threadNumber + " operation " + i + " failed.",
                 false);
    }
  }
}
 
Example #3
Source File: ExpAsStringVisibilityLabelServiceImpl.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public OperationStatus[] addLabels(List<byte[]> labels) throws IOException {
  // Not doing specific label add. We will just add labels in Mutation
  // visibility expression as it
  // is along with every cell.
  OperationStatus[] status = new OperationStatus[labels.size()];
  for (int i = 0; i < labels.size(); i++) {
    status[i] = new OperationStatus(OperationStatusCode.SUCCESS);
  }
  return status;
}
 
Example #4
Source File: OperationStatus.java    From hbase with Apache License 2.0 4 votes vote down vote up
public OperationStatus(OperationStatusCode code) {
  this(code, "");
}
 
Example #5
Source File: OperationStatus.java    From hbase with Apache License 2.0 4 votes vote down vote up
public OperationStatus(OperationStatusCode code, String exceptionMsg) {
  this.code = code;
  this.exceptionMsg = exceptionMsg;
}
 
Example #6
Source File: OperationStatus.java    From hbase with Apache License 2.0 4 votes vote down vote up
public OperationStatus(OperationStatusCode code, Exception e) {
  this.code = code;
  this.exceptionMsg = (e == null) ? "" : e.getClass().getName() + ": " + e.getMessage();
}
 
Example #7
Source File: OperationStatus.java    From hbase with Apache License 2.0 4 votes vote down vote up
/**
 * @return OperationStatusCode
 */
public OperationStatusCode getOperationStatusCode() {
  return code;
}