Search in sources :

Example 46 with MasterCoprocessorHost

use of org.apache.hadoop.hbase.master.MasterCoprocessorHost in project hbase by apache.

the class EnablePeerProcedure method postPeerModification.

@Override
protected void postPeerModification(MasterProcedureEnv env) throws IOException {
    LOG.info("Successfully enabled peer {}", peerId);
    MasterCoprocessorHost cpHost = env.getMasterCoprocessorHost();
    if (cpHost != null) {
        cpHost.postEnableReplicationPeer(peerId);
    }
}
Also used : MasterCoprocessorHost(org.apache.hadoop.hbase.master.MasterCoprocessorHost)

Example 47 with MasterCoprocessorHost

use of org.apache.hadoop.hbase.master.MasterCoprocessorHost in project hbase by apache.

the class TransitPeerSyncReplicationStateProcedure method preTransit.

protected void preTransit(MasterProcedureEnv env) throws IOException {
    MasterCoprocessorHost cpHost = env.getMasterCoprocessorHost();
    if (cpHost != null) {
        cpHost.preTransitReplicationPeerSyncReplicationState(peerId, toState);
    }
    ReplicationPeerDescription desc = env.getReplicationPeerManager().preTransitPeerSyncReplicationState(peerId, toState);
    if (toState == SyncReplicationState.ACTIVE) {
        Path remoteWALDirForPeer = ReplicationUtils.getPeerRemoteWALDir(desc.getPeerConfig().getRemoteWALDir(), peerId);
        // check whether the remote wal directory is present
        if (!remoteWALDirForPeer.getFileSystem(env.getMasterConfiguration()).exists(remoteWALDirForPeer)) {
            throw new DoNotRetryIOException("The remote WAL directory " + remoteWALDirForPeer + " does not exist");
        }
    }
    fromState = desc.getSyncReplicationState();
    enabled = desc.isEnabled();
    serial = desc.getPeerConfig().isSerial();
}
Also used : Path(org.apache.hadoop.fs.Path) MasterCoprocessorHost(org.apache.hadoop.hbase.master.MasterCoprocessorHost) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) ReplicationPeerDescription(org.apache.hadoop.hbase.replication.ReplicationPeerDescription)

Example 48 with MasterCoprocessorHost

use of org.apache.hadoop.hbase.master.MasterCoprocessorHost in project hbase by apache.

the class TransitPeerSyncReplicationStateProcedure method postTransit.

private void postTransit(MasterProcedureEnv env) throws IOException {
    LOG.info("Successfully transit current cluster state from {} to {} for sync replication peer {}", fromState, toState, peerId);
    MasterCoprocessorHost cpHost = env.getMasterCoprocessorHost();
    if (cpHost != null) {
        env.getMasterCoprocessorHost().postTransitReplicationPeerSyncReplicationState(peerId, fromState, toState);
    }
}
Also used : MasterCoprocessorHost(org.apache.hadoop.hbase.master.MasterCoprocessorHost)

Example 49 with MasterCoprocessorHost

use of org.apache.hadoop.hbase.master.MasterCoprocessorHost in project hbase by apache.

the class RemovePeerProcedure method prePeerModification.

@Override
protected void prePeerModification(MasterProcedureEnv env) throws IOException {
    MasterCoprocessorHost cpHost = env.getMasterCoprocessorHost();
    if (cpHost != null) {
        cpHost.preRemoveReplicationPeer(peerId);
    }
    peerConfig = env.getReplicationPeerManager().preRemovePeer(peerId);
}
Also used : MasterCoprocessorHost(org.apache.hadoop.hbase.master.MasterCoprocessorHost)

Example 50 with MasterCoprocessorHost

use of org.apache.hadoop.hbase.master.MasterCoprocessorHost in project hbase by apache.

the class TestMasterObserver method testSnapshotOperations.

@Test
public void testSnapshotOperations() throws Exception {
    final TableName tableName = TableName.valueOf(name.getMethodName());
    SingleProcessHBaseCluster cluster = UTIL.getHBaseCluster();
    HMaster master = cluster.getMaster();
    MasterCoprocessorHost host = master.getMasterCoprocessorHost();
    CPMasterObserver cp = host.findCoprocessor(CPMasterObserver.class);
    cp.resetStates();
    // create a table
    TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(tableName).setColumnFamily(ColumnFamilyDescriptorBuilder.of(TEST_FAMILY)).build();
    Admin admin = UTIL.getAdmin();
    tableCreationLatch = new CountDownLatch(1);
    admin.createTable(tableDescriptor);
    tableCreationLatch.await();
    tableCreationLatch = new CountDownLatch(1);
    admin.disableTable(tableName);
    assertTrue(admin.isTableDisabled(tableName));
    try {
        // Test snapshot operation
        assertFalse("Coprocessor should not have been called yet", cp.wasSnapshotCalled());
        admin.snapshot(TEST_SNAPSHOT, tableName);
        assertTrue("Coprocessor should have been called on snapshot", cp.wasSnapshotCalled());
        // Test list operation
        admin.listSnapshots();
        assertTrue("Coprocessor should have been called on snapshot list", cp.wasListSnapshotCalled());
        // Test clone operation
        admin.cloneSnapshot(TEST_SNAPSHOT, TEST_CLONE);
        assertTrue("Coprocessor should have been called on snapshot clone", cp.wasCloneSnapshotCalled());
        assertFalse("Coprocessor restore should not have been called on snapshot clone", cp.wasRestoreSnapshotCalled());
        admin.disableTable(TEST_CLONE);
        assertTrue(admin.isTableDisabled(tableName));
        deleteTable(admin, TEST_CLONE);
        // Test restore operation
        cp.resetStates();
        admin.restoreSnapshot(TEST_SNAPSHOT);
        assertTrue("Coprocessor should have been called on snapshot restore", cp.wasRestoreSnapshotCalled());
        assertFalse("Coprocessor clone should not have been called on snapshot restore", cp.wasCloneSnapshotCalled());
        admin.deleteSnapshot(TEST_SNAPSHOT);
        assertTrue("Coprocessor should have been called on snapshot delete", cp.wasDeleteSnapshotCalled());
    } finally {
        deleteTable(admin, tableName);
    }
}
Also used : SingleProcessHBaseCluster(org.apache.hadoop.hbase.SingleProcessHBaseCluster) TableName(org.apache.hadoop.hbase.TableName) MasterCoprocessorHost(org.apache.hadoop.hbase.master.MasterCoprocessorHost) HMaster(org.apache.hadoop.hbase.master.HMaster) Admin(org.apache.hadoop.hbase.client.Admin) CountDownLatch(java.util.concurrent.CountDownLatch) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor) Test(org.junit.Test)

Aggregations

MasterCoprocessorHost (org.apache.hadoop.hbase.master.MasterCoprocessorHost)62 Test (org.junit.Test)18 IOException (java.io.IOException)16 HMaster (org.apache.hadoop.hbase.master.HMaster)14 SingleProcessHBaseCluster (org.apache.hadoop.hbase.SingleProcessHBaseCluster)13 TableName (org.apache.hadoop.hbase.TableName)12 RegionServerCoprocessorHost (org.apache.hadoop.hbase.regionserver.RegionServerCoprocessorHost)7 BeforeClass (org.junit.BeforeClass)7 ArrayList (java.util.ArrayList)6 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)6 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)6 Admin (org.apache.hadoop.hbase.client.Admin)5 Configuration (org.apache.hadoop.conf.Configuration)4 Path (org.apache.hadoop.fs.Path)4 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)4 Mutation (org.apache.hadoop.hbase.client.Mutation)4 InterruptedIOException (java.io.InterruptedIOException)3 FileSystem (org.apache.hadoop.fs.FileSystem)3 MasterFileSystem (org.apache.hadoop.hbase.master.MasterFileSystem)3 FileNotFoundException (java.io.FileNotFoundException)2