当前位置: 首页>>代码示例>>Java>>正文


Java Action类代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.client.Action的典型用法代码示例。如果您正苦于以下问题:Java Action类的具体用法?Java Action怎么用?Java Action使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Action类属于org.apache.hadoop.hbase.client包,在下文中一共展示了Action类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildRegionAction

import org.apache.hadoop.hbase.client.Action; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:35,代码来源:RequestConverter.java

示例2: buildNoDataRegionAction

import org.apache.hadoop.hbase.client.Action; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:36,代码来源:RequestConverter.java

示例3: buildGrantRequest

import org.apache.hadoop.hbase.client.Action; //导入依赖的package包/类
/**
 * Create a request to grant user permissions.
 *
 * @param username the short user name who to grant permissions
 * @param actions the permissions to be granted
 * @return A {@link AccessControlProtos} GrantRequest
 */
public static AccessControlProtos.GrantRequest buildGrantRequest(
    String username, AccessControlProtos.Permission.Action... actions) {
  AccessControlProtos.Permission.Builder ret =
      AccessControlProtos.Permission.newBuilder();
  AccessControlProtos.GlobalPermission.Builder permissionBuilder =
      AccessControlProtos.GlobalPermission.newBuilder();
  for (AccessControlProtos.Permission.Action a : actions) {
    permissionBuilder.addAction(a);
  }
  ret.setType(AccessControlProtos.Permission.Type.Global)
     .setGlobalPermission(permissionBuilder);
  return AccessControlProtos.GrantRequest.newBuilder()
    .setUserPermission(
        AccessControlProtos.UserPermission.newBuilder()
            .setUser(ByteString.copyFromUtf8(username))
            .setPermission(ret)
    ).build();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:26,代码来源:RequestConverter.java

示例4: buildRevokeRequest

import org.apache.hadoop.hbase.client.Action; //导入依赖的package包/类
/**
 * Create a request to revoke user permissions.
 *
 * @param username the short user name whose permissions to be revoked
 * @param actions the permissions to be revoked
 * @return A {@link AccessControlProtos} RevokeRequest
 */
public static AccessControlProtos.RevokeRequest buildRevokeRequest(
    String username, AccessControlProtos.Permission.Action... actions) {
  AccessControlProtos.Permission.Builder ret =
      AccessControlProtos.Permission.newBuilder();
  AccessControlProtos.GlobalPermission.Builder permissionBuilder =
      AccessControlProtos.GlobalPermission.newBuilder();
  for (AccessControlProtos.Permission.Action a : actions) {
    permissionBuilder.addAction(a);
  }
  ret.setType(AccessControlProtos.Permission.Type.Global)
     .setGlobalPermission(permissionBuilder);
  return AccessControlProtos.RevokeRequest.newBuilder()
    .setUserPermission(
        AccessControlProtos.UserPermission.newBuilder()
            .setUser(ByteString.copyFromUtf8(username))
            .setPermission(ret)
    ).build();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:26,代码来源:RequestConverter.java

示例5: buildGrantRequest

import org.apache.hadoop.hbase.client.Action; //导入依赖的package包/类
/**
 * Create a request to grant user permissions.
 *
 * @param username the short user name who to grant permissions
 * @param table optional table name the permissions apply
 * @param family optional column family
 * @param qualifier optional qualifier
 * @param actions the permissions to be granted
 * @return A {@link AccessControlProtos} GrantRequest
 */
public static AccessControlProtos.GrantRequest buildGrantRequest(
    String username, byte[] table, byte[] family, byte[] qualifier,
    AccessControlProtos.Permission.Action... actions) {
  AccessControlProtos.Permission.Builder permissionBuilder =
      AccessControlProtos.Permission.newBuilder();
  for (AccessControlProtos.Permission.Action a : actions) {
    permissionBuilder.addAction(a);
  }
  if (table != null) {
    permissionBuilder.setTable(ByteString.copyFrom(table));
  }
  if (family != null) {
    permissionBuilder.setFamily(ByteString.copyFrom(family));
  }
  if (qualifier != null) {
    permissionBuilder.setQualifier(ByteString.copyFrom(qualifier));
  }

  return AccessControlProtos.GrantRequest.newBuilder()
    .setPermission(
        AccessControlProtos.UserPermission.newBuilder()
            .setUser(ByteString.copyFromUtf8(username))
            .setPermission(permissionBuilder.build())
    ).build();
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:36,代码来源:RequestConverter.java

示例6: buildRevokeRequest

import org.apache.hadoop.hbase.client.Action; //导入依赖的package包/类
/**
 * Create a request to revoke user permissions.
 *
 * @param username the short user name whose permissions to be revoked
 * @param table optional table name the permissions apply
 * @param family optional column family
 * @param qualifier optional qualifier
 * @param actions the permissions to be revoked
 * @return A {@link AccessControlProtos} RevokeRequest
 */
public static AccessControlProtos.RevokeRequest buildRevokeRequest(
    String username, byte[] table, byte[] family, byte[] qualifier,
    AccessControlProtos.Permission.Action... actions) {
  AccessControlProtos.Permission.Builder permissionBuilder =
      AccessControlProtos.Permission.newBuilder();
  for (AccessControlProtos.Permission.Action a : actions) {
    permissionBuilder.addAction(a);
  }
  if (table != null) {
    permissionBuilder.setTable(ByteString.copyFrom(table));
  }
  if (family != null) {
    permissionBuilder.setFamily(ByteString.copyFrom(family));
  }
  if (qualifier != null) {
    permissionBuilder.setQualifier(ByteString.copyFrom(qualifier));
  }

  return AccessControlProtos.RevokeRequest.newBuilder()
    .setPermission(
        AccessControlProtos.UserPermission.newBuilder()
            .setUser(ByteString.copyFromUtf8(username))
            .setPermission(permissionBuilder.build())
    ).build();
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:36,代码来源:RequestConverter.java

示例7: toPermission

import org.apache.hadoop.hbase.client.Action; //导入依赖的package包/类
/**
 * Convert a client Permission to a Permission proto
 *
 * @param perm the client Permission
 * @return the protobuf Permission
 */
public static AccessControlProtos.Permission toPermission(Permission perm) {
  AccessControlProtos.Permission.Builder builder = AccessControlProtos.Permission.newBuilder();
  if (perm instanceof TablePermission) {
    TablePermission tablePerm = (TablePermission)perm;
    if (tablePerm.hasTable()) {
      builder.setTable(ByteString.copyFrom(tablePerm.getTable()));
    }
    if (tablePerm.hasFamily()) {
      builder.setFamily(ByteString.copyFrom(tablePerm.getFamily()));
    }
    if (tablePerm.hasQualifier()) {
      builder.setQualifier(ByteString.copyFrom(tablePerm.getQualifier()));
    }
  }
  for (Permission.Action a : perm.getActions()) {
    builder.addAction(toPermissionAction(a));
  }
  return builder.build();
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:26,代码来源:ProtobufUtil.java

示例8: toPermissionAction

import org.apache.hadoop.hbase.client.Action; //导入依赖的package包/类
/**
 * Converts a Permission.Action proto to a client Permission.Action object.
 *
 * @param action the protobuf Action
 * @return the converted Action
 */
public static Permission.Action toPermissionAction(
    AccessControlProtos.Permission.Action action) {
  switch (action) {
    case READ:
      return Permission.Action.READ;
    case WRITE:
      return Permission.Action.WRITE;
    case EXEC:
      return Permission.Action.EXEC;
    case CREATE:
      return Permission.Action.CREATE;
    case ADMIN:
      return Permission.Action.ADMIN;
  }
  throw new IllegalArgumentException("Unknown action value "+action.name());
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:23,代码来源:ProtobufUtil.java

示例9: toUserPermission

import org.apache.hadoop.hbase.client.Action; //导入依赖的package包/类
/**
 * Convert a client user permission to a user permission proto
 *
 * @param perm the client UserPermission
 * @return the protobuf UserPermission
 */
public static AccessControlProtos.UserPermission toUserPermission(UserPermission perm) {
  AccessControlProtos.Permission.Builder permissionBuilder =
      AccessControlProtos.Permission.newBuilder();
  for (Permission.Action a : perm.getActions()) {
    permissionBuilder.addAction(toPermissionAction(a));
  }
  if (perm.hasTable()) {
    permissionBuilder.setTable(ByteString.copyFrom(perm.getTable()));
  }
  if (perm.hasFamily()) {
    permissionBuilder.setFamily(ByteString.copyFrom(perm.getFamily()));
  }
  if (perm.hasQualifier()) {
    permissionBuilder.setQualifier(ByteString.copyFrom(perm.getQualifier()));
  }

  return AccessControlProtos.UserPermission.newBuilder()
      .setUser(ByteString.copyFrom(perm.getUser()))
      .setPermission(permissionBuilder)
      .build();
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:28,代码来源:ProtobufUtil.java

示例10: buildMutateRequest

import org.apache.hadoop.hbase.client.Action; //导入依赖的package包/类
/**
 * Create a protocol buffer MutateRequest for conditioned row mutations
 *
 * @param regionName
 * @param row
 * @param family
 * @param qualifier
 * @param comparator
 * @param compareType
 * @param rowMutations
 * @return a mutate request
 * @throws IOException
 */
public static ClientProtos.MultiRequest buildMutateRequest(
    final byte[] regionName, final byte[] row, final byte[] family,
    final byte [] qualifier, final ByteArrayComparable comparator,
    final CompareType compareType, final RowMutations rowMutations) throws IOException {
  RegionAction.Builder builder =
      getRegionActionBuilderWithRegion(RegionAction.newBuilder(), regionName);
  builder.setAtomic(true);
  ClientProtos.Action.Builder actionBuilder = ClientProtos.Action.newBuilder();
  MutationProto.Builder mutationBuilder = MutationProto.newBuilder();
  Condition condition = buildCondition(
      row, family, qualifier, comparator, compareType);
  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());
  }
  ClientProtos.MultiRequest request =
      ClientProtos.MultiRequest.newBuilder().addRegionAction(builder.build())
          .setCondition(condition).build();
  return request;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:46,代码来源:RequestConverter.java


注:本文中的org.apache.hadoop.hbase.client.Action类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。