Search in sources :

Example 16 with ForeignExceptionDispatcher

use of org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher in project hbase by apache.

the class TestProcedureMember method testPropagateConnectionErrorBackToManager.

/**
   * Fail correctly on getting an external error while waiting for the prepared latch
   * @throws Exception on failure
   */
@Test(timeout = 60000)
public void testPropagateConnectionErrorBackToManager() throws Exception {
    // setup the operation
    member = buildCohortMember();
    ProcedureMember memberSpy = spy(member);
    // setup the commit and the spy
    final ForeignExceptionDispatcher dispatcher = new ForeignExceptionDispatcher();
    ForeignExceptionDispatcher dispSpy = spy(dispatcher);
    Subprocedure commit = new EmptySubprocedure(member, dispatcher);
    Subprocedure spy = spy(commit);
    when(mockBuilder.buildSubprocedure(op, data)).thenReturn(spy);
    // fail during the prepare phase
    doThrow(new ForeignException("SRC", "prepare exception")).when(spy).acquireBarrier();
    // and throw a connection error when we try to tell the controller about it
    doThrow(new IOException("Controller is down!")).when(mockMemberComms).sendMemberAborted(eq(spy), any(ForeignException.class));
    // run the operation
    // build a new operation
    Subprocedure subproc = memberSpy.createSubprocedure(op, data);
    memberSpy.submitSubprocedure(subproc);
    // if the operation doesn't die properly, then this will timeout
    memberSpy.closeAndWait(TIMEOUT);
    // make sure everything ran in order
    InOrder order = inOrder(mockMemberComms, spy, dispSpy);
    // make sure we acquire.
    order.verify(spy).acquireBarrier();
    order.verify(mockMemberComms, never()).sendMemberAcquired(spy);
// TODO Need to do another refactor to get this to propagate to the coordinator.
// make sure we pass a remote exception back the controller
//    order.verify(mockMemberComms).sendMemberAborted(eq(spy),
//      any(ExternalException.class));
//    order.verify(dispSpy).receiveError(anyString(),
//        any(ExternalException.class), any());
}
Also used : InOrder(org.mockito.InOrder) ForeignException(org.apache.hadoop.hbase.errorhandling.ForeignException) IOException(java.io.IOException) ForeignExceptionDispatcher(org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher) Test(org.junit.Test)

Example 17 with ForeignExceptionDispatcher

use of org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher in project hbase by apache.

the class TestProcedureMember method buildCohortMemberPair.

/**
   * Setup a procedure member that returns the spied-upon {@link Subprocedure}.
   */
private void buildCohortMemberPair() throws IOException {
    dispatcher = new ForeignExceptionDispatcher();
    String name = "node";
    ThreadPoolExecutor pool = ProcedureMember.defaultPool(name, 1, POOL_KEEP_ALIVE);
    member = new ProcedureMember(mockMemberComms, pool, mockBuilder);
    // needed for generating exception
    when(mockMemberComms.getMemberName()).thenReturn("membername");
    Subprocedure subproc = new EmptySubprocedure(member, dispatcher);
    spySub = spy(subproc);
    when(mockBuilder.buildSubprocedure(op, data)).thenReturn(spySub);
    addCommitAnswer();
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) ForeignExceptionDispatcher(org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher)

Example 18 with ForeignExceptionDispatcher

use of org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher in project hbase by apache.

the class SimpleRSProcedureManager method buildSubprocedure.

/**
   * If in a running state, creates the specified subprocedure for handling a procedure.
   * @return Subprocedure to submit to the ProcedureMemeber.
   */
public Subprocedure buildSubprocedure(String name) {
    // don't run a procedure if the parent is stop(ping)
    if (rss.isStopping() || rss.isStopped()) {
        throw new IllegalStateException("Can't start procedure on RS: " + rss.getServerName() + ", because stopping/stopped!");
    }
    LOG.info("Attempting to run a procedure.");
    ForeignExceptionDispatcher errorDispatcher = new ForeignExceptionDispatcher();
    Configuration conf = rss.getConfiguration();
    SimpleSubprocedurePool taskManager = new SimpleSubprocedurePool(rss.getServerName().toString(), conf);
    return new SimpleSubprocedure(rss, member, errorDispatcher, taskManager, name);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) ForeignExceptionDispatcher(org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher)

Example 19 with ForeignExceptionDispatcher

use of org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher in project hbase by apache.

the class TestRestoreSnapshotHelper method getRestoreHelper.

/**
   * Initialize the restore helper, based on the snapshot and table information provided.
   */
private RestoreSnapshotHelper getRestoreHelper(final Path rootDir, final Path snapshotDir, final SnapshotDescription sd, final HTableDescriptor htdClone) throws IOException {
    ForeignExceptionDispatcher monitor = Mockito.mock(ForeignExceptionDispatcher.class);
    MonitoredTask status = Mockito.mock(MonitoredTask.class);
    SnapshotManifest manifest = SnapshotManifest.open(conf, fs, snapshotDir, sd);
    return new RestoreSnapshotHelper(conf, fs, manifest, htdClone, rootDir, monitor, status);
}
Also used : ForeignExceptionDispatcher(org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher) MonitoredTask(org.apache.hadoop.hbase.monitoring.MonitoredTask)

Example 20 with ForeignExceptionDispatcher

use of org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher in project hbase by apache.

the class CloneSnapshotProcedure method createFilesystemLayout.

/**
   * Create regions in file system.
   * @param env MasterProcedureEnv
   * @throws IOException
   */
private List<HRegionInfo> createFilesystemLayout(final MasterProcedureEnv env, final HTableDescriptor hTableDescriptor, final List<HRegionInfo> newRegions) throws IOException {
    return createFsLayout(env, hTableDescriptor, newRegions, new CreateHdfsRegions() {

        @Override
        public List<HRegionInfo> createHdfsRegions(final MasterProcedureEnv env, final Path tableRootDir, final TableName tableName, final List<HRegionInfo> newRegions) throws IOException {
            final MasterFileSystem mfs = env.getMasterServices().getMasterFileSystem();
            final FileSystem fs = mfs.getFileSystem();
            final Path rootDir = mfs.getRootDir();
            final Configuration conf = env.getMasterConfiguration();
            final ForeignExceptionDispatcher monitorException = new ForeignExceptionDispatcher();
            getMonitorStatus().setStatus("Clone snapshot - creating regions for table: " + tableName);
            try {
                // 1. Execute the on-disk Clone
                Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshot, rootDir);
                SnapshotManifest manifest = SnapshotManifest.open(conf, fs, snapshotDir, snapshot);
                RestoreSnapshotHelper restoreHelper = new RestoreSnapshotHelper(conf, fs, manifest, hTableDescriptor, tableRootDir, monitorException, monitorStatus);
                RestoreSnapshotHelper.RestoreMetaChanges metaChanges = restoreHelper.restoreHdfsRegions();
                // Clone operation should not have stuff to restore or remove
                Preconditions.checkArgument(!metaChanges.hasRegionsToRestore(), "A clone should not have regions to restore");
                Preconditions.checkArgument(!metaChanges.hasRegionsToRemove(), "A clone should not have regions to remove");
                // At this point the clone is complete. Next step is enabling the table.
                String msg = "Clone snapshot=" + snapshot.getName() + " on table=" + tableName + " completed!";
                LOG.info(msg);
                monitorStatus.setStatus(msg + " Waiting for table to be enabled...");
                // 2. Let the next step to add the regions to meta
                return metaChanges.getRegionsToAdd();
            } catch (Exception e) {
                String msg = "clone snapshot=" + ClientSnapshotDescriptionUtils.toString(snapshot) + " failed because " + e.getMessage();
                LOG.error(msg, e);
                IOException rse = new RestoreSnapshotException(msg, e, ProtobufUtil.createSnapshotDesc(snapshot));
                // these handlers aren't futures so we need to register the error here.
                monitorException.receive(new ForeignException("Master CloneSnapshotProcedure", rse));
                throw rse;
            }
        }
    });
}
Also used : Path(org.apache.hadoop.fs.Path) MasterFileSystem(org.apache.hadoop.hbase.master.MasterFileSystem) Configuration(org.apache.hadoop.conf.Configuration) CreateHdfsRegions(org.apache.hadoop.hbase.master.procedure.CreateTableProcedure.CreateHdfsRegions) IOException(java.io.IOException) ForeignExceptionDispatcher(org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher) RestoreSnapshotException(org.apache.hadoop.hbase.snapshot.RestoreSnapshotException) ForeignException(org.apache.hadoop.hbase.errorhandling.ForeignException) TableExistsException(org.apache.hadoop.hbase.TableExistsException) IOException(java.io.IOException) RestoreSnapshotException(org.apache.hadoop.hbase.snapshot.RestoreSnapshotException) HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) TableName(org.apache.hadoop.hbase.TableName) SnapshotManifest(org.apache.hadoop.hbase.snapshot.SnapshotManifest) FileSystem(org.apache.hadoop.fs.FileSystem) MasterFileSystem(org.apache.hadoop.hbase.master.MasterFileSystem) ForeignException(org.apache.hadoop.hbase.errorhandling.ForeignException) ArrayList(java.util.ArrayList) List(java.util.List) RestoreSnapshotHelper(org.apache.hadoop.hbase.snapshot.RestoreSnapshotHelper)

Aggregations

ForeignExceptionDispatcher (org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher)21 ForeignException (org.apache.hadoop.hbase.errorhandling.ForeignException)13 IOException (java.io.IOException)9 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)7 Configuration (org.apache.hadoop.conf.Configuration)5 Matchers.anyString (org.mockito.Matchers.anyString)5 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)3 Path (org.apache.hadoop.fs.Path)3 ServerName (org.apache.hadoop.hbase.ServerName)3 RestoreSnapshotHelper (org.apache.hadoop.hbase.snapshot.RestoreSnapshotHelper)3 Pair (org.apache.hadoop.hbase.util.Pair)3 ZooKeeperWatcher (org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 List (java.util.List)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 FileSystem (org.apache.hadoop.fs.FileSystem)2 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)2 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)2