示例#1
0
  /** {@inheritDoc} */
  @Override()
  public long getEntryCount() {
    if (rootContainer != null) {
      try {
        return rootContainer.getEntryCount();
      } catch (Exception e) {
        if (debugEnabled()) {
          TRACER.debugCaught(DebugLogLevel.ERROR, e);
        }
      }
    }

    return -1;
  }
示例#2
0
  /** {@inheritDoc} */
  @Override()
  public void initializeBackend() throws ConfigException, InitializationException {
    // Checksum this db environment and register its offline state id/checksum.
    DirectoryServer.registerOfflineBackendStateID(this.getBackendID(), checksumDbEnv());

    if (rootContainer == null) {
      EnvironmentConfig envConfig = ConfigurableEnvironment.parseConfigEntry(cfg);
      rootContainer = initializeRootContainer(envConfig);
    }

    // Preload the database cache.
    rootContainer.preload(cfg.getPreloadTimeLimit());

    try {
      // Log an informational message about the number of entries.
      Message message =
          NOTE_JEB_BACKEND_STARTED.get(cfg.getBackendId(), rootContainer.getEntryCount());
      logError(message);
    } catch (DatabaseException databaseException) {
      if (debugEnabled()) {
        TRACER.debugCaught(DebugLogLevel.ERROR, databaseException);
      }
      Message message = WARN_JEB_GET_ENTRY_COUNT_FAILED.get(databaseException.getMessage());
      throw new InitializationException(message, databaseException);
    }

    for (DN dn : cfg.getBaseDN()) {
      try {
        DirectoryServer.registerBaseDN(dn, this, false);
      } catch (Exception e) {
        if (debugEnabled()) {
          TRACER.debugCaught(DebugLogLevel.ERROR, e);
        }

        Message message =
            ERR_BACKEND_CANNOT_REGISTER_BASEDN.get(String.valueOf(dn), String.valueOf(e));
        throw new InitializationException(message, e);
      }
    }

    // Register a monitor provider for the environment.
    rootContainerMonitor = rootContainer.getMonitorProvider();
    DirectoryServer.registerMonitorProvider(rootContainerMonitor);

    // Register as disk space monitor handler
    File parentDirectory = getFileForPath(cfg.getDBDirectory());
    File backendDirectory = new File(parentDirectory, cfg.getBackendId());
    diskMonitor =
        new DiskSpaceMonitor(
            getBackendID() + " backend",
            backendDirectory,
            cfg.getDiskLowThreshold(),
            cfg.getDiskFullThreshold(),
            5,
            TimeUnit.SECONDS,
            this);
    diskMonitor.initializeMonitorProvider(null);
    DirectoryServer.registerMonitorProvider(diskMonitor);

    // Register as an AlertGenerator.
    DirectoryServer.registerAlertGenerator(this);
    // Register this backend as a change listener.
    cfg.addLocalDBChangeListener(this);
  }