/** * Creates a new instance. * * @param storeDirectory * The directory used to hold the contents of the store. * @param saveCurrentState * If true, the current state will be updated by the * {@link #saveState(ReplicationState)} operation as well as the * sequenced state. */ public FileReplicationStore(File storeDirectory, boolean saveCurrentState) { currentStatePersister = new PropertiesPersister(new File(storeDirectory, STATE_FILE)); sequenceFormatter = new ReplicationFileSequenceFormatter(storeDirectory); this.saveCurrentState = saveCurrentState; }
@Override public XmlChangeReader getData(long sequence) { File changeFile = sequenceFormatter.getFormattedName(sequence, ".osc.gz"); return new XmlChangeReader(changeFile, false, CompressionMethod.GZip); }
@Override public XmlChangeWriter saveData(long sequence) { File changeFile = sequenceFormatter.getFormattedName(sequence, ".osc.gz"); return new XmlChangeWriter(changeFile, CompressionMethod.GZip); } }
/** * Creates a new instance. * * @param storeDirectory * The directory used to hold the contents of the store. * @param saveCurrentState * If true, the current state will be updated by the * {@link #saveState(ReplicationState)} operation as well as the * sequenced state. */ public FileReplicationStore(File storeDirectory, boolean saveCurrentState) { currentStatePersister = new PropertiesPersister(new File(storeDirectory, STATE_FILE)); sequenceFormatter = new ReplicationFileSequenceFormatter(storeDirectory); this.saveCurrentState = saveCurrentState; }
@Override public XmlChangeReader getData(long sequence) { File changeFile = sequenceFormatter.getFormattedName(sequence, ".osc.gz"); return new XmlChangeReader(changeFile, false, CompressionMethod.GZip); }
@Override public XmlChangeWriter saveData(long sequence) { File changeFile = sequenceFormatter.getFormattedName(sequence, ".osc.gz"); return new XmlChangeWriter(changeFile, CompressionMethod.GZip); } }
@Override public ReplicationState getState(long sequence) { File stateFile = sequenceFormatter.getFormattedName(sequence, ".state.txt"); return new ReplicationState(new PropertiesPersister(stateFile).loadMap()); }
@Override public ReplicationState getState(long sequence) { File stateFile = sequenceFormatter.getFormattedName(sequence, ".state.txt"); return new ReplicationState(new PropertiesPersister(stateFile).loadMap()); }
@Override public void saveState(ReplicationState state) { File stateFile = sequenceFormatter.getFormattedName(state.getSequenceNumber(), ".state.txt"); new PropertiesPersister(stateFile).store(state.store()); if (saveCurrentState) { currentStatePersister.store(state.store()); } }
@Override public void saveState(ReplicationState state) { File stateFile = sequenceFormatter.getFormattedName(state.getSequenceNumber(), ".state.txt"); new PropertiesPersister(stateFile).store(state.store()); if (saveCurrentState) { currentStatePersister.store(state.store()); } }