use of alluxio.exception.status.UnavailableException in project alluxio by Alluxio.
the class RpcContextTest method blockDeletionContextThrows.
@Test
public void blockDeletionContextThrows() throws Throwable {
Exception bdcException = new UnavailableException("block deletion context exception");
doThrow(bdcException).when(mMockBDC).close();
checkClose(bdcException);
}
use of alluxio.exception.status.UnavailableException in project alluxio by Alluxio.
the class RpcContextTest method journalContextThrows.
@Test
public void journalContextThrows() throws Throwable {
Exception jcException = new UnavailableException("journal context exception");
doThrow(jcException).when(mMockJC).close();
checkClose(jcException);
}
use of alluxio.exception.status.UnavailableException in project alluxio by Alluxio.
the class JournalContextTest method pauseBlocksJournalContext.
@Test
public void pauseBlocksJournalContext() throws Exception {
LockResource lock = mMasterContext.getStateLockManager().lockExclusive(StateLockOptions.defaults());
AtomicBoolean journalContextCreated = new AtomicBoolean(false);
Runnable run = () -> {
// new journal contexts should be blocked
try (JournalContext journalContext = mBlockMaster.createJournalContext()) {
journalContextCreated.set(true);
} catch (UnavailableException e) {
throw new RuntimeException("Failed to create journal context", e);
}
};
Thread thread = new Thread(run);
Thread thread2 = new Thread(run);
thread.start();
try {
// since state is paused, new contexts should not be created
CommonUtils.sleepMs(100);
assertFalse(journalContextCreated.get());
// after un-pausing, new journal contexts can be created
lock.close();
thread2.run();
CommonUtils.waitFor("journal context created", journalContextCreated::get, WaitForOptions.defaults().setTimeoutMs(5 * Constants.SECOND_MS).setInterval(10));
} finally {
thread.interrupt();
thread.join();
thread2.interrupt();
thread2.join();
}
}
use of alluxio.exception.status.UnavailableException in project alluxio by Alluxio.
the class JournalContextTest method stateChangeFairness.
@Test
public void stateChangeFairness() throws Exception {
JournalContext journalContext = mBlockMaster.createJournalContext();
AtomicBoolean paused = new AtomicBoolean(false);
ExecutorService service = ExecutorServiceFactories.cachedThreadPool("stateChangeFairness").create();
// create tasks that continually create journal contexts
for (int i = 0; i < 100; i++) {
service.submit(() -> {
while (!Thread.currentThread().isInterrupted()) {
try {
mBlockMaster.createJournalContext().close();
} catch (UnavailableException e) {
// ignore
}
}
});
}
// task that attempts to pause the state
service.submit(() -> {
// the pause lock should block
try (LockResource lr = mMasterContext.getStateLockManager().lockExclusive(StateLockOptions.defaults())) {
paused.set(true);
} catch (Exception e) {
throw new IllegalStateException("Failed to acquire state-lock exclusively.");
}
});
try {
// since the journal context is still open, the pause should be blocked
CommonUtils.sleepMs(100);
assertFalse(paused.get());
// after closing the journal context, the pause lock should succeed, even when there are many
// threads creating journal contexts.
journalContext.close();
CommonUtils.waitFor("pause lock to succeed", paused::get, WaitForOptions.defaults().setTimeoutMs(10 * Constants.SECOND_MS).setInterval(10));
} finally {
service.shutdownNow();
service.awaitTermination(5, TimeUnit.SECONDS);
}
assertTrue(paused.get());
}
use of alluxio.exception.status.UnavailableException in project alluxio by Alluxio.
the class JobUfsManager method get.
@Override
public UfsClient get(long mountId) throws NotFoundException, UnavailableException {
try {
return super.get(mountId);
} catch (NotFoundException e) {
// Not cached locally, let's query master
}
UfsInfo info;
try {
info = mMasterClient.getUfsInfo(mountId);
} catch (IOException e) {
throw new UnavailableException(String.format("Failed to create UFS info for mount point with id %d", mountId), e);
}
Preconditions.checkState((info.hasUri() && info.hasProperties()), "unknown mountId");
super.addMount(mountId, new AlluxioURI(info.getUri()), UnderFileSystemConfiguration.defaults(ServerConfiguration.global()).setReadOnly(info.getProperties().getReadOnly()).setShared(info.getProperties().getShared()).createMountSpecificConf(info.getProperties().getPropertiesMap()));
UfsClient ufsClient = super.get(mountId);
try (CloseableResource<UnderFileSystem> ufsResource = ufsClient.acquireUfsResource()) {
UnderFileSystem ufs = ufsResource.get();
ufs.connectFromWorker(NetworkAddressUtils.getConnectHost(NetworkAddressUtils.ServiceType.WORKER_RPC, ServerConfiguration.global()));
} catch (IOException e) {
removeMount(mountId);
throw new UnavailableException(String.format("Failed to connect to UFS %s with id %d", info.getUri(), mountId), e);
}
return ufsClient;
}
Aggregations