boolean retried = false; while (true) { HRegionLocation regionLocation = retried ? connection.relocateRegion(PhoenixDatabaseMetaData.TYPE_TABLE_NAME_BYTES, tableKey) : connection.locateRegion(PhoenixDatabaseMetaData.TYPE_TABLE_NAME_BYTES, tableKey); List<byte[]> regionKeys = Collections.singletonList(regionLocation.getRegionInfo().getStartKey()); final Map<byte[],MetaDataMutationResult> results = Maps.newHashMapWithExpectedSize(1);
private HRegionLocation getFirstMetaServerForTable(final byte [] tableName) throws IOException { return connection.locateRegion(HConstants.META_TABLE_NAME, HRegionInfo.createRegionName(tableName, null, HConstants.NINES, false)); }
/** * setup this HTable's parameter based on the passed configuration * @param conf */ private void finishSetup() throws IOException { this.connection.locateRegion(tableName, HConstants.EMPTY_START_ROW); this.operationTimeout = HTableDescriptor.isMetaTable(tableName) ? HConstants.DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT : this.configuration.getInt(HConstants.HBASE_CLIENT_OPERATION_TIMEOUT, HConstants.DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT); this.writeBufferSize = this.configuration.getLong( "hbase.client.write.buffer", 2097152); this.clearBufferOnFail = true; this.autoFlush = true; this.currentWriteBufferSize = 0; this.scannerCaching = this.configuration.getInt( "hbase.client.scanner.caching", 1); this.maxKeyValueSize = this.configuration.getInt( "hbase.client.keyvalue.maxsize", -1); this.closed = false; }
@Override public void prepare(boolean reload) throws IOException { if (!reload) return; // relocate regions in case we have a new dead server or network hiccup // if not due to connection issue, the following code should run fast because it uses // cached location boolean skip = false; for (Entry entry : this.entries) { WALEdit edit = entry.getEdit(); List<Cell> cells = edit.getCells(); for (Cell cell : cells) { // filtering WAL meta entries setLocation(conn.locateRegion(tableName, cell.getRow())); skip = true; break; } // use first log entry to relocate region because all entries are for one region if (skip) break; } } }
/** * Record the location of the ROOT region as found in ZooKeeper, * as if it were in a META table. This is so that we can check * deployment of ROOT. */ private boolean recordRootRegion() throws IOException { HRegionLocation rootLocation = connection.locateRegion( HConstants.ROOT_TABLE_NAME, HConstants.EMPTY_START_ROW); // Check if Root region is valid and existing if (rootLocation == null || rootLocation.getRegionInfo() == null || rootLocation.getHostname() == null) { errors.reportError(ERROR_CODE.NULL_ROOT_REGION, "Root Region or some of its attributes are null."); return false; } ServerName sn; try { sn = getRootRegionServerName(); } catch (InterruptedException e) { throw new IOException("Interrupted", e); } MetaEntry m = new MetaEntry(rootLocation.getRegionInfo(), sn, System.currentTimeMillis()); HbckInfo hbInfo = new HbckInfo(m); regionInfoMap.put(rootLocation.getRegionInfo().getEncodedName(), hbInfo); return true; }
HRegionLocation rootLocation = connection.locateRegion( HConstants.ROOT_TABLE_NAME, HConstants.EMPTY_START_ROW); HbckInfo root =