예제 #1
0
 TransactionState(final String ctx) {
   this.startTime = System.currentTimeMillis();
   this.txUuid = String.format("%s:%s", ctx, UUID.randomUUID().toString());
   this.stopWatch = new StopWatch();
   this.stopWatch.start();
   this.owner = Logs.isExtrrreeeme() ? Threads.currentStackString() : "n/a";
   try {
     this.eventLog(TxStep.BEGIN, TxEvent.CREATE);
     final EntityManagerFactory anemf =
         (EntityManagerFactoryImpl) PersistenceContexts.getEntityManagerFactory(ctx);
     checkParam(anemf, notNullValue());
     this.em = anemf.createEntityManager();
     checkParam(this.em, notNullValue());
     this.transaction = this.em.getTransaction();
     this.transaction.begin();
     this.session = new WeakReference<Session>((Session) this.em.getDelegate());
     this.eventLog(TxStep.END, TxEvent.CREATE);
   } catch (final Throwable ex) {
     Logs.exhaust().error(ex, ex);
     this.eventLog(TxStep.FAIL, TxEvent.CREATE);
     this.rollback();
     throw new RuntimeException(PersistenceExceptions.throwFiltered(ex));
   } finally {
     outstanding.put(this.txUuid, this);
   }
 }
    @Override
    public boolean apply(ModifyServiceType request) {
      try {
        final Topology.Transitions transition =
            Topology.Transitions.valueOf(request.getState().toUpperCase());
        String name = request.getName();
        ServiceConfiguration config = findService(name);
        if (Topology.Transitions.RESTART.equals(transition)) {
          Topology.stop(config).get();
          try {
            Topology.start(config).get();
          } catch (Exception ex) {
            Exceptions.maybeInterrupted(ex);
            Logs.extreme().error(ex, ex);
            throw Exceptions.toUndeclared(ex);
          }
        } else {
          Topology.transition(transition.get()).apply(config).get();
        }
      } catch (final IllegalArgumentException ex) {
        return false;
      } catch (final Exception ex) {
        Exceptions.maybeInterrupted(ex);
        Logs.extreme().error(ex, ex);
        throw Exceptions.toUndeclared(ex);
      }

      return true;
    }
예제 #3
0
 static void update() {
   final Multimap<String, String> partitionVolumeMap = HashMultimap.create();
   final EntityTransaction db = Entities.get(Volume.class);
   try {
     for (final Volume v : Entities.query(Volume.named(null, null))) {
       partitionVolumeMap.put(v.getPartition(), v.getDisplayName());
     }
     db.rollback();
   } catch (final Exception ex) {
     Logs.extreme().error(ex, ex);
     db.rollback();
   }
   Logs.extreme()
       .debug("Volume state update: " + Joiner.on("\n").join(partitionVolumeMap.entries()));
   for (final String partition : partitionVolumeMap.keySet()) {
     try {
       final Map<String, StorageVolume> idStorageVolumeMap =
           updateVolumesInPartition(partition); // TODO:GRZE: restoring volume state
       for (final String v : partitionVolumeMap.get(partition)) {
         try {
           final StorageVolume storageVolume = idStorageVolumeMap.get(v);
           volumeStateUpdate(v, storageVolume);
         } catch (final Exception ex) {
           LOG.error(ex);
           Logs.extreme().error(ex, ex);
         }
       }
     } catch (final Exception ex) {
       LOG.error(ex);
       Logs.extreme().error(ex, ex);
     }
   }
 }
예제 #4
0
 public static NetworkGroup delete(final OwnerFullName ownerFullName, final String groupName)
     throws MetadataException {
   if (defaultNetworkName().equals(groupName)) {
     createDefault(ownerFullName);
   }
   final EntityTransaction db = Entities.get(NetworkGroup.class);
   try {
     final NetworkGroup ret = Entities.uniqueResult(new NetworkGroup(ownerFullName, groupName));
     Entities.delete(ret);
     db.commit();
     return ret;
   } catch (final ConstraintViolationException ex) {
     Logs.exhaust().error(ex, ex);
     db.rollback();
     throw new IllegalMetadataAccessException(
         "Failed to delete security group: "
             + groupName
             + " for "
             + ownerFullName
             + " because of: "
             + Exceptions.causeString(ex),
         ex);
   } catch (final Exception ex) {
     Logs.exhaust().error(ex, ex);
     db.rollback();
     throw new NoSuchMetadataException(
         "Failed to find security group: " + groupName + " for " + ownerFullName, ex);
   }
 }
 private static VmInstance maybeFindVm(
     final String instanceId, final String publicIp, final String privateIp) {
   VmInstance vm = null;
   if (instanceId != null) {
     try {
       vm = VmInstances.lookup(instanceId);
     } catch (NoSuchElementException ex) {
       Logs.extreme().error(ex);
     }
   }
   if (vm == null && privateIp != null) {
     try {
       vm = VmInstances.lookupByPrivateIp(privateIp);
     } catch (NoSuchElementException ex) {
       Logs.extreme().error(ex);
     }
   }
   if (vm == null && publicIp != null) {
     try {
       vm = VmInstances.lookupByPublicIp(publicIp);
     } catch (NoSuchElementException ex) {
       Logs.extreme().error(ex);
     }
   }
   if (vm != null
       && VmState.RUNNING.equals(vm.getState())
       && publicIp.equals(vm.getPublicAddress())) {
     Logs.extreme()
         .debug(
             "Candidate vm which claims this address: "
                 + vm.getInstanceId()
                 + " "
                 + vm.getState()
                 + " "
                 + publicIp);
     if (publicIp.equals(vm.getPublicAddress())) {
       Logs.extreme()
           .debug(
               "Found vm which claims this address: "
                   + vm.getInstanceId()
                   + " "
                   + vm.getState()
                   + " "
                   + publicIp);
     }
     return vm;
   } else {
     return null;
   }
 }
예제 #6
0
 @Override
 public Set<String> get() {
   Set<String> hosts = DBHOSTS.get();
   Set<String> union = Sets.newHashSet();
   Set<String> intersection = Sets.newHashSet(hosts);
   Logs.extreme().debug("ActiveHostSet: universe of db hosts: " + hosts);
   for (String ctx : PersistenceContexts.list()) {
     try {
       Set<String> activeDatabases = Databases.lookup(ctx, 0).getactiveDatabases();
       if (BootstrapArgs.isCloudController()) {
         activeDatabases.add(
             Internets
                 .localHostIdentifier()); // GRZE: use Internets.localHostIdentifier() which is
                                          // static, rather than the Hosts reference as it is
                                          // stateful
       }
       union.addAll(activeDatabases);
       intersection.retainAll(activeDatabases);
     } catch (Exception ex) {
     }
   }
   Logs.extreme().debug("ActiveHostSet: union of activated db connections: " + union);
   Logs.extreme()
       .debug(
           "ActiveHostSet: intersection of db hosts and activated db connections: "
               + intersection);
   boolean dbVolatile = !hosts.equals(intersection);
   String msg =
       String.format(
           "ActiveHostSet: %-14.14s %s%s%s",
           dbVolatile ? "volatile" : "synchronized",
           hosts,
           dbVolatile ? "!=" : "=",
           intersection);
   if (dbVolatile) {
     if (last.compareAndSet(false, dbVolatile)) {
       LOG.warn(msg);
     } else {
       LOG.debug(msg);
     }
   } else {
     if (last.compareAndSet(true, dbVolatile)) {
       LOG.warn(msg);
     } else {
       Logs.extreme().info(msg);
     }
   }
   return intersection;
 }
예제 #7
0
 /**
  * @delegate Do not change semantics here.
  * @see javax.persistence.EntityTransaction#rollback()
  */
 @Override
 public void rollback() throws RecoverablePersistenceException {
   removeTransaction(this);
   if ((this.txState != null) && this.txState.isActive()) {
     try {
       this.txState.rollback();
       this.txState = null;
     } catch (final RuntimeException ex) {
       Logs.extreme().error(ex);
       //          throw PersistenceExceptions.throwFiltered( ex );
     }
   } else {
     Logs.extreme().debug("Duplicate call to rollback( )");
   }
 }
예제 #8
0
 public void abort() {
   for (final ResourceToken token : this.allocationTokens) {
     LOG.warn("Aborting resource token: " + token);
     Logs.exhaust().error("Aborting resource token", new RuntimeException());
     final EntityTransaction db = Entities.get(VmInstance.class);
     try {
       token.abort();
       db.commit();
     } catch (final Exception ex) {
       LOG.warn(ex.getMessage());
       Logs.exhaust().error(ex, ex);
       db.rollback();
     }
   }
 }
예제 #9
0
 public TypeBinding getTypeBinding(Field field) {
   Class itsType = field.getType();
   if (this.isIgnored(field)) {
     return new NoopTypeBinding(field);
   } else if (List.class.isAssignableFrom(itsType)) {
     Class listType = getTypeArgument(field);
     if (listType == null) {
       Logs.extreme()
           .debug(
               String.format(
                   "IGNORE: %-70s [type=%s] NO GENERIC TYPE FOR LIST\n",
                   field.getDeclaringClass().getCanonicalName() + "." + field.getName(),
                   listType));
       return new NoopTypeBinding(field);
     } else if (this.typeBindings.containsKey(listType.getCanonicalName())) {
       return new CollectionTypeBinding(
           field.getName(), this.typeBindings.get(listType.getCanonicalName()));
     } else if (BindingFileSearch.INSTANCE.MSG_DATA_CLASS.isAssignableFrom(listType)) {
       return new CollectionTypeBinding(
           field.getName(), new ObjectTypeBinding(field.getName(), listType));
     } else {
       Logs.extreme()
           .debug(
               String.format(
                   "IGNORE: %-70s [type=%s] LIST'S GENERIC TYPE DOES NOT CONFORM TO EucalyptusData\n",
                   field.getDeclaringClass().getCanonicalName() + "." + field.getName(),
                   listType.getCanonicalName()));
       return new NoopTypeBinding(field);
     }
   } else if (this.typeBindings.containsKey(itsType.getCanonicalName())) {
     TypeBinding t = this.typeBindings.get(itsType.getCanonicalName());
     try {
       t = this.typeBindings.get(itsType.getCanonicalName()).getClass().newInstance();
     } catch (Exception e) {
     }
     return t.value(field.getName());
   } else if (BindingFileSearch.INSTANCE.MSG_DATA_CLASS.isAssignableFrom(field.getType())) {
     return new ObjectTypeBinding(field);
   } else {
     Logs.extreme()
         .debug(
             String.format(
                 "IGNORE: %-70s [type=%s] TYPE DOES NOT CONFORM TO EucalyptusData\n",
                 field.getDeclaringClass().getCanonicalName() + "." + field.getName(),
                 field.getType().getCanonicalName()));
     return new NoopTypeBinding(field);
   }
 }
예제 #10
0
 public void processClass(Class klass) {
   if (this.out == null) {
     if (this.outFile.exists()) {
       this.outFile.delete();
     }
     try {
       this.out = new PrintWriter(this.outFile);
     } catch (FileNotFoundException e) {
       e.printStackTrace(System.err);
       System.exit(-1); // GRZE: special case to fail build
     }
     this.bindingName = this.ns.replaceAll("(http://)|(/$)", "").replaceAll("[./-]", "_");
     this.out.write(
         "<binding xmlns:euca=\"" + this.ns + "\" name=\"" + this.bindingName + "\">\n");
     this.out.write(
         "  <namespace uri=\"" + this.ns + "\" default=\"elements\" prefix=\"euca\"/>\n");
     this.out.flush();
   }
   if (!classNames.contains(klass.getName())) {
     classNames.add(klass.getName());
     String mapping = new RootObjectTypeBinding(klass).process();
     this.out.write(mapping);
     this.out.flush();
   } else {
     Logs.extreme().debug("Skipping duplicate class: " + klass);
   }
 }
예제 #11
0
 /** * @param message * @return */
 public static RuntimeException noSuchElement(String message, Throwable... t) {
   if (Logs.isExtrrreeeme() && t != null && t.length > 0) {
     return new NoSuchElementException(message + "\n" + string(message, t[0]));
   } else {
     return new NoSuchElementException(message);
   }
 }
예제 #12
0
 @Override
 public void handleUpstream(final ChannelHandlerContext ctx, final ChannelEvent e)
     throws Exception {
   final MappingHttpRequest request = MappingHttpMessage.extractMessage(e);
   final BaseMessage msg = BaseMessage.extractMessage(e);
   if (msg != null) {
     try {
       final Class<? extends ComponentId> compClass = ComponentMessages.lookup(msg);
       ComponentId compId = ComponentIds.lookup(compClass);
       if (compId.isAlwaysLocal() || Topology.isEnabledLocally(compClass)) {
         ctx.sendUpstream(e);
       } else {
         Handlers.sendRedirect(ctx, e, compClass, request);
       }
     } catch (final NoSuchElementException ex) {
       LOG.warn(
           "Failed to find reverse component mapping for message type: " + msg.getClass());
       ctx.sendUpstream(e);
     } catch (final Exception ex) {
       Logs.extreme().error(ex, ex);
       ctx.sendUpstream(e);
     }
   } else {
     ctx.sendUpstream(e);
   }
 }
예제 #13
0
  /**
   * Remove launch permissions.
   *
   * @param accountIds
   */
  public void removePermissions(final List<String> accountIds) {

    final EntityTransaction db = Entities.get(ImageInfo.class);
    try {
      final ImageInfo entity = Entities.merge(this);
      Iterables.all(
          accountIds,
          new Predicate<String>() {

            @Override
            public boolean apply(final String input) {
              try {
                final Account account = Accounts.lookupAccountById(input);
                ImageInfo.this.getPermissions().remove(input);
              } catch (final Exception e) {
                LOG.error(e, e);
              }
              return true;
            }
          });

      db.commit();
    } catch (final Exception ex) {
      Logs.exhaust().error(ex, ex);
      db.rollback();
    }
  }
예제 #14
0
  /**
   * Add launch permissions.
   *
   * @param accountIds
   */
  public void addPermissions(final List<String> accountIds) {
    final EntityTransaction db = Entities.get(ImageInfo.class);
    try {
      final ImageInfo entity = Entities.merge(this);
      Iterables.all(
          accountIds,
          new Predicate<String>() {

            @Override
            public boolean apply(final String input) {
              try {
                final Account account = Accounts.lookupAccountById(input);
                ImageInfo.this.getPermissions().add(input);
              } catch (final Exception e) {
                try {
                  final User user = Accounts.lookupUserById(input);
                  ImageInfo.this.getPermissions().add(user.getAccount().getAccountNumber());
                } catch (AuthException ex) {
                  try {
                    final User user = Accounts.lookupUserByAccessKeyId(input);
                    ImageInfo.this.getPermissions().add(user.getAccount().getAccountNumber());
                  } catch (AuthException ex1) {
                    LOG.error(ex1, ex1);
                  }
                }
              }
              return true;
            }
          });
      db.commit();
    } catch (final Exception ex) {
      Logs.exhaust().error(ex, ex);
      db.rollback();
    }
  }
예제 #15
0
 @Override
 public R apply(final D input) {
   RuntimeException rootCause = null;
   for (int i = 0; i < retries; i++) {
     EntityTransaction db = Entities.get(this.entityType);
     try {
       R ret = this.function.apply(input);
       db.commit();
       return ret;
     } catch (RuntimeException ex) {
       db.rollback();
       if (Exceptions.isCausedBy(ex, OptimisticLockException.class)) {
         rootCause = Exceptions.findCause(ex, OptimisticLockException.class);
       } else if (Exceptions.isCausedBy(ex, LockAcquisitionException.class)) {
         rootCause = Exceptions.findCause(ex, LockAcquisitionException.class);
       } else {
         rootCause = ex;
         Logs.extreme().error(ex, ex);
         throw ex;
       }
       try {
         TimeUnit.MILLISECONDS.sleep(20);
       } catch (InterruptedException ex1) {
         Exceptions.maybeInterrupted(ex1);
       }
       continue;
     }
   }
   throw (rootCause != null
       ? rootCause
       : new NullPointerException(
           "BUG: Transaction retry failed but root cause exception is unknown!"));
 }
예제 #16
0
 private boolean transition(
     State expectedState,
     State newState,
     boolean expectedMark,
     boolean newMark,
     SplitTransition transition) {
   this.transition = transition;
   if (!this.atomicState.compareAndSet(expectedState, newState, expectedMark, newMark)) {
     throw new IllegalStateException(
         String.format(
             "Cannot mark address as %s[%s.%s->%s.%s] when it is %s.%s: %s",
             transition.getName(),
             expectedState,
             expectedMark,
             newState,
             newMark,
             this.atomicState.getReference(),
             this.atomicState.isMarked(),
             this.toString()));
   }
   EventRecord.caller(this.getClass(), EventType.ADDRESS_STATE, "TOP", this.toString()).info();
   try {
     this.transition.top();
   } catch (RuntimeException ex) {
     LOG.error(ex);
     Logs.extreme().error(ex, ex);
     throw ex;
   }
   return true;
 }
예제 #17
0
 public static WebServicesException notFound(String message, Throwable... t) {
   if (Logs.isExtrrreeeme() && t != null && t.length > 0) {
     return new ServiceDispatchException(message + "\n" + string(message, t[0]));
   } else {
     return new ServiceDispatchException(message);
   }
 }
  @Override
  public void messageReceived(ChannelHandlerContext ctx, MessageEvent event) throws Exception {
    if (event.getMessage() instanceof MappingHttpRequest) {
      MappingHttpRequest httpRequest = (MappingHttpRequest) event.getMessage();

      if (httpRequest.getMessage() instanceof ObjectStorageDataRequestType) {
        if (httpRequest.isChunked()) {
          // Chunked request, and beginning, setup map etc.
          initializeNewPut(ctx, (ObjectStorageDataRequestType) httpRequest.getMessage());
        }
      }
    } else if (event.getMessage() instanceof HttpChunk) {
      // Add the chunk to the current streams channel buffer.
      HttpChunk chunk = (HttpChunk) event.getMessage();
      appendChunk(chunk.getContent(), ctx.getChannel());

      if (chunk.isLast()) {
        // Remove from the map
        Logs.extreme()
            .debug(
                "Removing data map due to last chunk processed event for channel: "
                    + ctx.getChannel().getId());
        dataMap.remove(ctx.getChannel());
      }
    }
    // Always pass it on
    ctx.sendUpstream(event);
  }
예제 #19
0
 public String getMessage() {
   if (Logs.isExtrrreeeme()) {
     return Threads.currentStackString();
   } else {
     return "n.a";
   }
 }
예제 #20
0
 @Override
 public String toString() {
   Logs.extreme()
       .debug("Found list type: " + this.type.getTypeName() + " for name: " + this.name);
   String ret = this.type.collection(this.name).buf.toString();
   this.type.collection(this.name).buf = new StringBuilder();
   return ret;
 }
예제 #21
0
 private final void eventLog(final TxStep txState, final TxEvent txAction) {
   if (Logs.isExtrrreeeme()) {
     final long oldSplit = this.splitTime;
     this.stopWatch.split();
     this.splitTime = this.stopWatch.getSplitTime();
     this.stopWatch.unsplit();
     final Long split = this.splitTime - oldSplit;
     Logs.exhaust()
         .debug(
             Joiner.on(":")
                 .join(
                     EventType.PERSISTENCE,
                     txState.event(txAction),
                     Long.toString(split),
                     this.getTxUuid()));
   }
 }
 protected void initializeNewPut(ChannelHandlerContext ctx, ObjectStorageDataRequestType request)
     throws IllegalStateException {
   Logs.extreme()
       .debug(
           "Adding entry to data map in PUT aggregator for channel: " + ctx.getChannel().getId());
   ChannelBufferStreamingInputStream stream = request.getData();
   ChannelBufferStreamingInputStream foundStream = dataMap.putIfAbsent(ctx.getChannel(), stream);
   if (foundStream != null) {
     Logs.extreme()
         .debug(
             "Found existing entry in map for this channel. Streams should never cross. Throwing illegal state for channel: "
                 + ctx.getChannel().getId());
     throw new IllegalStateException(
         "Duplicate messages for same PUT, cannot overwrite data buffer. Channel:"
             + ctx.getChannel().getId());
   }
 }
 @Override
 public void fireException(Throwable e) {
   LOG.debug(e);
   Logs.extreme().error(e, e);
   LOG.debug(
       "Trying to remove invalid volume attachment "
           + this.getRequest().getVolumeId()
           + " from instance "
           + this.getRequest().getInstanceId());
   try {
     VmInstance vm = VmInstances.lookup(this.getRequest().getInstanceId());
     Partition partition = vm.lookupPartition();
     ServiceConfiguration sc = Topology.lookup(Storage.class, partition);
     /** clean up SC session state * */
     try {
       LOG.debug(
           "Sending detach after async failure in attach volume: "
               + this.getRequest().getVolumeId()
               + " sc="
               + sc);
       AsyncRequests.sendSync(sc, new DetachStorageVolumeType(this.getRequest().getVolumeId()));
     } catch (Exception ex) {
       LOG.error(ex);
       Logs.extreme().error(ex, ex);
     }
     /** clean up internal attachment state * */
     final Function<String, VmInstance> removeVolAttachment =
         new Function<String, VmInstance>() {
           public VmInstance apply(final String input) {
             VmInstance vm = VmInstances.lookup(input);
             vm.removeVolumeAttachment(VolumeAttachCallback.this.getRequest().getVolumeId());
             return vm;
           }
         };
     Entities.asTransaction(VmInstance.class, removeVolAttachment)
         .apply(this.getRequest().getInstanceId());
     LOG.debug(
         "Removed failed attachment: "
             + this.getRequest().getVolumeId()
             + " -> "
             + vm.getInstanceId());
   } catch (Exception e1) {
     LOG.error(e1);
     Logs.extreme().error(e1, e1);
   }
 }
예제 #24
0
 /**
  * @delegate Do not change semantics here.
  * @see javax.persistence.EntityTransaction#commit()
  */
 @Override
 public void commit() {
   try {
     this.transaction.commit();
   } catch (final RuntimeException ex) {
     LOG.trace(ex, ex);
     Logs.extreme().warn(ex, ex);
     throw ex;
   }
 }
 private BaseMessage buildFatalResponse(Throwable exception) {
   final ErrorResponse errorResponse = new ErrorResponse();
   ErrorDetail error = new ErrorDetail();
   error.setCode(HttpResponseStatus.INTERNAL_SERVER_ERROR.getCode());
   error.setMessage(exception.getMessage());
   error.setType(defaultCode);
   if (Logs.isDebug()) {
     error.setStackTrace(Exceptions.string(exception));
   }
   return errorResponse;
 }
예제 #26
0
 private static void rollback(final Host host, Exception ex) {
   try {
     Databases.runDbStateChange(
         Databases.DeactivateHostFunction.INSTANCE.apply(host.getDisplayName()));
   } catch (LockTimeoutException ex1) {
     Databases.LOG.error("Databases.enable(): failed because of: " + ex.getMessage());
   } catch (Exception ex1) {
     Databases.LOG.error("Databases.enable(): failed because of: " + ex.getMessage());
     Logs.extreme().error(ex, ex);
   }
 }
예제 #27
0
    public void process(File f) throws Exception {
      if (f.isDirectory()) {
        File[] files =
            f.listFiles(
                new FilenameFilter() {

                  @Override
                  public boolean accept(File dir, String name) {
                    return name.matches(FILE_PATTERN);
                  }
                });
        for (File ff : files) {
          byte[] bindingBytes = Files.toByteArray(ff);
          this.addCurrentBinding(bindingBytes, ff.getName(), "file:" + ff.getAbsolutePath());
        }
      } else {
        String digest = new BigInteger(Files.getDigest(f, Digest.MD5.get())).abs().toString(16);
        CURRENT_PROPS.put(BINDING_CACHE_JAR_PREFIX + f.getName(), digest);
        final JarFile jar = new JarFile(f);
        final List<JarEntry> jarList = Collections.list(jar.entries());
        for (final JarEntry j : jarList) {
          try {
            if (j.getName().matches(FILE_PATTERN)) {
              byte[] bindingBytes = ByteStreams.toByteArray(jar.getInputStream(j));
              String bindingName = j.getName();
              String bindingFullPath = "jar:file:" + f.getAbsolutePath() + "!/" + bindingName;
              this.addCurrentBinding(bindingBytes, bindingName, bindingFullPath);
            } else if (j.getName().matches(".*\\.class.{0,1}")) {
              final String classGuess =
                  j.getName().replaceAll("/", ".").replaceAll("\\.class.{0,1}", "");
              final Class candidate = ClassLoader.getSystemClassLoader().loadClass(classGuess);
              if (MSG_BASE_CLASS.isAssignableFrom(candidate)
                  || MSG_DATA_CLASS.isAssignableFrom(candidate)) {
                InputSupplier<InputStream> classSupplier =
                    Resources.newInputStreamSupplier(ClassLoader.getSystemResource(j.getName()));
                File destClassFile = SubDirectory.CLASSCACHE.getChildFile(j.getName());
                if (!destClassFile.exists()) {
                  Files.createParentDirs(destClassFile);
                  Files.copy(classSupplier, destClassFile);
                  Logs.extreme()
                      .debug("Caching: " + j.getName() + " => " + destClassFile.getAbsolutePath());
                }
                BINDING_CLASS_MAP.putIfAbsent(classGuess, candidate);
              }
            }
          } catch (RuntimeException ex) {
            LOG.error(ex, ex);
            jar.close();
            throw ex;
          }
        }
        jar.close();
      }
    }
예제 #28
0
 public static NetworkGroup lookupByNaturalId(final String uuid) throws NoSuchMetadataException {
   EntityTransaction db = Entities.get(NetworkGroup.class);
   try {
     NetworkGroup entity = Entities.uniqueResult(NetworkGroup.withNaturalId(uuid));
     db.commit();
     return entity;
   } catch (Exception ex) {
     Logs.exhaust().error(ex, ex);
     db.rollback();
     throw new NoSuchMetadataException("Failed to find security group: " + uuid, ex);
   }
 }
예제 #29
0
 /**
  * @delegate Do not change semantics here.
  * @see javax.persistence.EntityTransaction#commit()
  */
 @Override
 public void commit() throws RecoverablePersistenceException {
   removeTransaction(this);
   if ((this.txState != null) && this.txState.isActive()) {
     try {
       this.txState.commit();
     } catch (final RuntimeException ex) {
       throw PersistenceExceptions.throwFiltered(ex);
     }
   } else {
     Logs.extreme().error("Duplicate call to commit( ): " + Threads.currentStackString());
   }
 }
예제 #30
0
 /**
  * Private for a reason.
  *
  * @see {@link CascadingTx#get(Class)}
  * @param persistenceContext
  * @throws RecoverablePersistenceException
  */
 @SuppressWarnings("unchecked")
 CascadingTx(final String ctx) throws RecoverablePersistenceException {
   final StackTraceElement ste = Threads.currentStackFrame(4);
   final String uuid = UUID.randomUUID().toString();
   this.record = new TxRecord(ctx, uuid, ste);
   try {
     this.txState = new TxState(ctx);
   } catch (final RuntimeException ex) {
     Logs.extreme().error(ex, ex);
     this.rollback();
     throw PersistenceExceptions.throwFiltered(ex);
   }
 }