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.io.File;
  
This task creates a HTTP server that sends updated replication data to clients. It is notified of updated sequence numbers as they occur by connecting to a replication sequence server.

Author(s):
Brett Henderson
 
 public class ReplicationDataServer implements RunnableTask {
 
 	private int notificationPort;
 	private File dataDirectory;
 	private int port;


Creates a new instance.

Parameters:
notificationPort The port to connect to for notification updates.
dataDirectory The location of the replication data and state files.
port The port to listen on.
 
 	public ReplicationDataServer(int notificationPortFile dataDirectoryint port) {
 		this. = notificationPort;
 		this. = dataDirectory;
 		this. = port;
 	}


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

Returns:
The port number.
 
 	public int getPort() {
 		return ;
 	}
 
 
 	private long getCurrentSequenceNumber() {
 		try {
 		} catch (MalformedURLException e) {
 			throw new OsmosisRuntimeException("Unable to get the current sequence number"e);
 		}
 	}
 
 
 	public void run() {
 		// Instantiate the replication data server.
 
 		// Configure a listener to send sequence number events from the
 		// client to the server.
 			public void notifySequenceNumber(long sequenceNumber) {
 				server.update(sequenceNumber);
 			}
 		};
 
 		// Create a sequence client restart manager so that our sequence
 		// client continues processing in the face of temporary connectivity
 		// issues.
 
 		// Create the client for receiving updated sequence numbers..
 		SequenceNumberClientChannelPipelineFactory channelPipelineFactory =
 						clientRestartManager.getControl(), numberListener"localhost");
 		SequenceClient client = new SequenceClient(new InetSocketAddress(), channelPipelineFactory);
 
 		try {
 			// Start the server with the current replication number.
 
 			// Update the port. It may have been allocated dynamically if the
			// port was specified as 0.
			 = server.getPort();
			// Run the client and perform restarts if it fails. This call will
			// block.
			clientRestartManager.manageClient(client);
finally {
			server.stop();
		}
	}
New to GrepCode? Check out our FAQ X