Package org.nasutekds.server.api

Examples of org.nasutekds.server.api.Backend


    if (backUpAll)
    {
      for (Map.Entry<String,ConfigEntry> mapEntry : configEntries.entrySet())
      {
        Backend b = DirectoryServer.getBackend(mapEntry.getKey());
        if (b != null && b.supportsBackup())
        {
          backendsToArchive.add(b);
        }
      }
    }
    else
    {
      // Iterate through the set of requested backends and make sure they can
      // be used.
      for (String id : backendIDList)
      {
        Backend b = DirectoryServer.getBackend(id);
        if (b == null || configEntries.get(id) == null)
        {
          Message message = ERR_BACKUPDB_NO_BACKENDS_FOR_ID.get(id);
          logError(message);
        }
        else if (! b.supportsBackup())
        {
          Message message =
              WARN_BACKUPDB_BACKUP_NOT_SUPPORTED.get(b.getBackendID());
          logError(message);
        }
        else
        {
          backendsToArchive.add(b);
View Full Code Here


      else
      {
        subordinateBaseDNs = new ConcurrentHashMap<DN,Backend>();
        for (DN baseDN : subDNs)
        {
          Backend backend = DirectoryServer.getBackend(baseDN);
          if (backend == null)
          {
            Message message = WARN_ROOTDSE_NO_BACKEND_FOR_SUBORDINATE_BASE.get(
                String.valueOf(baseDN));
            logError(message);
View Full Code Here

      baseMap = subordinateBaseDNs;
    }

    for (DN subBase : baseMap.keySet())
    {
      Backend b = baseMap.get(subBase);
      Entry subBaseEntry = b.getEntry(subBase);
      if (subBaseEntry != null)
      {
        if(subtree)
        {
          long subCount = b.numSubordinates(subBase, true);
          if(subCount < 0)
          {
            return -1;
          }
View Full Code Here

    for (DN baseDN : baseMap.keySet())
    {
      if (entryDN.isDescendantOf(baseDN))
      {
        Backend b = baseMap.get(baseDN);
        if (b.entryExists(entryDN))
        {
          return true;
        }
      }
    }
View Full Code Here

        for (DN subBase : baseMap.keySet())
        {
          searchOperation.checkIfCanceled(false);

          Backend b = baseMap.get(subBase);
          Entry subBaseEntry = b.getEntry(subBase);
          if ((subBaseEntry != null) && filter.matchesEntry(subBaseEntry))
          {
            searchOperation.returnEntry(subBaseEntry, null);
          }
        }
        break;


      case WHOLE_SUBTREE:
      case SUBORDINATE_SUBTREE:
        if (subordinateBaseDNs == null)
        {
          baseMap = DirectoryServer.getPublicNamingContexts();
        }
        else
        {
          baseMap = subordinateBaseDNs;
        }

        try
        {
          for (DN subBase : baseMap.keySet())
          {
            searchOperation.checkIfCanceled(false);

            Backend b = baseMap.get(subBase);
            searchOperation.setBaseDN(subBase);

            try
            {
              b.search(searchOperation);
            }
            catch (DirectoryException de)
            {
              // If it's a "no such object" exception, then the base entry for
              // the backend doesn't exist.  This isn't an error, so ignore it.
View Full Code Here

      }
      else
      {
        for (DN baseDN : subDNs)
        {
          Backend backend = DirectoryServer.getBackend(baseDN);
          if (backend == null)
          {
            Message message = WARN_ROOTDSE_NO_BACKEND_FOR_SUBORDINATE_BASE.get(
                    String.valueOf(baseDN));
            unacceptableReasons.add(message);
View Full Code Here

      else
      {
        subBases = new ConcurrentHashMap<DN,Backend>();
        for (DN baseDN : subDNs)
        {
          Backend backend = DirectoryServer.getBackend(baseDN);
          if (backend == null)
          {
            // This is not fine.  We can't use a suffix that doesn't exist.
            Message message = WARN_ROOTDSE_NO_BACKEND_FOR_SUBORDINATE_BASE.get(
                    String.valueOf(baseDN));
View Full Code Here

    ArrayList<BackendCfg> entryList   = new ArrayList<BackendCfg>();
    ArrayList<List<DN>>    dnList      = new ArrayList<List<DN>>();
    BackendToolUtils.getBackends(backendList, entryList, dnList);


    Backend     backend     = null;
    int         numBackends = backendList.size();
    for (int i=0; i < numBackends; i++)
    {
      Backend     b = backendList.get(i);
      BackendCfg e = entryList.get(i);
      if (e.dn().equals(configEntryDN))
      {
        backend     = b;
        break;
View Full Code Here

    {
      rebuildConfig.addRebuildIndex(index);
    }


    Backend backend =
        DirectoryServer.getBackendWithBaseDN(rebuildConfig.getBaseDN());

    if(backend == null)
    {
      Message message = ERR_NO_BACKENDS_FOR_BASE.get(baseDN);
      logError(message);
      return TaskState.STOPPED_BY_ERROR;
    }

    if (!(backend instanceof BackendImpl))
    {
      Message message = ERR_REBUILDINDEX_WRONG_BACKEND_TYPE.get();
      logError(message);
      return TaskState.STOPPED_BY_ERROR;
    }

    // Acquire a shared lock for the backend if we are rebuilding attribute
    // indexes only. If we are rebuilding one or more system indexes, we have
    // to aquire exclusive lock.
    String lockFile = LockFileManager.getBackendLockFileName(backend);
    StringBuilder failureReason = new StringBuilder();

    // Disable the backend.
    try
    {
      TaskUtils.disableBackend(backend.getBackendID());
    }
    catch (DirectoryException e)
    {
      if (debugEnabled())
      {
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }

      logError(e.getMessageObject());
      return TaskState.STOPPED_BY_ERROR;
    }

    try
    {
      if(! LockFileManager.acquireExclusiveLock(lockFile, failureReason))
      {
        Message message = ERR_REBUILDINDEX_CANNOT_EXCLUSIVE_LOCK_BACKEND.get(
            backend.getBackendID(), String.valueOf(failureReason));
        logError(message);
        return TaskState.STOPPED_BY_ERROR;
      }
    }
    catch (Exception e)
    {
      Message message = ERR_REBUILDINDEX_CANNOT_EXCLUSIVE_LOCK_BACKEND.get(
          backend.getBackendID(), getExceptionMessage(e));
      logError(message);
      return TaskState.STOPPED_BY_ERROR;
    }

     if(tmpDirectory == null)
    {
      tmpDirectory = "import-tmp";
    }
    rebuildConfig.setTmpDirectory(tmpDirectory);
    rebuildConfig.setRebuildAll(rebuildAll);
    TaskState returnCode = TaskState.COMPLETED_SUCCESSFULLY;
    // Launch the rebuild process.
    try
    {
      BackendImpl jebBackend = (BackendImpl)backend;
      jebBackend.rebuildBackend(rebuildConfig);
    }
    catch (Exception e)
    {
      if (debugEnabled())
      {
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }

      Message message =
          ERR_REBUILDINDEX_ERROR_DURING_REBUILD.get(e.getMessage());
      logError(message);
      returnCode = TaskState.STOPPED_BY_ERROR;
    }
    // Release the lock on the backend.
    finally
    {
      try
      {
        lockFile = LockFileManager.getBackendLockFileName(backend);
        failureReason = new StringBuilder();
        if (! LockFileManager.releaseLock(lockFile, failureReason))
        {
          Message message = WARN_REBUILDINDEX_CANNOT_UNLOCK_BACKEND.get(
              backend.getBackendID(), String.valueOf(failureReason));
          logError(message);
          returnCode = TaskState.COMPLETED_WITH_ERRORS;
        }
      }
      catch (Throwable t)
      {
        Message message = WARN_REBUILDINDEX_CANNOT_UNLOCK_BACKEND.get(
            backend.getBackendID(), getExceptionMessage(t));
        logError(message);
        returnCode = TaskState.COMPLETED_WITH_ERRORS;
      }
    }

    if(returnCode == TaskState.COMPLETED_SUCCESSFULLY)
    {
      // Enable the backend.
      try
      {
        TaskUtils.enableBackend(backend.getBackendID());
      }
      catch (DirectoryException e)
      {
        if (debugEnabled())
        {
View Full Code Here

    // Get the backend ID from the configuration entry.
    String backendID = TaskUtils.getBackendID(configEntry);

    // Get the backend.
    Backend backend = DirectoryServer.getBackend(backendID);

    if (! backend.supportsRestore())
    {
      Message message =
          ERR_RESTOREDB_CANNOT_RESTORE.get(backend.getBackendID());
      logError(message);
      return TaskState.STOPPED_BY_ERROR;
    }

    // Create the restore config object from the information available.
    restoreConfig = new RestoreConfig(backupDir, backupID, verifyOnly);

    // Notify the task listeners that a restore is going to start
    // this must be done before disabling the backend to allow
    // listener to get access to the backend configuration
    // and to take appropriate actions.
    DirectoryServer.notifyRestoreBeginning(backend, restoreConfig);

    // Disable the backend.
    if ( !verifyOnly)
    {
      try
      {
        TaskUtils.disableBackend(backendID);
      } catch (DirectoryException e)
      {
        if (debugEnabled())
        {
          TRACER.debugCaught(DebugLogLevel.ERROR, e);
        }

        logError(e.getMessageObject());
        return TaskState.STOPPED_BY_ERROR;
      }
    }

    // From here we must make sure to re-enable the backend before returning.
    boolean errorsEncountered = false;
    try
    {
      // Acquire an exclusive lock for the backend.
      if (verifyOnly || lockBackend(backend))
      {
        // From here we must make sure to release the backend exclusive lock.
        try
        {
          // Perform the restore.
          try
          {
            backend.restoreBackup(restoreConfig);
          }
          catch (DirectoryException de)
          {
            DirectoryServer.notifyRestoreEnded(backend, restoreConfig, false);
            Message message = ERR_RESTOREDB_ERROR_DURING_BACKUP.get(
View Full Code Here

TOP

Related Classes of org.nasutekds.server.api.Backend

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.