Codota Logo
CompoundRuntimeException
Code IndexAdd Codota to your IDE (free)

How to use
CompoundRuntimeException
in
org.apache.brooklyn.util.exceptions

Best Java code snippets using org.apache.brooklyn.util.exceptions.CompoundRuntimeException (Showing top 15 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Dictionary d =
  • Codota Iconnew Hashtable()
  • Codota IconBundle bundle;bundle.getHeaders()
  • Codota Iconnew Properties()
  • Smart code suggestions by Codota
}
origin: org.apache.brooklyn/brooklyn-test-framework

  /**
   * @throws AssertionError if any failures were collected.
   */
  public void validate() {
    if (0 < failures.size()) {
      if (1 == failures.size()) {
        throw failures.get(0);
      }
      StringBuilder builder = new StringBuilder();
      for (AssertionError assertionError : failures) {
        builder.append(assertionError.getMessage()).append("\n");
      }
      throw new AssertionError("Assertions failed:\n" + builder, new CompoundRuntimeException("Assertions", failures));
    }
  }
}
origin: org.apache.brooklyn/brooklyn-core

@Override @Beta
public Collection<Throwable> validateType(RegisteredType typeToValidate, RegisteredTypeLoadingContext constraint) {
  ReferenceWithError<RegisteredType> result = resolve(typeToValidate, constraint);
  if (result.hasError()) {
    if (RegisteredTypes.isTemplate(typeToValidate)) {
      // ignore for templates
      return Collections.emptySet();
    }
    if (result.getError() instanceof CompoundRuntimeException) {
      return ((CompoundRuntimeException)result.getError()).getAllCauses();
    }
    return Collections.singleton(result.getError());
  }
  // replace what's in catalog with resolved+validated version
  ((BasicBrooklynTypeRegistry) mgmt.getTypeRegistry()).addToLocalUnpersistedTypeRegistry(result.get(), true);
  return Collections.emptySet();
}
origin: org.apache.brooklyn/brooklyn-locations-jclouds

public void tryObtainAndCheck(Map<?, ?> flags, Predicate<? super ConfigBag> test) {
  try {
    obtain(flags);
  } catch (Exception e) {
    boolean found = Iterables.tryFind(Throwables.getCausalChain(e), Predicates.<Throwable>equalTo(e)).isPresent();
    if (!found && e instanceof CompoundRuntimeException) {
      for (Throwable cause : ((CompoundRuntimeException) e).getAllCauses()) {
        found = Iterables.tryFind(Throwables.getCausalChain(cause), Predicates.<Throwable>equalTo(e)).isPresent();
        if (found) break;
      }
    }
    if (found) {
      test.apply(lastConfigBag);
    } else {
      throw Exceptions.propagate(e);
    }
  }
}
origin: org.apache.brooklyn/brooklyn-utils-common

/** creates the given exception, but without propagating it, for use when caller will be wrapping */
public static RuntimeException create(@Nullable String prefix, Iterable<? extends Throwable> exceptions) {
  if (Iterables.size(exceptions)==1) {
    Throwable e = exceptions.iterator().next();
    if (Strings.isBlank(prefix)) return new PropagatedRuntimeException(e);
    return new PropagatedRuntimeException(prefix + ": " + Exceptions.collapseText(e), e);
  }
  if (Iterables.isEmpty(exceptions)) {
    if (Strings.isBlank(prefix)) return new CompoundRuntimeException("(empty compound exception)", exceptions);
    return new CompoundRuntimeException(prefix, exceptions);
  }
  if (Strings.isBlank(prefix)) return new CompoundRuntimeException(Iterables.size(exceptions)+" errors, including: " + Exceptions.collapseText(exceptions.iterator().next()), exceptions);
  return new CompoundRuntimeException(prefix+"; "+Iterables.size(exceptions)+" errors including: " + Exceptions.collapseText(exceptions.iterator().next()), exceptions);
}
origin: org.apache.brooklyn/brooklyn-utils-common

  @Override
  @SuppressWarnings("unchecked")
  public <T> Maybe<T> tryCoerce(Object input, TypeToken<T> targetType) {
    Class<? super T> rawTargetType = targetType.getRawType();
    
    List<ClassCoercionException> exceptions = Lists.newArrayList();
    //now look for static TargetType.fromType(Type t) where value instanceof Type  
    for (Method m: rawTargetType.getMethods()) {
      if (((m.getModifiers()&Modifier.STATIC)==Modifier.STATIC) && 
          m.getName().startsWith("from") && m.getParameterTypes().length==1 &&
          m.getParameterTypes()[0].isInstance(input)) {
        if (m.getName().equals("from"+JavaClassNames.verySimpleClassName(m.getParameterTypes()[0]))) {
          try {
            return Maybe.of((T) m.invoke(null, input));
          } catch (Exception e) {
            exceptions.add(new ClassCoercionException("Cannot coerce type "+input.getClass()+" to "+rawTargetType.getCanonicalName()+" ("+input+"): "+m.getName()+" adapting failed", e));
          }
        }
      }
    }
    if (exceptions.isEmpty()) {
      return null;
    } else if (exceptions.size() == 1) {
      return Maybe.absent(exceptions.get(0));
    } else {
      String errMsg = "Failed coercing type "+input.getClass()+" to "+rawTargetType.getCanonicalName();
      return Maybe.absent(new CompoundRuntimeException(errMsg, exceptions));
    }
  }
}
origin: org.apache.brooklyn/brooklyn-core

public static void stopSequentially(Iterable<? extends Startable> entities) {
  List<Exception> exceptions = Lists.newArrayList();
  List<Startable> failedEntities = Lists.newArrayList();
  
  for (final Startable entity : entities) {
    if (!Entities.isManaged((Entity)entity)) {
      log.debug("Not stopping {} because it is not managed; continuing", entity);
      continue;
    }
    try {
      TaskAdaptable<Void> task = TaskTags.markInessential(Effectors.invocation((Entity)entity, Startable.STOP, Collections.emptyMap()));
      DynamicTasks.submit(task, (Entity)entity).getUnchecked();
    } catch (Exception e) {
      log.warn("Error stopping "+entity+"; continuing with shutdown", e);
      exceptions.add(e);
      failedEntities.add(entity);
    }
  }
  
  if (exceptions.size() > 0) {
    throw new CompoundRuntimeException("Error stopping "+(failedEntities.size() > 1 ? "entities" : "entity")+": "+failedEntities, exceptions);
  }
}
origin: org.apache.brooklyn/brooklyn-core

String msg;
if (errors.size()>1) {
  wrapped = new CompoundRuntimeException(errors.size()+" sublocation exceptions, including: "+
    Exceptions.collapseText(errors.get(0)), errors);
  msg = Exceptions.collapseText(wrapped);
origin: org.apache.brooklyn/brooklyn-core

} else {
  throw new CompoundRuntimeException("Problem loading mementos ("+phase+")", exceptions);
origin: org.apache.brooklyn/brooklyn-locations-jclouds

@Override
@AfterMethod(alwaysRun=true)
public void tearDown() throws Exception {
  List<Exception> exceptions = Lists.newArrayList();
  try {
    exceptions.addAll(releaseMachineSafely(machines));
    machines.clear();
  } finally {
    super.tearDown();
  }
  
  if (exceptions.size() > 0) {
    throw new CompoundRuntimeException("Error in tearDown of "+getClass(), exceptions);
  }
}
origin: org.apache.brooklyn/brooklyn-locations-jclouds

@AfterMethod(alwaysRun=true)
public void tearDown() throws Exception {
  List<Exception> exceptions = Lists.newArrayList();
  try {
    if (machines != null) {
      exceptions.addAll(releaseMachineSafely(machines));
      machines.clear();
    }
  } finally {
    try {
      if (managementContext != null) Entities.destroyAll(managementContext);
    } catch (Exception e) {
      LOG.warn("Error destroying management context", e);
      exceptions.add(e);
    }
    managementContext = null;
  }
  
  // TODO Debate about whether to:
  //  - use destroyAllCatching (i.e. not propagating exception)
  //    Benefit is that other tests in class will subsequently be run, rather than bailing out.
  //  - propagate exceptions from tearDown
  //    Benefit is that we don't hide errors; release(...) etc should not be throwing exceptions.
  if (exceptions.size() > 0) {
    throw new CompoundRuntimeException("Error in tearDown of "+getClass(), exceptions);
  }
}
origin: org.apache.brooklyn/brooklyn-locations-jclouds

@Override
@AfterMethod(alwaysRun=true)
public void tearDown() throws Exception {
  List<Exception> exceptions = Lists.newArrayList();
  for (ManagementContext mgmt : mgmts) {
    try {
      if (mgmt.isRunning()) Entities.destroyAll(mgmt);
    } catch (Exception e) {
      LOG.warn("Error destroying management context", e);
      exceptions.add(e);
    }
  }
  mgmts.clear();
  origManagementContext = null;
  newManagementContext = null;
  origApp = null;
  newApp = null;
  
  super.tearDown();
  
  if (exceptions.size() > 0) {
    throw new CompoundRuntimeException("Error in tearDown of "+getClass(), exceptions);
  }
}
origin: org.apache.brooklyn/brooklyn-software-messaging

@Override
public void stop() {
  List<Exception> errors = Lists.newArrayList();
  if (getZooKeeper() != null && Objects.equal(this, getZooKeeper().getParent())) {
    try {
      getZooKeeper().stop();
    } catch (Exception e) {
      errors.add(e);
    }
  }
  if (getCurrentSize() > 0) {
    try {
      getCluster().stop();
    } catch (Exception e) {
      errors.add(e);
    }
  }
  clearLocations();
  sensors().set(SERVICE_UP, false);
  if (errors.size() != 0) {
    throw new CompoundRuntimeException("Error stopping Kafka cluster", errors);
  }
}
origin: org.apache.brooklyn/brooklyn-locations-jclouds

@Override
@AfterMethod(alwaysRun=true)
public void tearDown() throws Exception {
  List<Exception> exceptions = Lists.newArrayList();
  try {
    if (provisioningManagementContext != null && provisionedMachine != null) {
      provisionedMachine.getParent().release(provisionedMachine);
    }
  } finally {
    Entities.destroyAll(provisioningManagementContext);
    provisioningManagementContext = null;
    provisionedMachine = null;
    
    super.tearDown();
  }
  
  if (exceptions.size() > 0) {
    throw new CompoundRuntimeException("Error in tearDown of "+getClass(), exceptions);
  }
}
origin: org.apache.brooklyn/brooklyn-locations-jclouds

@Override
@AfterMethod(alwaysRun=true)
public void tearDown() throws Exception {
  try {
    List<Exception> exceptions = Lists.newArrayList();
    for (ManagementContext mgmt : mgmts) {
      try {
        if (mgmt.isRunning()) Entities.destroyAll(mgmt);
      } catch (Exception e) {
        LOG.warn("Error destroying management context", e);
        exceptions.add(e);
      }
    }
    
    super.tearDown();
    
    if (exceptions.size() > 0) {
      throw new CompoundRuntimeException("Error in tearDown of "+getClass(), exceptions);
    }
  } finally {
    mgmts.clear();
    origManagementContext = null;
    newManagementContext = null;
    origApp = null;
    newApp = null;
    RecordingSshTool.clear();
    RecordingWinRmTool.clear();
  }
}
origin: org.apache.brooklyn/brooklyn-core

throw new CompoundRuntimeException("Aborted waiting for ready from "+source+" "+sensor, abortionExceptions);
  throw new CompoundRuntimeException("Aborted waiting for ready from "+source+" "+sensor, abortionExceptions);
    throw new CompoundRuntimeException("Aborted waiting for ready from "+source+" "+sensor, abortionExceptions);
org.apache.brooklyn.util.exceptionsCompoundRuntimeException

Most used methods

  • <init>
  • getAllCauses

Popular in Java

  • Creating JSON documents from java classes using gson
  • getContentResolver (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • findViewById (Activity)
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • Locale (java.util)
    A Locale object represents a specific geographical, political, or cultural region. An operation that
  • Set (java.util)
    A collection that contains no duplicate elements. More formally, sets contain no pair of elements e1
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • JButton (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now