org.openstreetmap.osmosis.core.merge.v0_6
Class ReplicationDownloader

java.lang.Object
  extended by org.openstreetmap.osmosis.core.merge.v0_6.BaseReplicationDownloader
      extended by org.openstreetmap.osmosis.core.merge.v0_6.ReplicationDownloader
All Implemented Interfaces:
java.lang.Runnable, RunnableTask, Task, ChangeSource, RunnableChangeSource

public class ReplicationDownloader
extends BaseReplicationDownloader
implements RunnableChangeSource

Downloads a set of replication files from a HTTP server, and merges them into a single output stream. It tracks the intervals covered by the current files and stores the current timestamp between invocations forming the basis of a replication mechanism.

Author:
Brett Henderson

Constructor Summary
ReplicationDownloader(java.io.File workingDirectory)
          Creates a new instance.
 
Method Summary
protected  void processChangeset(XmlChangeReader xmlReader, ReplicationState replicationState)
          Processes the changeset.
protected  void processComplete()
          This is implemented by sub-classes and is called when all changesets have been processed.
protected  void processInitialize(ReplicationState initialState)
          Invoked once during the first execution run to allow initialisation based on the initial replication state downloaded from the server.
protected  void processRelease()
          This is implemented by sub-classes and is called and the completion of all processing regardless of whether it was successful or not.
 void setChangeSink(ChangeSink changeSink)
          Sets the change sink to send data to.
 
Methods inherited from class org.openstreetmap.osmosis.core.merge.v0_6.BaseReplicationDownloader
calculateMaximumTimestamp, getWorkingDirectory, run
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Runnable
run
 

Constructor Detail

ReplicationDownloader

public ReplicationDownloader(java.io.File workingDirectory)
Creates a new instance.

Parameters:
workingDirectory - The directory containing configuration and tracking files.
Method Detail

setChangeSink

public void setChangeSink(ChangeSink changeSink)
Sets the change sink to send data to.

Specified by:
setChangeSink in interface ChangeSource
Parameters:
changeSink - The sink for receiving all produced data.

processInitialize

protected void processInitialize(ReplicationState initialState)
Invoked once during the first execution run to allow initialisation based on the initial replication state downloaded from the server.

Specified by:
processInitialize in class BaseReplicationDownloader
Parameters:
initialState - The first server state.

processChangeset

protected void processChangeset(XmlChangeReader xmlReader,
                                ReplicationState replicationState)
Processes the changeset.

Specified by:
processChangeset in class BaseReplicationDownloader
Parameters:
xmlReader - The changeset reader initialised to point to the changeset file.
replicationState - The replication state associated with the changeset file.

processComplete

protected void processComplete()
This is implemented by sub-classes and is called when all changesets have been processed. This should perform any completion tasks such as committing changes to a database.

Specified by:
processComplete in class BaseReplicationDownloader

processRelease

protected void processRelease()
This is implemented by sub-classes and is called and the completion of all processing regardless of whether it was successful or not. This should perform any cleanup tasks such as closing files or releasing database connections.

Specified by:
processRelease in class BaseReplicationDownloader