Search in sources :

Example 16 with JournalRuntimeException

use of com.questdb.common.JournalRuntimeException in project questdb by bluestreak01.

the class CachingWriterFactory method canClose.

@Override
public boolean canClose(Journal journal) {
    String name = journal.getName();
    Entry e = entries.get(name);
    long thread = Thread.currentThread().getId();
    if (e != null) {
        if (e.owner != -1) {
            if (e.writer.isCommitOnClose()) {
                try {
                    e.writer.commit();
                } catch (JournalException ex) {
                    notifyListener(thread, name, FactoryEventListener.EV_COMMIT_EX);
                    throw new JournalRuntimeException(ex);
                }
            }
            LOG.info().$("Writer '").$(name).$(" is back in pool").$();
            e.lastReleaseTime = System.currentTimeMillis();
            if (closed || e.writer.isInError()) {
                LOG.info().$("Closing writer '").$(name).$('\'').$();
                e.writer.setCloseInterceptor(null);
                e.writer = null;
                entries.remove(name);
                notifyListener(thread, name, FactoryEventListener.EV_OUT_OF_POOL_CLOSE);
                return true;
            }
            e.owner = -1L;
            notifyListener(thread, name, FactoryEventListener.EV_RETURN);
        } else {
            LOG.error().$("Writer '").$(name).$("' is not allocated ").$(e.owner).$();
            notifyListener(thread, name, FactoryEventListener.EV_UNEXPECTED_CLOSE);
        }
    } else {
        LOG.error().$("Writer '").$(name).$("' is not managed by this pool").$();
        journal.setCloseInterceptor(null);
        notifyListener(thread, name, FactoryEventListener.EV_NOT_IN_POOL);
        return true;
    }
    return false;
}
Also used : JournalException(com.questdb.std.ex.JournalException) JournalRuntimeException(com.questdb.common.JournalRuntimeException)

Example 17 with JournalRuntimeException

use of com.questdb.common.JournalRuntimeException in project questdb by bluestreak01.

the class JournalIteratorImpl method next.

@Override
public T next() {
    try {
        T result = journal.read(Rows.toRowID(currentPartitionID, currentRowID));
        if (currentRowID < currentUpperBound) {
            currentRowID++;
        } else {
            currentIndex++;
            updateVariables();
        }
        return result;
    } catch (JournalException e) {
        throw new JournalRuntimeException("Error in iterator [%s]", e, this);
    }
}
Also used : JournalException(com.questdb.std.ex.JournalException) JournalRuntimeException(com.questdb.common.JournalRuntimeException)

Example 18 with JournalRuntimeException

use of com.questdb.common.JournalRuntimeException in project questdb by bluestreak01.

the class QueryAllImpl method createRanges.

private ObjList<JournalIteratorRange> createRanges(long lo) {
    ObjList<JournalIteratorRange> ranges = new ObjList<>();
    int loPartitionID = Rows.toPartitionIndex(lo);
    long loLocalRowID = Rows.toLocalRowID(lo);
    try {
        int count = journal.getPartitionCount();
        for (int i = loPartitionID; i < count; i++) {
            long localRowID = 0;
            if (i == loPartitionID) {
                localRowID = loLocalRowID;
            }
            Partition<T> p = journal.getPartition(i, true);
            long size = p.size();
            if (size > 0) {
                ranges.add(new JournalIteratorRange(p.getPartitionIndex(), localRowID, size - 1));
            }
        }
        return ranges;
    } catch (JournalException e) {
        throw new JournalRuntimeException(e);
    }
}
Also used : ObjList(com.questdb.std.ObjList) JournalException(com.questdb.std.ex.JournalException) JournalRuntimeException(com.questdb.common.JournalRuntimeException)

Example 19 with JournalRuntimeException

use of com.questdb.common.JournalRuntimeException in project questdb by bluestreak01.

the class QueryAllImpl method createRanges.

private ObjList<JournalIteratorRange> createRanges() {
    final int partitionCount = journal.getPartitionCount();
    ObjList<JournalIteratorRange> ranges = new ObjList<>(partitionCount);
    try {
        for (int i = 0; i < partitionCount; i++) {
            Partition<T> p = journal.getPartition(i, true);
            long size = p.size();
            if (size > 0) {
                ranges.add(new JournalIteratorRange(p.getPartitionIndex(), 0, size - 1));
            }
        }
    } catch (JournalException e) {
        throw new JournalRuntimeException(e);
    }
    return ranges;
}
Also used : ObjList(com.questdb.std.ObjList) JournalException(com.questdb.std.ex.JournalException) JournalRuntimeException(com.questdb.common.JournalRuntimeException)

Example 20 with JournalRuntimeException

use of com.questdb.common.JournalRuntimeException in project questdb by bluestreak01.

the class QueryAllImpl method incrementIterator.

@Override
public JournalPeekingIterator<T> incrementIterator() {
    try {
        long lo = journal.getMaxRowID();
        journal.refresh();
        return new JournalIteratorImpl<>(journal, createRanges(journal.incrementRowID(lo)));
    } catch (JournalException e) {
        throw new JournalRuntimeException(e);
    }
}
Also used : JournalException(com.questdb.std.ex.JournalException) JournalRuntimeException(com.questdb.common.JournalRuntimeException)

Aggregations

JournalRuntimeException (com.questdb.common.JournalRuntimeException)41 JournalException (com.questdb.std.ex.JournalException)30 KVIndex (com.questdb.store.KVIndex)9 IOException (java.io.IOException)6 IndexCursor (com.questdb.store.IndexCursor)5 Partition (com.questdb.store.Partition)5 ObjList (com.questdb.std.ObjList)4 FixedColumn (com.questdb.store.FixedColumn)2 File (java.io.File)2 MappedByteBuffer (java.nio.MappedByteBuffer)2 BootstrapEnv (com.questdb.BootstrapEnv)1 ServerConfiguration (com.questdb.ServerConfiguration)1 NumericException (com.questdb.common.NumericException)1 ImportColumnCountException (com.questdb.ex.ImportColumnCountException)1 ImportNameException (com.questdb.ex.ImportNameException)1 IncompatibleJournalException (com.questdb.ex.IncompatibleJournalException)1 JournalIOException (com.questdb.ex.JournalIOException)1 Quote (com.questdb.model.Quote)1 ClientConfig (com.questdb.net.ha.config.ClientConfig)1 ImportedColumnMetadata (com.questdb.parser.ImportedColumnMetadata)1