当前位置: 首页>>代码示例>>Java>>正文


Java ForeignException类代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.errorhandling.ForeignException的典型用法代码示例。如果您正苦于以下问题:Java ForeignException类的具体用法?Java ForeignException怎么用?Java ForeignException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ForeignException类属于org.apache.hadoop.hbase.errorhandling包,在下文中一共展示了ForeignException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendMemberAborted

import org.apache.hadoop.hbase.errorhandling.ForeignException; //导入依赖的package包/类
/**
 * This should be called by the member and should write a serialized root cause exception as
 * to the abort znode.
 */
@Override
public void sendMemberAborted(Subprocedure sub, ForeignException ee) {
  if (sub == null) {
    LOG.error("Failed due to null subprocedure", ee);
    return;
  }
  String procName = sub.getName();
  LOG.debug("Aborting procedure (" + procName + ") in zk");
  String procAbortZNode = zkController.getAbortZNode(procName);
  try {
    String source = (ee.getSource() == null) ? memberName: ee.getSource();
    byte[] errorInfo = ProtobufUtil.prependPBMagic(ForeignException.serialize(source, ee));
    ZKUtil.createAndFailSilent(zkController.getWatcher(), procAbortZNode, errorInfo);
    LOG.debug("Finished creating abort znode:" + procAbortZNode);
  } catch (KeeperException e) {
    // possible that we get this error for the procedure if we already reset the zk state, but in
    // that case we should still get an error for that procedure anyways
    zkController.logZKTree(zkController.getBaseZnode());
    member.controllerConnectionFailure("Failed to post zk node:" + procAbortZNode
        + " to abort procedure", e, procName);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:27,代码来源:ZKProcedureMemberRpcs.java

示例2: rpcConnectionFailure

import org.apache.hadoop.hbase.errorhandling.ForeignException; //导入依赖的package包/类
/**
 * The connection to the rest of the procedure group (members and coordinator) has been
 * broken/lost/failed. This should fail any interested procedures, but not attempt to notify other
 * members since we cannot reach them anymore.
 * @param message description of the error
 * @param cause the actual cause of the failure
 */
void rpcConnectionFailure(final String message, final IOException cause) {
  Collection<Procedure> toNotify = procedures.values();

  boolean isTraceEnabled = LOG.isTraceEnabled();
  LOG.debug("received connection failure: " + message, cause);
  for (Procedure proc : toNotify) {
    if (proc == null) {
      continue;
    }
    // notify the elements, if they aren't null
    if (isTraceEnabled) {
      LOG.trace("connection failure - notify procedure: " + proc.getName());
    }
    proc.receive(new ForeignException(proc.getName(), cause));
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:24,代码来源:ProcedureCoordinator.java

示例3: waitForLatch

import org.apache.hadoop.hbase.errorhandling.ForeignException; //导入依赖的package包/类
/**
 * Wait for latch to count to zero, ignoring any spurious wake-ups, but waking periodically to
 * check for errors
 * @param latch latch to wait on
 * @param monitor monitor to check for errors while waiting
 * @param wakeFrequency frequency to wake up and check for errors (in
 *          {@link TimeUnit#MILLISECONDS})
 * @param latchDescription description of the latch, for logging
 * @throws ForeignException type of error the monitor can throw, if the task fails
 * @throws InterruptedException if we are interrupted while waiting on latch
 */
public static void waitForLatch(CountDownLatch latch, ForeignExceptionSnare monitor,
    long wakeFrequency, String latchDescription) throws ForeignException,
    InterruptedException {
  boolean released = false;
  while (!released) {
    if (monitor != null) {
      monitor.rethrowException();
    }
    /*
    ForeignExceptionDispatcher.LOG.debug("Waiting for '" + latchDescription + "' latch. (sleep:"
        + wakeFrequency + " ms)"); */
    released = latch.await(wakeFrequency, TimeUnit.MILLISECONDS);
  }
  // check error again in case an error raised during last wait
  if (monitor != null) {
    monitor.rethrowException();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:30,代码来源:Procedure.java

示例4: sendAbortToMembers

import org.apache.hadoop.hbase.errorhandling.ForeignException; //导入依赖的package包/类
/**
 * This is the abort message being sent by the coordinator to member
 *
 * TODO this code isn't actually used but can be used to issue a cancellation from the
 * coordinator.
 */
@Override
final public void sendAbortToMembers(Procedure proc, ForeignException ee) {
  String procName = proc.getName();
  LOG.debug("Aborting procedure '" + procName + "' in zk");
  String procAbortNode = zkProc.getAbortZNode(procName);
  try {
    LOG.debug("Creating abort znode:" + procAbortNode);
    String source = (ee.getSource() == null) ? coordName : ee.getSource();
    byte[] errorInfo = ProtobufUtil.prependPBMagic(ForeignException.serialize(source, ee));
    // first create the znode for the procedure
    ZKUtil.createAndFailSilent(zkProc.getWatcher(), procAbortNode, errorInfo);
    LOG.debug("Finished creating abort node:" + procAbortNode);
  } catch (KeeperException e) {
    // possible that we get this error for the procedure if we already reset the zk state, but in
    // that case we should still get an error for that procedure anyways
    zkProc.logZKTree(zkProc.baseZNode);
    coordinator.rpcConnectionFailure("Failed to post zk node:" + procAbortNode
        + " to abort procedure '" + procName + "'", new IOException(e));
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:27,代码来源:ZKProcedureCoordinatorRpcs.java

示例5: waitAndVerifyProc

import org.apache.hadoop.hbase.errorhandling.ForeignException; //导入依赖的package包/类
/**
 * Wait for the coordinator task to complete, and verify all the mocks
 * @param task to wait on
 * @throws Exception on unexpected failure
 */
private void waitAndVerifyProc(Procedure proc, VerificationMode prepare,
    VerificationMode commit, VerificationMode cleanup, VerificationMode finish, boolean opHasError)
    throws Exception {
  boolean caughtError = false;
  try {
    proc.waitForCompleted();
  } catch (ForeignException fe) {
    caughtError = true;
  }
  // make sure that the task called all the expected phases
  Mockito.verify(proc, prepare).sendGlobalBarrierStart();
  Mockito.verify(proc, commit).sendGlobalBarrierReached();
  Mockito.verify(proc, finish).sendGlobalBarrierComplete();
  assertEquals("Operation error state was unexpected", opHasError, proc.getErrorMonitor()
      .hasException());
  assertEquals("Operation error state was unexpected", opHasError, caughtError);

}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:24,代码来源:TestZKProcedure.java

示例6: waitAndVerifySubproc

import org.apache.hadoop.hbase.errorhandling.ForeignException; //导入依赖的package包/类
/**
 * Wait for the coordinator task to complete, and verify all the mocks
 * @param task to wait on
 * @throws Exception on unexpected failure
 */
private void waitAndVerifySubproc(Subprocedure op, VerificationMode prepare,
    VerificationMode commit, VerificationMode cleanup, VerificationMode finish, boolean opHasError)
    throws Exception {
  boolean caughtError = false;
  try {
    op.waitForLocallyCompleted();
  } catch (ForeignException fe) {
    caughtError = true;
  }
  // make sure that the task called all the expected phases
  Mockito.verify(op, prepare).acquireBarrier();
  Mockito.verify(op, commit).insideBarrier();
  // We cannot guarantee that cleanup has run so we don't check it.

  assertEquals("Operation error state was unexpected", opHasError, op.getErrorCheckable()
      .hasException());
  assertEquals("Operation error state was unexpected", opHasError, caughtError);

}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:25,代码来源:TestZKProcedure.java

示例7: testErrorPropagation

import org.apache.hadoop.hbase.errorhandling.ForeignException; //导入依赖的package包/类
@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);

  // start the barrier procedure
  Thread t = new Thread() {
    public void run() {
      procspy.call();
    }
  };
  t.start();
  t.join();

  verify(procspy, never()).sendGlobalBarrierStart();
  verify(procspy, never()).sendGlobalBarrierReached();
  verify(procspy).sendGlobalBarrierComplete();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:25,代码来源:TestProcedure.java

示例8: sendMemberAborted

import org.apache.hadoop.hbase.errorhandling.ForeignException; //导入依赖的package包/类
/**
 * This should be called by the member and should write a serialized root cause exception as
 * to the abort znode.
 */
@Override
public void sendMemberAborted(Subprocedure sub, ForeignException ee) {
  if (sub == null) {
    LOG.error("Failed due to null subprocedure", ee);
    return;
  }
  String procName = sub.getName();
  LOG.debug("Aborting procedure (" + procName + ") in zk");
  String procAbortZNode = zkController.getAbortZNode(procName);
  try {
    String source = (ee.getSource() == null) ? memberName: ee.getSource();
    byte[] errorInfo = ProtobufUtil.prependPBMagic(ForeignException.serialize(source, ee));
    ZKUtil.createAndFailSilent(zkController.getWatcher(), procAbortZNode, errorInfo);
    LOG.debug("Finished creating abort znode:" + procAbortZNode);
  } catch (KeeperException e) {
    // possible that we get this error for the procedure if we already reset the zk state, but in
    // that case we should still get an error for that procedure anyways
    zkController.logZKTree(zkController.getBaseZnode());
    member.controllerConnectionFailure("Failed to post zk node:" + procAbortZNode
        + " to abort procedure", new IOException(e));
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:27,代码来源:ZKProcedureMemberRpcs.java

示例9: testErrorPropagation

import org.apache.hadoop.hbase.errorhandling.ForeignException; //导入依赖的package包/类
/**
 * 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
    public Void call() {
      snapshotFailure("Injected failure", thrown);
      return null;
    }
  };
  fail.call();

  verify(error, Mockito.times(1)).receive(any(ForeignException.class));
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:21,代码来源:TestSnapshotTask.java

示例10: cancel

import org.apache.hadoop.hbase.errorhandling.ForeignException; //导入依赖的package包/类
@Override
public void cancel(String why) {
  if (this.stopped) return;
  this.stopped = true;
  String msg = "Stopping restore snapshot=" + ClientSnapshotDescriptionUtils.toString(snapshot)
      + " because: " + why;
  LOG.info(msg);
  CancellationException ce = new CancellationException(why);
  this.monitor.receive(new ForeignException(masterServices.getServerName().toString(), ce));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:11,代码来源:RestoreSnapshotHandler.java

示例11: cancel

import org.apache.hadoop.hbase.errorhandling.ForeignException; //导入依赖的package包/类
@Override
public void cancel(String why) {
  if (this.stopped) return;
  this.stopped = true;
  String msg = "Stopping clone snapshot=" + snapshot + " because: " + why;
  LOG.info(msg);
  status.abort(msg);
  this.monitor.receive(new ForeignException(NAME, new CancellationException(why)));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:10,代码来源:CloneSnapshotHandler.java

示例12: cancel

import org.apache.hadoop.hbase.errorhandling.ForeignException; //导入依赖的package包/类
@Override
public void cancel(String why) {
  if (finished) return;

  this.finished = true;
  LOG.info("Stop taking snapshot=" + ClientSnapshotDescriptionUtils.toString(snapshot) +
      " because: " + why);
  CancellationException ce = new CancellationException(why);
  monitor.receive(new ForeignException(master.getServerName().toString(), ce));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:11,代码来源:TakeSnapshotHandler.java

示例13: cancel

import org.apache.hadoop.hbase.errorhandling.ForeignException; //导入依赖的package包/类
/**
 * Method to cancel the Subprocedure by injecting an exception from and external source.
 * @param cause
 */
public void cancel(String msg, Throwable cause) {
  LOG.error(msg, cause);
  complete = true;
  if (cause instanceof ForeignException) {
    monitor.receive((ForeignException) cause);
  } else {
    monitor.receive(new ForeignException(getMemberName(), cause));
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:14,代码来源:Subprocedure.java

示例14: receiveAbortProcedure

import org.apache.hadoop.hbase.errorhandling.ForeignException; //导入依赖的package包/类
/**
 * Send abort to the specified procedure
 * @param procName name of the procedure to about
 * @param ee exception information about the abort
 */
public void receiveAbortProcedure(String procName, ForeignException ee) {
  LOG.debug("Request received to abort procedure " + procName, ee);
  // if we know about the procedure, notify it
  Subprocedure sub = subprocs.get(procName);
  if (sub == null) {
    LOG.info("Received abort on procedure with no local subprocedure " + procName +
        ", ignoring it.", ee);
    return; // Procedure has already completed
  }
  String msg = "Propagating foreign exception to subprocedure " + sub.getName();
  LOG.error(msg, ee);
  sub.cancel(msg, ee);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:ProcedureMember.java

示例15: flushRegions

import org.apache.hadoop.hbase.errorhandling.ForeignException; //导入依赖的package包/类
private void flushRegions() throws ForeignException {
  if (regions.isEmpty()) {
    // No regions on this RS, we are basically done.
    return;
  }

  monitor.rethrowException();

  // assert that the taskManager is empty.
  if (taskManager.hasTasks()) {
    throw new IllegalStateException("Attempting to flush "
        + table + " but we currently have outstanding tasks");
  }

  // Add all hfiles already existing in region.
  for (Region region : regions) {
    // submit one task per region for parallelize by region.
    taskManager.submitTask(new RegionFlushTask(region));
    monitor.rethrowException();
  }

  // wait for everything to complete.
  LOG.debug("Flush region tasks submitted for " + regions.size() + " regions");
  try {
    taskManager.waitForOutstandingTasks();
  } catch (InterruptedException e) {
    throw new ForeignException(getMemberName(), e);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:30,代码来源:FlushTableSubprocedure.java


注:本文中的org.apache.hadoop.hbase.errorhandling.ForeignException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。