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;
}
}
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());
}
}
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());
}
}
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);
}
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;
});
}
Aggregations