Search in sources :

Example 1 with BrokerPoolServiceException

use of org.exist.storage.BrokerPoolServiceException in project exist by eXist-db.

the class IndexManager method prepare.

/**
 * Registers the indexes specified in
 * the global configuration object, i.e. in the :
 * <pre>
 * &lt;modules&gt;
 *   &lt;module id="foo" class="bar" foo1="bar1" ... /&gt;
 * &lt;/modules&gt;
 * </pre>
 * section of the configuration file.
 */
@Override
public void prepare(final BrokerPool brokerPool) throws BrokerPoolServiceException {
    try {
        if (modConfigs != null) {
            for (final Configuration.IndexModuleConfig modConfig : modConfigs) {
                final String className = modConfig.getClassName();
                initIndex(pool, modConfig.getId(), modConfig.getConfig(), dataDir, className);
            }
        }
        // check if a structural index was configured. If not, create one based on default settings.
        AbstractIndex structural = (AbstractIndex) indexers.get(StructuralIndex.STRUCTURAL_INDEX_ID);
        if (structural == null) {
            structural = initIndex(pool, StructuralIndex.STRUCTURAL_INDEX_ID, null, dataDir, StructuralIndex.DEFAULT_CLASS);
            if (structural != null) {
                structural.setName(StructuralIndex.STRUCTURAL_INDEX_ID);
            }
        }
    } catch (final DatabaseConfigurationException e) {
        throw new BrokerPoolServiceException(e);
    } finally {
        configurationChanged();
    }
}
Also used : BrokerPoolServiceException(org.exist.storage.BrokerPoolServiceException) Configuration(org.exist.util.Configuration) DatabaseConfigurationException(org.exist.util.DatabaseConfigurationException)

Example 2 with BrokerPoolServiceException

use of org.exist.storage.BrokerPoolServiceException in project exist by eXist-db.

the class FileLockService method configure.

@Override
public void configure(final Configuration configuration) throws BrokerPoolServiceException {
    dataDir = Optional.ofNullable((Path) configuration.getProperty(confDirPropName)).orElse(Paths.get(defaultDirName));
    if (!Files.exists(dataDir)) {
        try {
            // TODO : shall we force the creation ? use a parameter to decide ?
            LOG.info("Data directory '{}' does not exist. Creating one ...", dataDir.toAbsolutePath().toString());
            Files.createDirectories(dataDir);
        } catch (final SecurityException | IOException e) {
            throw new BrokerPoolServiceException("Cannot create data directory '" + dataDir.toAbsolutePath().toString() + "'", e);
        }
    }
    // Save it for further use.
    configuration.setProperty(confDirPropName, dataDir);
    if (!Files.isWritable(dataDir)) {
        LOG.warn("Cannot write to data directory: {}", dataDir.toAbsolutePath().toString());
        writable = false;
    } else {
        writable = true;
    }
}
Also used : BrokerPoolServiceException(org.exist.storage.BrokerPoolServiceException) IOException(java.io.IOException)

Example 3 with BrokerPoolServiceException

use of org.exist.storage.BrokerPoolServiceException in project exist by eXist-db.

the class FileLockService method prepare.

@Override
public void prepare(final BrokerPool brokerPool) throws BrokerPoolServiceException {
    // try to acquire lock on the data dir
    final FileLock fileLock = new FileLock(brokerPool, dataDir.resolve(lockFileName));
    this.dataLock.compareAndSet(null, fileLock);
    try {
        final boolean locked = fileLock.tryLock();
        if (!locked) {
            throw new BrokerPoolServiceException(new EXistException("The directory seems to be locked by another " + "database instance. Found a valid lock file: " + fileLock.getFile().toAbsolutePath().toString()));
        }
    } catch (final ReadOnlyException e) {
        LOG.warn(e);
        writable = false;
    }
    if (!writable) {
        brokerPool.setReadOnly();
    }
}
Also used : BrokerPoolServiceException(org.exist.storage.BrokerPoolServiceException) EXistException(org.exist.EXistException) ReadOnlyException(org.exist.util.ReadOnlyException)

Example 4 with BrokerPoolServiceException

use of org.exist.storage.BrokerPoolServiceException in project exist by eXist-db.

the class JournalManager method prepare.

@Override
public synchronized void prepare(final BrokerPool pool) throws BrokerPoolServiceException {
    if (!journallingDisabled) {
        try {
            this.journal = new Journal(pool, journalDir);
            this.journal.initialize();
            this.initialized = true;
        } catch (final EXistException | ReadOnlyException e) {
            throw new BrokerPoolServiceException(e);
        }
    }
}
Also used : BrokerPoolServiceException(org.exist.storage.BrokerPoolServiceException) EXistException(org.exist.EXistException) ReadOnlyException(org.exist.util.ReadOnlyException)

Example 5 with BrokerPoolServiceException

use of org.exist.storage.BrokerPoolServiceException in project exist by eXist-db.

the class BlobStoreImplService method startSystem.

@Override
public void startSystem(final DBBroker systemBroker, final Txn transaction) throws BrokerPoolServiceException {
    try {
        this.blobStore.open();
        LOG.info("Opened de-duplicating Blob Store v" + BlobStoreImpl.BLOB_STORE_VERSION + ". metadata={}, store={}/", dataDir.relativize(persistentFile), dataDir.relativize(blobDir));
    } catch (final IOException e) {
        throw new BrokerPoolServiceException(e);
    }
}
Also used : BrokerPoolServiceException(org.exist.storage.BrokerPoolServiceException) IOException(java.io.IOException)

Aggregations

BrokerPoolServiceException (org.exist.storage.BrokerPoolServiceException)8 IOException (java.io.IOException)4 EXistException (org.exist.EXistException)3 Configuration (org.exist.util.Configuration)2 ReadOnlyException (org.exist.util.ReadOnlyException)2 Either (com.evolvedbinary.j8fu.Either)1 InputStream (java.io.InputStream)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 java.util (java.util)1 Calendar (java.util.Calendar)1 Collectors (java.util.stream.Collectors)1 Nullable (javax.annotation.Nullable)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 org.exist.scheduler (org.exist.scheduler)1 JobDescription (org.exist.scheduler.JobDescription)1 Scheduler (org.exist.scheduler.Scheduler)1 Subject (org.exist.security.Subject)1 BrokerPool (org.exist.storage.BrokerPool)1