/** * Run the loop. * * @return true if the exit condition was satisfied; false if the loop terminated for any other reason. */ public boolean run() { return runKeepingError().getWithoutError(); }
/** @deprecated since 0.7.0, use {@link #activateHotProxy(ManagementNodeState)} */ @Deprecated protected boolean attemptHotStandby() { return activateHotProxy(ManagementNodeState.HOT_STANDBY).getWithoutError(); }
@Override public Map<ConfigKey<?>, Object> getAllConfigInheritedRawValuesIgnoringErrors() { Map<ConfigKey<?>, ReferenceWithError<ConfigValueAtContainer<TContainer, ?>>> input = getAllConfigInheritedRawWithErrors(); Map<ConfigKey<?>, Object> result = MutableMap.of(); for (Map.Entry<ConfigKey<?>, ReferenceWithError<ConfigValueAtContainer<TContainer, ?>>> pair: input.entrySet()) { result.put(pair.getKey(), pair.getValue().getWithoutError().get()); } return result; } @Override
@Override public <T> T getConfig(ConfigKey<T> key) { return getConfigImpl(key, false).getWithoutError().get(); }
/** returns the underlying value, throwing if there is an error which is not masked (ie {@link #throwsErrorOnAccess()} is set) */ @Override public T get() { if (masksErrorIfPresent()) { return getWithoutError(); } return getWithError(); }
@SuppressWarnings("unchecked") @Override public Maybe<Object> getRaw(ConfigKey<?> key) { return (Maybe<Object>) getConfigsInternal().getConfigInheritedRaw(key).getWithoutError().asMaybe(); }
@Override public <T> T getConfig(HasConfigKey<T> key) { return getConfigImpl(key.getConfigKey(), false).getWithoutError().get(); }
protected ReferenceWithError<Optional<Entity>> addInSingleLocation(@Nullable Location location, Map<?,?> flags) { ReferenceWithError<Collection<Entity>> added = addInEachLocation(Arrays.asList(location), flags); Optional<Entity> result = Iterables.isEmpty(added.getWithoutError()) ? Optional.<Entity>absent() : Optional.of(Iterables.getOnlyElement(added.get())); if (!added.hasError()) { return ReferenceWithError.newInstanceWithoutError( result ); } else { if (added.masksErrorIfPresent()) { return ReferenceWithError.newInstanceMaskingError( result, added.getError() ); } else { return ReferenceWithError.newInstanceThrowingError( result, added.getError() ); } } }
/** * @throws StopFailedRuntimeException If stop failed, after successfully starting replacement */ protected Entity replaceMember(Entity member, @Nullable Location memberLoc, Map<?, ?> extraFlags) { synchronized (mutex) { ReferenceWithError<Optional<Entity>> added = addInSingleLocation(memberLoc, extraFlags); if (!added.getWithoutError().isPresent()) { String msg = String.format("In %s, failed to grow, to replace %s; not removing", this, member); if (added.hasError()) throw new IllegalStateException(msg, added.getError()); throw new IllegalStateException(msg); } try { stopAndRemoveNode(member); } catch (Exception e) { Exceptions.propagateIfFatal(e); throw new StopFailedRuntimeException("replaceMember failed to stop and remove old member "+member.getId(), e); } return added.getWithError().get(); } }
@Override @Deprecated public boolean hasConfig(ConfigKey<?> key, boolean includeInherited) { return config().getInternalConfigMap().getConfigInheritedRaw(key).getWithoutError().asMaybe().isPresent(); }
Object result = installResult.getWithoutError(); if (result instanceof Bundle) { String v = OsgiUtils.getVersionedId( (Bundle)result );
protected void waitForSshable(final SshMachineLocation machine, Duration timeout) { Callable<Boolean> checker = new Callable<Boolean>() { public Boolean call() { int exitstatus = machine.execScript( ImmutableMap.of( // TODO investigate why SSH connection does not time out with this config SshTool.PROP_CONNECT_TIMEOUT.getName(), Duration.TEN_SECONDS.toMilliseconds(), SshTool.PROP_SESSION_TIMEOUT.getName(), Duration.TEN_SECONDS.toMilliseconds(), SshTool.PROP_SSH_TRIES_TIMEOUT.getName(), Duration.TEN_SECONDS.toMilliseconds(), SshTool.PROP_SSH_TRIES.getName(), 1), "check-sshable", ImmutableList.of("true")); boolean success = (exitstatus == 0); return success; } }; Stopwatch stopwatch = Stopwatch.createStarted(); ReferenceWithError<Boolean> reachable = Repeater.create("reachable") .threaded() .backoff(Duration.FIVE_SECONDS, 2, Duration.TEN_SECONDS) // Exponential backoff, to 10 seconds .until(checker) .limitTimeTo(timeout) .runKeepingError(); if (!reachable.getWithoutError()) { throw new IllegalStateException("Connection failed for " + machine.getSshHostAndPort() + " after waiting " + stopwatch.elapsed(TimeUnit.SECONDS), reachable.getError()); } else { LOG.debug("Connection succeeded for {} after {}", machine.getSshHostAndPort(), stopwatch.elapsed(TimeUnit.SECONDS)); } }
@Override public Boolean call() { ReferenceWithError<Boolean> result; Tasks.setBlockingDetails(repeater.getDescription()); try { result = repeater.runKeepingError(); } finally { Tasks.resetBlockingDetails(); } if (Boolean.TRUE.equals(result.getWithoutError())) return true; if (result.hasError()) throw Exceptions.propagate(result.getError()); if (requireTrue) throw new IllegalStateException("timeout - "+repeater.getDescription()); return false; } }
@Override @Beta public Response createFromArchive(byte[] zipInput, boolean detail, boolean forceUpdate) { if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.ROOT, null)) { throw WebResourceUtils.forbidden("User '%s' is not authorized to add catalog item", Entitlements.getEntitlementContext().user()); } ReferenceWithError<OsgiBundleInstallationResult> result = ((ManagementContextInternal)mgmt()).getOsgiManager().get() .install(null, new ByteArrayInputStream(zipInput), true, true, forceUpdate); if (OsgiBundleInstallationResult.ResultCode.IGNORING_BUNDLE_AREADY_INSTALLED.equals(result.getWithoutError().getCode())) { result = ReferenceWithError.newInstanceThrowingError(result.getWithoutError(), new IllegalStateException( "Cannot add bundle" + result.getWithoutError().getMetadata().getVersionedName() + "; different bundle with same name already installed")); } if (result.hasError()) { // (rollback already done as part of install, if necessary) if (log.isTraceEnabled()) { log.trace("Unable to create from archive, returning 400: "+result.getError().getMessage(), result.getError()); } return ApiError.builder().errorCode(Status.BAD_REQUEST).message(result.getWithoutError().getMessage()) .data(BundleInstallationRestResult.of(result.getWithoutError(), mgmt(), brooklyn(), ui)).build().asJsonResponse(); } BundleInstallationRestResult resultR = BundleInstallationRestResult.of(result.get(), mgmt(), brooklyn(), ui); return Response.status(Status.CREATED).entity( detail ? resultR : resultR.types ).build(); }
if (currentInheritance.considerParent(local, parent, context)) { ReferenceWithError<ConfigValueAtContainer<TContainer, TValue>> parentResult = resolveInheriting(parent, ancestorContainerKeyValues, queryKey, context, currentInheritance); ReferenceWithError<ConfigValueAtContainer<TContainer,TValue>> resultWithParent = currentInheritance.resolveWithParent(local, parentResult.getWithoutError(), context); if (resultWithParent!=null) { if (resultWithParent.getWithoutError()!=null && resultWithParent.getWithoutError().isValueExplicitlySet()) { if (!resultWithParent.hasError() && parentResult!=null && parentResult.hasError()) { return ReferenceWithError.newInstanceThrowingError(resultWithParent.getWithoutError(), parentResult.getError()); result = new BasicConfigValueAtContainer<TContainer, TValue>( resultWithParent.getWithoutError() );
ConfigValueAtContainer<TContainer, Object> vp = vpr==null ? null : (ConfigValueAtContainer<TContainer,Object>) vpr.getWithoutError();
new ResourceUtils(getClass()).getResourceFromUrl(BROOKLYN_TEST_MORE_ENTITIES_V2_EVIL_TWIN_URL) ); Assert.assertTrue(installEvilTwin.hasError()); Assert.assertEquals(installEvilTwin.getWithoutError().getCode(), OsgiBundleInstallationResult.ResultCode.ERROR_PREPARING_BUNDLE);
parent.isValueExplicitlySet() ? parent.asMaybe() : getAncestorDefaultInheritable() ? parent.getDefaultValue() : Maybe.<TValue>absent()); result.setValue(resolvedValue.getWithoutError()); return ReferenceWithError.newInstanceThrowingError(result, resolvedValue.getError());