org.openstreetmap.osmosis.core.apidb.v0_6.impl
Class FileReplicationDestination

java.lang.Object
  extended by org.openstreetmap.osmosis.core.apidb.v0_6.impl.FileReplicationDestination
All Implemented Interfaces:
ReplicationDestination, ReplicationStatePersister, Completable, Releasable, Task, ChangeSink

public class FileReplicationDestination
extends java.lang.Object
implements ReplicationDestination

A file-based destination for replication data. This writes files beginning at 1.osc.gz and increasing incrementally.


Constructor Summary
FileReplicationDestination(java.io.File workingDirectory)
          Creates a new instance.
 
Method Summary
 void complete()
          Ensures that all information is fully persisted.
 ReplicationState loadState()
          Loads the existing state.
 void process(ChangeContainer change)
          Process the change.
 void release()
          Performs resource cleanup tasks such as closing files, or database connections.
 void saveState(ReplicationState newState)
          Persists the state.
 boolean stateExists()
          Checks if state currently exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileReplicationDestination

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

Parameters:
workingDirectory - The directory that all files will be produced in.
Method Detail

process

public void process(ChangeContainer change)
Process the change.

Specified by:
process in interface ChangeSink
Parameters:
change - The change to be processed.

complete

public void complete()
Ensures that all information is fully persisted. This includes database commits, file buffer flushes, etc. Implementations must call complete on any nested Completable objects. Where the releasable method of a Releasable class should be called within a finally block, this method should typically be the final statement within the try block.

Specified by:
complete in interface Completable

release

public void release()
Performs resource cleanup tasks such as closing files, or database connections. This must be called after all processing is complete and may be called multiple times. Implementations must call release on any nested Releasable objects. It should be called within a finally block to ensure it is called in exception scenarios.

Specified by:
release in interface Releasable

loadState

public ReplicationState loadState()
Loads the existing state.

Specified by:
loadState in interface ReplicationStatePersister
Returns:
The state to be loaded.

saveState

public void saveState(ReplicationState newState)
Persists the state.

Specified by:
saveState in interface ReplicationStatePersister
Parameters:
newState - The state to be persisted.

stateExists

public boolean stateExists()
Checks if state currently exists. If no state exists it will need to be initialized.

Specified by:
stateExists in interface ReplicationStatePersister
Returns:
True if state exists, false otherwise.