Examples of ForeignExceptionDispatcher


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

    // Snapshot information
    this.snapshot = snapshot;

    // Monitor
    this.monitor = new ForeignExceptionDispatcher();
    this.status = TaskMonitor.get().createStatus("Cloning  snapshot '" + snapshot.getName() +
      "' to table " + hTableDescriptor.getTableName());
  }
View Full Code Here

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

    // 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.
View Full Code Here

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

   */
  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

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

    }

    // 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

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

    // 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();
      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);
            r.monitor.receive(remoteCause);
            // 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 int[] i = new int[] { 0 };
    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[0];
          Subprocedure commit = cohortTasks.get(index);
          index++;
          i[0] = 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

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

  /**
   * 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(WAKE_FREQUENCY, POOL_KEEP_ALIVE, 1, name);
    member = new ProcedureMember(mockMemberComms, pool, mockBuilder);
    when(mockMemberComms.getMemberName()).thenReturn("membername"); // needed for generating exception
    Subprocedure subproc = new EmptySubprocedure(member, dispatcher);
View Full Code Here

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

    // 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
View Full Code Here

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

   * @param args argument data associated with the procedure instance
   * @param expectedMembers names of the expected members
   */
  public Procedure(ProcedureCoordinator coord, long wakeFreq, long timeout,
      String procName, byte[] args, List<String> expectedMembers) {
    this(coord, new ForeignExceptionDispatcher(), wakeFreq, timeout, procName, args,
        expectedMembers);
  }
View Full Code Here

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

    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();

    this.tableLockManager = master.getTableLockManager();
    this.tableLock = this.tableLockManager.writeLock(Bytes.toBytes(snapshot.getTable())
      , EventType.C_M_SNAPSHOT_TABLE.toString());
View Full Code Here

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

    // Snapshot information
    this.snapshot = snapshot;

    // Monitor
    this.monitor = new ForeignExceptionDispatcher();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.