/********************************* Master related hooks **********************************/ @Override public void postStartMaster(ObserverContext<MasterCoprocessorEnvironment> ctx) throws IOException { // Need to create the new system table for labels here MasterServices master = ctx.getEnvironment().getMasterServices(); if (!MetaTableAccessor.tableExists(master.getConnection(), LABELS_TABLE_NAME)) { HTableDescriptor labelsTable = new HTableDescriptor(LABELS_TABLE_NAME); HColumnDescriptor labelsColumn = new HColumnDescriptor(LABELS_TABLE_FAMILY); labelsColumn.setBloomFilterType(BloomType.NONE); labelsColumn.setBlockCacheEnabled(false); // We will cache all the labels. No need of normal // table block cache. labelsTable.addFamily(labelsColumn); // Let the "labels" table having only one region always. We are not expecting too many labels in // the system. labelsTable.setValue(HTableDescriptor.SPLIT_POLICY, DisabledRegionSplitPolicy.class.getName()); labelsTable.setValue(Bytes.toBytes(HConstants.DISALLOW_WRITES_IN_RECOVERING), Bytes.toBytes(true)); master.createTable(labelsTable, null, HConstants.NO_NONCE, HConstants.NO_NONCE); } }
/** * Converting writable serialization to PB, if it is needed. * @param services MasterServices to get a handle on master * @return num migrated rows * @throws IOException or RuntimeException if something goes wrong */ public static long updateMetaIfNecessary(final MasterServices services) throws IOException { if (isMetaTableUpdated(services.getConnection())) { LOG.info("META already up-to date with PB serialization"); return 0; } LOG.info("META has Writable serializations, migrating hbase:meta to PB serialization"); try { long rows = updateMeta(services); LOG.info("META updated with PB serialization. Total rows updated: " + rows); return rows; } catch (IOException e) { LOG.warn("Update hbase:meta with PB serialization failed." + "Master startup aborted."); throw e; } }
/** * Create the ACL table * @param master * @throws IOException */ static void createACLTable(MasterServices master) throws IOException { master.createTable(new HTableDescriptor(ACL_TABLE_NAME) .addFamily(new HColumnDescriptor(ACL_LIST_FAMILY) .setMaxVersions(1) .setInMemory(true) .setBlockCacheEnabled(true) .setBlocksize(8 * 1024) .setBloomFilterType(BloomType.NONE) .setScope(HConstants.REPLICATION_SCOPE_LOCAL) // Set cache data blocks in L1 if more than one cache tier deployed; e.g. this will // be the case if we are using CombinedBlockCache (Bucket Cache). .setCacheDataInL1(true)), null, HConstants.NO_NONCE, HConstants.NO_NONCE); }
@Override public void preGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx, List<TableName> tableNamesList, List<HTableDescriptor> descriptors, String regex) throws IOException { // We are delegating the authorization check to postGetTableDescriptors as we don't have // any concrete set of table names when a regex is present or the full list is requested. if (regex == null && tableNamesList != null && !tableNamesList.isEmpty()) { // Otherwise, if the requestor has ADMIN or CREATE privs for all listed tables, the // request can be granted. MasterServices masterServices = ctx.getEnvironment().getMasterServices(); for (TableName tableName: tableNamesList) { // Skip checks for a table that does not exist if (masterServices.getTableDescriptors().get(tableName) == null) { continue; } requirePermission("getTableDescriptors", tableName, null, null, Action.ADMIN, Action.CREATE); } } }
/** * If hbase:meta is not assigned already, assign. * @throws InterruptedException * @throws IOException * @throws KeeperException */ private void verifyAndAssignMeta(final MasterProcedureEnv env) throws InterruptedException, IOException, KeeperException { MasterServices services = env.getMasterServices(); if (!isMetaAssignedQuickTest(env)) { services.getAssignmentManager().assignMeta(HRegionInfo.FIRST_META_REGIONINFO); } else if (serverName.equals(services.getMetaTableLocator(). getMetaRegionLocation(services.getZooKeeper()))) { // hbase:meta seems to be still alive on the server whom master is expiring // and thinks is dying. Let's re-assign the hbase:meta anyway. services.getAssignmentManager().assignMeta(HRegionInfo.FIRST_META_REGIONINFO); } else { LOG.info("Skip assigning hbase:meta because it is online at " + services.getMetaTableLocator().getMetaRegionLocation(services.getZooKeeper())); } }
public RestoreSnapshotHandler(final MasterServices masterServices, final SnapshotDescription snapshot, final HTableDescriptor htd) throws IOException { super(EventType.C_M_RESTORE_SNAPSHOT, htd.getTableName(), masterServices, masterServices); // Snapshot information this.snapshot = snapshot; // Monitor this.monitor = new ForeignExceptionDispatcher(); // Check table exists. getTableDescriptor(); // This is the new schema we are going to write out as this modification. this.hTableDescriptor = htd; this.status = TaskMonitor.get().createStatus( "Restoring snapshot '" + snapshot.getName() + "' to table " + hTableDescriptor.getTableName()); }
@Override public void initialize(MasterServices master, MetricsMaster metricsMaster) throws KeeperException, IOException, UnsupportedOperationException { this.master = master; // get the configuration for the coordinator Configuration conf = master.getConfiguration(); long wakeFrequency = conf.getInt(FLUSH_WAKE_MILLIS_KEY, FLUSH_WAKE_MILLIS_DEFAULT); long timeoutMillis = conf.getLong(FLUSH_TIMEOUT_MILLIS_KEY, FLUSH_TIMEOUT_MILLIS_DEFAULT); int threads = conf.getInt(FLUSH_PROC_POOL_THREADS_KEY, FLUSH_PROC_POOL_THREADS_DEFAULT); // setup the procedure coordinator String name = master.getServerName().toString(); ThreadPoolExecutor tpool = ProcedureCoordinator.defaultPool(name, threads); ProcedureCoordinatorRpcs comms = new ZKProcedureCoordinatorRpcs( master.getZooKeeper(), getProcedureSignature(), name); this.coordinator = new ProcedureCoordinator(comms, tpool, timeoutMillis, wakeFrequency); }
@BeforeClass public static void beforeAllTests() throws Exception { Configuration conf = HBaseConfiguration.create(); conf.setClass("hbase.util.ip.to.rack.determiner", MockMapping.class, DNSToSwitchMapping.class); loadBalancer = new MockBalancer(); loadBalancer.setConf(conf); MasterServices st = Mockito.mock(MasterServices.class); Mockito.when(st.getServerName()).thenReturn(master); loadBalancer.setMasterServices(st); // Set up the rack topologies (5 machines per rack) rackManager = Mockito.mock(RackManager.class); for (int i = 0; i < NUM_SERVERS; i++) { servers[i] = ServerName.valueOf("foo"+i+":1234",-1); if (i < 5) { Mockito.when(rackManager.getRack(servers[i])).thenReturn("rack1"); } if (i >= 5 && i < 10) { Mockito.when(rackManager.getRack(servers[i])).thenReturn("rack2"); } if (i >= 10) { Mockito.when(rackManager.getRack(servers[i])).thenReturn("rack3"); } } }
protected void setupMocksForNormalizer(Map<byte[], Integer> regionSizes, List<HRegionInfo> hris) { masterServices = Mockito.mock(MasterServices.class, RETURNS_DEEP_STUBS); // for simplicity all regions are assumed to be on one server; doesn't matter to us ServerName sn = ServerName.valueOf("localhost", -1, 1L); when(masterServices.getAssignmentManager().getRegionStates(). getRegionsOfTable(any(TableName.class))).thenReturn(hris); when(masterServices.getAssignmentManager().getRegionStates(). getRegionServerOfRegion(any(HRegionInfo.class))).thenReturn(sn); for (Map.Entry<byte[], Integer> region : regionSizes.entrySet()) { RegionLoad regionLoad = Mockito.mock(RegionLoad.class); when(regionLoad.getName()).thenReturn(region.getKey()); when(regionLoad.getStorefileSizeMB()).thenReturn(region.getValue()); when(masterServices.getServerManager().getLoad(sn). getRegionsLoad().get(region.getKey())).thenReturn(regionLoad); } normalizer.setMasterServices(masterServices); }
/** * @return True if the meta table has been migrated. * @throws IOException */ // Public because used in tests public static boolean isMetaHRIUpdated(final MasterServices services) throws IOException { List<Result> results = MetaReader.fullScanOfRoot(services.getCatalogTracker()); if (results == null || results.isEmpty()) { LOG.info("Not migrated"); return false; } // Presume only the one result because we only support on meta region. Result r = results.get(0); short version = getMetaVersion(r); boolean migrated = version >= HConstants.META_VERSION; LOG.info("Meta version=" + version + "; migrated=" + migrated); return migrated; }
/** * @return True if migrated. * @throws IOException */ public static boolean updateMetaWithNewHRI(final MasterServices services) throws IOException { if (isMetaHRIUpdated(services)) { LOG.info("ROOT/Meta already up-to date with new HRI."); return true; } LOG.info("Meta has HRI with HTDs. Updating meta now."); try { migrateRootAndMeta(services); LOG.info("ROOT and Meta updated with new HRI."); return true; } catch (IOException e) { throw new RuntimeException("Update ROOT/Meta with new HRI failed." + "Master startup aborted."); } }
private boolean checkRegionInTransition(ObserverContext<MasterCoprocessorEnvironment> ctx, HRegionInfo hri) { MasterServices master = ctx.getEnvironment().getMasterServices(); RegionStates regionStates = master.getAssignmentManager().getRegionStates(); String tableName = hri.getTable().getNameAsString(); if (!IndexUtils.isIndexTable(tableName)) { if (regionStates.isRegionInTransition(hri)) { return true; } else { String indexTableName = IndexUtils.getIndexTableName(tableName); for (Entry<String, RegionState> region : regionStates.getRegionsInTransition().entrySet()) { HRegionInfo regionInfo = region.getValue().getRegion(); if (indexTableName.equals(regionInfo.getTable().getNameAsString())) { if (Bytes.compareTo(hri.getStartKey(), regionInfo.getStartKey()) == 0) { return true; } } } } } return false; }
public TableEventHandler(EventType eventType, byte [] tableName, Server server, MasterServices masterServices) throws IOException { super(server, eventType); this.masterServices = masterServices; this.tableName = tableName; try { this.masterServices.checkTableModifiable(tableName); } catch (TableNotDisabledException ex) { if (isOnlineSchemaChangeAllowed() && eventType.isOnlineSchemaChangeSupported()) { LOG.debug("Ignoring table not disabled exception " + "for supporting online schema changes."); } else { throw ex; } } this.tableNameStr = Bytes.toString(this.tableName); }
public CloneSnapshotHandler(final MasterServices masterServices, final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor, final MasterMetrics metricsMaster) throws NotAllMetaRegionsOnlineException, TableExistsException, IOException { super(masterServices, masterServices.getMasterFileSystem(), masterServices.getServerManager(), hTableDescriptor, masterServices.getConfiguration(), null, masterServices.getCatalogTracker(), masterServices.getAssignmentManager()); this.metricsMaster = metricsMaster; // Snapshot information this.snapshot = snapshot; // Monitor this.monitor = new ForeignExceptionDispatcher(); this.status = TaskMonitor.get().createStatus("Cloning snapshot '" + snapshot.getName() + "' to table " + hTableDescriptor.getNameAsString()); }
/** * @param snapshot descriptor of the snapshot to take * @param masterServices master services provider * @throws IOException on unexpected error */ public TakeSnapshotHandler(SnapshotDescription snapshot, final MasterServices masterServices, final MasterMetrics metricsMaster) { super(masterServices, EventType.C_M_SNAPSHOT_TABLE); assert snapshot != null : "SnapshotDescription must not be nul1"; assert masterServices != null : "MasterServices must not be nul1"; this.master = masterServices; this.metricsMaster = metricsMaster; this.snapshot = snapshot; this.conf = this.master.getConfiguration(); this.fs = this.master.getMasterFileSystem().getFileSystem(); this.rootDir = this.master.getMasterFileSystem().getRootDir(); this.snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshot, rootDir); this.workingDir = SnapshotDescriptionUtils.getWorkingSnapshotDir(snapshot, rootDir); this.monitor = new ForeignExceptionDispatcher(snapshot.getName()); // prepare the verify this.verifier = new MasterSnapshotVerifier(masterServices, snapshot, rootDir); // update the running tasks this.status = TaskMonitor.get().createStatus( "Taking " + snapshot.getType() + " snapshot on table: " + snapshot.getTable()); }
/** * Modify table is async so wait on completion of the table operation in master. * @param tableName * @param htd * @throws IOException */ private void modifyTable(final byte [] tableName, final HTableDescriptor htd) throws IOException { MasterServices services = TEST_UTIL.getMiniHBaseCluster().getMaster(); ExecutorService executor = services.getExecutorService(); AtomicBoolean done = new AtomicBoolean(false); executor.registerListener(EventType.C_M_MODIFY_TABLE, new DoneListener(done)); this.admin.modifyTable(tableName, htd); while (!done.get()) { synchronized (done) { try { done.wait(100); } catch (InterruptedException e) { e.printStackTrace(); } } } executor.unregisterListener(EventType.C_M_MODIFY_TABLE); }
/********************************* Master related hooks **********************************/ @Override public void postStartMaster(ObserverContext<MasterCoprocessorEnvironment> ctx) throws IOException { // Need to create the new system table for labels here MasterServices master = ctx.getEnvironment().getMasterServices(); if (!MetaTableAccessor.tableExists(master.getConnection(), LABELS_TABLE_NAME)) { HTableDescriptor labelsTable = new HTableDescriptor(LABELS_TABLE_NAME); HColumnDescriptor labelsColumn = new HColumnDescriptor(LABELS_TABLE_FAMILY); labelsColumn.setBloomFilterType(BloomType.NONE); labelsColumn.setBlockCacheEnabled(false); // We will cache all the labels. No need of normal // table block cache. labelsTable.addFamily(labelsColumn); // Let the "labels" table having only one region always. We are not expecting too many labels in // the system. labelsTable.setValue(HTableDescriptor.SPLIT_POLICY, DisabledRegionSplitPolicy.class.getName()); labelsTable.setValue(Bytes.toBytes(HConstants.DISALLOW_WRITES_IN_RECOVERING), Bytes.toBytes(true)); master.createTable(labelsTable, null); } }
private void disableAndDeleteTable(MasterServices master, TableName tableName) throws IOException { LOG.error(tableName + " already exists. Disabling and deleting table " + tableName + '.'); boolean disabled = master.getAssignmentManager().getZKTable().isDisabledTable(tableName); if (false == disabled) { LOG.info("Disabling table " + tableName + '.'); new DisableTableHandler(master, tableName, master.getCatalogTracker(), master.getAssignmentManager(), master.getTableLockManager(), false).prepare().process(); if (false == master.getAssignmentManager().getZKTable().isDisabledTable(tableName)) { throw new DoNotRetryIOException("Table " + tableName + " not disabled."); } } LOG.info("Disabled table " + tableName + '.'); LOG.info("Deleting table " + tableName + '.'); new DeleteTableHandler(tableName, master, master).prepare().process(); if (true == MetaReader.tableExists(master.getCatalogTracker(), tableName)) { throw new DoNotRetryIOException("Table " + tableName + " not deleted."); } LOG.info("Deleted table " + tableName + '.'); }
@Override public void initialize(MasterServices master, MetricsMaster metricsMaster) throws KeeperException, IOException, UnsupportedOperationException { this.master = master; this.rootDir = master.getMasterFileSystem().getRootDir(); checkSnapshotSupport(master.getConfiguration(), master.getMasterFileSystem()); // get the configuration for the coordinator Configuration conf = master.getConfiguration(); long wakeFrequency = conf.getInt(SNAPSHOT_WAKE_MILLIS_KEY, SNAPSHOT_WAKE_MILLIS_DEFAULT); long timeoutMillis = conf.getLong(SNAPSHOT_TIMEOUT_MILLIS_KEY, SNAPSHOT_TIMEOUT_MILLIS_DEFAULT); int opThreads = conf.getInt(SNAPSHOT_POOL_THREADS_KEY, SNAPSHOT_POOL_THREADS_DEFAULT); // setup the default procedure coordinator String name = master.getServerName().toString(); ThreadPoolExecutor tpool = ProcedureCoordinator.defaultPool(name, opThreads); ProcedureCoordinatorRpcs comms = new ZKProcedureCoordinatorRpcs( master.getZooKeeper(), SnapshotManager.ONLINE_SNAPSHOT_CONTROLLER_DESCRIPTION, name); this.coordinator = new ProcedureCoordinator(comms, tpool, timeoutMillis, wakeFrequency); this.executorService = master.getExecutorService(); resetTempDir(); }
/** * Converting writable serialization to PB, if it is needed. * @param services MasterServices to get a handle on master * @return num migrated rows * @throws IOException or RuntimeException if something goes wrong */ public static long updateMetaIfNecessary(final MasterServices services) throws IOException { if (isMetaTableUpdated(services.getCatalogTracker())) { LOG.info("META already up-to date with PB serialization"); return 0; } LOG.info("META has Writable serializations, migrating hbase:meta to PB serialization"); try { long rows = updateMeta(services); LOG.info("META updated with PB serialization. Total rows updated: " + rows); return rows; } catch (IOException e) { LOG.warn("Update hbase:meta with PB serialization failed." + "Master startup aborted."); throw e; } }
@Override public void postDeleteTableHandler(ObserverContext<MasterCoprocessorEnvironment> ctx, TableName tableName) throws IOException { LOG.info("Entered into postDeleteTableHandler of table " + tableName + '.'); MasterServices master = ctx.getEnvironment().getMasterServices(); TableName indexTableName = TableName.valueOf(IndexUtils.getIndexTableName(tableName)); boolean indexTablePresent = master.getAssignmentManager().getZKTable().isTablePresent(indexTableName); // Not checking for disabled state because before deleting user table both user and index table // should be disabled. if ((!IndexUtils.isIndexTable(tableName)) && indexTablePresent) { LoadBalancer balancer = master.getAssignmentManager().getBalancer(); if (balancer instanceof SecIndexLoadBalancer) { ((SecIndexLoadBalancer) balancer).removeIndexedTable(tableName); } DeleteTableHandler dth = new DeleteTableHandler(indexTableName, master, master); dth.prepare(); dth.process(); } LOG.info("Exiting from postDeleteTableHandler of table " + tableName + '.'); }
ServerShutdownHandler(final Server server, final MasterServices services, final DeadServer deadServers, final ServerName serverName, EventType type, final boolean shouldSplitHlog) { super(server, type); this.serverName = serverName; this.server = server; this.services = services; this.deadServers = deadServers; if (!this.deadServers.isDeadServer(this.serverName)) { LOG.warn(this.serverName + " is NOT in deadservers; it should be!"); } this.shouldSplitHlog = shouldSplitHlog; this.distributedLogReplay = HLogSplitter.isDistributedLogReplay(server.getConfiguration()); this.regionAssignmentWaitTimeout = server.getConfiguration().getInt( HConstants.LOG_REPLAY_WAIT_REGION_TIMEOUT, 15000); }
public CreateTableHandler(Server server, MasterFileSystem fileSystemManager, HTableDescriptor hTableDescriptor, Configuration conf, HRegionInfo [] newRegions, MasterServices masterServices) { super(server, EventType.C_M_CREATE_TABLE); this.fileSystemManager = fileSystemManager; this.hTableDescriptor = hTableDescriptor; this.conf = conf; this.newRegions = newRegions; this.catalogTracker = masterServices.getCatalogTracker(); this.assignmentManager = masterServices.getAssignmentManager(); this.tableLockManager = masterServices.getTableLockManager(); this.tableLock = this.tableLockManager.writeLock(this.hTableDescriptor.getTableName() , EventType.C_M_CREATE_TABLE.toString()); }
/** * Update hbase:meta rows, converting writable serialization to PB * @return num migrated rows */ static long updateMeta(final MasterServices masterServices) throws IOException { LOG.info("Starting update of META"); ConvertToPBMetaVisitor v = new ConvertToPBMetaVisitor(masterServices); MetaTableAccessor.fullScan(masterServices.getConnection(), v); LOG.info("Finished update of META. Total rows updated:" + v.numMigratedRows); return v.numMigratedRows; }
public SplitLogManagerDetails(ConcurrentMap<String, Task> tasks, MasterServices master, Set<String> failedDeletions, ServerName serverName) { this.tasks = tasks; this.master = master; this.failedDeletions = failedDeletions; this.serverName = serverName; }
@Override public synchronized void setMasterServices(MasterServices masterServices) { super.setMasterServices(masterServices); this.localityCost.setServices(masterServices); this.localityCandidateGenerator.setServices(masterServices); }
public DispatchMergingRegionHandler(final MasterServices services, final CatalogJanitor catalogJanitor, final HRegionInfo region_a, final HRegionInfo region_b, final boolean forcible) { super(services, EventType.C_M_MERGE_REGION); this.masterServices = services; this.catalogJanitor = catalogJanitor; this.region_a = region_a; this.region_b = region_b; this.forcible = forcible; this.timeout = server.getConfiguration().getInt( "hbase.master.regionmerge.timeout", 120 * 1000); }
public CreateTableHandler(Server server, MasterFileSystem fileSystemManager, HTableDescriptor hTableDescriptor, Configuration conf, HRegionInfo [] newRegions, MasterServices masterServices) { super(server, EventType.C_M_CREATE_TABLE); this.fileSystemManager = fileSystemManager; this.hTableDescriptor = hTableDescriptor; this.conf = conf; this.newRegions = newRegions; this.assignmentManager = masterServices.getAssignmentManager(); this.tableLockManager = masterServices.getTableLockManager(); this.tableLock = this.tableLockManager.writeLock(this.hTableDescriptor.getTableName() , EventType.C_M_CREATE_TABLE.toString()); }
public EnableTableHandler(MasterServices services, TableName tableName, AssignmentManager assignmentManager, TableLockManager tableLockManager, boolean skipTableStateCheck) { this((Server)services, tableName, assignmentManager, tableLockManager, skipTableStateCheck); this.services = services; }
/** * @param services services for the master * @param snapshot snapshot to check * @param rootDir root directory of the hbase installation. */ public MasterSnapshotVerifier(MasterServices services, SnapshotDescription snapshot, Path rootDir) { this.fs = services.getMasterFileSystem().getFileSystem(); this.services = services; this.snapshot = snapshot; this.rootDir = rootDir; this.tableName = TableName.valueOf(snapshot.getTable()); }
/** * Fully specify all necessary components of a snapshot manager. Exposed for testing. * @param master services for the master where the manager is running * @param coordinator procedure coordinator instance. exposed for testing. * @param pool HBase ExecutorServcie instance, exposed for testing. */ public SnapshotManager(final MasterServices master, final MetricsMaster metricsMaster, ProcedureCoordinator coordinator, ExecutorService pool) throws IOException, UnsupportedOperationException { this.master = master; this.rootDir = master.getMasterFileSystem().getRootDir(); checkSnapshotSupport(master.getConfiguration(), master.getMasterFileSystem()); this.coordinator = coordinator; this.executorService = pool; resetTempDir(); }
@Override public void initialize(MasterServices master, MetricsMaster metricsMaster) throws KeeperException, IOException, UnsupportedOperationException { this.master = master; this.rootDir = master.getMasterFileSystem().getRootDir(); checkSnapshotSupport(master.getConfiguration(), master.getMasterFileSystem()); // get the configuration for the coordinator Configuration conf = master.getConfiguration(); long wakeFrequency = conf.getInt(SNAPSHOT_WAKE_MILLIS_KEY, SNAPSHOT_WAKE_MILLIS_DEFAULT); long timeoutMillis = Math.max(conf.getLong(SnapshotDescriptionUtils.SNAPSHOT_TIMEOUT_MILLIS_KEY, SnapshotDescriptionUtils.SNAPSHOT_TIMEOUT_MILLIS_DEFAULT), conf.getLong(SnapshotDescriptionUtils.MASTER_SNAPSHOT_TIMEOUT_MILLIS, SnapshotDescriptionUtils.DEFAULT_MAX_WAIT_TIME)); int opThreads = conf.getInt(SNAPSHOT_POOL_THREADS_KEY, SNAPSHOT_POOL_THREADS_DEFAULT); // setup the default procedure coordinator String name = master.getServerName().toString(); ThreadPoolExecutor tpool = ProcedureCoordinator.defaultPool(name, opThreads); ProcedureCoordinatorRpcs comms = new ZKProcedureCoordinatorRpcs( master.getZooKeeper(), SnapshotManager.ONLINE_SNAPSHOT_CONTROLLER_DESCRIPTION, name); this.coordinator = new ProcedureCoordinator(comms, tpool, timeoutMillis, wakeFrequency); this.executorService = master.getExecutorService(); resetTempDir(); }
public CloneSnapshotHandler(final MasterServices masterServices, final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor) { super(masterServices, masterServices.getMasterFileSystem(), hTableDescriptor, masterServices.getConfiguration(), null, masterServices); // Snapshot information this.snapshot = snapshot; // Monitor this.monitor = new ForeignExceptionDispatcher(); this.status = TaskMonitor.get().createStatus("Cloning snapshot '" + snapshot.getName() + "' to table " + hTableDescriptor.getTableName()); }
/** * @param snapshot descriptor of the snapshot to take * @param masterServices master services provider */ public TakeSnapshotHandler(SnapshotDescription snapshot, final MasterServices masterServices) { super(masterServices, EventType.C_M_SNAPSHOT_TABLE); assert snapshot != null : "SnapshotDescription must not be nul1"; assert masterServices != null : "MasterServices must not be nul1"; this.master = masterServices; this.snapshot = snapshot; this.snapshotTable = TableName.valueOf(snapshot.getTable()); this.conf = this.master.getConfiguration(); this.fs = this.master.getMasterFileSystem().getFileSystem(); this.rootDir = this.master.getMasterFileSystem().getRootDir(); this.snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshot, rootDir); this.workingDir = SnapshotDescriptionUtils.getWorkingSnapshotDir(snapshot, rootDir); this.monitor = new ForeignExceptionDispatcher(snapshot.getName()); this.snapshotManifest = SnapshotManifest.create(conf, fs, workingDir, snapshot, monitor); this.tableLockManager = master.getTableLockManager(); this.tableLock = this.tableLockManager.writeLock( snapshotTable, EventType.C_M_SNAPSHOT_TABLE.toString()); // prepare the verify this.verifier = new MasterSnapshotVerifier(masterServices, snapshot, rootDir); // update the running tasks this.status = TaskMonitor.get().createStatus( "Taking " + snapshot.getType() + " snapshot on table: " + snapshotTable); }
@Override public void initialize(MasterServices master, MetricsMaster metricsMaster) throws KeeperException, IOException, UnsupportedOperationException { this.master = master; this.done = false; // setup the default procedure coordinator String name = master.getServerName().toString(); ThreadPoolExecutor tpool = ProcedureCoordinator.defaultPool(name, 1); ProcedureCoordinatorRpcs comms = new ZKProcedureCoordinatorRpcs( master.getZooKeeper(), getProcedureSignature(), name); this.coordinator = new ProcedureCoordinator(comms, tpool); }