Java 类org.apache.hadoop.hbase.client.RowMutations 实例源码

项目:ditb    文件:HBaseFsck.java   
/**
 * Reset the split parent region info in meta table
 */
private void resetSplitParent(HbckInfo hi) throws IOException {
  RowMutations mutations = new RowMutations(hi.metaEntry.getRegionName());
  Delete d = new Delete(hi.metaEntry.getRegionName());
  d.deleteColumn(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER);
  d.deleteColumn(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER);
  mutations.add(d);

  HRegionInfo hri = new HRegionInfo(hi.metaEntry);
  hri.setOffline(false);
  hri.setSplit(false);
  Put p = MetaTableAccessor.makePutFromRegionInfo(hri);
  mutations.add(p);

  meta.mutateRow(mutations);
  LOG.info("Reset split parent " + hi.metaEntry.getRegionNameAsString() + " in META" );
}
项目:ditb    文件:RequestConverter.java   
/**
 * Create a protocol buffer MultiRequest for row mutations.
 * Does not propagate Action absolute position.  Does not set atomic action on the created
 * RegionAtomic.  Caller should do that if wanted.
 * @param regionName
 * @param rowMutations
 * @return a data-laden RegionMutation.Builder
 * @throws IOException
 */
public static RegionAction.Builder buildRegionAction(final byte [] regionName,
    final RowMutations rowMutations)
throws IOException {
  RegionAction.Builder builder =
    getRegionActionBuilderWithRegion(RegionAction.newBuilder(), regionName);
  ClientProtos.Action.Builder actionBuilder = ClientProtos.Action.newBuilder();
  MutationProto.Builder mutationBuilder = MutationProto.newBuilder();
  for (Mutation mutation: rowMutations.getMutations()) {
    MutationType mutateType = null;
    if (mutation instanceof Put) {
      mutateType = MutationType.PUT;
    } else if (mutation instanceof Delete) {
      mutateType = MutationType.DELETE;
    } else {
      throw new DoNotRetryIOException("RowMutations supports only put and delete, not " +
        mutation.getClass().getName());
    }
    mutationBuilder.clear();
    MutationProto mp = ProtobufUtil.toMutation(mutateType, mutation, mutationBuilder);
    actionBuilder.clear();
    actionBuilder.setMutation(mp);
    builder.addAction(actionBuilder.build());
  }
  return builder;
}
项目:ditb    文件:RequestConverter.java   
/**
 * Create a protocol buffer MultiRequest for row mutations that does not hold data.  Data/Cells
 * are carried outside of protobuf.  Return references to the Cells in <code>cells</code> param.
  * Does not propagate Action absolute position.  Does not set atomic action on the created
 * RegionAtomic.  Caller should do that if wanted.
 * @param regionName
 * @param rowMutations
 * @param cells Return in here a list of Cells as CellIterable.
 * @return a region mutation minus data
 * @throws IOException
 */
public static RegionAction.Builder buildNoDataRegionAction(final byte[] regionName,
    final RowMutations rowMutations, final List<CellScannable> cells,
    final RegionAction.Builder regionActionBuilder,
    final ClientProtos.Action.Builder actionBuilder,
    final MutationProto.Builder mutationBuilder)
throws IOException {
  for (Mutation mutation: rowMutations.getMutations()) {
    MutationType type = null;
    if (mutation instanceof Put) {
      type = MutationType.PUT;
    } else if (mutation instanceof Delete) {
      type = MutationType.DELETE;
    } else {
      throw new DoNotRetryIOException("RowMutations supports only put and delete, not " +
        mutation.getClass().getName());
    }
    mutationBuilder.clear();
    MutationProto mp = ProtobufUtil.toMutationNoData(type, mutation, mutationBuilder);
    cells.add(mutation);
    actionBuilder.clear();
    regionActionBuilder.addAction(actionBuilder.setMutation(mp).build());
  }
  return regionActionBuilder;
}
项目:ColumnManagerForHBase    文件:MTable.java   
@Override
public void mutateRow(RowMutations rm) throws IOException {
  // ColumnManager validation
  if (includedInRepositoryProcessing
          && mTableDescriptor.hasColDescriptorWithColDefinitionsEnforced()) {
    repository.validateColumns(mTableDescriptor, rm);
  }
  // Standard HBase processing (with aliasing, if necessary)
  if (includedInRepositoryProcessing
          && mTableDescriptor.hasColDescriptorWithColAliasesEnabled()) {
    wrappedTable.mutateRow(repository.convertQualifiersToAliases(mTableDescriptor, rm));
  } else {
    wrappedTable.mutateRow(rm);
  }
  // ColumnManager auditing
  if (includedInRepositoryProcessing) {
    repository.putColumnAuditorSchemaEntities(mTableDescriptor, rm);
  }
}
项目:ColumnManagerForHBase    文件:MTable.java   
@Override
public boolean checkAndMutate(byte[] rowId, byte[] colFamily, byte[] colQualifier,
        CompareOp co, byte[] colValue, RowMutations rm)
        throws IOException {
  // ColumnManager validation
  if (includedInRepositoryProcessing
          && mTableDescriptor.hasColDescriptorWithColDefinitionsEnforced()) {
    repository.validateColumns(mTableDescriptor, rm);
  }
  // Standard HBase processing (with aliasing, if necessary)
  boolean mutationsPerformed;
  if (includedInRepositoryProcessing
          && mTableDescriptor.hasColDescriptorWithColAliasesEnabled()) {
    mutationsPerformed = wrappedTable.checkAndMutate(rowId, colFamily,
            repository.getAlias(mTableDescriptor, colFamily, colQualifier), co, colValue,
            repository.convertQualifiersToAliases(mTableDescriptor, rm));
  } else {
    mutationsPerformed
            = wrappedTable.checkAndMutate(rowId, colFamily, colQualifier, co, colValue, rm);
  }
  // ColumnManager auditing
  if (mutationsPerformed && includedInRepositoryProcessing) {
    repository.putColumnAuditorSchemaEntities(mTableDescriptor, rm);
  }
  return mutationsPerformed;
}
项目:ColumnManagerForHBase    文件:Repository.java   
NavigableMap<byte[], NavigableMap<byte[], byte[]>> getFamilyQualifierToAliasMap(
        MTableDescriptor mTableDescriptor, Mutation mutation)
        throws IOException {
  NavigableMap<byte[], NavigableMap<byte[], byte[]>> familyQualifierToAliasMap
          = new TreeMap<>(Bytes.BYTES_COMPARATOR);
  Class<?> mutationClass = mutation.getClass();
  if (Append.class.isAssignableFrom(mutationClass)) {
    familyQualifierToAliasMap
            = getFamilyQualifierToAliasMap(mTableDescriptor, (Append)mutation);
  } else if (Increment.class.isAssignableFrom(mutationClass)) {
    familyQualifierToAliasMap
            = getFamilyQualifierToAliasMap(mTableDescriptor, (Increment)mutation);
  } else if (Delete.class.isAssignableFrom(mutationClass)
          || Put.class.isAssignableFrom(mutationClass)
          || RowMutations.class.isAssignableFrom(mutationClass)) {
    // ignore: familyQualifierToAliasMap not passed to alias-processing for these mutation-types
  }
  return familyQualifierToAliasMap;
}
项目:ColumnManagerForHBase    文件:Repository.java   
Row convertQualifiersToAliases(MTableDescriptor mTableDescriptor, final Row originalRow,
        NavigableMap<byte[], NavigableMap<byte[], byte[]>> familyQualifierToAliasMap,
        int intForUniqueSignature)
        throws IOException {
  // Append, Delete, Get, Increment, Mutation, Put, RowMutations
  Class<?> originalRowClass = originalRow.getClass();
  if (Append.class.isAssignableFrom(originalRowClass)) {
    return convertQualifiersToAliases(
            mTableDescriptor, (Append)originalRow, familyQualifierToAliasMap);
  } else if (Delete.class.isAssignableFrom(originalRowClass)) {
    return convertQualifiersToAliases(mTableDescriptor, (Delete)originalRow);
  } else if (Get.class.isAssignableFrom(originalRowClass)) {
    return convertQualifiersToAliases(
            mTableDescriptor, (Get)originalRow, familyQualifierToAliasMap);
  } else if (Increment.class.isAssignableFrom(originalRowClass)) {
    return convertQualifiersToAliases(
            mTableDescriptor, (Increment)originalRow, familyQualifierToAliasMap);
  } else if (Put.class.isAssignableFrom(originalRowClass)) {
    return convertQualifiersToAliases(mTableDescriptor, (Put)originalRow);
  } else if (RowMutations.class.isAssignableFrom(originalRowClass)) {
    return convertQualifiersToAliases(mTableDescriptor, (RowMutations)originalRow);
  }
  return null;
}
项目:ColumnManagerForHBase    文件:Repository.java   
RowMutations convertQualifiersToAliases(MTableDescriptor mTableDescriptor,
        final RowMutations originalRowMutations)
        throws IOException{
  RowMutations modifiedRowMutations = new RowMutations(originalRowMutations.getRow());
  for (Mutation originalMutation : originalRowMutations.getMutations()) {
    Class<?> mutationClass = originalMutation.getClass();
    if (Put.class.isAssignableFrom(mutationClass)) {
      modifiedRowMutations.add(
              convertQualifiersToAliases(mTableDescriptor, (Put)originalMutation));
    } else if (Delete.class.isAssignableFrom(mutationClass)) {
      modifiedRowMutations.add(
              convertQualifiersToAliases(mTableDescriptor, (Delete)originalMutation));
    }
  }
  return modifiedRowMutations;
}
项目:LCIndex-HBase-0.94.16    文件:HBaseFsck.java   
/**
 * Reset the split parent region info in meta table
 */
private void resetSplitParent(HbckInfo hi) throws IOException {
  RowMutations mutations = new RowMutations(hi.metaEntry.getRegionName());
  Delete d = new Delete(hi.metaEntry.getRegionName());
  d.deleteColumn(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER);
  d.deleteColumn(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER);
  mutations.add(d);

  Put p = new Put(hi.metaEntry.getRegionName());
  HRegionInfo hri = new HRegionInfo(hi.metaEntry);
  hri.setOffline(false);
  hri.setSplit(false);
  p.add(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER,
    Writables.getBytes(hri));
  mutations.add(p);

  meta.mutateRow(mutations);
  meta.flushCommits();
  LOG.info("Reset split parent " + hi.metaEntry.getRegionNameAsString() + " in META" );
}
项目:LCIndex-HBase-0.94.16    文件:HRegionServer.java   
@Override
public void mutateRow(byte[] regionName, RowMutations rm) throws IOException {
  checkOpen();
  if (regionName == null) {
    throw new IOException("Invalid arguments to mutateRow " + "regionName is null");
  }
  requestCount.incrementAndGet();
  try {
    HRegion region = getRegion(regionName);
    if (!region.getRegionInfo().isMetaTable()) {
      this.cacheFlusher.reclaimMemStoreMemory();
    }
    region.mutateRow(rm);
  } catch (IOException e) {
    checkFileSystem();
    throw e;
  }
}
项目:LCIndex-HBase-0.94.16    文件:TestHRegion.java   
public void testmutateRowsWithLocks_wrongCF() throws IOException {
  this.region = initHRegion(tableName, this.getName(), conf, fam1, fam2);
  try {
    Put put = new Put(row2);
    put.add(fam3, qual1, value1);
    RowMutations rm = new RowMutations(row2);
    rm.add(put);
    try {
      region.mutateRow(rm);
      fail();
    } catch (DoNotRetryIOException expected) {
      // expected exception.
      LOG.debug("Caught expected exception: " + expected.getMessage());
    }
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}
项目:cloud-bigtable-client    文件:BigtableTable.java   
@Override
public void mutateRow(RowMutations rm) throws IOException {
  LOG.trace("mutateRow(RowMutation)");
  MutateRowRequest.Builder requestBuilder = rowMutationsAdapter.adapt(rm);
  metadataSetter.setMetadata(requestBuilder);
  try {
    client.mutateRow(requestBuilder.build());
  } catch (Throwable throwable) {
    throw new IOException(
        makeGenericExceptionMessage(
            "mutateRow",
            options.getProjectId(),
            tableName.getQualifierAsString(),
            rm.getRow()),
        throwable);
  }
}
项目:cloud-bigtable-client    文件:BatchExecutor.java   
ListenableFuture<? extends GeneratedMessage> issueRequest(Row row) {
  if (row instanceof Put) {
    return issuePutRequest((Put) row);
  } else if (row instanceof Delete) {
    return issueDeleteRequest((Delete) row);
  } else if (row instanceof Append) {
    return issueAppendRequest((Append) row);
  } else if (row instanceof Increment) {
    return issueIncrementRequest((Increment) row);
  } else if (row instanceof Get) {
    return issueGetRequest((Get) row);
  } else if (row instanceof RowMutations) {
    return issueRowMutationsRequest((RowMutations) row);
  }

  LOG.error("Encountered unknown action type %s", row.getClass());
  return Futures.immediateFailedFuture(
      new IllegalArgumentException("Encountered unknown action type: " + row.getClass()));
}
项目:pbase    文件:HBaseFsck.java   
/**
 * Reset the split parent region info in meta table
 */
private void resetSplitParent(HbckInfo hi) throws IOException {
  RowMutations mutations = new RowMutations(hi.metaEntry.getRegionName());
  Delete d = new Delete(hi.metaEntry.getRegionName());
  d.deleteColumn(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER);
  d.deleteColumn(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER);
  mutations.add(d);

  HRegionInfo hri = new HRegionInfo(hi.metaEntry);
  hri.setOffline(false);
  hri.setSplit(false);
  Put p = MetaTableAccessor.makePutFromRegionInfo(hri);
  mutations.add(p);

  meta.mutateRow(mutations);
  LOG.info("Reset split parent " + hi.metaEntry.getRegionNameAsString() + " in META" );
}
项目:pbase    文件:RequestConverter.java   
/**
 * Create a protocol buffer MultiRequest for row mutations.
 * Does not propagate Action absolute position.  Does not set atomic action on the created
 * RegionAtomic.  Caller should do that if wanted.
 * @param regionName
 * @param rowMutations
 * @return a data-laden RegionMutation.Builder
 * @throws IOException
 */
public static RegionAction.Builder buildRegionAction(final byte [] regionName,
    final RowMutations rowMutations)
throws IOException {
  RegionAction.Builder builder =
    getRegionActionBuilderWithRegion(RegionAction.newBuilder(), regionName);
  ClientProtos.Action.Builder actionBuilder = ClientProtos.Action.newBuilder();
  MutationProto.Builder mutationBuilder = MutationProto.newBuilder();
  for (Mutation mutation: rowMutations.getMutations()) {
    MutationType mutateType = null;
    if (mutation instanceof Put) {
      mutateType = MutationType.PUT;
    } else if (mutation instanceof Delete) {
      mutateType = MutationType.DELETE;
    } else {
      throw new DoNotRetryIOException("RowMutations supports only put and delete, not " +
        mutation.getClass().getName());
    }
    mutationBuilder.clear();
    MutationProto mp = ProtobufUtil.toMutation(mutateType, mutation, mutationBuilder);
    actionBuilder.clear();
    actionBuilder.setMutation(mp);
    builder.addAction(actionBuilder.build());
  }
  return builder;
}
项目:pbase    文件:RequestConverter.java   
/**
 * Create a protocol buffer MultiRequest for row mutations that does not hold data.  Data/Cells
 * are carried outside of protobuf.  Return references to the Cells in <code>cells</code> param.
  * Does not propagate Action absolute position.  Does not set atomic action on the created
 * RegionAtomic.  Caller should do that if wanted.
 * @param regionName
 * @param rowMutations
 * @param cells Return in here a list of Cells as CellIterable.
 * @return a region mutation minus data
 * @throws IOException
 */
public static RegionAction.Builder buildNoDataRegionAction(final byte[] regionName,
    final RowMutations rowMutations, final List<CellScannable> cells,
    final RegionAction.Builder regionActionBuilder,
    final ClientProtos.Action.Builder actionBuilder,
    final MutationProto.Builder mutationBuilder)
throws IOException {
  for (Mutation mutation: rowMutations.getMutations()) {
    MutationType type = null;
    if (mutation instanceof Put) {
      type = MutationType.PUT;
    } else if (mutation instanceof Delete) {
      type = MutationType.DELETE;
    } else {
      throw new DoNotRetryIOException("RowMutations supports only put and delete, not " +
        mutation.getClass().getName());
    }
    mutationBuilder.clear();
    MutationProto mp = ProtobufUtil.toMutationNoData(type, mutation, mutationBuilder);
    cells.add(mutation);
    actionBuilder.clear();
    regionActionBuilder.addAction(actionBuilder.setMutation(mp).build());
  }
  return regionActionBuilder;
}
项目:HIndex    文件:HBaseFsck.java   
/**
 * Reset the split parent region info in meta table
 */
private void resetSplitParent(HbckInfo hi) throws IOException {
  RowMutations mutations = new RowMutations(hi.metaEntry.getRegionName());
  Delete d = new Delete(hi.metaEntry.getRegionName());
  d.deleteColumn(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER);
  d.deleteColumn(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER);
  mutations.add(d);

  HRegionInfo hri = new HRegionInfo(hi.metaEntry);
  hri.setOffline(false);
  hri.setSplit(false);
  Put p = MetaEditor.makePutFromRegionInfo(hri);
  mutations.add(p);

  meta.mutateRow(mutations);
  meta.flushCommits();
  LOG.info("Reset split parent " + hi.metaEntry.getRegionNameAsString() + " in META" );
}
项目:HIndex    文件:RequestConverter.java   
/**
 * Create a protocol buffer MultiRequest for row mutations.
 * Does not propagate Action absolute position.  Does not set atomic action on the created
 * RegionAtomic.  Caller should do that if wanted.
 * @param regionName
 * @param rowMutations
 * @return a data-laden RegionMutation.Builder
 * @throws IOException
 */
public static RegionAction.Builder buildRegionAction(final byte [] regionName,
    final RowMutations rowMutations)
throws IOException {
  RegionAction.Builder builder =
    getRegionActionBuilderWithRegion(RegionAction.newBuilder(), regionName);
  ClientProtos.Action.Builder actionBuilder = ClientProtos.Action.newBuilder();
  MutationProto.Builder mutationBuilder = MutationProto.newBuilder();
  for (Mutation mutation: rowMutations.getMutations()) {
    MutationType mutateType = null;
    if (mutation instanceof Put) {
      mutateType = MutationType.PUT;
    } else if (mutation instanceof Delete) {
      mutateType = MutationType.DELETE;
    } else {
      throw new DoNotRetryIOException("RowMutations supports only put and delete, not " +
        mutation.getClass().getName());
    }
    mutationBuilder.clear();
    MutationProto mp = ProtobufUtil.toMutation(mutateType, mutation, mutationBuilder);
    actionBuilder.clear();
    actionBuilder.setMutation(mp);
    builder.addAction(actionBuilder.build());
  }
  return builder;
}
项目:HIndex    文件:RequestConverter.java   
/**
 * Create a protocol buffer MultiRequest for row mutations that does not hold data.  Data/Cells
 * are carried outside of protobuf.  Return references to the Cells in <code>cells</code> param.
  * Does not propagate Action absolute position.  Does not set atomic action on the created
 * RegionAtomic.  Caller should do that if wanted.
 * @param regionName
 * @param rowMutations
 * @param cells Return in here a list of Cells as CellIterable.
 * @return a region mutation minus data
 * @throws IOException
 */
public static RegionAction.Builder buildNoDataRegionAction(final byte[] regionName,
    final RowMutations rowMutations, final List<CellScannable> cells,
    final RegionAction.Builder regionActionBuilder,
    final ClientProtos.Action.Builder actionBuilder,
    final MutationProto.Builder mutationBuilder)
throws IOException {
  for (Mutation mutation: rowMutations.getMutations()) {
    MutationType type = null;
    if (mutation instanceof Put) {
      type = MutationType.PUT;
    } else if (mutation instanceof Delete) {
      type = MutationType.DELETE;
    } else {
      throw new DoNotRetryIOException("RowMutations supports only put and delete, not " +
        mutation.getClass().getName());
    }
    mutationBuilder.clear();
    MutationProto mp = ProtobufUtil.toMutationNoData(type, mutation, mutationBuilder);
    cells.add(mutation);
    actionBuilder.clear();
    regionActionBuilder.addAction(actionBuilder.setMutation(mp).build());
  }
  return regionActionBuilder;
}
项目:IRIndex    文件:HBaseFsck.java   
/**
 * Reset the split parent region info in meta table
 */
private void resetSplitParent(HbckInfo hi) throws IOException {
  RowMutations mutations = new RowMutations(hi.metaEntry.getRegionName());
  Delete d = new Delete(hi.metaEntry.getRegionName());
  d.deleteColumn(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER);
  d.deleteColumn(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER);
  mutations.add(d);

  Put p = new Put(hi.metaEntry.getRegionName());
  HRegionInfo hri = new HRegionInfo(hi.metaEntry);
  hri.setOffline(false);
  hri.setSplit(false);
  p.add(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER,
    Writables.getBytes(hri));
  mutations.add(p);

  meta.mutateRow(mutations);
  meta.flushCommits();
  LOG.info("Reset split parent " + hi.metaEntry.getRegionNameAsString() + " in META" );
}
项目:IRIndex    文件:HRegionServer.java   
@Override
public void mutateRow(byte[] regionName, RowMutations rm)
    throws IOException {
  checkOpen();
  if (regionName == null) {
    throw new IOException("Invalid arguments to mutateRow " +
    "regionName is null");
  }
  requestCount.incrementAndGet();
  try {
    HRegion region = getRegion(regionName);
    if (!region.getRegionInfo().isMetaTable()) {
      this.cacheFlusher.reclaimMemStoreMemory();
    }
    region.mutateRow(rm);
  } catch (IOException e) {
    checkFileSystem();
    throw e;
  }
}
项目:IRIndex    文件:TestHRegion.java   
public void testmutateRowsWithLocks_wrongCF() throws IOException {
  this.region = initHRegion(tableName, this.getName(), conf, fam1, fam2);
  try {
    Put put = new Put(row2);
    put.add(fam3, qual1, value1);
    RowMutations rm = new RowMutations(row2);
    rm.add(put);
    try {
      region.mutateRow(rm);
      fail();
    } catch (DoNotRetryIOException expected) {
      // expected exception.
      LOG.debug("Caught expected exception: " + expected.getMessage());
    }
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}
项目:hbase    文件:HBaseFsck.java   
/**
 * Reset the split parent region info in meta table
 */
private void resetSplitParent(HbckInfo hi) throws IOException {
  RowMutations mutations = new RowMutations(hi.metaEntry.getRegionName());
  Delete d = new Delete(hi.metaEntry.getRegionName());
  d.addColumn(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER);
  d.addColumn(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER);
  mutations.add(d);

  RegionInfo hri = RegionInfoBuilder.newBuilder(hi.metaEntry)
      .setOffline(false)
      .setSplit(false)
      .build();
  Put p = MetaTableAccessor.makePutFromRegionInfo(hri);
  mutations.add(p);

  meta.mutateRow(mutations);
  LOG.info("Reset split parent " + hi.metaEntry.getRegionNameAsString() + " in META" );
}
项目:hbase    文件:TestHRegion.java   
@Test
public void testMutateRow_WriteRequestCount() throws Exception {
  byte[] row1 = Bytes.toBytes("row1");
  byte[] fam1 = Bytes.toBytes("fam1");
  byte[] qf1 = Bytes.toBytes("qualifier");
  byte[] val1 = Bytes.toBytes("value1");

  RowMutations rm = new RowMutations(row1);
  Put put = new Put(row1);
  put.addColumn(fam1, qf1, val1);
  rm.add(put);

  this.region = initHRegion(tableName, method, CONF, fam1);
  try {
    long wrcBeforeMutate = this.region.writeRequestsCount.longValue();
    this.region.mutateRow(rm);
    long wrcAfterMutate = this.region.writeRequestsCount.longValue();
    Assert.assertEquals(wrcBeforeMutate + rm.getMutations().size(), wrcAfterMutate);
  } finally {
    HBaseTestingUtility.closeRegionAndWAL(this.region);
    this.region = null;
  }
}
项目:hbase    文件:RequestConverter.java   
/**
 * Create a protocol buffer MultiRequest for row mutations.
 * Does not propagate Action absolute position.  Does not set atomic action on the created
 * RegionAtomic.  Caller should do that if wanted.
 * @param regionName
 * @param rowMutations
 * @return a data-laden RegionMutation.Builder
 * @throws IOException
 */
public static RegionAction.Builder buildRegionAction(final byte [] regionName,
    final RowMutations rowMutations)
throws IOException {
  RegionAction.Builder builder =
    getRegionActionBuilderWithRegion(RegionAction.newBuilder(), regionName);
  ClientProtos.Action.Builder actionBuilder = ClientProtos.Action.newBuilder();
  MutationProto.Builder mutationBuilder = MutationProto.newBuilder();
  for (Mutation mutation: rowMutations.getMutations()) {
    MutationType mutateType = null;
    if (mutation instanceof Put) {
      mutateType = MutationType.PUT;
    } else if (mutation instanceof Delete) {
      mutateType = MutationType.DELETE;
    } else {
      throw new DoNotRetryIOException("RowMutations supports only put and delete, not " +
        mutation.getClass().getName());
    }
    mutationBuilder.clear();
    MutationProto mp = ProtobufUtil.toMutation(mutateType, mutation, mutationBuilder);
    actionBuilder.clear();
    actionBuilder.setMutation(mp);
    builder.addAction(actionBuilder.build());
  }
  return builder;
}
项目:hbase    文件:RequestConverter.java   
/**
 * Create a protocol buffer MultiRequest for row mutations that does not hold data.  Data/Cells
 * are carried outside of protobuf.  Return references to the Cells in <code>cells</code> param.
  * Does not propagate Action absolute position.  Does not set atomic action on the created
 * RegionAtomic.  Caller should do that if wanted.
 * @param regionName
 * @param rowMutations
 * @param cells Return in here a list of Cells as CellIterable.
 * @return a region mutation minus data
 * @throws IOException
 */
public static RegionAction.Builder buildNoDataRegionAction(final byte[] regionName,
    final RowMutations rowMutations, final List<CellScannable> cells,
    final RegionAction.Builder regionActionBuilder,
    final ClientProtos.Action.Builder actionBuilder,
    final MutationProto.Builder mutationBuilder)
throws IOException {
  for (Mutation mutation: rowMutations.getMutations()) {
    MutationType type = null;
    if (mutation instanceof Put) {
      type = MutationType.PUT;
    } else if (mutation instanceof Delete) {
      type = MutationType.DELETE;
    } else {
      throw new DoNotRetryIOException("RowMutations supports only put and delete, not " +
        mutation.getClass().getName());
    }
    mutationBuilder.clear();
    MutationProto mp = ProtobufUtil.toMutationNoData(type, mutation, mutationBuilder);
    cells.add(mutation);
    actionBuilder.clear();
    regionActionBuilder.addAction(actionBuilder.setMutation(mp).build());
  }
  return regionActionBuilder;
}
项目:PyroDB    文件:HBaseFsck.java   
/**
 * Reset the split parent region info in meta table
 */
private void resetSplitParent(HbckInfo hi) throws IOException {
  RowMutations mutations = new RowMutations(hi.metaEntry.getRegionName());
  Delete d = new Delete(hi.metaEntry.getRegionName());
  d.deleteColumn(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER);
  d.deleteColumn(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER);
  mutations.add(d);

  HRegionInfo hri = new HRegionInfo(hi.metaEntry);
  hri.setOffline(false);
  hri.setSplit(false);
  Put p = MetaEditor.makePutFromRegionInfo(hri);
  mutations.add(p);

  meta.mutateRow(mutations);
  meta.flushCommits();
  LOG.info("Reset split parent " + hi.metaEntry.getRegionNameAsString() + " in META" );
}
项目:PyroDB    文件:RequestConverter.java   
/**
 * Create a protocol buffer MultiRequest for row mutations.
 * Does not propagate Action absolute position.  Does not set atomic action on the created
 * RegionAtomic.  Caller should do that if wanted.
 * @param regionName
 * @param rowMutations
 * @return a data-laden RegionMutation.Builder
 * @throws IOException
 */
public static RegionAction.Builder buildRegionAction(final byte [] regionName,
    final RowMutations rowMutations)
throws IOException {
  RegionAction.Builder builder =
    getRegionActionBuilderWithRegion(RegionAction.newBuilder(), regionName);
  ClientProtos.Action.Builder actionBuilder = ClientProtos.Action.newBuilder();
  MutationProto.Builder mutationBuilder = MutationProto.newBuilder();
  for (Mutation mutation: rowMutations.getMutations()) {
    MutationType mutateType = null;
    if (mutation instanceof Put) {
      mutateType = MutationType.PUT;
    } else if (mutation instanceof Delete) {
      mutateType = MutationType.DELETE;
    } else {
      throw new DoNotRetryIOException("RowMutations supports only put and delete, not " +
        mutation.getClass().getName());
    }
    mutationBuilder.clear();
    MutationProto mp = ProtobufUtil.toMutation(mutateType, mutation, mutationBuilder);
    actionBuilder.clear();
    actionBuilder.setMutation(mp);
    builder.addAction(actionBuilder.build());
  }
  return builder;
}
项目:PyroDB    文件:RequestConverter.java   
/**
 * Create a protocol buffer MultiRequest for row mutations that does not hold data.  Data/Cells
 * are carried outside of protobuf.  Return references to the Cells in <code>cells</code> param.
  * Does not propagate Action absolute position.  Does not set atomic action on the created
 * RegionAtomic.  Caller should do that if wanted.
 * @param regionName
 * @param rowMutations
 * @param cells Return in here a list of Cells as CellIterable.
 * @return a region mutation minus data
 * @throws IOException
 */
public static RegionAction.Builder buildNoDataRegionAction(final byte[] regionName,
    final RowMutations rowMutations, final List<CellScannable> cells,
    final RegionAction.Builder regionActionBuilder,
    final ClientProtos.Action.Builder actionBuilder,
    final MutationProto.Builder mutationBuilder)
throws IOException {
  for (Mutation mutation: rowMutations.getMutations()) {
    MutationType type = null;
    if (mutation instanceof Put) {
      type = MutationType.PUT;
    } else if (mutation instanceof Delete) {
      type = MutationType.DELETE;
    } else {
      throw new DoNotRetryIOException("RowMutations supports only put and delete, not " +
        mutation.getClass().getName());
    }
    mutationBuilder.clear();
    MutationProto mp = ProtobufUtil.toMutationNoData(type, mutation, mutationBuilder);
    cells.add(mutation);
    actionBuilder.clear();
    regionActionBuilder.addAction(actionBuilder.setMutation(mp).build());
  }
  return regionActionBuilder;
}
项目:c5    文件:RequestConverter.java   
/**
 * Create a protocol buffer MultiRequest for row mutations.
 * Does not propagate Action absolute position.
 *
 * @param regionName   The region name the actions apply to.
 * @param rowMutations The row mutations to apply to the region
 * @return a data-laden RegionAction
 */
public static RegionAction buildRegionAction(final byte[] regionName,
                                             final RowMutations rowMutations)
    throws IOException {
  final RegionSpecifier region = buildRegionSpecifier(regionName);
  final List<Action> actions = new ArrayList<>();
  int index = 0;
  for (Mutation mutation : rowMutations.getMutations()) {
    MutationProto.MutationType mutateType;
    if (mutation instanceof Put) {
      mutateType = MutationProto.MutationType.PUT;
    } else if (mutation instanceof Delete) {
      mutateType = MutationProto.MutationType.DELETE;
    } else {
      throw new DoNotRetryIOException("RowMutations supports only put and delete, not "
          + mutation.getClass().getName());
    }
    final MutationProto mp = ProtobufUtil.toMutation(mutateType, mutation);
    final Action action = new Action(++index, mp, new c5db.client.generated.Get());
    actions.add(action);

  }
  return new RegionAction(region, true, actions);
}
项目:c5    文件:HBaseFsck.java   
/**
 * Reset the split parent region info in meta table
 */
private void resetSplitParent(HbckInfo hi) throws IOException {
  RowMutations mutations = new RowMutations(hi.metaEntry.getRegionName());
  Delete d = new Delete(hi.metaEntry.getRegionName());
  d.deleteColumn(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER);
  d.deleteColumn(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER);
  mutations.add(d);

  HRegionInfo hri = new HRegionInfo(hi.metaEntry);
  hri.setOffline(false);
  hri.setSplit(false);
  Put p = MetaEditor.makePutFromRegionInfo(hri);
  mutations.add(p);

  meta.mutateRow(mutations);
  meta.flushCommits();
  LOG.info("Reset split parent " + hi.metaEntry.getRegionNameAsString() + " in META" );
}
项目:c5    文件:RequestConverter.java   
/**
 * Create a protocol buffer MultiRequest for row mutations.
 * Does not propagate Action absolute position.  Does not set atomic action on the created
 * RegionAtomic.  Caller should do that if wanted.
 * @param regionName
 * @param rowMutations
 * @return a data-laden RegionMutation.Builder
 * @throws IOException
 */
public static RegionAction.Builder buildRegionAction(final byte [] regionName,
    final RowMutations rowMutations)
throws IOException {
  RegionAction.Builder builder =
    getRegionActionBuilderWithRegion(RegionAction.newBuilder(), regionName);
  ClientProtos.Action.Builder actionBuilder = ClientProtos.Action.newBuilder();
  MutationProto.Builder mutationBuilder = MutationProto.newBuilder();
  for (Mutation mutation: rowMutations.getMutations()) {
    MutationType mutateType = null;
    if (mutation instanceof Put) {
      mutateType = MutationType.PUT;
    } else if (mutation instanceof Delete) {
      mutateType = MutationType.DELETE;
    } else {
      throw new DoNotRetryIOException("RowMutations supports only put and delete, not " +
        mutation.getClass().getName());
    }
    mutationBuilder.clear();
    MutationProto mp = ProtobufUtil.toMutation(mutateType, mutation, mutationBuilder);
    actionBuilder.clear();
    actionBuilder.setMutation(mp);
    builder.addAction(actionBuilder.build());
  }
  return builder;
}
项目:c5    文件:RequestConverter.java   
/**
 * Create a protocol buffer MultiRequest for row mutations that does not hold data.  Data/Cells
 * are carried outside of protobuf.  Return references to the Cells in <code>cells</code> param.
  * Does not propagate Action absolute position.  Does not set atomic action on the created
 * RegionAtomic.  Caller should do that if wanted.
 * @param regionName
 * @param rowMutations
 * @param cells Return in here a list of Cells as CellIterable.
 * @return a region mutation minus data
 * @throws IOException
 */
public static RegionAction.Builder buildNoDataRegionAction(final byte[] regionName,
    final RowMutations rowMutations, final List<CellScannable> cells,
    final RegionAction.Builder regionActionBuilder,
    final ClientProtos.Action.Builder actionBuilder,
    final MutationProto.Builder mutationBuilder)
throws IOException {
  for (Mutation mutation: rowMutations.getMutations()) {
    MutationType type = null;
    if (mutation instanceof Put) {
      type = MutationType.PUT;
    } else if (mutation instanceof Delete) {
      type = MutationType.DELETE;
    } else {
      throw new DoNotRetryIOException("RowMutations supports only put and delete, not " +
        mutation.getClass().getName());
    }
    mutationBuilder.clear();
    MutationProto mp = ProtobufUtil.toMutationNoData(type, mutation, mutationBuilder);
    cells.add(mutation);
    actionBuilder.clear();
    regionActionBuilder.addAction(actionBuilder.setMutation(mp).build());
  }
  return regionActionBuilder;
}
项目:geowave    文件:HBaseSecondaryIndexDataStore.java   
@Override
protected Writer<RowMutations> getWriter(
        final ByteArrayId secondaryIndexId ) {
    final String secondaryIndexName = secondaryIndexId.getString();
    if (writerCache.containsKey(secondaryIndexName)) {
        return writerCache.get(secondaryIndexName);
    }
    HBaseWriter writer = null;
    try {
        writer = hbaseOperations.createWriter(
                secondaryIndexName,
                new String[] {},
                false);
    }
    catch (final IOException e) {
        LOGGER.error(
                "Unable to create HBase Writer.",
                e);
        return null;
    }
    writerCache.put(
            secondaryIndexName,
            writer);

    return writer;
}
项目:geowave    文件:HBaseSecondaryIndexDataStore.java   
@Override
protected RowMutations buildJoinMutation(
        final byte[] secondaryIndexRowId,
        final byte[] adapterId,
        final byte[] indexedAttributeFieldId,
        final byte[] primaryIndexId,
        final byte[] primaryIndexRowId,
        final byte[] attributeVisibility )
        throws IOException {
    final RowMutations m = new RowMutations(
            secondaryIndexRowId);
    final Put p = new Put(
            secondaryIndexRowId);
    p.setCellVisibility(new CellVisibility(
            StringUtils.stringFromBinary(attributeVisibility)));
    p.addColumn(
            SecondaryIndexUtils.constructColumnFamily(
                    adapterId,
                    indexedAttributeFieldId),
            SecondaryIndexUtils.constructColumnQualifier(
                    primaryIndexId,
                    primaryIndexRowId),
            EMPTY_VALUE);
    m.add(p);
    return m;
}
项目:geowave    文件:HBaseSecondaryIndexDataStore.java   
@Override
protected RowMutations buildJoinDeleteMutation(
        final byte[] secondaryIndexRowId,
        final byte[] adapterId,
        final byte[] indexedAttributeFieldId,
        final byte[] primaryIndexId,
        final byte[] primaryIndexRowId )
        throws IOException {
    final RowMutations m = new RowMutations(
            secondaryIndexRowId);
    final Delete d = new Delete(
            secondaryIndexRowId);
    d.addColumns(
            SecondaryIndexUtils.constructColumnFamily(
                    adapterId,
                    indexedAttributeFieldId),
            SecondaryIndexUtils.constructColumnQualifier(
                    primaryIndexId,
                    primaryIndexRowId));
    m.add(d);
    return m;
}
项目:geowave    文件:HBaseSecondaryIndexDataStore.java   
@Override
protected RowMutations buildFullDeleteMutation(
        final byte[] secondaryIndexRowId,
        final byte[] adapterId,
        final byte[] indexedAttributeFieldId,
        final byte[] dataId,
        final byte[] fieldId )
        throws IOException {
    final RowMutations m = new RowMutations(
            secondaryIndexRowId);
    final Delete d = new Delete(
            secondaryIndexRowId);
    d.addColumn(
            SecondaryIndexUtils.constructColumnFamily(
                    adapterId,
                    indexedAttributeFieldId),
            SecondaryIndexUtils.constructColumnQualifier(
                    fieldId,
                    dataId));
    m.add(d);
    return m;
}
项目:geowave    文件:HBaseUtils.java   
public static RowMutations getDeleteMutations(
        final byte[] rowId,
        final byte[] columnFamily,
        final byte[] columnQualifier,
        final String[] authorizations )
        throws IOException {
    final RowMutations m = new RowMutations(
            rowId);
    final Delete d = new Delete(
            rowId);
    d.addColumns(
            columnFamily,
            columnQualifier);
    m.add(d);
    return m;
}
项目:HBase-Research    文件:HBaseFsck.java   
/**
 * Reset the split parent region info in meta table
 */
private void resetSplitParent(HbckInfo hi) throws IOException {
  RowMutations mutations = new RowMutations(hi.metaEntry.getRegionName());
  Delete d = new Delete(hi.metaEntry.getRegionName());
  d.deleteColumn(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER);
  d.deleteColumn(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER);
  mutations.add(d);

  Put p = new Put(hi.metaEntry.getRegionName());
  HRegionInfo hri = new HRegionInfo(hi.metaEntry);
  hri.setOffline(false);
  hri.setSplit(false);
  p.add(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER,
    Writables.getBytes(hri));
  mutations.add(p);

  meta.mutateRow(mutations);
  meta.flushCommits();
  LOG.info("Reset split parent " + hi.metaEntry.getRegionNameAsString() + " in META" );
}
项目:HBase-Research    文件:HRegionServer.java   
@Override
public void mutateRow(byte[] regionName, RowMutations rm)
    throws IOException {
  checkOpen();
  if (regionName == null) {
    throw new IOException("Invalid arguments to mutateRow " +
    "regionName is null");
  }
  requestCount.incrementAndGet();
  try {
    HRegion region = getRegion(regionName);
    if (!region.getRegionInfo().isMetaTable()) {
      this.cacheFlusher.reclaimMemStoreMemory();
    }
    region.mutateRow(rm);
  } catch (IOException e) {
    checkFileSystem();
    throw e;
  }
}