use of com.questdb.ex.IncompatibleJournalException in project questdb by bluestreak01.
the class JournalDeltaConsumer method doRead.
@Override
@SuppressWarnings("unchecked")
protected void doRead(ReadableByteChannel channel) throws JournalNetworkException {
try {
reset();
journalServerStateConsumer.read(channel);
this.state = journalServerStateConsumer.getValue();
if (state.getTxn() == -1) {
journal.notifyListener(JournalEvents.EVT_JNL_TRANSACTION_REFUSED);
throw new IncompatibleJournalException("Server refused txn for %s", journal.getLocation());
}
if (state.getTxn() < journal.getTxn()) {
journal.rollback(state.getTxn(), state.getTxPin());
return;
}
journal.beginTx();
createPartitions(state);
if (state.isSymbolTables()) {
journalSymbolTableConsumer.read(channel);
}
for (int i = 0, k = state.getNonLagPartitionCount(); i < k; i++) {
JournalServerState.PartitionMetadata meta = state.getMeta(i);
if (meta.getEmpty() == 0) {
PartitionDeltaConsumer partitionDeltaConsumer = getPartitionDeltaConsumer(meta.getPartitionIndex());
partitionDeltaConsumer.read(channel);
}
}
if (state.getLagPartitionName() == null && journal.hasIrregularPartition()) {
// delete lag partition
journal.removeIrregularPartition();
} else if (state.getLagPartitionName() != null) {
if (lagPartitionDeltaConsumer == null || !journal.hasIrregularPartition() || !state.getLagPartitionName().equals(journal.getIrregularPartition().getName())) {
Partition temp = journal.createTempPartition(state.getLagPartitionName());
lagPartitionDeltaConsumer = new PartitionDeltaConsumer(temp.open());
journal.setIrregularPartition(temp);
}
lagPartitionDeltaConsumer.read(channel);
}
} catch (JournalException e) {
throw new JournalNetworkException(e);
}
}
Aggregations