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.replication.common;
  
  import java.util.Date;
  import java.util.HashMap;
  import java.util.Map;
  
Contains the state to be remembered between replication invocations. This state ensures that no data is missed during replication, and ensures that none is repeated except after certain failure situations.
 
 public class ReplicationState {
The key used when passing an instance through the pipeline as metadata.
 
 	public static final String META_DATA_KEY = "replication.state";
 	
 	
 	private Date timestamp;
 	private long sequenceNumber;


Creates a new instance with all values set to defaults.
 
 	public ReplicationState() {
 		this. = new Date(0);
 		this. = 0;
 	}


Creates a new instance.

Parameters:
timestamp The maximum timestamp of data currently read from the database.
sequenceNumber The replication sequence number.
 
 	public ReplicationState(Date timestamplong sequenceNumber) {
 		this. = timestamp;
 		this. = sequenceNumber;
 	}


Creates a new instance.

Parameters:
properties The properties to load state from.
 
 	public ReplicationState(Map<StringStringproperties) {
 		load(properties);
 	}
 	
 	
 	private String loadProperty(Map<StringStringpropertiesString key) {
 		if (!properties.containsKey(key)) {
 			throw new OsmosisRuntimeException("The replication state doesn't contain a " + key + " property.");
 		}
 		return properties.get(key);
 	}


Loads all state from the provided properties object.

Parameters:
properties The properties to be read.
 
 	public void load(Map<StringStringproperties) {
 		 = new DateParser().parse(loadProperty(properties"timestamp"));
 		 = Long.parseLong(loadProperty(properties"sequenceNumber"));
 	}


Writes all state into the provided properties object.

Parameters:
properties The properties to be updated.
 
 	public void store(Map<StringStringproperties) {
 		properties.put("timestamp"new DateFormatter().format());
 		properties.put("sequenceNumber", Long.toString());
 	}


Writes all state into a new properties object.

Returns:
The properties.
 
	public Map<StringStringstore() {
		Map<StringStringproperties = new HashMap<StringString>();
		store(properties);
		return properties;
	}


Gets the maximum timestamp of data currently read from the database.

Returns:
The timestamp.
	public Date getTimestamp() {
		return ;
	}


Sets the maximum timestamp of data currently read from the database.

Parameters:
timestamp The timestamp.
	public void setTimestamp(Date timestamp) {
		this. = timestamp;
	}


Gets the replication sequence number.

Returns:
The sequence number.
	public long getSequenceNumber() {
	}


Sets the replication sequence number.

Parameters:
sequenceNumber The sequence number.
	public void setSequenceNumber(long sequenceNumber) {
		this. = sequenceNumber;
	}


	public boolean equals(Object obj) {
		boolean result;
		if (obj instanceof ReplicationState) {
			ReplicationState compareState = (ReplicationStateobj;
			if (.equals(compareState.timestamp)
					&&  == compareState.sequenceNumber) {
				result = true;
else {
				result = false;
			}
else {
			result = false;
		}
		return result;
	}


	public int hashCode() {
		return (int + (int.getTime();
	}


	public String toString() {
		return "ReplicationState(timestamp=" +  + ", sequenceNumber=" +  + ")";
	}
New to GrepCode? Check out our FAQ X