Search in sources :

Example 1 with SnapshotManager

use of org.apache.hadoop.hbase.master.snapshot.SnapshotManager in project hbase by apache.

the class HMaster method initializeZKBasedSystemTrackers.

/**
 * Initialize all ZK based system trackers. But do not include {@link RegionServerTracker}, it
 * should have already been initialized along with {@link ServerManager}.
 */
private void initializeZKBasedSystemTrackers() throws IOException, KeeperException, ReplicationException {
    if (maintenanceMode) {
        // in maintenance mode, always use MaintenanceLoadBalancer.
        conf.unset(LoadBalancer.HBASE_RSGROUP_LOADBALANCER_CLASS);
        conf.setClass(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, MaintenanceLoadBalancer.class, LoadBalancer.class);
    }
    this.balancer = new RSGroupBasedLoadBalancer();
    this.loadBalancerTracker = new LoadBalancerTracker(zooKeeper, this);
    this.loadBalancerTracker.start();
    this.regionNormalizerManager = RegionNormalizerFactory.createNormalizerManager(conf, zooKeeper, this);
    this.configurationManager.registerObserver(regionNormalizerManager);
    this.regionNormalizerManager.start();
    this.splitOrMergeTracker = new SplitOrMergeTracker(zooKeeper, conf, this);
    this.splitOrMergeTracker.start();
    // This is for backwards compatible. We do not need the CP for rs group now but if user want to
    // load it, we need to enable rs group.
    String[] cpClasses = conf.getStrings(MasterCoprocessorHost.MASTER_COPROCESSOR_CONF_KEY);
    if (cpClasses != null) {
        for (String cpClass : cpClasses) {
            if (RSGroupAdminEndpoint.class.getName().equals(cpClass)) {
                RSGroupUtil.enableRSGroup(conf);
                break;
            }
        }
    }
    this.rsGroupInfoManager = RSGroupInfoManager.create(this);
    this.replicationPeerManager = ReplicationPeerManager.create(zooKeeper, conf, clusterId);
    this.drainingServerTracker = new DrainingServerTracker(zooKeeper, this, this.serverManager);
    this.drainingServerTracker.start();
    this.snapshotCleanupTracker = new SnapshotCleanupTracker(zooKeeper, this);
    this.snapshotCleanupTracker.start();
    String clientQuorumServers = conf.get(HConstants.CLIENT_ZOOKEEPER_QUORUM);
    boolean clientZkObserverMode = conf.getBoolean(HConstants.CLIENT_ZOOKEEPER_OBSERVER_MODE, HConstants.DEFAULT_CLIENT_ZOOKEEPER_OBSERVER_MODE);
    if (clientQuorumServers != null && !clientZkObserverMode) {
        // we need to take care of the ZK information synchronization
        // if given client ZK are not observer nodes
        ZKWatcher clientZkWatcher = new ZKWatcher(conf, getProcessName() + ":" + rpcServices.getSocketAddress().getPort() + "-clientZK", this, false, true);
        this.metaLocationSyncer = new MetaLocationSyncer(zooKeeper, clientZkWatcher, this);
        this.metaLocationSyncer.start();
        this.masterAddressSyncer = new MasterAddressSyncer(zooKeeper, clientZkWatcher, this);
        this.masterAddressSyncer.start();
        // set cluster id is a one-go effort
        ZKClusterId.setClusterId(clientZkWatcher, fileSystemManager.getClusterId());
    }
    // Set the cluster as up.  If new RSs, they'll be waiting on this before
    // going ahead with their startup.
    boolean wasUp = this.clusterStatusTracker.isClusterUp();
    if (!wasUp)
        this.clusterStatusTracker.setClusterUp();
    LOG.info("Active/primary master=" + this.serverName + ", sessionid=0x" + Long.toHexString(this.zooKeeper.getRecoverableZooKeeper().getSessionId()) + ", setting cluster-up flag (Was=" + wasUp + ")");
    // create/initialize the snapshot manager and other procedure managers
    this.snapshotManager = new SnapshotManager();
    this.mpmHost = new MasterProcedureManagerHost();
    this.mpmHost.register(this.snapshotManager);
    this.mpmHost.register(new MasterFlushTableProcedureManager());
    this.mpmHost.loadProcedures(conf);
    this.mpmHost.initialize(this, this.metricsMaster);
}
Also used : MasterFlushTableProcedureManager(org.apache.hadoop.hbase.procedure.flush.MasterFlushTableProcedureManager) MasterProcedureManagerHost(org.apache.hadoop.hbase.procedure.MasterProcedureManagerHost) RSGroupAdminEndpoint(org.apache.hadoop.hbase.rsgroup.RSGroupAdminEndpoint) MetaLocationSyncer(org.apache.hadoop.hbase.master.zksyncer.MetaLocationSyncer) SnapshotCleanupTracker(org.apache.hadoop.hbase.zookeeper.SnapshotCleanupTracker) LoadBalancerTracker(org.apache.hadoop.hbase.zookeeper.LoadBalancerTracker) ZKWatcher(org.apache.hadoop.hbase.zookeeper.ZKWatcher) RSGroupBasedLoadBalancer(org.apache.hadoop.hbase.rsgroup.RSGroupBasedLoadBalancer) MasterAddressSyncer(org.apache.hadoop.hbase.master.zksyncer.MasterAddressSyncer) SnapshotManager(org.apache.hadoop.hbase.master.snapshot.SnapshotManager)

Example 2 with SnapshotManager

use of org.apache.hadoop.hbase.master.snapshot.SnapshotManager in project hbase by apache.

the class TestSnapshotCleanerChore method testSnapshotCleanerWithReadIOE.

@Test
public void testSnapshotCleanerWithReadIOE() throws IOException {
    snapshotManager = Mockito.mock(SnapshotManager.class);
    Stoppable stopper = new StoppableImplementation();
    Configuration conf = new HBaseTestingUtil().getConfiguration();
    SnapshotCleanerChore snapshotCleanerChore = new SnapshotCleanerChore(stopper, conf, snapshotManager);
    Mockito.when(snapshotManager.getCompletedSnapshots()).thenThrow(IOException.class);
    try {
        LOG.info("While getting completed Snapshots, IOException would occur. Hence, No Snapshot" + " should be deleted");
        snapshotCleanerChore.chore();
    } finally {
        stopper.stop("Stopping Test Stopper");
    }
    Mockito.verify(snapshotManager, Mockito.times(0)).deleteSnapshot(Mockito.any());
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) Stoppable(org.apache.hadoop.hbase.Stoppable) HBaseTestingUtil(org.apache.hadoop.hbase.HBaseTestingUtil) SnapshotManager(org.apache.hadoop.hbase.master.snapshot.SnapshotManager) Test(org.junit.Test)

Example 3 with SnapshotManager

use of org.apache.hadoop.hbase.master.snapshot.SnapshotManager in project hbase by apache.

the class TestSnapshotCleanerChore method testSnapshotCleanerWithoutAnyCompletedSnapshot.

@Test
public void testSnapshotCleanerWithoutAnyCompletedSnapshot() throws IOException {
    snapshotManager = Mockito.mock(SnapshotManager.class);
    Stoppable stopper = new StoppableImplementation();
    Configuration conf = getSnapshotCleanerConf();
    SnapshotCleanerChore snapshotCleanerChore = new SnapshotCleanerChore(stopper, conf, snapshotManager);
    try {
        snapshotCleanerChore.chore();
    } finally {
        stopper.stop("Stopping Test Stopper");
    }
    Mockito.verify(snapshotManager, Mockito.times(0)).deleteSnapshot(Mockito.any());
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) Stoppable(org.apache.hadoop.hbase.Stoppable) SnapshotManager(org.apache.hadoop.hbase.master.snapshot.SnapshotManager) Test(org.junit.Test)

Example 4 with SnapshotManager

use of org.apache.hadoop.hbase.master.snapshot.SnapshotManager in project hbase by apache.

the class TestSnapshotCleanerChore method testSnapshotChoreWithTtlOutOfRange.

@Test
public void testSnapshotChoreWithTtlOutOfRange() throws IOException {
    snapshotManager = Mockito.mock(SnapshotManager.class);
    Stoppable stopper = new StoppableImplementation();
    Configuration conf = getSnapshotCleanerConf();
    List<SnapshotProtos.SnapshotDescription> snapshotDescriptionList = new ArrayList<>();
    snapshotDescriptionList.add(getSnapshotDescription(Long.MAX_VALUE, "snapshot01", "table01", 1));
    snapshotDescriptionList.add(getSnapshotDescription(5, "snapshot02", "table02", 2));
    Mockito.when(snapshotManager.getCompletedSnapshots()).thenReturn(snapshotDescriptionList);
    SnapshotCleanerChore snapshotCleanerChore = new SnapshotCleanerChore(stopper, conf, snapshotManager);
    try {
        LOG.info("Snapshot Chore is disabled. No cleanup performed for Expired Snapshots");
        snapshotCleanerChore.chore();
    } finally {
        stopper.stop("Stopping Test Stopper");
    }
    Mockito.verify(snapshotManager, Mockito.times(1)).getCompletedSnapshots();
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) ArrayList(java.util.ArrayList) Stoppable(org.apache.hadoop.hbase.Stoppable) SnapshotManager(org.apache.hadoop.hbase.master.snapshot.SnapshotManager) Test(org.junit.Test)

Example 5 with SnapshotManager

use of org.apache.hadoop.hbase.master.snapshot.SnapshotManager in project hbase by apache.

the class TestSnapshotCleanerChore method testSnapshotCleanerWithSomeTtlExpired.

@Test
public void testSnapshotCleanerWithSomeTtlExpired() throws IOException {
    snapshotManager = Mockito.mock(SnapshotManager.class);
    Stoppable stopper = new StoppableImplementation();
    Configuration conf = getSnapshotCleanerConf();
    SnapshotCleanerChore snapshotCleanerChore = new SnapshotCleanerChore(stopper, conf, snapshotManager);
    List<SnapshotProtos.SnapshotDescription> snapshotDescriptionList = new ArrayList<>();
    snapshotDescriptionList.add(getSnapshotDescription(10, "snapshot01", "table01", 1));
    snapshotDescriptionList.add(getSnapshotDescription(5, "snapshot02", "table02", 2));
    snapshotDescriptionList.add(getSnapshotDescription(30, "snapshot01", "table01", EnvironmentEdgeManager.currentTime()));
    snapshotDescriptionList.add(getSnapshotDescription(0, "snapshot02", "table02", EnvironmentEdgeManager.currentTime()));
    snapshotDescriptionList.add(getSnapshotDescription(40, "snapshot03", "table03", EnvironmentEdgeManager.currentTime()));
    Mockito.when(snapshotManager.getCompletedSnapshots()).thenReturn(snapshotDescriptionList);
    try {
        LOG.info("5 Snapshots are completed. TTL is expired for 2 them. Going to delete them");
        snapshotCleanerChore.chore();
    } finally {
        stopper.stop("Stopping Test Stopper");
    }
    Mockito.verify(snapshotManager, Mockito.times(2)).deleteSnapshot(Mockito.any());
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) ArrayList(java.util.ArrayList) Stoppable(org.apache.hadoop.hbase.Stoppable) SnapshotManager(org.apache.hadoop.hbase.master.snapshot.SnapshotManager) Test(org.junit.Test)

Aggregations

SnapshotManager (org.apache.hadoop.hbase.master.snapshot.SnapshotManager)6 Configuration (org.apache.hadoop.conf.Configuration)5 Stoppable (org.apache.hadoop.hbase.Stoppable)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)3 HBaseTestingUtil (org.apache.hadoop.hbase.HBaseTestingUtil)1 MasterAddressSyncer (org.apache.hadoop.hbase.master.zksyncer.MasterAddressSyncer)1 MetaLocationSyncer (org.apache.hadoop.hbase.master.zksyncer.MetaLocationSyncer)1 MasterProcedureManagerHost (org.apache.hadoop.hbase.procedure.MasterProcedureManagerHost)1 MasterFlushTableProcedureManager (org.apache.hadoop.hbase.procedure.flush.MasterFlushTableProcedureManager)1 RSGroupAdminEndpoint (org.apache.hadoop.hbase.rsgroup.RSGroupAdminEndpoint)1 RSGroupBasedLoadBalancer (org.apache.hadoop.hbase.rsgroup.RSGroupBasedLoadBalancer)1 LoadBalancerTracker (org.apache.hadoop.hbase.zookeeper.LoadBalancerTracker)1 SnapshotCleanupTracker (org.apache.hadoop.hbase.zookeeper.SnapshotCleanupTracker)1 ZKWatcher (org.apache.hadoop.hbase.zookeeper.ZKWatcher)1