private void invokeSinkInit() { replicationState = new ReplicationState(); Map<String, Object> metaData = new HashMap<String, Object>(1); metaData.put(ReplicationState.META_DATA_KEY, replicationState); changeSink.initialize(metaData); sinkInitInvoked = true; }
@Override public ReplicationState getCurrentState() { ReplicationState state = new ReplicationState(); state.load(currentStatePersister.loadMap()); return state; }
@Override public ReplicationState getCurrentState() { ReplicationState state = new ReplicationState(); state.load(currentStatePersister.loadMap()); return state; }
state = new ReplicationState(stateMap);
state = new ReplicationState(stateMap);
private ReplicationState loadState(File stateFile) { PropertiesPersister persister = new PropertiesPersister(stateFile); ReplicationState state = new ReplicationState(); state.load(persister.loadMap()); return state; }
localState = new ReplicationState(localStatePersistor.loadMap());
localState = new ReplicationState(localStatePersistor.loadMap());
private ReplicationState getReplicationState(long sequenceNumber) { PropertiesPersister persister = new PropertiesPersister(getStateFile(sequenceNumber)); ReplicationState state = new ReplicationState(); state.load(persister.loadMap()); return state; }
@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()); }
/** * {@inheritDoc} */ @Override protected void processInitializeState(ReplicationState initialState) { Date initialDate; Date alignedDate; long intervalLength; intervalLength = getConfiguration().getIntervalLength(); initialDate = initialState.getTimestamp(); // Align the date to an interval boundary. alignedDate = alignDateToIntervalBoundary(initialDate, intervalLength); // If the date has been moved, then advance it to the next interval. We // do this because // during replication we never claim to have covered a time period that // we haven't received // data for. We may include extra data from a previous interval. By // advancing the stated // initial timestamp to the next interval our first replication will // include some data from // the previous interval. if (alignedDate.compareTo(initialDate) < 0) { alignedDate = new Date(alignedDate.getTime() + intervalLength); } // Create an initial replication state object. currentDataState = new ReplicationState(alignedDate, 0); // Write out the initial "0" state file. replicationStore.saveState(currentDataState); }
/** * {@inheritDoc} */ @Override protected void processInitializeState(ReplicationState initialState) { Date initialDate; Date alignedDate; long intervalLength; intervalLength = getConfiguration().getIntervalLength(); initialDate = initialState.getTimestamp(); // Align the date to an interval boundary. alignedDate = alignDateToIntervalBoundary(initialDate, intervalLength); // If the date has been moved, then advance it to the next interval. We // do this because // during replication we never claim to have covered a time period that // we haven't received // data for. We may include extra data from a previous interval. By // advancing the stated // initial timestamp to the next interval our first replication will // include some data from // the previous interval. if (alignedDate.compareTo(initialDate) < 0) { alignedDate = new Date(alignedDate.getTime() + intervalLength); } // Create an initial replication state object. currentDataState = new ReplicationState(alignedDate, 0); // Write out the initial "0" state file. replicationStore.saveState(currentDataState); }
localState = new ReplicationState(localStatePersistor.loadMap());
localState = new ReplicationState(localStatePersistor.loadMap());
/** * Very basic test that launches the server, runs several replication * iterations and then shuts down without connecting any clients. * * @throws InterruptedException * if processing is interrupted. */ @Test public void testStartupShutdown() throws InterruptedException { ReplicationSequenceServer server; server = new ReplicationSequenceServer(0); server.setChangeSink(new MockReplicationDestination()); try { for (int i = 0; i < 10; i++) { ReplicationState state = new ReplicationState(); Map<String, Object> metaData = new HashMap<String, Object>(); metaData.put(ReplicationState.META_DATA_KEY, state); server.initialize(metaData); Thread.sleep(10); server.complete(); } } finally { server.close(); } } }
ReplicationState state = new ReplicationState(); Map<String, Object> metaData = new HashMap<String, Object>(1); metaData.put(ReplicationState.META_DATA_KEY, state);