Esempio n. 1
0
  public void shutdown() {
    acquireExclusiveLock();
    try {
      if (!active) return;

      active = false;

      if (shutdownHook != null) shutdownHook.cancel();
      if (profiler != null) profiler.shutdown();

      OLogManager.instance().debug(this, "Orient Engine is shutting down...");

      if (listeners != null)
        // CALL THE SHUTDOWN ON ALL THE LISTENERS
        for (OOrientListener l : listeners) {
          if (l != null) l.onShutdown();
        }

      // SHUTDOWN ENGINES
      for (OEngine engine : engines.values()) {
        engine.shutdown();
      }

      if (databaseFactory != null)
        // CLOSE ALL DATABASES
        databaseFactory.shutdown();

      if (storages != null) {
        // CLOSE ALL THE STORAGES
        final List<OStorage> storagesCopy = new ArrayList<OStorage>(storages.values());
        for (OStorage stg : storagesCopy) {
          OLogManager.instance().info(this, "Shutting down storage: " + stg.getName() + "...");
          stg.close(true);
        }
      }

      if (OMMapManagerLocator.getInstance() != null) OMMapManagerLocator.getInstance().shutdown();

      if (threadGroup != null)
        // STOP ALL THE PENDING THREADS
        threadGroup.interrupt();

      if (listeners != null) listeners.clear();

      OLogManager.instance().info(this, "Orient Engine shutdown complete\n");

    } finally {
      releaseExclusiveLock();
    }
  }