Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  // This software is released into the Public Domain.  See copying.txt for details.
  package org.openstreetmap.osmosis.replicationhttp.v0_6;
  import java.util.Map;
This task creates a HTTP server that sends updated replication sequence numbers to clients. It is notified of updated sequence numbers as they occur by being inserted into the middle of a replication pipeline.

Brett Henderson
 public class ReplicationSequenceServer implements ChangeSinkChangeSource {
 	private static final Logger LOG = Logger.getLogger(ReplicationSequenceServer.class.getName());
 	private ChangeSink changeSink;
 	private long sequenceNumber;
 	private SequenceServer server;
 	private boolean serverStarted;

Creates a new instance.

port The port to listen on.
 	public ReplicationSequenceServer(int port) {
 		 = false;
 	public void setChangeSink(ChangeSink changeSink) {
 		this. = changeSink;

Returns the port that is being used to listen for new connections.

The port number.
 	public int getPort() {
 		return .getPort();
 	public void initialize(Map<StringObjectmetaData) {
 		// Get the replication state from the upstream task.
 			throw new OsmosisRuntimeException("No replication state has been provided in metadata key "
 		// Call the downstream initialize which will among other things
 		// initialise the state.
 		// We must only read from the state object during initialize and
 		// complete because it may be updated by other threads at other times.
 		// If the sequence id is still 0 then replication hasn't been fully
 		// initialized and we can't start the server yet.
 		if ( > 0 && !) {
 			// We can start the server now. We give it the previous sequence
 			// number because the current one is still in progress.
 			 = true;
 	public void process(ChangeContainer change) {
 	public void complete() {
		// The sink has completed persisting the replication so now we must
		// notify the server which will notify the listening clients.
		if (!) {
			 = true;
else {
	public void release() {
			try {
catch (RuntimeException e) {
				.log(."Replication sequence server stop failed."e);
			 = false;
New to GrepCode? Check out our FAQ X