@Override public long getLWMark() { return _waterMarksClock.getLWMScn(_source); }
@Override public synchronized void saveHWMark(long hwMark) { if(hwMark > _hwmScn) { _hwmScn = hwMark; _waterMarksClock.setHWMark(_source, _hwmScn); } }
/** * Creates a new RetentionStoreWriter instance. * * @param source - the source of store * @param retention - the retention for store update events. * @param store - the store * @param waterMarksClock */ public SimpleRetentionStoreWriter(String source, Retention<K> retention, DataStore<K, V> store, WaterMarksClock waterMarksClock) { this._source = source; this._retention = retention; this._store = store; this._waterMarksClock = waterMarksClock; // Initialize the high water mark scn _hwmScn = waterMarksClock.getHWMScn(source); // Reset low/high water marks if necessary long lwmScn = waterMarksClock.getLWMScn(source); if(_hwmScn < lwmScn) { lwmScn = _hwmScn; waterMarksClock.updateWaterMarks(source, lwmScn, _hwmScn); } else { waterMarksClock.setHWMark(source, _hwmScn); } // Log water marks getLogger().info(String.format("init %s lwmScn=%d hwmScn=%d", source, lwmScn, _hwmScn)); }
@Override public synchronized void sync() throws IOException { _store.sync(); _retention.flush(); _waterMarksClock.setHWMark(_source, _hwmScn); _waterMarksClock.syncWaterMarks(_source); }
@Override public synchronized boolean delete(K key, long scn) throws Exception { if(scn >= _hwmScn) { Clock clock; _store.delete(key); clock = (scn == _hwmScn) ? _waterMarksClock.current() : _waterMarksClock.updateHWMark(_source, scn); _retention.put(new SimpleEvent<K>(key, clock)); _hwmScn = scn; return true; } else { return false; } } }
/** * Creates a new RetentionStoreWriter instance. * * @param source - the source of store * @param retention - the retention for store update events. * @param store - the store * @param waterMarksClock */ public SimpleRetentionStoreWriter(String source, Retention<K> retention, DataStore<K, V> store, WaterMarksClock waterMarksClock) { this._source = source; this._retention = retention; this._store = store; this._waterMarksClock = waterMarksClock; // Initialize the high water mark scn _hwmScn = waterMarksClock.getHWMScn(source); // Reset low/high water marks if necessary long lwmScn = waterMarksClock.getLWMScn(source); if(_hwmScn < lwmScn) { lwmScn = _hwmScn; waterMarksClock.updateWaterMarks(source, lwmScn, _hwmScn); } else { waterMarksClock.setHWMark(source, _hwmScn); } // Log water marks getLogger().info(String.format("init %s lwmScn=%d hwmScn=%d", source, lwmScn, _hwmScn)); }
@Override public synchronized void persist() throws IOException { _store.persist(); _retention.flush(); _waterMarksClock.setHWMark(_source, _hwmScn); _waterMarksClock.syncWaterMarks(_source); }
@Override public synchronized boolean put(K key, V value, long scn) throws Exception { if(scn >= _hwmScn) { Clock clock; _store.put(key, value); clock = (scn == _hwmScn) ? _waterMarksClock.current() : _waterMarksClock.updateHWMark(_source, scn); _retention.put(new SimpleEvent<K>(key, clock)); _hwmScn = scn; return true; } else { return false; } }
@Override public synchronized void persist() throws IOException { _store.persist(); _retention.flush(); _waterMarksClock.setHWMark(_source, _hwmScn); _waterMarksClock.syncWaterMarks(_source); }
@Override public synchronized boolean put(K key, V value, long scn) throws Exception { if(scn >= _hwmScn) { Clock clock; _store.put(key, value); clock = (scn == _hwmScn) ? _waterMarksClock.current() : _waterMarksClock.updateHWMark(_source, scn); _retention.put(new SimpleEvent<K>(key, clock)); _hwmScn = scn; return true; } else { return false; } }
@Override public synchronized void saveHWMark(long hwMark) { if(hwMark > _hwmScn) { _hwmScn = hwMark; _waterMarksClock.setHWMark(_source, _hwmScn); } }
@Override public long getLWMark() { return _waterMarksClock.getLWMScn(_source); }
@Override public synchronized void sync() throws IOException { _store.sync(); _retention.flush(); _waterMarksClock.setHWMark(_source, _hwmScn); _waterMarksClock.syncWaterMarks(_source); }
@Override public synchronized boolean delete(K key, long scn) throws Exception { if(scn >= _hwmScn) { Clock clock; _store.delete(key); clock = (scn == _hwmScn) ? _waterMarksClock.current() : _waterMarksClock.updateHWMark(_source, scn); _retention.put(new SimpleEvent<K>(key, clock)); _hwmScn = scn; return true; } else { return false; } } }