Search in sources :

Example 11 with UnavailableException

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);
}
Also used : UnavailableException(alluxio.exception.status.UnavailableException) ExpectedException(org.junit.rules.ExpectedException) UnavailableException(alluxio.exception.status.UnavailableException) Test(org.junit.Test)

Example 12 with UnavailableException

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);
}
Also used : UnavailableException(alluxio.exception.status.UnavailableException) ExpectedException(org.junit.rules.ExpectedException) UnavailableException(alluxio.exception.status.UnavailableException) Test(org.junit.Test)

Example 13 with UnavailableException

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();
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) LockResource(alluxio.resource.LockResource) UnavailableException(alluxio.exception.status.UnavailableException) Test(org.junit.Test)

Example 14 with UnavailableException

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());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) LockResource(alluxio.resource.LockResource) ExecutorService(java.util.concurrent.ExecutorService) UnavailableException(alluxio.exception.status.UnavailableException) UnavailableException(alluxio.exception.status.UnavailableException) Test(org.junit.Test)

Example 15 with UnavailableException

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;
}
Also used : UfsInfo(alluxio.grpc.UfsInfo) UnavailableException(alluxio.exception.status.UnavailableException) NotFoundException(alluxio.exception.status.NotFoundException) IOException(java.io.IOException) AlluxioURI(alluxio.AlluxioURI)

Aggregations

UnavailableException (alluxio.exception.status.UnavailableException)58 IOException (java.io.IOException)25 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)10 AlluxioURI (alluxio.AlluxioURI)9 AlluxioStatusException (alluxio.exception.status.AlluxioStatusException)9 NotFoundException (alluxio.exception.status.NotFoundException)9 InetSocketAddress (java.net.InetSocketAddress)9 BlockInfo (alluxio.wire.BlockInfo)8 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)7 WorkerNetAddress (alluxio.wire.WorkerNetAddress)7 WorkerInfo (alluxio.wire.WorkerInfo)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 Set (java.util.Set)6 RetryPolicy (alluxio.retry.RetryPolicy)5 TimeoutException (java.util.concurrent.TimeoutException)5 BlockInfoException (alluxio.exception.BlockInfoException)4 ExceptionMessage (alluxio.exception.ExceptionMessage)4 InodeFile (alluxio.master.file.meta.InodeFile)4