/** * Creates a new instance. * * @param workingDirectory * The directory containing configuration and tracking files. */ public BaseReplicationDownloader(File workingDirectory) { this.workingDirectory = workingDirectory; sequenceFormatter = new ReplicationSequenceFormatter(9, 3); serverStateReader = new ServerStateReader(); }
/** * Retrieves the specified state from the server. * * @param baseUrl * The url of the directory containing change files. * @param sequenceNumber * The sequence number of the state to be retrieved from the server. * @return The state. */ public ReplicationState getServerState(URL baseUrl, long sequenceNumber) { return getServerState(baseUrl, sequenceFormatter.getFormattedName(sequenceNumber, SEQUENCE_STATE_FILE_SUFFIX)); }
/** * Creates a timestamp tracker object for persisting the currently extracted timestamp. * * @return The timestamp tracker. */ private TimestampTracker getTimestampTracker() { return new TimestampTracker(TSTAMP_FILE, TSTAMP_NEW_FILE); }
@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()); } }
/** * Creates a new instance. */ public ServerStateReader() { sequenceFormatter = new ReplicationSequenceFormatter(9, 3); }
/** * Creates a new instance. * * @param properties * The properties to load state from. */ public ReplicationState(Map<String, String> properties) { load(properties); }
@Override public ReplicationState getState(long sequence) { File stateFile = sequenceFormatter.getFormattedName(sequence, ".state.txt"); return new ReplicationState(new PropertiesPersister(stateFile).loadMap()); }
/** * {@inheritDoc} */ @Override public void complete() { currentState.store(storedState); stateExists = true; }
/** * Retrieves the latest state from the server. * * @param baseUrl * The url of the directory containing change files. * @return The state. */ public ReplicationState getServerState(URL baseUrl) { return getServerState(baseUrl, SERVER_STATE_FILE); }
@Override public int hashCode() { return super.hashCode() + (int) txnMax + (int) txnMaxQueried; }
@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()); } }
/** * Creates a new instance. * * @param workingDirectory * The directory containing configuration and tracking files. */ public BaseReplicationDownloader(File workingDirectory) { this.workingDirectory = workingDirectory; sequenceFormatter = new ReplicationSequenceFormatter(9, 3); serverStateReader = new ServerStateReader(); }
/** * Retrieves the specified state from the server. * * @param baseUrl * The url of the directory containing change files. * @param sequenceNumber * The sequence number of the state to be retrieved from the server. * @return The state. */ public ReplicationState getServerState(URL baseUrl, long sequenceNumber) { return getServerState(baseUrl, sequenceFormatter.getFormattedName(sequenceNumber, SEQUENCE_STATE_FILE_SUFFIX)); }
/** * Creates a new instance. */ public ServerStateReader() { sequenceFormatter = new ReplicationSequenceFormatter(9, 3); }
/** * Creates a new instance. * * @param properties * The properties to load state from. */ public ReplicationState(Map<String, String> properties) { load(properties); }
@Override public ReplicationState getState(long sequence) { File stateFile = sequenceFormatter.getFormattedName(sequence, ".state.txt"); return new ReplicationState(new PropertiesPersister(stateFile).loadMap()); }
/** * Creates a new instance with an initial state. * * @param initialState * The initial replication state. */ public MockReplicationDestination(ReplicationState initialState) { this(); initialState.store(storedState); stateExists = true; }
/** * Creates a timestamp tracker object for persisting the currently extracted timestamp into the * data directory for consumers to download. * * @return The timestamp tracker. */ private TimestampTracker getDataTimestampSetter() { return new TimestampTracker(DATA_TSTAMP_FILE, DATA_TSTAMP_NEW_FILE); }
/** * Retrieves the latest state from the server. * * @param baseUrl * The url of the directory containing change files. * @return The state. */ public ReplicationState getServerState(URL baseUrl) { return getServerState(baseUrl, SERVER_STATE_FILE); }
/** * Creates a new instance. * * @param control * Provides the Netty handlers with access to the controller. * @param dataDirectory * The directory containing the replication data files. */ public ReplicationDataServerHandler(SequenceServerControl control, File dataDirectory) { super(control); this.dataDirectory = dataDirectory; sequenceFormatter = new ReplicationSequenceFormatter(9, 3); }