org.apache.hadoop.hbase.replication.ReplicationPeerConfig#newBuilder ( )源码实例Demo

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

源代码1 项目: hbase   文件: ReplicationPeerManager.java
public void updatePeerConfig(String peerId, ReplicationPeerConfig peerConfig)
    throws ReplicationException {
  // the checking rules are too complicated here so we give up checking whether this is a retry.
  ReplicationPeerDescription desc = peers.get(peerId);
  ReplicationPeerConfig oldPeerConfig = desc.getPeerConfig();
  ReplicationPeerConfigBuilder newPeerConfigBuilder =
    ReplicationPeerConfig.newBuilder(peerConfig);
  // we need to use the new conf to overwrite the old one.
  newPeerConfigBuilder.putAllConfiguration(oldPeerConfig.getConfiguration());
  newPeerConfigBuilder.putAllConfiguration(peerConfig.getConfiguration());
  newPeerConfigBuilder.putAllConfiguration(oldPeerConfig.getConfiguration());
  newPeerConfigBuilder.putAllConfiguration(peerConfig.getConfiguration());
  ReplicationPeerConfig newPeerConfig = newPeerConfigBuilder.build();
  peerStorage.updatePeerConfig(peerId, newPeerConfig);
  peers.put(peerId, new ReplicationPeerDescription(peerId, desc.isEnabled(), newPeerConfig,
    desc.getSyncReplicationState()));
}
 
private ReplicationPeerConfig buildSyncReplicationPeerConfig(String clusterKey,
    TableName tableName) throws IOException {
  Path rootDir = TEST_UTIL.getDataTestDirOnTestFS("remoteWAL");
  ReplicationPeerConfigBuilder builder = ReplicationPeerConfig.newBuilder();
  builder.setClusterKey(clusterKey);
  builder.setRemoteWALDir(rootDir.makeQualified(TEST_UTIL.getTestFileSystem().getUri(),
      TEST_UTIL.getTestFileSystem().getWorkingDirectory()).toString());
  builder.setReplicateAllUserTables(false);
  Map<TableName, List<String>> tableCfs = new HashMap<>();
  tableCfs.put(tableName, new ArrayList<>());
  builder.setTableCFsMap(tableCfs);
  return builder.build();
}
 
源代码3 项目: hbase   文件: ReplicationPeerConfigUtil.java
public static ReplicationPeerConfig appendTableCFsToReplicationPeerConfig(
    Map<TableName, List<String>> tableCfs, ReplicationPeerConfig peerConfig) {
  ReplicationPeerConfigBuilder builder = ReplicationPeerConfig.newBuilder(peerConfig);
  Map<TableName, List<String>> preTableCfs = peerConfig.getTableCFsMap();
  if (preTableCfs == null) {
    builder.setTableCFsMap(tableCfs);
  } else {
    builder.setTableCFsMap(mergeTableCFs(preTableCfs, tableCfs));
  }
  return builder.build();
}
 
源代码4 项目: hbase   文件: ReplicationPeerConfigUtil.java
public static ReplicationPeerConfig appendExcludeTableCFsToReplicationPeerConfig(
    Map<TableName, List<String>> excludeTableCfs, ReplicationPeerConfig peerConfig)
    throws ReplicationException {
  if (excludeTableCfs == null) {
    throw new ReplicationException("exclude tableCfs is null");
  }
  ReplicationPeerConfigBuilder builder = ReplicationPeerConfig.newBuilder(peerConfig);
  Map<TableName, List<String>> preExcludeTableCfs = peerConfig.getExcludeTableCFsMap();
  if (preExcludeTableCfs == null) {
    builder.setExcludeTableCFsMap(excludeTableCfs);
  } else {
    builder.setExcludeTableCFsMap(mergeTableCFs(preExcludeTableCfs, excludeTableCfs));
  }
  return builder.build();
}
 
源代码5 项目: hbase   文件: ReplicationPeerConfigUtil.java
public static ReplicationPeerConfig removeTableCFsFromReplicationPeerConfig(
    Map<TableName, List<String>> tableCfs, ReplicationPeerConfig peerConfig,
    String id) throws ReplicationException {
  Map<TableName, List<String>> preTableCfs = peerConfig.getTableCFsMap();
  if (preTableCfs == null) {
    throw new ReplicationException("Table-Cfs for peer: " + id + " is null");
  }
  Map<TableName, List<String>> newTableCfs = copyTableCFsMap(preTableCfs);
  for (Map.Entry<TableName, ? extends Collection<String>> entry : tableCfs.entrySet()) {
    TableName table = entry.getKey();
    Collection<String> removeCfs = entry.getValue();
    if (newTableCfs.containsKey(table)) {
      List<String> cfs = newTableCfs.get(table);
      if (cfs == null && (removeCfs == null || removeCfs.isEmpty())) {
        newTableCfs.remove(table);
      } else if (cfs != null && (removeCfs != null && !removeCfs.isEmpty())) {
        Set<String> cfSet = new HashSet<String>(cfs);
        cfSet.removeAll(removeCfs);
        if (cfSet.isEmpty()) {
          newTableCfs.remove(table);
        } else {
          newTableCfs.put(table, Lists.newArrayList(cfSet));
        }
      } else if (cfs == null && (removeCfs != null && !removeCfs.isEmpty())) {
        throw new ReplicationException("Cannot remove cf of table: " + table
            + " which doesn't specify cfs from table-cfs config in peer: " + id);
      } else if (cfs != null && (removeCfs == null || removeCfs.isEmpty())) {
        throw new ReplicationException("Cannot remove table: " + table
            + " which has specified cfs from table-cfs config in peer: " + id);
      }
    } else {
      throw new ReplicationException(
          "No table: " + table + " in table-cfs config of peer: " + id);
    }
  }
  ReplicationPeerConfigBuilder builder = ReplicationPeerConfig.newBuilder(peerConfig);
  builder.setTableCFsMap(newTableCfs);
  return builder.build();
}
 
源代码6 项目: hbase   文件: ReplicationPeerConfigUtil.java
public static ReplicationPeerConfig removeExcludeTableCFsFromReplicationPeerConfig(
    Map<TableName, List<String>> excludeTableCfs, ReplicationPeerConfig peerConfig, String id)
    throws ReplicationException {
  if (excludeTableCfs == null) {
    throw new ReplicationException("exclude tableCfs is null");
  }
  Map<TableName, List<String>> preExcludeTableCfs = peerConfig.getExcludeTableCFsMap();
  if (preExcludeTableCfs == null) {
    throw new ReplicationException("exclude-Table-Cfs for peer: " + id + " is null");
  }
  Map<TableName, List<String>> newExcludeTableCfs = copyTableCFsMap(preExcludeTableCfs);
  for (Map.Entry<TableName, ? extends Collection<String>> entry : excludeTableCfs.entrySet()) {
    TableName table = entry.getKey();
    Collection<String> removeCfs = entry.getValue();
    if (newExcludeTableCfs.containsKey(table)) {
      List<String> cfs = newExcludeTableCfs.get(table);
      if (cfs == null && (removeCfs == null || removeCfs.isEmpty())) {
        newExcludeTableCfs.remove(table);
      } else if (cfs != null && (removeCfs != null && !removeCfs.isEmpty())) {
        Set<String> cfSet = new HashSet<String>(cfs);
        cfSet.removeAll(removeCfs);
        if (cfSet.isEmpty()) {
          newExcludeTableCfs.remove(table);
        } else {
          newExcludeTableCfs.put(table, Lists.newArrayList(cfSet));
        }
      } else if (cfs == null && (removeCfs != null && !removeCfs.isEmpty())) {
        throw new ReplicationException("Cannot remove cf of table: " + table
            + " which doesn't specify cfs from exclude-table-cfs config in peer: " + id);
      } else if (cfs != null && (removeCfs == null || removeCfs.isEmpty())) {
        throw new ReplicationException("Cannot remove table: " + table
            + " which has specified cfs from exclude-table-cfs config in peer: " + id);
      }
    } else {
      throw new ReplicationException(
          "No table: " + table + " in exclude-table-cfs config of peer: " + id);
    }
  }
  ReplicationPeerConfigBuilder builder = ReplicationPeerConfig.newBuilder(peerConfig);
  builder.setExcludeTableCFsMap(newExcludeTableCfs);
  return builder.build();
}