/** * Try to initialize the Configuration and TransactionStateStorage instances. Obtaining the Configuration may * fail until ReactorServiceMain has been started. */ private void tryInit() { try { Configuration conf = getSnapshotConfiguration(); if (conf != null) { // Since this is only used for background loading of transaction snapshots, we use the no-op metrics collector, // as there are no relevant metrics to report this.storage = new HDFSTransactionStateStorage(conf, new SnapshotCodecProvider(conf), new TxMetricsCollector()); this.storage.startAndWait(); this.snapshotRefreshFrequency = conf.getLong(TxConstants.Manager.CFG_TX_SNAPSHOT_INTERVAL, TxConstants.Manager.DEFAULT_TX_SNAPSHOT_INTERVAL) * 1000; this.initialized = true; } else { LOG.info("Could not load configuration"); } } catch (Exception e) { LOG.info("Failed to initialize TransactionStateCache due to: " + e.getMessage()); } }
/** * Try to initialize the Configuration and TransactionStateStorage instances. Obtaining the Configuration may * fail until ReactorServiceMain has been started. */ private void tryInit() { try { Configuration conf = getSnapshotConfiguration(); if (conf != null) { // Since this is only used for background loading of transaction snapshots, we use the no-op metrics collector, // as there are no relevant metrics to report this.storage = new HDFSTransactionStateStorage(conf, new SnapshotCodecProvider(conf), new TxMetricsCollector()); this.storage.startAndWait(); this.snapshotRefreshFrequency = conf.getLong(TxConstants.Manager.CFG_TX_SNAPSHOT_INTERVAL, TxConstants.Manager.DEFAULT_TX_SNAPSHOT_INTERVAL) * 1000; this.initialized = true; } else { LOG.info("Could not load configuration"); } } catch (Exception e) { LOG.info("Failed to initialize TransactionStateCache due to: " + e.getMessage()); } }
@Override public synchronized void doStart() { LOG.info("Starting transaction manager."); txMetricsCollector.start(); // start up the persistor persistor.startAndWait(); try { persistor.setupStorage(); } catch (IOException e) { Throwables.propagate(e); } // establish defaults in case there is no persistence clear(); // attempt to recover state from last run recoverState(); // start the periodic cleanup thread startCleanupThread(); startSnapshotThread(); startMetricsThread(); // initialize the WAL if we did not force a snapshot in recoverState() initLog(); // initialize next write pointer if needed if (lastWritePointer == 0) { lastWritePointer = getNextWritePointer(); readPointer = lastWritePointer; } notifyStarted(); }
@Override public synchronized void doStart() { LOG.info("Starting transaction manager."); txMetricsCollector.start(); // start up the persistor persistor.startAndWait(); try { persistor.setupStorage(); } catch (IOException e) { Throwables.propagate(e); } // establish defaults in case there is no persistence clear(); // attempt to recover state from last run recoverState(); // start the periodic cleanup thread startCleanupThread(); startSnapshotThread(); startMetricsThread(); // initialize the WAL if we did not force a snapshot in recoverState() initLog(); // initialize next write pointer if needed if (lastWritePointer == 0) { lastWritePointer = getNextWritePointer(); readPointer = lastWritePointer; } notifyStarted(); }
try { long now = System.currentTimeMillis(); storage.startAndWait(); TransactionLog log = storage.createLog(now); for (TransactionEdit edit : edits) {
txStorage.startAndWait(); txStorage2.startAndWait();
try { storage = getStorage(conf); storage.startAndWait();
txStorage.startAndWait(); txStorage2.startAndWait();
@Test public void testSnapshotPersistence() throws Exception { Configuration conf = getConfiguration("testSnapshotPersistence"); TransactionSnapshot snapshot = createRandomSnapshot(); TransactionStateStorage storage = getStorage(conf); try { storage.startAndWait(); storage.writeSnapshot(snapshot); TransactionSnapshot readSnapshot = storage.getLatestSnapshot(); assertNotNull(readSnapshot); assertEquals(snapshot, readSnapshot); } finally { storage.stopAndWait(); } }
try { storage = getStorage(conf); storage.startAndWait(); long now = System.currentTimeMillis(); long writePointer = 1;
try { storage = getStorage(conf); storage.startAndWait();
try { storage = getStorage(conf); storage.startAndWait();
try { storage = getStorage(conf); storage.startAndWait();