org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos#TableName ( )源码实例Demo

下面列出了org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos#TableName ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hbase   文件: BackupManifest.java
static BackupImage fromProto(BackupProtos.BackupImage im) {
  String backupId = im.getBackupId();
  String rootDir = im.getBackupRootDir();
  long startTs = im.getStartTs();
  long completeTs = im.getCompleteTs();
  List<HBaseProtos.TableName> tableListList = im.getTableListList();
  List<TableName> tableList = new ArrayList<>();
  for (HBaseProtos.TableName tn : tableListList) {
    tableList.add(ProtobufUtil.toTableName(tn));
  }

  List<BackupProtos.BackupImage> ancestorList = im.getAncestorsList();

  BackupType type =
      im.getBackupType() == BackupProtos.BackupType.FULL ? BackupType.FULL
          : BackupType.INCREMENTAL;

  BackupImage image = new BackupImage(backupId, type, rootDir, tableList, startTs, completeTs);
  for (BackupProtos.BackupImage img : ancestorList) {
    image.addAncestor(fromProto(img));
  }
  image.setIncrTimeRanges(loadIncrementalTimestampMap(im));
  return image;
}
 
源代码2 项目: hbase   文件: RegionServerSpaceQuotaManager.java
/**
 * Builds the protobuf message to inform the Master of files being archived.
 *
 * @param tn The table the files previously belonged to.
 * @param archivedFiles The files and their size in bytes that were archived.
 * @return The protobuf representation
 */
public RegionServerStatusProtos.FileArchiveNotificationRequest buildFileArchiveRequest(
    TableName tn, Collection<Entry<String,Long>> archivedFiles) {
  RegionServerStatusProtos.FileArchiveNotificationRequest.Builder builder =
      RegionServerStatusProtos.FileArchiveNotificationRequest.newBuilder();
  HBaseProtos.TableName protoTn = ProtobufUtil.toProtoTableName(tn);
  for (Entry<String,Long> archivedFile : archivedFiles) {
    RegionServerStatusProtos.FileArchiveNotificationRequest.FileWithSize fws =
        RegionServerStatusProtos.FileArchiveNotificationRequest.FileWithSize.newBuilder()
            .setName(archivedFile.getKey())
            .setSize(archivedFile.getValue())
            .setTableName(protoTn)
            .build();
    builder.addArchivedFiles(fws);
  }
  final RegionServerStatusProtos.FileArchiveNotificationRequest request = builder.build();
  if (LOG.isTraceEnabled()) {
    LOG.trace("Reporting file archival to Master: " + TextFormat.shortDebugString(request));
  }
  return request;
}
 
源代码3 项目: hbase   文件: RSGroupAdminServiceImpl.java
@Override
public void moveTables(RpcController controller, MoveTablesRequest request,
    RpcCallback<MoveTablesResponse> done) {
  MoveTablesResponse.Builder builder = MoveTablesResponse.newBuilder();
  Set<TableName> tables = new HashSet<>(request.getTableNameList().size());
  for (HBaseProtos.TableName tableName : request.getTableNameList()) {
    tables.add(ProtobufUtil.toTableName(tableName));
  }
  LOG.info(master.getClientIdAuditPrefix() + " move tables " + tables + " to rsgroup " +
      request.getTargetGroup());
  try {
    if (master.getMasterCoprocessorHost() != null) {
      master.getMasterCoprocessorHost().preMoveTables(tables, request.getTargetGroup());
    }
    moveTablesAndWait(tables, request.getTargetGroup());
    if (master.getMasterCoprocessorHost() != null) {
      master.getMasterCoprocessorHost().postMoveTables(tables, request.getTargetGroup());
    }
  } catch (IOException e) {
    CoprocessorRpcUtils.setControllerException(controller, e);
  }
  done.run(builder.build());
}
 
源代码4 项目: hbase   文件: ProtobufUtil.java
public static RSGroupProtos.RSGroupInfo toProtoGroupInfo(RSGroupInfo pojo) {
  List<HBaseProtos.TableName> tables = new ArrayList<>(pojo.getTables().size());
  for (TableName arg : pojo.getTables()) {
    tables.add(ProtobufUtil.toProtoTableName(arg));
  }
  List<HBaseProtos.ServerName> hostports = new ArrayList<>(pojo.getServers().size());
  for (Address el : pojo.getServers()) {
    hostports.add(HBaseProtos.ServerName.newBuilder().setHostName(el.getHostname())
        .setPort(el.getPort()).build());
  }
  List<NameStringPair> configuration = pojo.getConfiguration().entrySet()
      .stream().map(entry -> NameStringPair.newBuilder()
          .setName(entry.getKey()).setValue(entry.getValue()).build())
      .collect(Collectors.toList());
  return RSGroupProtos.RSGroupInfo.newBuilder().setName(pojo.getName()).addAllServers(hostports)
      .addAllTables(tables).addAllConfiguration(configuration).build();
}
 
源代码5 项目: hbase   文件: MasterRpcServices.java
/**
 * Get list of TableDescriptors for requested tables.
 * @param c Unused (set to null).
 * @param req GetTableDescriptorsRequest that contains:
 *     - tableNames: requested tables, or if empty, all are requested.
 * @return GetTableDescriptorsResponse
 * @throws ServiceException
 */
@Override
public GetTableDescriptorsResponse getTableDescriptors(RpcController c,
    GetTableDescriptorsRequest req) throws ServiceException {
  try {
    master.checkInitialized();

    final String regex = req.hasRegex() ? req.getRegex() : null;
    final String namespace = req.hasNamespace() ? req.getNamespace() : null;
    List<TableName> tableNameList = null;
    if (req.getTableNamesCount() > 0) {
      tableNameList = new ArrayList<TableName>(req.getTableNamesCount());
      for (HBaseProtos.TableName tableNamePB: req.getTableNamesList()) {
        tableNameList.add(ProtobufUtil.toTableName(tableNamePB));
      }
    }

    List<TableDescriptor> descriptors = master.listTableDescriptors(namespace, regex,
        tableNameList, req.getIncludeSysTables());

    GetTableDescriptorsResponse.Builder builder = GetTableDescriptorsResponse.newBuilder();
    if (descriptors != null && descriptors.size() > 0) {
      // Add the table descriptors to the response
      for (TableDescriptor htd: descriptors) {
        builder.addTableSchema(ProtobufUtil.toTableSchema(htd));
      }
    }
    return builder.build();
  } catch (IOException ioe) {
    throw new ServiceException(ioe);
  }
}
 
源代码6 项目: hbase   文件: RSGroupAdminServiceImpl.java
@Override
public void moveServersAndTables(RpcController controller, MoveServersAndTablesRequest request,
    RpcCallback<MoveServersAndTablesResponse> done) {
  MoveServersAndTablesResponse.Builder builder = MoveServersAndTablesResponse.newBuilder();
  Set<Address> hostPorts = Sets.newHashSet();
  for (HBaseProtos.ServerName el : request.getServersList()) {
    hostPorts.add(Address.fromParts(el.getHostName(), el.getPort()));
  }
  Set<TableName> tables = new HashSet<>(request.getTableNameList().size());
  for (HBaseProtos.TableName tableName : request.getTableNameList()) {
    tables.add(ProtobufUtil.toTableName(tableName));
  }
  LOG.info(master.getClientIdAuditPrefix() + " move servers " + hostPorts + " and tables " +
      tables + " to rsgroup" + request.getTargetGroup());
  try {
    if (master.getMasterCoprocessorHost() != null) {
      master.getMasterCoprocessorHost().preMoveServersAndTables(hostPorts, tables,
        request.getTargetGroup());
    }
    rsGroupInfoManager.moveServers(hostPorts, request.getTargetGroup());
    moveTablesAndWait(tables, request.getTargetGroup());
    if (master.getMasterCoprocessorHost() != null) {
      master.getMasterCoprocessorHost().postMoveServersAndTables(hostPorts, tables,
        request.getTargetGroup());
    }
  } catch (IOException e) {
    CoprocessorRpcUtils.setControllerException(controller, e);
  }
  done.run(builder.build());
}
 
源代码7 项目: hbase   文件: ProtobufUtil.java
public static TableName[] getTableNameArray(List<HBaseProtos.TableName> tableNamesList) {
  if (tableNamesList == null) {
    return new TableName[0];
  }
  TableName[] tableNames = new TableName[tableNamesList.size()];
  for (int i = 0; i < tableNamesList.size(); i++) {
    tableNames[i] = toTableName(tableNamesList.get(i));
  }
  return tableNames;
}
 
源代码8 项目: hbase   文件: ProtobufUtil.java
public static RSGroupInfo toGroupInfo(RSGroupProtos.RSGroupInfo proto) {
  RSGroupInfo rsGroupInfo = new RSGroupInfo(proto.getName());
  for (HBaseProtos.ServerName el : proto.getServersList()) {
    rsGroupInfo.addServer(Address.fromParts(el.getHostName(), el.getPort()));
  }
  for (HBaseProtos.TableName pTableName : proto.getTablesList()) {
    rsGroupInfo.addTable(ProtobufUtil.toTableName(pTableName));
  }
  proto.getConfigurationList().forEach(pair ->
      rsGroupInfo.setConfiguration(pair.getName(), pair.getValue()));
  return rsGroupInfo;
}
 
源代码9 项目: hbase   文件: RawAsyncHBaseAdmin.java
@Override
public CompletableFuture<SpaceQuotaSnapshot> getCurrentSpaceQuotaSnapshot(TableName tableName) {
  HBaseProtos.TableName protoTableName = ProtobufUtil.toProtoTableName(tableName);
  return getCurrentSpaceQuotaSnapshot(resp -> resp.getTableSnapshotsList().stream()
    .filter(s -> s.getTableName().equals(protoTableName)).findFirst()
    .map(s -> SpaceQuotaSnapshot.toSpaceQuotaSnapshot(s.getSnapshot())).orElse(null));
}
 
源代码10 项目: hbase   文件: ShadedAccessControlUtil.java
public static org.apache.hadoop.hbase.TableName toTableName(HBaseProtos.TableName tableNamePB) {
  return org.apache.hadoop.hbase.TableName.valueOf(
    tableNamePB.getNamespace().asReadOnlyByteBuffer(),
    tableNamePB.getQualifier().asReadOnlyByteBuffer());
}
 
源代码11 项目: hbase   文件: ShadedAccessControlUtil.java
public static HBaseProtos.TableName toProtoTableName(TableName tableName) {
  return HBaseProtos.TableName.newBuilder()
      .setNamespace(ByteString.copyFrom(tableName.getNamespace()))
      .setQualifier(ByteString.copyFrom(tableName.getQualifier())).build();
}
 
源代码12 项目: hbase   文件: ProtobufUtil.java
public static TableName toTableName(HBaseProtos.TableName tableNamePB) {
  return TableName.valueOf(tableNamePB.getNamespace().asReadOnlyByteBuffer(),
      tableNamePB.getQualifier().asReadOnlyByteBuffer());
}
 
源代码13 项目: hbase   文件: ProtobufUtil.java
public static HBaseProtos.TableName toProtoTableName(TableName tableName) {
  return HBaseProtos.TableName.newBuilder()
      .setNamespace(UnsafeByteOperations.unsafeWrap(tableName.getNamespace()))
      .setQualifier(UnsafeByteOperations.unsafeWrap(tableName.getQualifier())).build();
}
 
源代码14 项目: hbase   文件: ProtobufUtil.java
public static List<TableName> toTableNameList(List<HBaseProtos.TableName> tableNamesList) {
  if (tableNamesList == null) {
    return new ArrayList<>();
  }
  return tableNamesList.stream().map(ProtobufUtil::toTableName).collect(Collectors.toList());
}