Package org.openstreetmap.osmosis.core.util

Examples of org.openstreetmap.osmosis.core.util.PropertiesPersister


    return new File(dataDirectory, sequenceFormatter.getFormattedName(sequenceNumber, ".osc.gz"));
  }


  private ReplicationState getReplicationState(long sequenceNumber) {
    PropertiesPersister persister = new PropertiesPersister(getStateFile(sequenceNumber));
    ReplicationState state = new ReplicationState();
    state.load(persister.loadMap());

    return state;
  }
View Full Code Here


   *
   * @param configFile
   *            The configuration file to read from.
   */
  public IntervalDownloaderConfiguration(File configFile) {
    properties = new PropertiesPersister(configFile).load();
  }
View Full Code Here

   *
   * @param configFile
   *            The configuration file to read from.
   */
  public ReplicationFileMergerConfiguration(File configFile) {
    properties = new PropertiesPersister(configFile).load();
  }
View Full Code Here

   *
   * @param configFile
   *            The configuration file to read from.
   */
  public ReplicationDownloaderConfiguration(File configFile) {
    properties = new PropertiesPersister(configFile).load();
  }
View Full Code Here

  private void runImpl() {
    try {
      ReplicationDownloaderConfiguration configuration;
      ReplicationState serverState;
      ReplicationState localState;
      PropertiesPersister localStatePersistor;
     
      // Instantiate utility objects.
      configuration = new ReplicationDownloaderConfiguration(new File(workingDirectory, CONFIG_FILE));
     
      // Obtain the server state.
      LOG.fine("Reading current server state.");
      serverState = serverStateReader.getServerState(configuration.getBaseUrl());
     
      // Build the local state persister which is used for both loading and storing local state.
      localStatePersistor = new PropertiesPersister(new File(workingDirectory, LOCAL_STATE_FILE));
     
      // Begin processing.
      processInitialize(Collections.<String, Object>emptyMap());
     
      // If local state isn't available we need to copy server state to be the initial local state
      // then exit.
      if (localStatePersistor.exists()) {
        localState = new ReplicationState(localStatePersistor.loadMap());
       
        // Download and process the replication files.
        localState = download(configuration, serverState, localState);
       
      } else {
        localState = serverState;
       
        processInitializeState(localState);
      }
     
      // Commit downstream changes.
      processComplete();
     
      // Persist the local state.
      localStatePersistor.store(localState.store());
     
    } finally {
      processRelease();
    }
  }
View Full Code Here

    // Create the lock object used to ensure only a single process attempts
    // to write to the data directory.
    fileLock = new FileBasedLock(new File(workingDirectory, LOCK_FILE));

    // Create the object used to persist current state.
    statePersistor = new PropertiesPersister(new File(workingDirectory, STATE_FILE));
  }
View Full Code Here

    return pathPrefix + "/replicationData/" + requestSequenceNumber + "/tail";
  }


  private ReplicationState loadState(File stateFile) {
    PropertiesPersister persister = new PropertiesPersister(stateFile);
    ReplicationState state = new ReplicationState();
    state.load(persister.loadMap());

    return state;
  }
View Full Code Here

   */
  private void getLag() {
    ReplicationDownloaderConfiguration configuration;
    ReplicationState serverState;
    ReplicationState localState;
    PropertiesPersister localStatePersistor;
   
    // Instantiate utility objects.
    configuration = new ReplicationDownloaderConfiguration(new File(workingDirectory, CONFIG_FILE));
   
    // Obtain the server state.
    LOG.fine("Reading current server state.");
    serverState = serverStateReader.getServerState(configuration.getBaseUrl());
   
    // Build the local state persister which is used for both loading and storing local state.
    localStatePersistor = new PropertiesPersister(new File(workingDirectory, LOCAL_STATE_FILE));
   
    // If local state isn't available we need to fail because no lag can be calculated.
    if (!localStatePersistor.exists()) {
      throw new OsmosisRuntimeException("Can't read local state.");
    }
   
    // fetch the local state from the file
    localState = new ReplicationState(localStatePersistor.loadMap());
   
    // extract the time of the local and the remote state files
    long local = localState.getTimestamp().getTime();
    long server = serverState.getTimestamp().getTime();
   
View Full Code Here

   *            If true, the current state will be updated by the
   *            {@link #saveState(ReplicationState)} operation as well as the
   *            sequenced state.
   */
  public FileReplicationStore(File storeDirectory, boolean saveCurrentState) {
    currentStatePersister = new PropertiesPersister(new File(storeDirectory, STATE_FILE));
    sequenceFormatter = new ReplicationFileSequenceFormatter(storeDirectory);
    this.saveCurrentState = saveCurrentState;
  }
View Full Code Here


  @Override
  public ReplicationState getState(long sequence) {
    File stateFile = sequenceFormatter.getFormattedName(sequence, ".state.txt");
    return new ReplicationState(new PropertiesPersister(stateFile).loadMap());
  }
View Full Code Here

TOP

Related Classes of org.openstreetmap.osmosis.core.util.PropertiesPersister

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.