Pass ServerContext object down method calls to the pluggable backend Importer class.
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFImportResult importLDIF(LDIFImportConfig arg0) |
| | | public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext) |
| | | throws DirectoryException |
| | | { |
| | | return null; |
| | |
| | | * returns {@code true}. Note that the server will not explicitly |
| | | * initialize this backend before calling this method. |
| | | * |
| | | * @param importConfig The configuration to use when performing |
| | | * the import. |
| | | * |
| | | * @param importConfig The configuration to use when performing the import. |
| | | * @param serverContext The server context |
| | | * @return Information about the result of the import processing. |
| | | * |
| | | * @throws DirectoryException If a problem occurs while performing |
| | | * the LDIF import. |
| | | */ |
| | | public abstract LDIFImportResult importLDIF(LDIFImportConfig importConfig) |
| | | public abstract LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext) |
| | | throws DirectoryException; |
| | | |
| | | /** |
| | |
| | | * @throws DirectoryException |
| | | * If a Directory Server error occurs. |
| | | */ |
| | | public void rebuildBackend(RebuildConfig rebuildConfig) throws InitializationException, ConfigException, |
| | | DirectoryException |
| | | public void rebuildBackend(RebuildConfig rebuildConfig, ServerContext serverContext) |
| | | throws InitializationException, ConfigException, DirectoryException |
| | | { |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, |
| | | ERR_INDEXES_NOT_SUPPORTED.get(getBackendID())); |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFImportResult importLDIF(LDIFImportConfig importConfig) |
| | | public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext) |
| | | throws DirectoryException |
| | | { |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFImportResult importLDIF(LDIFImportConfig importConfig) |
| | | public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext) |
| | | throws DirectoryException |
| | | { |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFImportResult importLDIF(LDIFImportConfig importConfig) |
| | | public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext) |
| | | throws DirectoryException |
| | | { |
| | | return importLDIF(importConfig, true); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes an LDIF import operation, optionally writing the resulting LDIF |
| | | * to disk. |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public synchronized LDIFImportResult importLDIF(LDIFImportConfig importConfig) |
| | | public synchronized LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext) |
| | | throws DirectoryException |
| | | { |
| | | clearMemoryBackend(); |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFImportResult importLDIF(final LDIFImportConfig importConfig) |
| | | public LDIFImportResult importLDIF(final LDIFImportConfig importConfig, ServerContext serverContext) |
| | | throws DirectoryException |
| | | { |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFImportResult importLDIF(LDIFImportConfig importConfig) |
| | | public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext) |
| | | throws DirectoryException |
| | | { |
| | | LDIFReader reader; |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFImportResult importLDIF(LDIFImportConfig importConfig) |
| | | public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext) |
| | | throws DirectoryException |
| | | { |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFImportResult importLDIF(LDIFImportConfig importConfig) |
| | | public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext) |
| | | throws DirectoryException |
| | | { |
| | | LDIFReader reader; |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFImportResult importLDIF(LDIFImportConfig importConfig) |
| | | public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext) |
| | | throws DirectoryException |
| | | { |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFImportResult importLDIF(LDIFImportConfig importConfig) |
| | | public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext) |
| | | throws DirectoryException |
| | | { |
| | | RuntimeInformation.logInfo(); |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void rebuildBackend(RebuildConfig rebuildConfig) |
| | | public void rebuildBackend(RebuildConfig rebuildConfig, ServerContext serverContext) |
| | | throws InitializationException, ConfigException, DirectoryException |
| | | { |
| | | // If the backend already has the root container open, we must use the same |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFImportResult importLDIF(LDIFImportConfig importConfig) throws DirectoryException |
| | | public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext) |
| | | throws DirectoryException |
| | | { |
| | | RuntimeInformation.logInfo(); |
| | | |
| | |
| | | } |
| | | |
| | | rootContainer = initializeRootContainer(); |
| | | return rootContainer.importLDIF(importConfig); |
| | | return rootContainer.importLDIF(importConfig, serverContext); |
| | | } |
| | | catch (StorageRuntimeException e) |
| | | { |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void rebuildBackend(RebuildConfig rebuildConfig) |
| | | public void rebuildBackend(RebuildConfig rebuildConfig, ServerContext serverContext) |
| | | throws InitializationException, ConfigException, DirectoryException |
| | | { |
| | | // If the backend already has the root container open, we must use the same |
| | |
| | | { |
| | | rootContainer = initializeRootContainer(); |
| | | } |
| | | final Importer importer = new Importer(rebuildConfig, (PersistitBackendCfg) cfg); // FIXME JNR remove cast |
| | | final Importer importer = new Importer(rebuildConfig, (PersistitBackendCfg) cfg, serverContext); // FIXME JNR remove cast |
| | | importer.rebuildIndexes(rootContainer); |
| | | } |
| | | catch (ExecutionException execEx) |
| | |
| | | import org.opends.server.backends.pluggable.spi.WriteOperation; |
| | | import org.opends.server.backends.pluggable.spi.WriteableTransaction; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.extensions.DiskSpaceMonitor; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | |
| | | private final LDIFImportConfig importConfiguration; |
| | | /** Backend configuration. */ |
| | | private final PersistitBackendCfg backendConfiguration; |
| | | private final ServerContext serverContext; |
| | | |
| | | /** LDIF reader. */ |
| | | private ImportLDIFReader reader; |
| | |
| | | * @throws ConfigException |
| | | * If a problem occurs during initialization. |
| | | */ |
| | | Importer(RebuildConfig rebuildConfig, PersistitBackendCfg cfg) |
| | | Importer(RebuildConfig rebuildConfig, PersistitBackendCfg cfg, ServerContext serverContext) |
| | | throws InitializationException, StorageRuntimeException, ConfigException |
| | | { |
| | | this.importConfiguration = null; |
| | | this.backendConfiguration = cfg; |
| | | this.serverContext = serverContext; |
| | | this.tmpEnv = null; |
| | | this.threadCount = 1; |
| | | this.rebuildManager = new RebuildIndexManager(rebuildConfig, cfg); |
| | |
| | | * @throws StorageRuntimeException |
| | | * If an error occurred when opening the DB. |
| | | */ |
| | | Importer(LDIFImportConfig importConfiguration, PersistitBackendCfg backendCfg) |
| | | Importer(LDIFImportConfig importConfiguration, PersistitBackendCfg backendCfg, ServerContext serverContext) |
| | | throws InitializationException, ConfigException, StorageRuntimeException |
| | | { |
| | | this.rebuildManager = null; |
| | | this.importConfiguration = importConfiguration; |
| | | this.backendConfiguration = backendCfg; |
| | | this.serverContext = serverContext; |
| | | |
| | | if (importConfiguration.getThreadCount() == 0) |
| | | { |
| | |
| | | import org.opends.server.backends.pluggable.spi.WriteableTransaction; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * |
| | | * @param importConfig |
| | | * The configuration to use when performing the import. |
| | | * @param serverContext The server context |
| | | * @return information about the result of the import processing. |
| | | * @throws DirectoryException |
| | | * If a problem occurs while performing the LDIF import. |
| | | */ |
| | | LDIFImportResult importLDIF(LDIFImportConfig importConfig) throws DirectoryException |
| | | LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext) throws DirectoryException |
| | | {//TODO JNR may call importLDIFWithSuccessiveAdds(importConfig) depending on configured import strategy |
| | | return importLDIFWithOnDiskMerge(importConfig); |
| | | return importLDIFWithOnDiskMerge(importConfig, serverContext); |
| | | } |
| | | |
| | | private LDIFImportResult importLDIFWithSuccessiveAdds(LDIFImportConfig importConfig) throws DirectoryException |
| | |
| | | timerService.awaitTermination(20, TimeUnit.SECONDS); |
| | | } |
| | | |
| | | private LDIFImportResult importLDIFWithOnDiskMerge(final LDIFImportConfig importConfig) throws DirectoryException |
| | | private LDIFImportResult importLDIFWithOnDiskMerge(final LDIFImportConfig importConfig, ServerContext serverContext) throws DirectoryException |
| | | { |
| | | try |
| | | { |
| | | final Importer importer = new Importer(importConfig, (PersistitBackendCfg) config); // TODO JNR remove cast |
| | | final Importer importer = new Importer(importConfig, (PersistitBackendCfg) config, serverContext); // TODO JNR remove cast |
| | | return importer.processImport(this); |
| | | } |
| | | catch (DirectoryException e) |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFImportResult importLDIF(LDIFImportConfig importConfig) |
| | | throws DirectoryException |
| | | public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext sContext) throws DirectoryException |
| | | { |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, |
| | | ERR_BACKEND_IMPORT_NOT_SUPPORTED.get(getBackendID())); |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFImportResult importLDIF(LDIFImportConfig importConfig) |
| | | public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext) |
| | | throws DirectoryException |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_FILE_UNWILLING_TO_IMPORT.get(); |
| | |
| | | |
| | | // Process import |
| | | preBackendImport(backend); |
| | | backend.importLDIF(importConfig); |
| | | backend.importLDIF(importConfig, DirectoryServer.getInstance().getServerContext()); |
| | | |
| | | stateSavingDisabled = false; |
| | | } |
| | |
| | | // Launch the import. |
| | | try |
| | | { |
| | | backend.importLDIF(importConfig); |
| | | backend.importLDIF(importConfig, DirectoryServer.getInstance().getServerContext()); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | |
| | | // Launch the rebuild process. |
| | | try |
| | | { |
| | | backend.rebuildBackend(rebuildConfig); |
| | | backend.rebuildBackend(rebuildConfig, DirectoryServer.getInstance().getServerContext()); |
| | | } |
| | | catch (InitializationException e) |
| | | { |
| | |
| | | int retCode = 0; |
| | | try |
| | | { |
| | | LDIFImportResult importResult = backend.importLDIF(importConfig); |
| | | LDIFImportResult importResult = |
| | | backend.importLDIF(importConfig, DirectoryServer.getInstance().getServerContext()); |
| | | if (countRejects.isPresent()) |
| | | { |
| | | if (importResult.getEntriesRejected() > Integer.MAX_VALUE) |
| | |
| | | int returnCode = 0; |
| | | try |
| | | { |
| | | backend.rebuildBackend(rebuildConfig); |
| | | backend.rebuildBackend(rebuildConfig, DirectoryServer.getInstance().getServerContext()); |
| | | } |
| | | catch (InitializationException e) |
| | | { |
| | |
| | | */ |
| | | package org.opends.server.backends; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.File; |
| | | import java.util.Map; |
| | | |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * A set of test cases for the schema backend. |
| | | */ |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test |
| | | public void testImportLDIF() |
| | | throws Exception |
| | | public void testImportLDIF() throws Exception |
| | | { |
| | | File tempFile = File.createTempFile("schema", "testImportLDIF"); |
| | | tempFile.deleteOnExit(); |
| | |
| | | |
| | | schemaBackend.exportLDIF(exportConfig); |
| | | |
| | | LDIFImportConfig importConfig = |
| | | new LDIFImportConfig(tempFile.getAbsolutePath()); |
| | | |
| | | schemaBackend.importLDIF(importConfig); |
| | | LDIFImportConfig importConfig = new LDIFImportConfig(tempFile.getAbsolutePath()); |
| | | schemaBackend.importLDIF(importConfig, DirectoryServer.getInstance().getServerContext()); |
| | | } |
| | | |
| | | |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test |
| | | public void testGetComponentEntryDN() |
| | | throws Exception |
| | | public void testGetComponentEntryDN() throws Exception |
| | | { |
| | | DN configEntryDN = |
| | | DN.valueOf("ds-cfg-backend-id=schema,cn=Backends,cn=config"); |
| | |
| | | TaskUtils.disableBackend(backendID); |
| | | try |
| | | { |
| | | backend.importLDIF(importConfig); |
| | | backend.importLDIF(importConfig, DirectoryServer.getInstance().getServerContext()); |
| | | } |
| | | finally |
| | | { |
| | |
| | | RebuildConfig rebuildConfig = new RebuildConfig(); |
| | | rebuildConfig.setBaseDN(baseDNs[0]); |
| | | rebuildConfig.addRebuildIndex(index); |
| | | backend = DirectoryServer.getBackend(backendID); |
| | | backend.rebuildBackend(rebuildConfig); |
| | | rebuildBackend(backendID, rebuildConfig); |
| | | |
| | | if(index.contains(".") && !index.startsWith("vlv.")) |
| | | { |
| | |
| | | RebuildConfig rebuildConfig = new RebuildConfig(); |
| | | rebuildConfig.setBaseDN(baseDNs[0]); |
| | | rebuildConfig.addRebuildIndex("id2entry"); |
| | | backend = DirectoryServer.getBackend(backendID); |
| | | backend.rebuildBackend(rebuildConfig); |
| | | rebuildBackend(backendID, rebuildConfig); |
| | | |
| | | } |
| | | |
| | |
| | | RebuildConfig rebuildConfig = new RebuildConfig(); |
| | | rebuildConfig.setBaseDN(baseDNs[0]); |
| | | rebuildConfig.addRebuildIndex("id2entry"); |
| | | backend = DirectoryServer.getBackend(backendID); |
| | | TaskUtils.disableBackend(backendID); |
| | | |
| | | try { |
| | | backend.rebuildBackend(rebuildConfig); |
| | | rebuildBackend(backendID, rebuildConfig); |
| | | } finally { |
| | | TaskUtils.enableBackend(backendID); |
| | | } |
| | |
| | | RebuildConfig rebuildConfig = new RebuildConfig(); |
| | | rebuildConfig.setBaseDN(baseDNs[0]); |
| | | rebuildConfig.addRebuildIndex(index); |
| | | backend = DirectoryServer.getBackend(backendID); |
| | | backend.rebuildBackend(rebuildConfig); |
| | | rebuildBackend(backendID, rebuildConfig); |
| | | } |
| | | |
| | | @Test(dataProvider = "systemIndexes", |
| | |
| | | RebuildConfig rebuildConfig = new RebuildConfig(); |
| | | rebuildConfig.setBaseDN(baseDNs[0]); |
| | | rebuildConfig.addRebuildIndex(index); |
| | | backend = DirectoryServer.getBackend(backendID); |
| | | backend.rebuildBackend(rebuildConfig); |
| | | rebuildBackend(backendID, rebuildConfig); |
| | | } |
| | | |
| | | @Test(dataProvider = "systemIndexes") |
| | |
| | | rebuildConfig.setBaseDN(baseDNs[0]); |
| | | rebuildConfig.addRebuildIndex(index); |
| | | |
| | | backend = DirectoryServer.getBackend(backendID); |
| | | TaskUtils.disableBackend(backendID); |
| | | backend.rebuildBackend(rebuildConfig); |
| | | rebuildBackend(backendID, rebuildConfig); |
| | | |
| | | //TODO: Verify dn2uri database as well. |
| | | if (!"dn2uri".equalsIgnoreCase(index)) |
| | |
| | | |
| | | private void rebuildIndexes(RebuildConfig rebuildConfig) throws Exception |
| | | { |
| | | backend = DirectoryServer.getBackend(backendID); |
| | | TaskUtils.disableBackend(backendID); |
| | | try |
| | | { |
| | | backend.rebuildBackend(rebuildConfig); |
| | | rebuildBackend(backendID, rebuildConfig); |
| | | assertEquals(verifyBackend(null), 0); |
| | | } |
| | | finally |
| | |
| | | } |
| | | } |
| | | |
| | | private void rebuildBackend(String backendID, RebuildConfig rebuildConfig) throws Exception |
| | | { |
| | | backend = DirectoryServer.getBackend(backendID); |
| | | backend.rebuildBackend(rebuildConfig, DirectoryServer.getInstance().getServerContext()); |
| | | } |
| | | |
| | | @Test |
| | | public void testRebuildRedundentIndexes() throws Exception |
| | | { |
| | |
| | | importConf.setClearBackend(true); |
| | | importConf.writeRejectedEntries(rejectedEntries); |
| | | try { |
| | | backend.importLDIF(importConf); |
| | | backend.importLDIF(importConf, DirectoryServer.getInstance().getServerContext()); |
| | | } |
| | | finally { |
| | | importConf.close(); |
| | |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.File; |
| | | import java.io.FileReader; |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * This class defines a set of test cases for testing the binary transfer option |
| | | * functionality across different protocol versions of LDAP. |
| | |
| | | importConfig = new LDIFImportConfig(ldif.getAbsolutePath()); |
| | | TestCaseUtils.initializeTestBackend(false); |
| | | backend = DirectoryServer.getBackend("test"); |
| | | backend.importLDIF(importConfig); |
| | | backend.importLDIF(importConfig, DirectoryServer.getInstance().getServerContext()); |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.replication; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.File; |
| | | import java.net.SocketTimeoutException; |
| | | import java.util.ArrayList; |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * Tests contained here: |
| | | * |
| | |
| | | LDIFImportConfig importConfig = new LDIFImportConfig(ldifFile.getAbsolutePath()); |
| | | |
| | | MemoryBackend memoryBackend = (MemoryBackend) DirectoryServer.getBackend(TEST_BACKEND_ID); |
| | | memoryBackend.importLDIF(importConfig); |
| | | memoryBackend.importLDIF(importConfig, DirectoryServer.getInstance().getServerContext()); |
| | | } |
| | | |
| | | private String createEntry(UUID uid) |