/** * return TableDescriptor for a given tableName * * @param tableName the table name * @return TableDescriptor * @throws IOException */ protected TableDescriptor getTableDescriptor(TableName tableName) throws IOException { TableDescriptor tableDescriptor = null; try { if (this.services != null && this.services.getTableDescriptors() != null) { tableDescriptor = this.services.getTableDescriptors().get(tableName); } } catch (FileNotFoundException fnfe) { LOG.debug("tableName={}", tableName, fnfe); } return tableDescriptor; }
private TableDescriptor loadTableDescriptor() throws FileNotFoundException, IOException { TableDescriptor htd = this.master.getTableDescriptors().get(snapshotTable); if (htd == null) { throw new IOException("TableDescriptor missing for " + snapshotTable); } return htd; }
private TableDescriptor getTableDescriptor(final TableName tableName) throws FileNotFoundException, IOException { return this.services.getTableDescriptors().get(tableName); }
private TableDescriptor getTableDescriptor(TableName tableName) throws IOException { return master.getTableDescriptors().get(tableName); }
protected static void deleteTableDescriptorCache(final MasterProcedureEnv env, final TableName tableName) throws IOException { LOG.debug("Removing '" + tableName + "' descriptor."); env.getMasterServices().getTableDescriptors().remove(tableName); }
/** * Update descriptor * @param env MasterProcedureEnv * @throws IOException **/ private void updateTableDescriptor(final MasterProcedureEnv env) throws IOException { env.getMasterServices().getTableDescriptors().add(modifiedTableDescriptor); }
/** * Update descriptor * @param env MasterProcedureEnv * @throws IOException **/ private void updateTableDescriptor(final MasterProcedureEnv env) throws IOException { env.getMasterServices().getTableDescriptors().add(modifiedTableDescriptor); }
protected static void updateTableDescCache(final MasterProcedureEnv env, final TableName tableName) throws IOException { env.getMasterServices().getTableDescriptors().get(tableName); }
public void start() throws IOException { TableDescriptors tableDescriptors = master.getTableDescriptors(); migrateZooKeeper(); Connection connection = master.getConnection(); fixTableStates(tableDescriptors, connection); }
protected static MasterServices getMockedMaster() throws IOException { TableDescriptors tds = Mockito.mock(TableDescriptors.class); Mockito.when(tds.get(tables[0])).thenReturn(tableDescs.get(0)); Mockito.when(tds.get(tables[1])).thenReturn(tableDescs.get(1)); Mockito.when(tds.get(tables[2])).thenReturn(tableDescs.get(2)); Mockito.when(tds.get(tables[3])).thenReturn(tableDescs.get(3)); MasterServices services = Mockito.mock(HMaster.class); Mockito.when(services.getTableDescriptors()).thenReturn(tds); AssignmentManager am = Mockito.mock(AssignmentManager.class); Mockito.when(services.getAssignmentManager()).thenReturn(am); return services; }
private int getRegionReplication(final MasterProcedureEnv env) throws IOException { final TableDescriptor htd = env.getMasterServices().getTableDescriptors().get(getTableName()); return htd.getRegionReplication(); }
@Override public synchronized void setClusterMetrics(ClusterMetrics st) { super.setClusterMetrics(st); updateRegionLoad(); for(CostFromRegionLoadFunction cost : regionLoadFunctions) { cost.setClusterMetrics(st); } // update metrics size try { // by-table or ensemble mode int tablesCount = isByTable ? services.getTableDescriptors().getAll().size() : 1; int functionsCount = getCostFunctionNames().length; updateMetricsSize(tablesCount * (functionsCount + 1)); // +1 for overall } catch (Exception e) { LOG.error("failed to get the size of all tables", e); } }
private int getRegionReplication(final MasterProcedureEnv env) throws IOException { final TableDescriptor htd = env.getMasterServices().getTableDescriptors().get(getTableName()); return htd.getRegionReplication(); }
protected final void setLastPushedSequenceId(MasterProcedureEnv env, ReplicationPeerConfig peerConfig) throws IOException, ReplicationException { Map<String, Long> lastSeqIds = new HashMap<String, Long>(); for (TableDescriptor td : env.getMasterServices().getTableDescriptors().getAll().values()) { if (!td.hasGlobalReplicationScope()) { continue; } TableName tn = td.getTableName(); if (!ReplicationUtils.contains(peerConfig, tn)) { continue; } setLastPushedSequenceIdForTable(env, tn, lastSeqIds); } if (!lastSeqIds.isEmpty()) { env.getReplicationPeerManager().getQueueStorage().setLastSequenceIds(peerId, lastSeqIds); } }
/** * Create reference file(s) of merging regions under the merged directory * @param env MasterProcedureEnv * @param regionFs region file system * @param mergedDir the temp directory of merged region */ private void mergeStoreFiles( final MasterProcedureEnv env, final HRegionFileSystem regionFs, final Path mergedDir) throws IOException { final MasterFileSystem mfs = env.getMasterServices().getMasterFileSystem(); final Configuration conf = env.getMasterConfiguration(); final TableDescriptor htd = env.getMasterServices().getTableDescriptors().get(getTableName()); for (String family : regionFs.getFamilies()) { final ColumnFamilyDescriptor hcd = htd.getColumnFamily(Bytes.toBytes(family)); final Collection<StoreFileInfo> storeFiles = regionFs.getStoreFiles(family); if (storeFiles != null && storeFiles.size() > 0) { for (StoreFileInfo storeFileInfo : storeFiles) { // Create reference file(s) of the region in mergedDir. // As this procedure is running on master, use CacheConfig.DISABLED means // don't cache any block. regionFs.mergeStoreFile(mergedRegion, family, new HStoreFile(mfs.getFileSystem(), storeFileInfo, conf, CacheConfig.DISABLED, hcd.getBloomFilterType(), true), mergedDir); } } } }
protected static List<RegionInfo> createFsLayout(final MasterProcedureEnv env, final TableDescriptor tableDescriptor, List<RegionInfo> newRegions, final CreateHdfsRegions hdfsRegionHandler) throws IOException { final MasterFileSystem mfs = env.getMasterServices().getMasterFileSystem(); final Path tempdir = mfs.getTempDir(); // 1. Create Table Descriptor // using a copy of descriptor, table will be created enabling first final Path tempTableDir = FSUtils.getTableDir(tempdir, tableDescriptor.getTableName()); ((FSTableDescriptors)(env.getMasterServices().getTableDescriptors())) .createTableDescriptorForTableDirectory( tempTableDir, tableDescriptor, false); // 2. Create Regions newRegions = hdfsRegionHandler.createHdfsRegions(env, tempdir, tableDescriptor.getTableName(), newRegions); // 3. Move Table temp directory to the hbase root location moveTempDirectoryToHBaseRoot(env, tableDescriptor, tempTableDir); return newRegions; }
@Override protected void run() throws IOException { TableDescriptor oldDescriptor = getMaster().getTableDescriptors().get(tableName); TableDescriptor newDescriptor = getMaster().getMasterCoprocessorHost() .preModifyTable(tableName, oldDescriptor, newDescriptorGetter.get()); sanityCheckTableDescriptor(newDescriptor); LOG.info("{} modify table {} from {} to {}", getClientIdAuditPrefix(), tableName, oldDescriptor, newDescriptor); // Execute the operation synchronously - wait for the operation completes before // continuing. // // We need to wait for the procedure to potentially fail due to "prepare" sanity // checks. This will block only the beginning of the procedure. See HBASE-19953. ProcedurePrepareLatch latch = ProcedurePrepareLatch.createBlockingLatch(); submitProcedure( new ModifyTableProcedure(procedureExecutor.getEnvironment(), newDescriptor, latch)); latch.await(); getMaster().getMasterCoprocessorHost().postModifyTable(tableName, oldDescriptor, newDescriptor); }
@VisibleForTesting protected void reopenRegions(MasterProcedureEnv env) throws IOException { ReplicationPeerConfig peerConfig = getNewPeerConfig(); ReplicationPeerConfig oldPeerConfig = getOldPeerConfig(); TableStateManager tsm = env.getMasterServices().getTableStateManager(); for (TableDescriptor td : env.getMasterServices().getTableDescriptors().getAll().values()) { if (!td.hasGlobalReplicationScope()) { continue; } TableName tn = td.getTableName(); if (!ReplicationUtils.contains(peerConfig, tn)) { continue; } if (oldPeerConfig != null && oldPeerConfig.isSerial() && ReplicationUtils.contains(oldPeerConfig, tn)) { continue; } if (needReopen(tsm, tn)) { addChildProcedure(new ReopenTableRegionsProcedure(tn)); } } }
/** * Create region layout in file system. * @param env MasterProcedureEnv * @throws IOException */ private List<RegionInfo> createFsLayout( final MasterProcedureEnv env, final TableDescriptor tableDescriptor, List<RegionInfo> newRegions, final CreateHdfsRegions hdfsRegionHandler) throws IOException { final MasterFileSystem mfs = env.getMasterServices().getMasterFileSystem(); final Path tempdir = mfs.getTempDir(); // 1. Create Table Descriptor // using a copy of descriptor, table will be created enabling first final Path tempTableDir = FSUtils.getTableDir(tempdir, tableDescriptor.getTableName()); ((FSTableDescriptors)(env.getMasterServices().getTableDescriptors())) .createTableDescriptorForTableDirectory(tempTableDir, TableDescriptorBuilder.newBuilder(tableDescriptor).build(), false); // 2. Create Regions newRegions = hdfsRegionHandler.createHdfsRegions( env, tempdir, tableDescriptor.getTableName(), newRegions); // 3. Move Table temp directory to the hbase root location CreateTableProcedure.moveTempDirectoryToHBaseRoot(env, tableDescriptor, tempTableDir); // Move Table temp mob directory to the hbase root location Path tempMobTableDir = MobUtils.getMobTableDir(tempdir, tableDescriptor.getTableName()); if (mfs.getFileSystem().exists(tempMobTableDir)) { moveTempMobDirectoryToHBaseRoot(mfs, tableDescriptor, tempMobTableDir); } return newRegions; }
.setRegionId(rid) .build(); TableDescriptor htd = env.getMasterServices().getTableDescriptors().get(getTableName()); if(htd.getRegionSplitPolicyClassName() != null) {