本文整理汇总了Java中org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher类的典型用法代码示例。如果您正苦于以下问题:Java ForeignExceptionDispatcher类的具体用法?Java ForeignExceptionDispatcher怎么用?Java ForeignExceptionDispatcher使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ForeignExceptionDispatcher类属于org.apache.hadoop.hbase.errorhandling包,在下文中一共展示了ForeignExceptionDispatcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RestoreSnapshotHandler
import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher; //导入依赖的package包/类
public RestoreSnapshotHandler(final MasterServices masterServices,
final SnapshotDescription snapshot, final HTableDescriptor htd) throws IOException {
super(EventType.C_M_RESTORE_SNAPSHOT, htd.getTableName(), masterServices, masterServices);
// 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.
this.hTableDescriptor = htd;
this.status = TaskMonitor.get().createStatus(
"Restoring snapshot '" + snapshot.getName() + "' to table "
+ hTableDescriptor.getTableName());
}
示例2: Procedure
import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher; //导入依赖的package包/类
/**
* Creates a procedure. (FOR TESTING)
*
* {@link Procedure} state to be run by a {@link ProcedureCoordinator}.
* @param coord coordinator to call back to for general errors (e.g.
* {@link ProcedureCoordinator#rpcConnectionFailure(String, IOException)}).
* @param monitor error monitor to check for external errors
* @param wakeFreq frequency to check for errors while waiting
* @param timeout amount of time to allow the procedure to run before cancelling
* @param procName name of the procedure instance
* @param args argument data associated with the procedure instance
* @param expectedMembers names of the expected members
*/
public Procedure(ProcedureCoordinator coord, ForeignExceptionDispatcher monitor, long wakeFreq,
long timeout, String procName, byte[] args, List<String> expectedMembers) {
this.coord = coord;
this.acquiringMembers = new ArrayList<String>(expectedMembers);
this.inBarrierMembers = new ArrayList<String>(acquiringMembers.size());
this.dataFromFinishedMembers = new HashMap<String, byte[]>();
this.procName = procName;
this.args = args;
this.monitor = monitor;
this.wakeFrequency = wakeFreq;
int count = expectedMembers.size();
this.acquiredBarrierLatch = new CountDownLatch(count);
this.releasedBarrierLatch = new CountDownLatch(count);
this.completedLatch = new CountDownLatch(1);
this.timeoutInjector = new TimeoutExceptionInjector(monitor, timeout);
}
示例3: buildSubprocedure
import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher; //导入依赖的package包/类
/**
* 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);
}
示例4: testThreadPoolSize
import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher; //导入依赖的package包/类
/**
* Currently we can only handle one procedure at a time. This makes sure we handle that and
* reject submitting more.
*/
@Test
public void testThreadPoolSize() throws Exception {
ProcedureCoordinator coordinator = buildNewCoordinator();
Procedure proc = new Procedure(coordinator, monitor,
WAKE_FREQUENCY, TIMEOUT, procName, procData, expected);
Procedure procSpy = spy(proc);
Procedure proc2 = new Procedure(coordinator, monitor,
WAKE_FREQUENCY, TIMEOUT, procName +"2", procData, expected);
Procedure procSpy2 = spy(proc2);
when(coordinator.createProcedure(any(ForeignExceptionDispatcher.class), eq(procName), eq(procData), anyListOf(String.class)))
.thenReturn(procSpy, procSpy2);
coordinator.startProcedure(procSpy.getErrorMonitor(), procName, procData, expected);
// null here means second procedure failed to start.
assertNull("Coordinator successfully ran two tasks at once with a single thread pool.",
coordinator.startProcedure(proc2.getErrorMonitor(), "another op", procData, expected));
}
示例5: runCoordinatedOperation
import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher; //导入依赖的package包/类
public void runCoordinatedOperation(Procedure spy, AcquireBarrierAnswer prepareOperation,
BarrierAnswer commitOperation, String... cohort) throws Exception {
List<String> expected = Arrays.asList(cohort);
when(coordinator.createProcedure(any(ForeignExceptionDispatcher.class), eq(procName), eq(procData), anyListOf(String.class)))
.thenReturn(spy);
// use the passed controller responses
doAnswer(prepareOperation).when(controller).sendGlobalBarrierAcquire(spy, procData, expected);
doAnswer(commitOperation).when(controller)
.sendGlobalBarrierReached(eq(spy), anyListOf(String.class));
// run the operation
Procedure task = coordinator.startProcedure(spy.getErrorMonitor(), procName, procData, expected);
// and wait for it to finish
task.waitForCompleted();
// make sure we mocked correctly
prepareOperation.ensureRan();
// we never got an exception
InOrder inorder = inOrder(spy, controller);
inorder.verify(spy).sendGlobalBarrierStart();
inorder.verify(controller).sendGlobalBarrierAcquire(task, procData, expected);
inorder.verify(spy).sendGlobalBarrierReached();
inorder.verify(controller).sendGlobalBarrierReached(eq(task), anyListOf(String.class));
}
示例6: testErrorPropagation
import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher; //导入依赖的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();
}
示例7: RestoreSnapshotHandler
import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher; //导入依赖的package包/类
public RestoreSnapshotHandler(final MasterServices masterServices,
final SnapshotDescription snapshot, final HTableDescriptor htd,
final MasterMetrics metricsMaster) throws IOException {
super(EventType.C_M_RESTORE_SNAPSHOT, htd.getName(), masterServices, masterServices);
this.metricsMaster = metricsMaster;
// 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.
this.hTableDescriptor = htd;
this.status = TaskMonitor.get().createStatus(
"Restoring snapshot '" + snapshot.getName() + "' to table "
+ hTableDescriptor.getNameAsString());
}
示例8: CloneSnapshotHandler
import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher; //导入依赖的package包/类
public CloneSnapshotHandler(final MasterServices masterServices,
final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor,
final MasterMetrics metricsMaster)
throws NotAllMetaRegionsOnlineException, TableExistsException, IOException {
super(masterServices, masterServices.getMasterFileSystem(),
masterServices.getServerManager(), hTableDescriptor,
masterServices.getConfiguration(), null, masterServices.getCatalogTracker(),
masterServices.getAssignmentManager());
this.metricsMaster = metricsMaster;
// Snapshot information
this.snapshot = snapshot;
// Monitor
this.monitor = new ForeignExceptionDispatcher();
this.status = TaskMonitor.get().createStatus("Cloning snapshot '" + snapshot.getName() +
"' to table " + hTableDescriptor.getNameAsString());
}
示例9: Procedure
import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher; //导入依赖的package包/类
/**
* Creates a procedure. (FOR TESTING)
*
* {@link Procedure} state to be run by a {@link ProcedureCoordinator}.
* @param coord coordinator to call back to for general errors (e.g.
* {@link ProcedureCoordinator#rpcConnectionFailure(String, IOException)}).
* @param monitor error monitor to check for external errors
* @param wakeFreq frequency to check for errors while waiting
* @param timeout amount of time to allow the procedure to run before cancelling
* @param procName name of the procedure instance
* @param args argument data associated with the procedure instance
* @param expectedMembers names of the expected members
*/
public Procedure(ProcedureCoordinator coord, ForeignExceptionDispatcher monitor, long wakeFreq,
long timeout, String procName, byte[] args, List<String> expectedMembers) {
this.coord = coord;
this.acquiringMembers = new ArrayList<String>(expectedMembers);
this.inBarrierMembers = new ArrayList<String>(acquiringMembers.size());
this.procName = procName;
this.args = args;
this.monitor = monitor;
this.wakeFrequency = wakeFreq;
int count = expectedMembers.size();
this.acquiredBarrierLatch = new CountDownLatch(count);
this.releasedBarrierLatch = new CountDownLatch(count);
this.completedLatch = new CountDownLatch(1);
this.timeoutInjector = new TimeoutExceptionInjector(monitor, timeout);
}
示例10: ReferenceRegionHFilesTask
import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher; //导入依赖的package包/类
/**
* Reference all the files in the given region directory
* @param snapshot snapshot for which to add references
* @param monitor to check/send error
* @param regionDir region directory to look for errors
* @param fs {@link FileSystem} where the snapshot/region live
* @param regionSnapshotDir directory in the snapshot to store region files
*/
public ReferenceRegionHFilesTask(final SnapshotDescription snapshot,
ForeignExceptionDispatcher monitor, Path regionDir, final FileSystem fs, Path regionSnapshotDir) {
super(snapshot, monitor);
this.regiondir = regionDir;
this.fs = fs;
this.fileFilter = new PathFilter() {
@Override
public boolean accept(Path path) {
try {
return fs.isFile(path);
} catch (IOException e) {
LOG.error("Failed to reach fs to check file:" + path + ", marking as not file");
ReferenceRegionHFilesTask.this.snapshotFailure("Failed to reach fs to check file status",
e);
return false;
}
}
};
this.snapshotDir = regionSnapshotDir;
}
示例11: testNoEditsDir
import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher; //导入依赖的package包/类
/**
* Check that we don't get an exception if there is no recovered edits directory to copy
* @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);
try {
// doesn't really matter where the region's snapshot directory is, but this is pretty close
Path snapshotRegionDir = new Path(workingDir, regionName);
fs.mkdirs(snapshotRegionDir);
Path regionEdits = HLog.getRegionDirRecoveredEditsDir(regionDir);
assertFalse("Edits dir exists already - it shouldn't", fs.exists(regionEdits));
CopyRecoveredEditsTask task = new CopyRecoveredEditsTask(snapshot, monitor, fs, regionDir,
snapshotRegionDir);
task.call();
} finally {
// cleanup the working directory
FSUtils.delete(fs, regionDir, true);
FSUtils.delete(fs, workingDir, true);
}
}
示例12: testErrorPropagation
import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher; //导入依赖的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));
}
示例13: RestoreSnapshotHelper
import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher; //导入依赖的package包/类
public RestoreSnapshotHelper(final Configuration conf,
final FileSystem fs,
final SnapshotManifest manifest,
final HTableDescriptor tableDescriptor,
final Path rootDir,
final ForeignExceptionDispatcher monitor,
final MonitoredTask status)
{
this.fs = fs;
this.conf = conf;
this.snapshotManifest = manifest;
this.snapshotDesc = manifest.getSnapshotDescription();
this.snapshotTable = TableName.valueOf(snapshotDesc.getTable());
this.tableDesc = tableDescriptor;
this.rootDir = rootDir;
this.tableDir = FSUtils.getTableDir(rootDir, tableDesc.getTableName());
this.monitor = monitor;
this.status = status;
}
示例14: RestoreSnapshotHelper
import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher; //导入依赖的package包/类
public RestoreSnapshotHelper(final Configuration conf,
final FileSystem fs,
final SnapshotDescription snapshotDescription,
final Path snapshotDir,
final HTableDescriptor tableDescriptor,
final Path rootDir,
final ForeignExceptionDispatcher monitor,
final MonitoredTask status)
{
this.fs = fs;
this.conf = conf;
this.snapshotDesc = snapshotDescription;
this.snapshotTable = TableName.valueOf(snapshotDescription.getTable());
this.snapshotDir = snapshotDir;
this.tableDesc = tableDescriptor;
this.rootDir = rootDir;
this.tableDir = FSUtils.getTableDir(rootDir, tableDesc.getTableName());
this.monitor = monitor;
this.status = status;
}
示例15: getRestoreHelper
import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher; //导入依赖的package包/类
/**
* Initialize the restore helper, based on the snapshot and table information provided.
*/
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)
.build();
return new RestoreSnapshotHelper(conf, fs, sd, snapshotDir,
htdClone, rootDir, monitor, status);
}