Java Code Examples for org.apache.hadoop.hbase.util.Pair#newPair()
The following examples show how to use
org.apache.hadoop.hbase.util.Pair#newPair() .
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: ZKReplicationQueueStorage.java From hbase with Apache License 2.0 | 6 votes |
/** * Return the {lastPushedSequenceId, ZNodeDataVersion} pair. if ZNodeDataVersion is -1, it means * that the ZNode does not exist. */ @VisibleForTesting protected Pair<Long, Integer> getLastSequenceIdWithVersion(String encodedRegionName, String peerId) throws KeeperException { Stat stat = new Stat(); String path = getSerialReplicationRegionPeerNode(encodedRegionName, peerId); byte[] data = ZKUtil.getDataNoWatch(zookeeper, path, stat); if (data == null) { // ZNode does not exist, so just return version -1 to indicate that no node exist. return Pair.newPair(HConstants.NO_SEQNUM, -1); } try { return Pair.newPair(ZKUtil.parseWALPositionFrom(data), stat.getVersion()); } catch (DeserializationException de) { LOG.warn("Failed to parse log position (region=" + encodedRegionName + ", peerId=" + peerId + "), data=" + Bytes.toStringBinary(data)); } return Pair.newPair(HConstants.NO_SEQNUM, stat.getVersion()); }
Example 2
Source File: PrimaryKeyConstraint.java From phoenix with Apache License 2.0 | 6 votes |
PrimaryKeyConstraint(String name, List<ColumnDefInPkConstraint> columnDefs) { super(name); if (columnDefs == null) { this.columns = Collections.<Pair<ColumnName, SortOrder>>emptyList(); this.columnNameToSortOrder = Collections.<ColumnName, Pair<ColumnName, SortOrder>>emptyMap(); this.columnNameToRowTimestamp = Collections.<ColumnName, Pair<ColumnName, Boolean>>emptyMap(); numColumnsWithRowTimestamp = 0; } else { int numRowTimestampCols = 0; List<Pair<ColumnName, SortOrder>> l = new ArrayList<>(columnDefs.size()); this.columnNameToSortOrder = Maps.newHashMapWithExpectedSize(columnDefs.size()); this.columnNameToRowTimestamp = Maps.newHashMapWithExpectedSize(columnDefs.size()); for (ColumnDefInPkConstraint colDef : columnDefs) { Pair<ColumnName, SortOrder> p = Pair.newPair(colDef.getColumnName(), colDef.getSortOrder()); l.add(p); this.columnNameToSortOrder.put(colDef.getColumnName(), p); this.columnNameToRowTimestamp.put(colDef.getColumnName(), Pair.newPair(colDef.getColumnName(), colDef.isRowTimestamp())); if (colDef.isRowTimestamp()) { numRowTimestampCols++; } } this.numColumnsWithRowTimestamp = numRowTimestampCols; this.columns = ImmutableList.copyOf(l); } }
Example 3
Source File: NettyAsyncFSWALConfigHelper.java From hbase with Apache License 2.0 | 5 votes |
static Pair<EventLoopGroup, Class<? extends Channel>> getEventLoopConfig(Configuration conf) { String name = conf.get(EVENT_LOOP_CONFIG); if (StringUtils.isBlank(name)) { // create new event loop group if config is empty return Pair.<EventLoopGroup, Class<? extends Channel>> newPair( new NioEventLoopGroup(0, new DefaultThreadFactory("AsyncFSWAL", true, Thread.MAX_PRIORITY)), NioSocketChannel.class); } return EVENT_LOOP_CONFIG_MAP.get(name); }
Example 4
Source File: RegionServerTracker.java From hbase with Apache License 2.0 | 5 votes |
private Pair<ServerName, RegionServerInfo> getServerInfo(String name) throws KeeperException, IOException { ServerName serverName = ServerName.parseServerName(name); String nodePath = ZNodePaths.joinZNode(watcher.getZNodePaths().rsZNode, name); byte[] data; try { data = ZKUtil.getData(watcher, nodePath); } catch (InterruptedException e) { throw (InterruptedIOException) new InterruptedIOException().initCause(e); } if (data == null) { // we should receive a children changed event later and then we will expire it, so we still // need to add it to the region server set. LOG.warn("Server node {} does not exist, already dead?", name); return Pair.newPair(serverName, null); } if (data.length == 0 || !ProtobufUtil.isPBMagicPrefix(data)) { // this should not happen actually, unless we have bugs or someone has messed zk up. LOG.warn("Invalid data for region server node {} on zookeeper, data length = {}", name, data.length); return Pair.newPair(serverName, null); } RegionServerInfo.Builder builder = RegionServerInfo.newBuilder(); int magicLen = ProtobufUtil.lengthOfPBMagic(); ProtobufUtil.mergeFrom(builder, data, magicLen, data.length - magicLen); return Pair.newPair(serverName, builder.build()); }
Example 5
Source File: TestAsyncTableRegionLocator.java From hbase with Apache License 2.0 | 5 votes |
@Override protected Pair<byte[][], byte[][]> getStartEndKeys(TableName tableName) throws IOException { List<Pair<byte[], byte[]>> startEndKeys = get(CONN.getRegionLocator(tableName).getStartEndKeys()); byte[][] startKeys = new byte[startEndKeys.size()][]; byte[][] endKeys = new byte[startEndKeys.size()][]; for (int i = 0, n = startEndKeys.size(); i < n; i++) { Pair<byte[], byte[]> pair = startEndKeys.get(i); startKeys[i] = pair.getFirst(); endKeys[i] = pair.getSecond(); } return Pair.newPair(startKeys, endKeys); }
Example 6
Source File: TestAsyncTableScanMetrics.java From hbase with Apache License 2.0 | 5 votes |
private static Pair<List<Result>, ScanMetrics> doScanWithRawAsyncTable(Scan scan) throws IOException, InterruptedException { BufferingScanResultConsumer consumer = new BufferingScanResultConsumer(); CONN.getTable(TABLE_NAME).scan(scan, consumer); List<Result> results = new ArrayList<>(); for (Result result; (result = consumer.take()) != null;) { results.add(result); } return Pair.newPair(results, consumer.getScanMetrics()); }
Example 7
Source File: TestAsyncTableScanMetrics.java From hbase with Apache License 2.0 | 5 votes |
private static Pair<List<Result>, ScanMetrics> doScanWithAsyncTableScanner(Scan scan) throws IOException { try (ResultScanner scanner = CONN.getTable(TABLE_NAME, ForkJoinPool.commonPool()).getScanner(scan)) { List<Result> results = new ArrayList<>(); for (Result result; (result = scanner.next()) != null;) { results.add(result); } return Pair.newPair(results, scanner.getScanMetrics()); } }
Example 8
Source File: TestPerColumnFamilyFlush.java From hbase with Apache License 2.0 | 5 votes |
private static Pair<HRegion, HRegionServer> getRegionWithName(TableName tableName) { MiniHBaseCluster cluster = TEST_UTIL.getMiniHBaseCluster(); List<JVMClusterUtil.RegionServerThread> rsts = cluster.getRegionServerThreads(); for (int i = 0; i < cluster.getRegionServerThreads().size(); i++) { HRegionServer hrs = rsts.get(i).getRegionServer(); for (HRegion region : hrs.getRegions(tableName)) { return Pair.newPair(region, hrs); } } return null; }
Example 9
Source File: ZKConnectionRegistry.java From hbase with Apache License 2.0 | 5 votes |
private Pair<RegionState.State, ServerName> getStateAndServerName( ZooKeeperProtos.MetaRegionServer proto) { RegionState.State state; if (proto.hasState()) { state = RegionState.State.convert(proto.getState()); } else { state = RegionState.State.OPEN; } HBaseProtos.ServerName snProto = proto.getServer(); return Pair.newPair(state, ServerName.valueOf(snProto.getHostName(), snProto.getPort(), snProto.getStartCode())); }
Example 10
Source File: RegionLocator.java From hbase with Apache License 2.0 | 5 votes |
/** * Gets the starting and ending row keys for every region in the currently open table. * <p> * This is mainly useful for the MapReduce integration. * @return Pair of arrays of region starting and ending row keys * @throws IOException if a remote or network exception occurs */ default Pair<byte[][], byte[][]> getStartEndKeys() throws IOException { List<HRegionLocation> regions = getAllRegionLocations().stream() .filter(loc -> RegionReplicaUtil.isDefaultReplica(loc.getRegion())) .collect(Collectors.toList()); byte[][] startKeys = new byte[regions.size()][]; byte[][] endKeys = new byte[regions.size()][]; for (int i = 0, n = regions.size(); i < n; i++) { RegionInfo region = regions.get(i).getRegion(); startKeys[i] = region.getStartKey(); endKeys[i] = region.getEndKey(); } return Pair.newPair(startKeys, endKeys); }
Example 11
Source File: AddOrUpdateIndexerCli.java From hbase-indexer with Apache License 2.0 | 5 votes |
@Override public Pair<String, String> convert(String input) { int eqPos = input.indexOf('='); if (eqPos == -1) { throw new ValueConversionException("Parameter should be in the form key=value, which the " + "following is not: '" + input + "'."); } String key = input.substring(0, eqPos).trim(); String value = input.substring(eqPos + 1).trim(); return Pair.newPair(key, value); }
Example 12
Source File: ReplicationPeerImpl.java From hbase with Apache License 2.0 | 4 votes |
public Pair<SyncReplicationState, SyncReplicationState> getSyncReplicationStateAndNewState() { int bits = this.syncReplicationStateBits; return Pair.newPair(getSyncReplicationState(bits), getNewSyncReplicationState(bits)); }
Example 13
Source File: TestAsyncTableScanMetrics.java From hbase with Apache License 2.0 | 4 votes |
private static Pair<List<Result>, ScanMetrics> doScanWithAsyncTableScan(Scan scan) throws Exception { SimpleScanResultConsumer consumer = new SimpleScanResultConsumer(); CONN.getTable(TABLE_NAME, ForkJoinPool.commonPool()).scan(scan, consumer); return Pair.newPair(consumer.getAll(), consumer.getScanMetrics()); }