Search in sources :

Example 6 with DatabaseConfigurationException

use of org.exist.util.DatabaseConfigurationException in project exist by eXist-db.

the class XMLTestRunner method run.

@Override
public void run(final RunNotifier notifier) {
    try {
        final String pkgName = getClass().getPackage().getName().replace('.', '/');
        final Source query = new ClassLoaderSource(pkgName + "/xml-test-runner.xq");
        final List<java.util.function.Function<XQueryContext, Tuple2<String, Object>>> externalVariableDeclarations = Arrays.asList(context -> new Tuple2<>("doc", doc), context -> new Tuple2<>("id", Sequence.EMPTY_SEQUENCE), // set callback functions for notifying junit!
        context -> new Tuple2<>("test-ignored-function", new FunctionReference(new FunctionCall(context, new ExtTestIgnoredFunction(context, getSuiteName(), notifier)))), context -> new Tuple2<>("test-started-function", new FunctionReference(new FunctionCall(context, new ExtTestStartedFunction(context, getSuiteName(), notifier)))), context -> new Tuple2<>("test-failure-function", new FunctionReference(new FunctionCall(context, new ExtTestFailureFunction(context, getSuiteName(), notifier)))), context -> new Tuple2<>("test-assumption-failed-function", new FunctionReference(new FunctionCall(context, new ExtTestAssumptionFailedFunction(context, getSuiteName(), notifier)))), context -> new Tuple2<>("test-error-function", new FunctionReference(new FunctionCall(context, new ExtTestErrorFunction(context, getSuiteName(), notifier)))), context -> new Tuple2<>("test-finished-function", new FunctionReference(new FunctionCall(context, new ExtTestFinishedFunction(context, getSuiteName(), notifier)))));
        // NOTE: at this stage EXIST_EMBEDDED_SERVER_CLASS_INSTANCE in XSuite will be usable
        final BrokerPool brokerPool = XSuite.EXIST_EMBEDDED_SERVER_CLASS_INSTANCE.getBrokerPool();
        executeQuery(brokerPool, query, externalVariableDeclarations);
    } catch (final DatabaseConfigurationException | IOException | EXistException | PermissionDeniedException | XPathException e) {
        // TODO(AR) what to do here?
        throw new RuntimeException(e);
    }
}
Also used : ClassLoaderSource(org.exist.source.ClassLoaderSource) XPathException(org.exist.xquery.XPathException) IOException(java.io.IOException) EXistException(org.exist.EXistException) ClassLoaderSource(org.exist.source.ClassLoaderSource) Source(org.exist.source.Source) InputSource(org.xml.sax.InputSource) DatabaseConfigurationException(org.exist.util.DatabaseConfigurationException) FunctionReference(org.exist.xquery.value.FunctionReference) PermissionDeniedException(org.exist.security.PermissionDeniedException) FunctionCall(org.exist.xquery.FunctionCall) BrokerPool(org.exist.storage.BrokerPool)

Example 7 with DatabaseConfigurationException

use of org.exist.util.DatabaseConfigurationException in project exist by eXist-db.

the class XQueryTestRunner method run.

@Override
public void run(final RunNotifier notifier) {
    try {
        final String pkgName = getClass().getPackage().getName().replace('.', '/');
        final Source query = new ClassLoaderSource(pkgName + "/xquery-test-runner.xq");
        final URI testModuleUri = path.toAbsolutePath().toUri();
        final String suiteName = getSuiteName();
        final List<java.util.function.Function<XQueryContext, Tuple2<String, Object>>> externalVariableDeclarations = Arrays.asList(context -> new Tuple2<>("test-module-uri", new AnyURIValue(testModuleUri)), // set callback functions for notifying junit!
        context -> new Tuple2<>("test-ignored-function", new FunctionReference(new FunctionCall(context, new ExtTestIgnoredFunction(context, suiteName, notifier)))), context -> new Tuple2<>("test-started-function", new FunctionReference(new FunctionCall(context, new ExtTestStartedFunction(context, suiteName, notifier)))), context -> new Tuple2<>("test-failure-function", new FunctionReference(new FunctionCall(context, new ExtTestFailureFunction(context, suiteName, notifier)))), context -> new Tuple2<>("test-assumption-failed-function", new FunctionReference(new FunctionCall(context, new ExtTestAssumptionFailedFunction(context, suiteName, notifier)))), context -> new Tuple2<>("test-error-function", new FunctionReference(new FunctionCall(context, new ExtTestErrorFunction(context, suiteName, notifier)))), context -> new Tuple2<>("test-finished-function", new FunctionReference(new FunctionCall(context, new ExtTestFinishedFunction(context, suiteName, notifier)))));
        // NOTE: at this stage EXIST_EMBEDDED_SERVER_CLASS_INSTANCE in XSuite will be usable
        final BrokerPool brokerPool = XSuite.EXIST_EMBEDDED_SERVER_CLASS_INSTANCE.getBrokerPool();
        executeQuery(brokerPool, query, externalVariableDeclarations);
    } catch (final DatabaseConfigurationException | IOException | EXistException | PermissionDeniedException | XPathException e) {
        // TODO(AR) what to do here?
        throw new RuntimeException(e);
    }
}
Also used : URI(java.net.URI) ClassLoaderSource(org.exist.source.ClassLoaderSource) Source(org.exist.source.Source) FileSource(org.exist.source.FileSource) DatabaseConfigurationException(org.exist.util.DatabaseConfigurationException) FunctionReference(org.exist.xquery.value.FunctionReference) ClassLoaderSource(org.exist.source.ClassLoaderSource) AnyURIValue(org.exist.xquery.value.AnyURIValue) IOException(java.io.IOException) EXistException(org.exist.EXistException) java.util(java.util) PermissionDeniedException(org.exist.security.PermissionDeniedException) BrokerPool(org.exist.storage.BrokerPool)

Example 8 with DatabaseConfigurationException

use of org.exist.util.DatabaseConfigurationException in project exist by eXist-db.

the class BrokerPoolsTest method shutdownConcurrent.

@Test
public void shutdownConcurrent() throws InterruptedException, ExecutionException, EXistException, DatabaseConfigurationException, IOException {
    final int testThreads = 5;
    final CountDownLatch shutdownLatch = new CountDownLatch(1);
    final CountDownLatch acquiredLatch = new CountDownLatch(testThreads);
    final List<Future<Exception>> shutdownTasks = new ArrayList<>();
    final ExecutorService executorService = Executors.newFixedThreadPool(testThreads);
    for (int i = 0; i < testThreads; i++) {
        final Path dataDir = temporaryFolder.newFolder("exist" + i).toPath().normalize().toAbsolutePath();
        // load config from classpath and override data and journal dir
        final Configuration configuration = new Configuration("conf.xml");
        configuration.setProperty(BrokerPool.PROPERTY_DATA_DIR, dataDir);
        configuration.setProperty(Journal.PROPERTY_RECOVERY_JOURNAL_DIR, dataDir);
        BrokerPool.configure("instance" + i, 0, 1, configuration);
        shutdownTasks.add(executorService.submit(new BrokerPoolShutdownTask(acquiredLatch, shutdownLatch)));
    }
    // wait for all shutdown threads to be acquired
    acquiredLatch.await();
    shutdownLatch.countDown();
    executorService.shutdown();
    assertTrue(executorService.awaitTermination(8, TimeUnit.SECONDS));
    for (final Future<Exception> shutdownTask : shutdownTasks) {
        assertNull(shutdownTask.get());
    }
}
Also used : Path(java.nio.file.Path) Configuration(org.exist.util.Configuration) IOException(java.io.IOException) EXistException(org.exist.EXistException) DatabaseConfigurationException(org.exist.util.DatabaseConfigurationException) Test(org.junit.Test)

Example 9 with DatabaseConfigurationException

use of org.exist.util.DatabaseConfigurationException in project exist by eXist-db.

the class NativeStructuralIndex method open.

@Override
public void open() throws DatabaseConfigurationException {
    final Path file = getDataDir().resolve(FILE_NAME);
    LOG.debug("Creating '{}'...", FileUtils.fileName(file));
    try {
        btree = new BTreeStore(pool, STRUCTURAL_INDEX_ID, FILE_FORMAT_VERSION_ID, false, file, pool.getCacheManager());
    } catch (final DBException e) {
        LOG.error("Failed to initialize structural index: {}", e.getMessage(), e);
        throw new DatabaseConfigurationException(e.getMessage(), e);
    }
}
Also used : Path(java.nio.file.Path) BTreeStore(org.exist.storage.index.BTreeStore) DBException(org.exist.storage.btree.DBException) DatabaseConfigurationException(org.exist.util.DatabaseConfigurationException)

Example 10 with DatabaseConfigurationException

use of org.exist.util.DatabaseConfigurationException in project exist by eXist-db.

the class RangeIndexConfig method parseChildren.

private void parseChildren(NodeList configNodes, Map<String, String> namespaces) {
    Node node;
    for (int i = 0; i < configNodes.getLength(); i++) {
        node = configNodes.item(i);
        if (node.getNodeType() == Node.ELEMENT_NODE && CREATE_ELEM.equals(node.getLocalName())) {
            try {
                NodeList fields = getFieldsAndConditions((Element) node);
                RangeIndexConfigElement newConfig;
                if (fields.getLength() > 0) {
                    newConfig = new ComplexRangeIndexConfigElement((Element) node, fields, namespaces);
                } else {
                    newConfig = new RangeIndexConfigElement((Element) node, namespaces);
                }
                RangeIndexConfigElement idxConf = paths.get(newConfig.getNodePath().getLastComponent());
                if (idxConf == null) {
                    paths.put(newConfig.getNodePath().getLastComponent(), newConfig);
                } else {
                    idxConf.add(newConfig);
                }
            } catch (final DatabaseConfigurationException e) {
                String uri = null;
                final Document doc = node.getOwnerDocument();
                if (doc != null) {
                    uri = doc.getDocumentURI();
                }
                if (uri != null) {
                    LOG.error("Invalid range index configuration (" + uri + "): " + e.getMessage());
                } else {
                    LOG.error("Invalid range index configuration: " + e.getMessage());
                }
            }
        }
    }
}
Also used : DatabaseConfigurationException(org.exist.util.DatabaseConfigurationException) Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document)

Aggregations

DatabaseConfigurationException (org.exist.util.DatabaseConfigurationException)19 EXistException (org.exist.EXistException)8 IOException (java.io.IOException)6 Configuration (org.exist.util.Configuration)6 Path (java.nio.file.Path)5 Element (org.w3c.dom.Element)4 Node (org.w3c.dom.Node)4 ServletException (javax.servlet.ServletException)3 QName (org.exist.dom.QName)3 PermissionDeniedException (org.exist.security.PermissionDeniedException)3 ClassLoaderSource (org.exist.source.ClassLoaderSource)3 Source (org.exist.source.Source)3 BrokerPool (org.exist.storage.BrokerPool)3 NodeList (org.w3c.dom.NodeList)3 FileSource (org.exist.source.FileSource)2 DBException (org.exist.storage.btree.DBException)2 BTreeStore (org.exist.storage.index.BTreeStore)2 FunctionReference (org.exist.xquery.value.FunctionReference)2 URI (java.net.URI)1 Files (java.nio.file.Files)1