Search in sources :

Example 61 with UncheckedExecutionException

use of com.google.common.util.concurrent.UncheckedExecutionException in project Essentials by drtshock.

the class UserMap method getUser.

public User getUser(final String name) {
    try {
        final String sanitizedName = StringUtil.safeString(name);
        if (names.containsKey(sanitizedName)) {
            final UUID uuid = names.get(sanitizedName);
            return getUser(uuid);
        }
        final File userFile = getUserFileFromString(sanitizedName);
        if (userFile.exists()) {
            ess.getLogger().info("Importing user " + name + " to usermap.");
            User user = new User(new OfflinePlayer(sanitizedName, ess.getServer()), ess);
            trackUUID(user.getBase().getUniqueId(), user.getName(), true);
            return user;
        }
        return null;
    } catch (UncheckedExecutionException ex) {
        return null;
    }
}
Also used : UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) File(java.io.File)

Example 62 with UncheckedExecutionException

use of com.google.common.util.concurrent.UncheckedExecutionException in project verify-hub by alphagov.

the class TransactionsConfigProxy method getShouldHubUseLegacySamlStandard.

public Boolean getShouldHubUseLegacySamlStandard(String entityId) {
    final UriBuilder uriBuilder = UriBuilder.fromUri(configUri).path(Urls.ConfigUrls.SHOULD_HUB_USE_LEGACY_SAML_STANDARD_RESOURCE);
    for (Map.Entry<String, String> entry : ImmutableMap.<String, String>of().entrySet()) {
        uriBuilder.queryParam(entry.getKey(), entry.getValue());
    }
    URI uri = uriBuilder.buildFromEncoded(StringEncoding.urlEncode(entityId).replace("+", "%20"));
    try {
        return booleanCache.getUnchecked(uri);
    } catch (UncheckedExecutionException e) {
        Throwables.throwIfUnchecked(e.getCause());
        throw new RuntimeException(e.getCause());
    }
}
Also used : UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) UriBuilder(javax.ws.rs.core.UriBuilder) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) URI(java.net.URI)

Example 63 with UncheckedExecutionException

use of com.google.common.util.concurrent.UncheckedExecutionException in project sirix by sirixdb.

the class PageReadTrxImpl method dereferenceIndirectPageReference.

/**
 * Dereference indirect page reference.
 *
 * @param reference reference to dereference
 * @return dereferenced page
 *
 * @throws SirixIOException if something odd happens within the creation process
 * @throws NullPointerException if {@code reference} is {@code null}
 */
@Override
public IndirectPage dereferenceIndirectPageReference(final PageReference reference) {
    try {
        IndirectPage page = null;
        if (mTrxIntentLog != null) {
            // Try to get it from the transaction log if it's present.
            final PageContainer cont = mTrxIntentLog.get(reference);
            page = cont == null ? null : (IndirectPage) cont.getComplete();
        }
        if (page == null) {
            // Then try to get the in-memory reference.
            page = (IndirectPage) reference.getPage();
        }
        if (page == null && (reference.getKey() != Constants.NULL_ID_LONG || reference.getLogKey() != Constants.NULL_ID_INT || reference.getPersistentLogKey() != Constants.NULL_ID_LONG)) {
            // Then try to get it from the page cache which might read it from the persistent storage
            // on a cache miss.
            page = (IndirectPage) mPageCache.get(reference);
        }
        return page;
    } catch (final ExecutionException | UncheckedExecutionException e) {
        throw new SirixIOException(e.getCause());
    }
}
Also used : PageContainer(org.sirix.cache.PageContainer) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) ExecutionException(java.util.concurrent.ExecutionException) SirixIOException(org.sirix.exception.SirixIOException) IndirectPage(org.sirix.page.IndirectPage)

Example 64 with UncheckedExecutionException

use of com.google.common.util.concurrent.UncheckedExecutionException in project sirix by sirixdb.

the class PageReadTrxImpl method getRecord.

@Override
public Optional<Record> getRecord(final long nodeKey, final PageKind pageKind, @Nonnegative final int index) {
    checkNotNull(pageKind);
    assertNotClosed();
    if (nodeKey == Fixed.NULL_NODE_KEY.getStandardProperty()) {
        return Optional.empty();
    }
    final long recordPageKey = pageKey(nodeKey);
    final PageContainer cont;
    try {
        switch(pageKind) {
            case RECORDPAGE:
            case PATHSUMMARYPAGE:
            case PATHPAGE:
            case CASPAGE:
            case NAMEPAGE:
                cont = mNodeCache.get(new IndexLogKey(pageKind, recordPageKey, index));
                break;
            default:
                throw new IllegalStateException();
        }
    } catch (final ExecutionException | UncheckedExecutionException e) {
        throw new SirixIOException(e.getCause());
    }
    if (PageContainer.emptyInstance().equals(cont)) {
        return Optional.empty();
    }
    final Record retVal = ((UnorderedKeyValuePage) cont.getComplete()).getValue(nodeKey);
    return checkItemIfDeleted(retVal);
}
Also used : PageContainer(org.sirix.cache.PageContainer) IndexLogKey(org.sirix.cache.IndexLogKey) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) Record(org.sirix.node.interfaces.Record) UnorderedKeyValuePage(org.sirix.page.UnorderedKeyValuePage) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) ExecutionException(java.util.concurrent.ExecutionException) SirixIOException(org.sirix.exception.SirixIOException)

Example 65 with UncheckedExecutionException

use of com.google.common.util.concurrent.UncheckedExecutionException in project bookkeeper by apache.

the class CompactionTest method testSuspendGarbageCollection.

/**
 * Suspend garbage collection when suspendMajor/suspendMinor is set.
 */
@Test
public void testSuspendGarbageCollection() throws Exception {
    ServerConfiguration conf = newServerConfiguration();
    conf.setGcWaitTime(500);
    conf.setMinorCompactionInterval(1);
    conf.setMajorCompactionInterval(2);
    runFunctionWithLedgerManagerFactory(conf, lmf -> {
        try (LedgerManager lm = lmf.newLedgerManager()) {
            testSuspendGarbageCollection(conf, lm);
        } catch (Exception e) {
            throw new UncheckedExecutionException(e.getMessage(), e);
        }
        return null;
    });
}
Also used : LedgerManager(org.apache.bookkeeper.meta.LedgerManager) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) ServerConfiguration(org.apache.bookkeeper.conf.ServerConfiguration) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) IOException(java.io.IOException) NoWritableLedgerDirException(org.apache.bookkeeper.bookie.LedgerDirsManager.NoWritableLedgerDirException) Test(org.junit.Test)

Aggregations

UncheckedExecutionException (com.google.common.util.concurrent.UncheckedExecutionException)101 ExecutionException (java.util.concurrent.ExecutionException)60 IOException (java.io.IOException)31 InvalidCacheLoadException (com.google.common.cache.CacheLoader.InvalidCacheLoadException)22 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)10 Test (org.junit.Test)9 Map (java.util.Map)8 ArrayList (java.util.ArrayList)7 File (java.io.File)6 TimeoutException (java.util.concurrent.TimeoutException)6 Stopwatch (com.google.common.base.Stopwatch)5 ImmutableMap (com.google.common.collect.ImmutableMap)5 HashMap (java.util.HashMap)5 List (java.util.List)5 NoSuchElementException (java.util.NoSuchElementException)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 InputStream (java.io.InputStream)4 Callable (java.util.concurrent.Callable)4 SirixIOException (org.sirix.exception.SirixIOException)4 TypeSignature (com.facebook.presto.common.type.TypeSignature)3