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.impl;
  
  
This class creates a HTTP client that connects to a sequence server, listens for updated sequences as they are received, and notifies any configured listeners.

Author(s):
Brett Henderson
 
 public class SequenceClient {
 
A flag used only by the external control thread to remember if the server has been started or not.
 
 	private boolean masterRunning;
The factory for all processing threads.
 
 	private ChannelFactory factory;
The channel used to receive sequence updates from the server.
 
 	private Channel channel;


Creates a new instance.

Parameters:
serverAddress The address of the sequence server providing notification of updated sequence numbers.
channelPipelineFactory The factory for creating channel pipelines for new client connections.
 
 	public SequenceClient(InetSocketAddress serverAddress,
 			SequenceClientChannelPipelineFactory channelPipelineFactory) {
 		this. = serverAddress;
 		this. = channelPipelineFactory;
 	}


Starts the client.
 
 	public void start() {
 		if () {
 			throw new OsmosisRuntimeException("The server has already been started");
 		}
 
 		// Mark the client as running.
 		 = true;
 
 		// Create the processing thread pools.
 
 		ClientBootstrap bootstrap = new ClientBootstrap();
 		bootstrap.setOption("tcpNoDelay"true);
 		bootstrap.setOption("keepAlive"true);
 		ChannelFuture future = bootstrap.connect();
 
 		// Get a reference to the channel.
 		 = future.getChannel();
 
 		// Wait for the connection attempt to complete.
 
 		// Abort if the startup failed.
 		if (!future.isSuccess()) {
 			throw new OsmosisRuntimeException("Unable to launch sequence client.");
 		}
 	}


Stops the client. This must be called in all cases even if start failed.
 
 	public void stop() {
 		if () {
 
 			 = false;
		}
	}
New to GrepCode? Check out our FAQ X