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;
}
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);
}
}
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);
}
}
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;
}
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);
}
}
Aggregations