Skip to content

Commit

Permalink
Merge pull request #60 from mgcuthbert/master
Browse files Browse the repository at this point in the history
Code consolidation and refactoring
  • Loading branch information
migurski authored Mar 31, 2020
2 parents 38bb04b + ed7c11a commit 7da5b6a
Show file tree
Hide file tree
Showing 14 changed files with 263 additions and 416 deletions.
Original file line number Diff line number Diff line change
@@ -1,47 +1,27 @@
// This software is released into the Public Domain. See copying.txt for details.
package org.openstreetmap.osmosis.replication.v0_6;

import java.io.File;

import org.openstreetmap.osmosis.core.pipeline.common.TaskConfiguration;
import org.openstreetmap.osmosis.core.pipeline.common.TaskManager;
import org.openstreetmap.osmosis.core.pipeline.common.TaskManagerFactory;
import org.openstreetmap.osmosis.core.pipeline.v0_6.RunnableChangeSourceManager;


/**
* The task manager factory for a change downloader.
*
* @author Brett Henderson
*/
public class IntervalDownloaderFactory extends TaskManagerFactory {
private static final String ARG_WORKING_DIRECTORY = "workingDirectory";
private static final String DEFAULT_WORKING_DIRECTORY = "./";

public class IntervalDownloaderFactory extends WorkingTaskManagerFactory {

/**
* {@inheritDoc}
*/
@Override
protected TaskManager createTaskManagerImpl(TaskConfiguration taskConfig) {
String workingDirectoryString;
File workingDirectory;

// Get the task arguments.
workingDirectoryString = getStringArgument(
taskConfig,
ARG_WORKING_DIRECTORY,
getDefaultStringArgument(taskConfig, DEFAULT_WORKING_DIRECTORY)
);

// Convert argument strings to strongly typed objects.
workingDirectory = new File(workingDirectoryString);

return new RunnableChangeSourceManager(
taskConfig.getId(),
new IntervalDownloader(
taskConfig.getId(),
workingDirectory
this.getWorkingDirectory(taskConfig)
),
taskConfig.getPipeArgs()
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,51 +1,34 @@
// This software is released into the Public Domain. See copying.txt for details.
package org.openstreetmap.osmosis.replication.v0_6;

import java.io.File;
import java.util.Date;
import java.util.TimeZone;

import org.openstreetmap.osmosis.core.pipeline.common.RunnableTaskManager;
import org.openstreetmap.osmosis.core.pipeline.common.TaskConfiguration;
import org.openstreetmap.osmosis.core.pipeline.common.TaskManager;
import org.openstreetmap.osmosis.core.pipeline.common.TaskManagerFactory;


/**
* The task manager factory for a change download initializer.
*
* @author Brett Henderson
*/
public class IntervalDownloaderInitializerFactory extends TaskManagerFactory {
private static final String ARG_WORKING_DIRECTORY = "workingDirectory";
public class IntervalDownloaderInitializerFactory extends WorkingTaskManagerFactory {
private static final String ARG_INITIAL_DATE = "initialDate";
private static final String DEFAULT_WORKING_DIRECTORY = "./";



/**
* {@inheritDoc}
*/
@Override
protected TaskManager createTaskManagerImpl(TaskConfiguration taskConfig) {
String workingDirectoryString;
Date initialDate;
File workingDirectory;

// Get the task arguments.
workingDirectoryString = getStringArgument(
taskConfig,
ARG_WORKING_DIRECTORY,
getDefaultStringArgument(taskConfig, DEFAULT_WORKING_DIRECTORY)
);
initialDate = getDateArgument(taskConfig, ARG_INITIAL_DATE, TimeZone.getTimeZone("UTC"));

// Convert argument strings to strongly typed objects.
workingDirectory = new File(workingDirectoryString);

return new RunnableTaskManager(
taskConfig.getId(),
new IntervalDownloaderInitializer(
workingDirectory,
this.getWorkingDirectory(taskConfig),
initialDate
),
taskConfig.getPipeArgs()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,44 +1,24 @@
// This software is released into the Public Domain. See copying.txt for details.
package org.openstreetmap.osmosis.replication.v0_6;

import java.io.File;

import org.openstreetmap.osmosis.core.pipeline.common.TaskConfiguration;
import org.openstreetmap.osmosis.core.pipeline.common.TaskManager;
import org.openstreetmap.osmosis.core.pipeline.common.TaskManagerFactory;
import org.openstreetmap.osmosis.core.pipeline.v0_6.RunnableChangeSourceManager;


/**
* The task manager factory for a replication file downloader.
*/
public class ReplicationDownloaderFactory extends TaskManagerFactory {
private static final String ARG_WORKING_DIRECTORY = "workingDirectory";
private static final String DEFAULT_WORKING_DIRECTORY = "./";

public class ReplicationDownloaderFactory extends WorkingTaskManagerFactory {

/**
* {@inheritDoc}
*/
@Override
protected TaskManager createTaskManagerImpl(TaskConfiguration taskConfig) {
String workingDirectoryString;
File workingDirectory;

// Get the task arguments.
workingDirectoryString = getStringArgument(
taskConfig,
ARG_WORKING_DIRECTORY,
getDefaultStringArgument(taskConfig, DEFAULT_WORKING_DIRECTORY)
);

// Convert argument strings to strongly typed objects.
workingDirectory = new File(workingDirectoryString);

return new RunnableChangeSourceManager(
taskConfig.getId(),
new ReplicationDownloader(
workingDirectory
this.getWorkingDirectory(taskConfig)
),
taskConfig.getPipeArgs()
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,44 +1,24 @@
// This software is released into the Public Domain. See copying.txt for details.
package org.openstreetmap.osmosis.replication.v0_6;

import java.io.File;

import org.openstreetmap.osmosis.core.pipeline.common.RunnableTaskManager;
import org.openstreetmap.osmosis.core.pipeline.common.TaskConfiguration;
import org.openstreetmap.osmosis.core.pipeline.common.TaskManager;
import org.openstreetmap.osmosis.core.pipeline.common.TaskManagerFactory;


/**
* The task manager factory for a replication file download initializer.
*/
public class ReplicationDownloaderInitializerFactory extends TaskManagerFactory {
private static final String ARG_WORKING_DIRECTORY = "workingDirectory";
private static final String DEFAULT_WORKING_DIRECTORY = "./";

public class ReplicationDownloaderInitializerFactory extends WorkingTaskManagerFactory {

/**
* {@inheritDoc}
*/
@Override
protected TaskManager createTaskManagerImpl(TaskConfiguration taskConfig) {
String workingDirectoryString;
File workingDirectory;

// Get the task arguments.
workingDirectoryString = getStringArgument(
taskConfig,
ARG_WORKING_DIRECTORY,
getDefaultStringArgument(taskConfig, DEFAULT_WORKING_DIRECTORY)
);

// Convert argument strings to strongly typed objects.
workingDirectory = new File(workingDirectoryString);

return new RunnableTaskManager(
taskConfig.getId(),
new ReplicationDownloaderInitializer(
workingDirectory
this.getWorkingDirectory(taskConfig)
),
taskConfig.getPipeArgs()
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,44 +1,25 @@
// This software is released into the Public Domain. See copying.txt for details.
package org.openstreetmap.osmosis.replication.v0_6;

import java.io.File;

import org.openstreetmap.osmosis.core.pipeline.common.RunnableTaskManager;
import org.openstreetmap.osmosis.core.pipeline.common.TaskConfiguration;
import org.openstreetmap.osmosis.core.pipeline.common.TaskManager;
import org.openstreetmap.osmosis.core.pipeline.common.TaskManagerFactory;


/**
* The task manager factory for a replication file merger.
*/
public class ReplicationFileMergerFactory extends TaskManagerFactory {
private static final String ARG_WORKING_DIRECTORY = "workingDirectory";
private static final String DEFAULT_WORKING_DIRECTORY = "./";

public class ReplicationFileMergerFactory extends WorkingTaskManagerFactory {

/**
* {@inheritDoc}
*/
@Override
protected TaskManager createTaskManagerImpl(TaskConfiguration taskConfig) {
String workingDirectoryString;
File workingDirectory;

// Get the task arguments.
workingDirectoryString = getStringArgument(
taskConfig,
ARG_WORKING_DIRECTORY,
getDefaultStringArgument(taskConfig, DEFAULT_WORKING_DIRECTORY)
);

// Convert argument strings to strongly typed objects.
workingDirectory = new File(workingDirectoryString);

return new RunnableTaskManager(
taskConfig.getId(),
new ReplicationFileMerger(
workingDirectory
this.getWorkingDirectory(taskConfig)
),
taskConfig.getPipeArgs()
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,44 +1,24 @@
// This software is released into the Public Domain. See copying.txt for details.
package org.openstreetmap.osmosis.replication.v0_6;

import java.io.File;

import org.openstreetmap.osmosis.core.pipeline.common.RunnableTaskManager;
import org.openstreetmap.osmosis.core.pipeline.common.TaskConfiguration;
import org.openstreetmap.osmosis.core.pipeline.common.TaskManager;
import org.openstreetmap.osmosis.core.pipeline.common.TaskManagerFactory;


/**
* The task manager factory for a replication file merger initializer.
*/
public class ReplicationFileMergerInitializerFactory extends TaskManagerFactory {
private static final String ARG_WORKING_DIRECTORY = "workingDirectory";
private static final String DEFAULT_WORKING_DIRECTORY = "./";

public class ReplicationFileMergerInitializerFactory extends WorkingTaskManagerFactory {

/**
* {@inheritDoc}
*/
@Override
protected TaskManager createTaskManagerImpl(TaskConfiguration taskConfig) {
String workingDirectoryString;
File workingDirectory;

// Get the task arguments.
workingDirectoryString = getStringArgument(
taskConfig,
ARG_WORKING_DIRECTORY,
getDefaultStringArgument(taskConfig, DEFAULT_WORKING_DIRECTORY)
);

// Convert argument strings to strongly typed objects.
workingDirectory = new File(workingDirectoryString);

return new RunnableTaskManager(
taskConfig.getId(),
new ReplicationFileMergerInitializer(
workingDirectory
this.getWorkingDirectory(taskConfig)
),
taskConfig.getPipeArgs()
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,54 +1,35 @@
// This software is released into the Public Domain. See copying.txt for details.
package org.openstreetmap.osmosis.replication.v0_6;

import java.io.File;

import org.openstreetmap.osmosis.core.pipeline.common.RunnableTaskManager;
import org.openstreetmap.osmosis.core.pipeline.common.TaskConfiguration;
import org.openstreetmap.osmosis.core.pipeline.common.TaskManager;
import org.openstreetmap.osmosis.core.pipeline.common.TaskManagerFactory;


/**
* The task manager factory for a replication lag reader.
*
* @author Peter Koerner
*/
public class ReplicationLagReaderFactory extends TaskManagerFactory {
public class ReplicationLagReaderFactory extends WorkingTaskManagerFactory {
private static final String ARG_HUMAN_READABLE = "humanReadable";
private static final boolean DEFAULT_HUMAN_READABLE = false;
private static final String ARG_WORKING_DIRECTORY = "workingDirectory";
private static final String DEFAULT_WORKING_DIRECTORY = "./";


/**
* {@inheritDoc}
*/
@Override
protected TaskManager createTaskManagerImpl(TaskConfiguration taskConfig) {
String workingDirectoryString;
boolean humanReadableFlag;
File workingDirectory;

// Get the task arguments.
workingDirectoryString = getStringArgument(
taskConfig,
ARG_WORKING_DIRECTORY,
getDefaultStringArgument(taskConfig, DEFAULT_WORKING_DIRECTORY)
);
humanReadableFlag = getBooleanArgument(
taskConfig,
ARG_HUMAN_READABLE,
DEFAULT_HUMAN_READABLE
);

// Convert argument strings to strongly typed objects.
workingDirectory = new File(workingDirectoryString);

return new RunnableTaskManager(
taskConfig.getId(),
new ReplicationLagReader(
workingDirectory,
this.getWorkingDirectory(taskConfig),
humanReadableFlag
),
taskConfig.getPipeArgs()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,23 @@
// This software is released into the Public Domain. See copying.txt for details.
package org.openstreetmap.osmosis.replication.v0_6;

import java.io.File;

import org.openstreetmap.osmosis.core.pipeline.common.TaskConfiguration;
import org.openstreetmap.osmosis.core.pipeline.common.TaskManager;
import org.openstreetmap.osmosis.core.pipeline.common.TaskManagerFactory;
import org.openstreetmap.osmosis.core.pipeline.v0_6.ChangeSinkChangeSourceManager;


/**
* The task manager factory for a replication to change writer.
*/
public class ReplicationToChangeWriterFactory extends TaskManagerFactory {
private static final String ARG_WORKING_DIRECTORY = "workingDirectory";
private static final String DEFAULT_WORKING_DIRECTORY = "./";

public class ReplicationToChangeWriterFactory extends WorkingTaskManagerFactory {

/**
* {@inheritDoc}
*/
@Override
protected TaskManager createTaskManagerImpl(TaskConfiguration taskConfig) {
String workingDirectoryString;
File workingDirectory;

// Get the task arguments.
workingDirectoryString = getStringArgument(taskConfig, ARG_WORKING_DIRECTORY,
getDefaultStringArgument(taskConfig, DEFAULT_WORKING_DIRECTORY));

// Convert argument strings to strongly typed objects.
workingDirectory = new File(workingDirectoryString);

return new ChangeSinkChangeSourceManager(
taskConfig.getId(),
new ReplicationToChangeWriter(workingDirectory),
new ReplicationToChangeWriter(this.getWorkingDirectory(taskConfig)),
taskConfig.getPipeArgs());
}
}
Loading

0 comments on commit 7da5b6a

Please sign in to comment.