| | |
| | | import java.io.IOException; |
| | | import java.io.File; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | import java.util.concurrent.ExecutionException; |
| | | |
| | | import java.io.FileInputStream; |
| | | import java.io.FilenameFilter; |
| | |
| | | import com.sleepycat.je.EnvironmentConfig; |
| | | import com.sleepycat.je.RunRecoveryException; |
| | | |
| | | import org.opends.server.backends.jeb.importLDIF.*; |
| | | import org.opends.server.admin.std.meta.LocalDBIndexCfgDefn; |
| | | import org.opends.server.admin.std.server.MonitorProviderCfg; |
| | | import org.opends.server.api.Backend; |
| | |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.api.ExtensibleIndexer; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.backends.jeb.importLDIF.Importer; |
| | | |
| | | import org.opends.server.api.ExtensibleMatchingRule; |
| | | /** |
| | | * This is an implementation of a Directory Server Backend which stores entries |
| | |
| | | /** |
| | | * A count of the total operation threads currently in the backend. |
| | | */ |
| | | private AtomicInteger threadTotalCount = new AtomicInteger(0); |
| | | private final AtomicInteger threadTotalCount = new AtomicInteger(0); |
| | | |
| | | /** |
| | | * A count of the write operation threads currently in the backend. |
| | | */ |
| | | private AtomicInteger threadWriteCount = new AtomicInteger(0); |
| | | private final AtomicInteger threadWriteCount = new AtomicInteger(0); |
| | | |
| | | /** |
| | | * A list of monitor providers created for this backend instance. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void configureBackend(Configuration cfg) |
| | | throws ConfigException |
| | | { |
| | |
| | | envConfig.setAllowCreate(true); |
| | | envConfig.setTransactional(false); |
| | | envConfig.setTxnNoSync(false); |
| | | envConfig.setConfigParam("je.env.isLocking", "false"); |
| | | envConfig.setConfigParam("je.env.isLocking", "true"); |
| | | envConfig.setConfigParam("je.env.runCheckpointer", "false"); |
| | | //Loop through local indexes and see if any are substring. |
| | | boolean hasSubIndex = false; |
| | | int indexCount = cfg.listLocalDBIndexes().length; |
| | | subIndex: |
| | | for (String idx : cfg.listLocalDBIndexes()) { |
| | | final LocalDBIndexCfg indexCfg = cfg.getLocalDBIndex(idx); |
| | |
| | | } |
| | | } |
| | | } |
| | | Importer importer = new Importer(importConfig, hasSubIndex); |
| | | envConfig.setConfigParam("je.maxMemory", importer.getDBCacheSize()); |
| | | |
| | | Importer importer = new Importer(importConfig, cfg); |
| | | importer.init(envConfig); |
| | | rootContainer = initializeRootContainer(envConfig); |
| | | |
| | | return importer.processImport(rootContainer); |
| | | } |
| | | catch (ExecutionException execEx) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, execEx); |
| | | } |
| | | Message message = ERR_EXECUTION_ERROR.get(execEx.getMessage()); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | message); |
| | | } |
| | | catch (InterruptedException intEx) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, intEx); |
| | | } |
| | | Message message = ERR_INTERRUPTED_ERROR.get(intEx.getMessage()); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | message); |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | if (debugEnabled()) |
| | |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | je.getMessageObject()); |
| | | } |
| | | catch (DatabaseException de) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, de); |
| | | } |
| | | throw createDirectoryException(de); |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | if (debugEnabled()) |
| | |
| | | * @param e The DatabaseException to be converted. |
| | | * @return DirectoryException created from exception. |
| | | */ |
| | | DirectoryException createDirectoryException(DatabaseException e) |
| | | { |
| | | DirectoryException createDirectoryException(DatabaseException e) { |
| | | ResultCode resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | Message message = null; |
| | | if(e instanceof RunRecoveryException) |
| | | { |
| | | if (e instanceof RunRecoveryException) { |
| | | message = NOTE_BACKEND_ENVIRONMENT_UNUSABLE.get(getBackendID()); |
| | | logError(message); |
| | | DirectoryServer.sendAlertNotification(DirectoryServer.getInstance(), |
| | |
| | | } |
| | | |
| | | String jeMessage = e.getMessage(); |
| | | if (jeMessage == null) |
| | | { |
| | | if (jeMessage == null) { |
| | | jeMessage = stackTraceToSingleLineString(e); |
| | | } |
| | | message = ERR_JEB_DATABASE_EXCEPTION.get(jeMessage); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public String getClassName() |
| | | { |
| | | public String getClassName() { |
| | | return CLASS_NAME; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public LinkedHashMap<String,String> getAlerts() |
| | | { |
| | | LinkedHashMap<String,String> alerts = new LinkedHashMap<String,String>(); |
| | | public LinkedHashMap<String, String> getAlerts() { |
| | | LinkedHashMap<String, String> alerts = new LinkedHashMap<String, String>(); |
| | | |
| | | alerts.put(ALERT_TYPE_BACKEND_ENVIRONMENT_UNUSABLE, |
| | | ALERT_DESCRIPTION_BACKEND_ENVIRONMENT_UNUSABLE); |
| | | ALERT_DESCRIPTION_BACKEND_ENVIRONMENT_UNUSABLE); |
| | | return alerts; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public DN getComponentEntryDN() |
| | | { |
| | | public DN getComponentEntryDN() { |
| | | return cfg.dn(); |
| | | } |
| | | |
| | | private RootContainer initializeRootContainer(EnvironmentConfig envConfig) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | throws ConfigException, InitializationException { |
| | | // Open the database environment |
| | | try |
| | | { |
| | | try { |
| | | RootContainer rc = new RootContainer(this, cfg); |
| | | rc.open(envConfig); |
| | | return rc; |
| | | } |
| | | catch (DatabaseException e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | catch (DatabaseException e) { |
| | | if (debugEnabled()) { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | Message message = ERR_JEB_OPEN_ENV_FAIL.get(e.getMessage()); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void preloadEntryCache() throws |
| | | UnsupportedOperationException |
| | | { |
| | | UnsupportedOperationException { |
| | | EntryCachePreloader preloader = |
| | | new EntryCachePreloader(this); |
| | | new EntryCachePreloader(this); |
| | | preloader.preload(); |
| | | } |
| | | } |