Search in sources :

Example 1 with ExceptionWrapper

use of org.janusgraph.util.datastructures.ExceptionWrapper in project janusgraph by JanusGraph.

the class Backend method close.

public synchronized void close() throws BackendException {
    if (!hasAttemptedClose) {
        hasAttemptedClose = true;
        ExceptionWrapper exceptionWrapper = new ExceptionWrapper();
        executeWithCatching(managementLogManager::close, exceptionWrapper);
        executeWithCatching(txLogManager::close, exceptionWrapper);
        executeWithCatching(userLogManager::close, exceptionWrapper);
        executeWithCatching(scanner::close, exceptionWrapper);
        if (edgeStore != null)
            executeWithCatching(edgeStore::close, exceptionWrapper);
        if (indexStore != null)
            executeWithCatching(indexStore::close, exceptionWrapper);
        if (idAuthority != null)
            executeWithCatching(idAuthority::close, exceptionWrapper);
        if (systemConfig != null)
            executeWithCatching(systemConfig::close, exceptionWrapper);
        if (userConfig != null)
            executeWithCatching(userConfig::close, exceptionWrapper);
        executeWithCatching(storeManager::close, exceptionWrapper);
        gracefulExecutorServiceShutdown(threadPool, threadPoolShutdownMaxWaitTime);
        // Indexes
        for (IndexProvider index : indexes.values()) {
            executeWithCatching(index::close, exceptionWrapper);
        }
        throwIfException(exceptionWrapper);
    } else {
        log.debug("Backend {} has already been closed or cleared", this);
    }
}
Also used : MetricInstrumentedIndexProvider(org.janusgraph.diskstorage.util.MetricInstrumentedIndexProvider) IndexProvider(org.janusgraph.diskstorage.indexing.IndexProvider) ExceptionWrapper(org.janusgraph.util.datastructures.ExceptionWrapper)

Example 2 with ExceptionWrapper

use of org.janusgraph.util.datastructures.ExceptionWrapper in project janusgraph by JanusGraph.

the class KCVSLog method close.

/**
 * Closes the log by terminating all threads and waiting for their termination.
 *
 * @throws org.janusgraph.diskstorage.BackendException
 */
@Override
public synchronized void close() throws BackendException {
    if (!isOpen)
        return;
    this.isOpen = false;
    if (readExecutor != null)
        readExecutor.shutdown();
    if (sendThread != null)
        sendThread.close(CLOSE_DOWN_WAIT);
    if (readExecutor != null) {
        try {
            readExecutor.awaitTermination(1, TimeUnit.SECONDS);
        } catch (InterruptedException e) {
            log.error("Could not terminate reader thread pool for KCVSLog {} due to interruption", name, e);
        }
        if (!readExecutor.isTerminated()) {
            readExecutor.shutdownNow();
            log.error("Reader thread pool for KCVSLog {} did not shut down in time - could not clean up or set read markers", name);
        } else {
            for (MessagePuller puller : msgPullers) {
                puller.close();
            }
        }
    }
    ExceptionWrapper exceptionWrapper = new ExceptionWrapper();
    ExecuteUtil.executeWithCatching(() -> {
        try {
            writeSetting(manager.senderId, MESSAGE_COUNTER_COLUMN, numMsgCounter.get());
        } catch (Throwable e) {
            log.error("Could not persist message counter [{}] ; message counter [{}]", manager.senderId, numMsgCounter.get(), e);
            throw e;
        }
    }, exceptionWrapper);
    ExecuteUtil.executeWithCatching(() -> {
        try {
            store.close();
        } catch (Throwable e) {
            log.error("Could not correctly close store [{}]", store.getName(), e);
            throw e;
        }
    }, exceptionWrapper);
    ExecuteUtil.executeWithCatching(() -> {
        try {
            manager.closedLog(this);
        } catch (Throwable e) {
            log.error("Could not correctly close log [{}] and remove it from manager.", getName(), e);
            throw e;
        }
    }, exceptionWrapper);
    ExecuteUtil.throwIfException(exceptionWrapper);
}
Also used : ExceptionWrapper(org.janusgraph.util.datastructures.ExceptionWrapper)

Example 3 with ExceptionWrapper

use of org.janusgraph.util.datastructures.ExceptionWrapper in project janusgraph by JanusGraph.

the class StandardScanner method close.

public void close() throws BackendException {
    // Interrupt running jobs
    ExceptionWrapper exceptionWrapper = new ExceptionWrapper();
    for (StandardScannerExecutor exe : runningJobs.values()) {
        if (exe.isCancelled() || exe.isDone())
            continue;
        executeWithCatching(() -> exe.cancel(true), exceptionWrapper);
    }
    for (KeyColumnValueStore kcvs : openStores) {
        executeWithCatching(kcvs::close, exceptionWrapper);
    }
    throwIfException(exceptionWrapper);
}
Also used : KeyColumnValueStore(org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStore) ExceptionWrapper(org.janusgraph.util.datastructures.ExceptionWrapper)

Example 4 with ExceptionWrapper

use of org.janusgraph.util.datastructures.ExceptionWrapper in project janusgraph by JanusGraph.

the class KCVSConfiguration method close.

@Override
public void close() {
    try {
        ExceptionWrapper exceptionWrapper = new ExceptionWrapper();
        executeWithCatching(store::close, exceptionWrapper);
        executeWithCatching(txProvider::close, exceptionWrapper);
        IOUtils.closeQuietly(serializer);
        throwIfException(exceptionWrapper);
    } catch (BackendException e) {
        throw new JanusGraphException("Could not close configuration store", e);
    }
}
Also used : JanusGraphException(org.janusgraph.core.JanusGraphException) ExceptionWrapper(org.janusgraph.util.datastructures.ExceptionWrapper) BackendException(org.janusgraph.diskstorage.BackendException)

Example 5 with ExceptionWrapper

use of org.janusgraph.util.datastructures.ExceptionWrapper in project janusgraph by JanusGraph.

the class CQLStoreManager method close.

@Override
public void close() throws BackendException {
    try {
        ExceptionWrapper exceptionWrapper = new ExceptionWrapper();
        executeWithCatching(this::clearJmxMetrics, exceptionWrapper);
        executeWithCatching(session::close, exceptionWrapper);
        throwIfException(exceptionWrapper);
    } finally {
        gracefulExecutorServiceShutdown(executorService, threadPoolShutdownMaxWaitTime);
    }
}
Also used : ExceptionWrapper(org.janusgraph.util.datastructures.ExceptionWrapper)

Aggregations

ExceptionWrapper (org.janusgraph.util.datastructures.ExceptionWrapper)7 JanusGraphException (org.janusgraph.core.JanusGraphException)2 BackendException (org.janusgraph.diskstorage.BackendException)2 ArrayList (java.util.ArrayList)1 IndexProvider (org.janusgraph.diskstorage.indexing.IndexProvider)1 KeyColumnValueStore (org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStore)1 Log (org.janusgraph.diskstorage.log.Log)1 MetricInstrumentedIndexProvider (org.janusgraph.diskstorage.util.MetricInstrumentedIndexProvider)1