예제 #1
0
 @BeforeClass
 public static void setUp() {
   blockStorage = new BlockStorageController();
   try {
     BlockStorageController.configure();
   } catch (EucalyptusCloudException e) {
     e.printStackTrace();
   }
 }
예제 #2
0
 /**
  * Returns the unique result from the database that exactly matches <code>example</code>. This
  * method is same as {@link #uniqueResult(Object)} but calls {@link #getUniqueEscape(Object)}
  * instead of {@link #getUnique(Object)}
  *
  * @param example
  * @return
  * @throws TransactionException
  */
 @SuppressWarnings("unchecked")
 public <T> T uniqueResultEscape(final T example) throws TransactionException {
   try {
     return this.recast((Class<T>) example.getClass()).getUniqueEscape(example);
   } catch (final RuntimeException ex) {
     throw new TransactionInternalException(ex.getMessage(), ex);
   } catch (final EucalyptusCloudException ex) {
     throw new TransactionExecutionException(ex.getMessage(), ex);
   }
 }
예제 #3
0
 public <T> T lookupAndClose(final T example) throws NoSuchElementException {
   T ret = null;
   try {
     ret = this.getUnique(example);
     this.commit();
   } catch (final EucalyptusCloudException ex) {
     this.rollback();
     throw new NoSuchElementException(ex.getMessage());
   }
   return ret;
 }
 @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
 public void handle(final ExceptionMessage exMsg) {
   EventRecord.here(getClass(), EventType.MSG_REPLY, exMsg.getPayload().getClass().getSimpleName())
       .debug();
   LOG.trace("Caught exception while servicing: " + exMsg.getPayload());
   final Throwable exception = exMsg.getException();
   if (exception instanceof MessagingException
       && exception.getCause() instanceof EucalyptusCloudException) {
     try {
       final EucalyptusCloudException cloudException =
           (EucalyptusCloudException) exception.getCause();
       final BaseMessage payload = parsePayload(exMsg.getPayload());
       final HttpResponseStatus status;
       final Role role;
       final String code;
       if (cloudException instanceof EucalyptusWebServiceException) {
         final EucalyptusWebServiceException webServiceException =
             (EucalyptusWebServiceException) cloudException;
         role = webServiceException.getRole();
         code = webServiceException.getCode();
       } else {
         role = Role.Receiver;
         code = defaultCode;
       }
       final QueryBindingInfo info =
           Ats.inClassHierarchy(cloudException.getClass()).get(QueryBindingInfo.class);
       status =
           info == null
               ? HttpResponseStatus.INTERNAL_SERVER_ERROR
               : new HttpResponseStatus(info.statusCode(), code);
       final BaseMessage errorResp =
           buildErrorResponse(payload.getCorrelationId(), role, code, cloudException.getMessage());
       Contexts.response(new BaseMessageSupplier(errorResp, status));
     } catch (final PayloadParseException e) {
       LOG.error("Failed to parse payload ", e.getCause());
     }
   } else {
     LOG.error("Unable to handle exception", exception);
     final BaseMessage errorResp = buildFatalResponse(exception);
     Contexts.response(
         new BaseMessageSupplier(errorResp, HttpResponseStatus.INTERNAL_SERVER_ERROR));
   }
 }