private void refreshState() throws IOException { if (!initialized) { tryInit(); } // only continue if initialization was successful if (initialized) { long now = System.currentTimeMillis(); TransactionVisibilityState currentState = storage.getLatestTransactionVisibilityState(); if (currentState != null) { if (currentState.getTimestamp() < (now - 2 * snapshotRefreshFrequency)) { LOG.info("Current snapshot is old, will force a refresh on next run."); reset(); } else { latestState = currentState; LOG.info("Transaction state reloaded with snapshot from " + latestState.getTimestamp()); if (LOG.isDebugEnabled()) { LOG.debug("Latest transaction snapshot: " + latestState.toString()); } lastRefresh = now; } } else { LOG.info("No transaction state found."); } } }
private void refreshState() throws IOException { if (!initialized) { tryInit(); } // only continue if initialization was successful if (initialized) { long now = System.currentTimeMillis(); TransactionVisibilityState currentState = storage.getLatestTransactionVisibilityState(); if (currentState != null) { if (currentState.getTimestamp() < (now - 2 * snapshotRefreshFrequency)) { LOG.info("Current snapshot is old, will force a refresh on next run."); reset(); } else { latestState = currentState; LOG.info("Transaction state reloaded with snapshot from " + latestState.getTimestamp()); if (LOG.isDebugEnabled()) { LOG.debug("Latest transaction snapshot: " + latestState.toString()); } lastRefresh = now; } } else { LOG.info("No transaction state found."); } } }
@Override public TransactionSnapshot decode(InputStream in) { BinaryDecoder decoder = new BinaryDecoder(in); try { TransactionVisibilityState minTxSnapshot = decodeTransactionVisibilityState(in); NavigableMap<Long, Set<ChangeId>> committing = decodeChangeSets(decoder); NavigableMap<Long, Set<ChangeId>> committed = decodeChangeSets(decoder); return new TransactionSnapshot(minTxSnapshot.getTimestamp(), minTxSnapshot.getReadPointer(), minTxSnapshot.getWritePointer(), minTxSnapshot.getInvalid(), minTxSnapshot.getInProgress(), committing, committed); } catch (IOException e) { LOG.error("Unable to deserialize transaction state: ", e); throw Throwables.propagate(e); } }
@Override public TransactionSnapshot decode(InputStream in) { BinaryDecoder decoder = new BinaryDecoder(in); try { TransactionVisibilityState minTxSnapshot = decodeTransactionVisibilityState(in); NavigableMap<Long, Set<ChangeId>> committing = decodeChangeSets(decoder); NavigableMap<Long, Set<ChangeId>> committed = decodeChangeSets(decoder); return new TransactionSnapshot(minTxSnapshot.getTimestamp(), minTxSnapshot.getReadPointer(), minTxSnapshot.getWritePointer(), minTxSnapshot.getInvalid(), minTxSnapshot.getInProgress(), committing, committed); } catch (IOException e) { LOG.error("Unable to deserialize transaction state: ", e); throw Throwables.propagate(e); } }
private void assertTransactionVisibilityStateEquals(TransactionVisibilityState expected, TransactionVisibilityState input) { Assert.assertEquals(expected.getTimestamp(), input.getTimestamp()); Assert.assertEquals(expected.getReadPointer(), input.getReadPointer()); Assert.assertEquals(expected.getWritePointer(), input.getWritePointer()); Assert.assertEquals(expected.getInProgress(), input.getInProgress()); Assert.assertEquals(expected.getInvalid(), input.getInvalid()); } }