Пример #1
0
 private void close() {
   spacesMountManager.close();
   if (applicationScratchSpace != null) {
     cachingDirectory.unregister(applicationScratchSpace.getSpaceMountingPoint());
     try {
       applicationScratchSpace.close();
     } catch (FileSystemException x) {
       ProActiveLogger.logEatedException(
           logger, "Could not close correctly application scratch space", x);
     }
     applicationScratchSpace = null;
   }
 }
Пример #2
0
    private void configure(final long appId, final String namingServiceURL)
        throws FileSystemException, URISyntaxException, ProActiveException, ConfigurationException {

      // create naming service stub with URL and decorate it with local cache
      // use local variables so GC can collect them if something fails
      final NamingService namingService;
      try {
        namingService = NamingService.createNamingServiceStub(namingServiceURL);
      } catch (ProActiveException x) {
        logger.error("Could not access Naming Service", x);
        throw x;
      } catch (URISyntaxException x) {
        logger.error("Wrong Naming Service URI", x);
        throw x;
      }
      final CachingSpacesDirectory cachingDir = new CachingSpacesDirectory(namingService);

      // create scratch data space for this application and register it
      if (nodeScratchSpace != null) {
        applicationScratchSpace = nodeScratchSpace.initForApplication(appId);
        final SpaceInstanceInfo scratchInfo = applicationScratchSpace.getSpaceInstanceInfo();

        boolean registered = false;
        try {
          cachingDir.register(scratchInfo);
          registered = true;
          logger.debug("Scratch space for application registered");
        } catch (SpaceAlreadyRegisteredException e) {
          logger.error("Could not register application scratch space to Naming Service", e);
          throw e;
        } catch (WrongApplicationIdException e) {
          logger.error("Could not register application scratch space to Naming Service", e);
          throw e;
        } finally {
          if (!registered) {
            nodeScratchSpace.close();
          }
        }
      }
      // no exception can be thrown since now
      cachingDirectory = cachingDir;

      // create VFSSpacesMountManagerImpl
      spacesMountManager = new VFSSpacesMountManagerImpl(cachingDirectory);

      // create implementation object connected to the application's
      // configuration
      impl =
          new DataSpacesImpl(appId, spacesMountManager, cachingDirectory, applicationScratchSpace);
    }