Package org.apache.hadoop.hbase.errorhandling

Examples of org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher


  @Test(timeout = 60000)
  public void testErrorPropagation() throws Exception {
    List<String> members =  new ArrayList<String>();
    members.add("member");
    Procedure proc = new Procedure(coord, new ForeignExceptionDispatcher(), 100,
        Integer.MAX_VALUE, "op", null, members);
    final Procedure procspy = spy(proc);

    ForeignException cause = new ForeignException("SRC", "External Exception");
    proc.receive(cause);
View Full Code Here


  @Test(timeout = 60000)
  public void testBarrieredErrorPropagation() throws Exception {
    List<String> members =  new ArrayList<String>();
    members.add("member");
    LatchedProcedure proc = new LatchedProcedure(coord, new ForeignExceptionDispatcher(), 100,
        Integer.MAX_VALUE, "op", null, members);
    final LatchedProcedure procspy = spy(proc);

    // start the barrier procedure
    Thread t = new Thread() {
View Full Code Here

    }

    // setup mock member subprocedures
    final List<Subprocedure> subprocs = new ArrayList<Subprocedure>();
    for (int i = 0; i < procMembers.size(); i++) {
      ForeignExceptionDispatcher cohortMonitor = new ForeignExceptionDispatcher();
      Subprocedure commit = Mockito
      .spy(new SubprocedureImpl(procMembers.get(i).getFirst(), opName, cohortMonitor,
          WAKE_FREQUENCY, TIMEOUT));
      subprocs.add(commit);
    }

    // link subprocedure to buildNewOperation invocation.
    final AtomicInteger i = new AtomicInteger(0); // NOTE: would be racy if not an AtomicInteger
    Mockito.when(subprocFactory.buildSubprocedure(Mockito.eq(opName),
        (byte[]) Mockito.argThat(new ArrayEquals(data)))).thenAnswer(
      new Answer<Subprocedure>() {
        @Override
        public Subprocedure answer(InvocationOnMock invocation) throws Throwable {
          int index = i.getAndIncrement();
          LOG.debug("Task size:" + subprocs.size() + ", getting:" + index);
          Subprocedure commit = subprocs.get(index);
          return commit;
        }
      });

    // setup spying on the coordinator
//    Procedure proc = Mockito.spy(procBuilder.createProcedure(coordinator, opName, data, expected));
//    Mockito.when(procBuilder.build(coordinator, opName, data, expected)).thenReturn(proc);

    // start running the operation
    Procedure task = coordinator.startProcedure(new ForeignExceptionDispatcher(), opName, data, expected);
//    assertEquals("Didn't mock coordinator task", proc, task);

    // verify all things ran as expected
//    waitAndVerifyProc(proc, once, once, never(), once, false);
    waitAndVerifyProc(task, once, once, never(), once, false);
View Full Code Here

    // setup mock subprocedures
    final List<Subprocedure> cohortTasks = new ArrayList<Subprocedure>();
    final int[] elem = new int[1];
    for (int i = 0; i < members.size(); i++) {
      ForeignExceptionDispatcher cohortMonitor = new ForeignExceptionDispatcher();
      final ProcedureMember comms = members.get(i).getFirst();
      Subprocedure commit = Mockito
      .spy(new SubprocedureImpl(comms, opName, cohortMonitor, WAKE_FREQUENCY, TIMEOUT));
      // This nasty bit has one of the impls throw a TimeoutException
      Mockito.doAnswer(new Answer<Void>() {
        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
          int index = elem[0];
          if (index == memberErrorIndex) {
            LOG.debug("Sending error to coordinator");
            ForeignException remoteCause = new ForeignException("TIMER",
                new TimeoutException("subprocTimeout" , 1, 2, 0));
            Subprocedure r = ((Subprocedure) invocation.getMock());
            LOG.error("Remote commit failure, not propagating error:" + remoteCause);
            comms.receiveAbortProcedure(r.getName(), remoteCause);
            assertEquals(r.isComplete(), true);
            // don't complete the error phase until the coordinator has gotten the error
            // notification (which ensures that we never progress past prepare)
            try {
              Procedure.waitForLatch(coordinatorReceivedErrorLatch, new ForeignExceptionDispatcher(),
                  WAKE_FREQUENCY, "coordinator received error");
            } catch (InterruptedException e) {
              LOG.debug("Wait for latch interrupted, done:" + (coordinatorReceivedErrorLatch.getCount() == 0));
              // reset the interrupt status on the thread
              Thread.currentThread().interrupt();
            }
          }
          elem[0] = ++index;
          return null;
        }
      }).when(commit).acquireBarrier();
      cohortTasks.add(commit);
    }

    // pass out a task per member
    final AtomicInteger taskIndex = new AtomicInteger();
    Mockito.when(
      subprocFactory.buildSubprocedure(Mockito.eq(opName),
        (byte[]) Mockito.argThat(new ArrayEquals(data)))).thenAnswer(
      new Answer<Subprocedure>() {
        @Override
        public Subprocedure answer(InvocationOnMock invocation) throws Throwable {
          int index = taskIndex.getAndIncrement();
          Subprocedure commit = cohortTasks.get(index);
          return commit;
        }
      });

    // setup spying on the coordinator
    ForeignExceptionDispatcher coordinatorTaskErrorMonitor = Mockito
        .spy(new ForeignExceptionDispatcher());
    Procedure coordinatorTask = Mockito.spy(new Procedure(coordinator,
        coordinatorTaskErrorMonitor, WAKE_FREQUENCY, TIMEOUT,
        opName, data, expected));
    when(coordinator.createProcedure(any(ForeignExceptionDispatcher.class), eq(opName), eq(data), anyListOf(String.class)))
      .thenReturn(coordinatorTask);
View Full Code Here

    Path snapshotRegionDir = new Path(testdir, HConstants.SNAPSHOT_DIR_NAME);
    fs.mkdirs(snapshotRegionDir);

    SnapshotDescription snapshot = SnapshotDescription.newBuilder().setName("name")
        .setTable("table").build();
    ForeignExceptionDispatcher monitor = Mockito.mock(ForeignExceptionDispatcher.class);
    ReferenceRegionHFilesTask task = new ReferenceRegionHFilesTask(snapshot, monitor, regionDir,
        fs, snapshotRegionDir);
    ReferenceRegionHFilesTask taskSpy = Mockito.spy(task);
    task.call();
View Full Code Here

  /**
   * Check that errors from running the task get propagated back to the error listener.
   */
  @Test
  public void testErrorPropagation() throws Exception {
    ForeignExceptionDispatcher error = mock(ForeignExceptionDispatcher.class);
    SnapshotDescription snapshot = SnapshotDescription.newBuilder().setName("snapshot")
        .setTable("table").build();
    final Exception thrown = new Exception("Failed!");
    SnapshotTask fail = new SnapshotTask(snapshot, error) {
      @Override
View Full Code Here

    FSUtils.logFileSystemState(fs, testDir, LOG);
    FSUtils.setRootDir(conf, testDir);
    SnapshotDescription snapshot = SnapshotDescription.newBuilder()
        .setName("testWALReferenceSnapshot").build();
    ForeignExceptionDispatcher listener = Mockito.mock(ForeignExceptionDispatcher.class);

    // reference all the files in the first server directory
    ReferenceServerWALsTask task = new ReferenceServerWALsTask(snapshot, listener, server1Dir,
        conf, fs);
    task.call();
View Full Code Here

  @Test
  public void testCopyFiles() throws Exception {

    SnapshotDescription snapshot = SnapshotDescription.newBuilder().setName("snapshot").build();
    ForeignExceptionDispatcher monitor = Mockito.mock(ForeignExceptionDispatcher.class);
    FileSystem fs = UTIL.getTestFileSystem();
    Path root = UTIL.getDataTestDir();
    String regionName = "regionA";
    Path regionDir = new Path(root, regionName);
    Path workingDir = SnapshotDescriptionUtils.getWorkingSnapshotDir(snapshot, root);
View Full Code Here

   * @throws Exception on failure
   */
  @Test
  public void testNoEditsDir() throws Exception {
    SnapshotDescription snapshot = SnapshotDescription.newBuilder().setName("snapshot").build();
    ForeignExceptionDispatcher monitor = Mockito.mock(ForeignExceptionDispatcher.class);
    FileSystem fs = UTIL.getTestFileSystem();
    Path root = UTIL.getDataTestDir();
    String regionName = "regionA";
    Path regionDir = new Path(root, regionName);
    Path workingDir = SnapshotDescriptionUtils.getWorkingSnapshotDir(snapshot, root);
View Full Code Here

   */
  private RestoreSnapshotHelper getRestoreHelper(final Path rootDir, final Path snapshotDir,
      final String sourceTableName, final HTableDescriptor htdClone) throws IOException {
    CatalogTracker catalogTracker = Mockito.mock(CatalogTracker.class);
    HTableDescriptor tableDescriptor = Mockito.mock(HTableDescriptor.class);
    ForeignExceptionDispatcher monitor = Mockito.mock(ForeignExceptionDispatcher.class);
    MonitoredTask status = Mockito.mock(MonitoredTask.class);

    SnapshotDescription sd = SnapshotDescription.newBuilder()
      .setName("snapshot")
      .setTable(sourceTableName)
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.