Source:
protected void run(Bootstrap<SuripuConfiguration> bootstrap, Namespace namespace, SuripuConfiguration configuration) throws Exception { final DateTime startDate = DateTime.parse(namespace.getString("start_date") + " PST", DateTimeFormat.forPattern(DateTimeFormatString.FORMAT_TO_DAY + " z")); final DateTime endDate = DateTime.parse(namespace.getString("end_date") + " PST", DateTimeFormat.forPattern(DateTimeFormatString.FORMAT_TO_DAY + " z")); long accountId = Long.valueOf(namespace.getString("account_id")); final AWSCredentialsProvider awsCredentialsProvider= new DefaultAWSCredentialsProviderChain(); final AmazonDynamoDBClient dynamoDBClient = new AmazonDynamoDBClient(awsCredentialsProvider); dynamoDBClient.setEndpoint(configuration.getMotionDBConfiguration().getEndpoint()); final String tableName = configuration.getMotionDBConfiguration().getKeyStoreTable(); final TrackerMotionDAODynamoDB trackerMotionDAODynamoDB = new TrackerMotionDAODynamoDB(dynamoDBClient, tableName); final ManagedDataSourceFactory managedDataSourceFactory = new ManagedDataSourceFactory(); final ManagedDataSource dataSource = managedDataSourceFactory.build(configuration.getDatabaseConfiguration()); final DBI jdbi = new DBI(dataSource); jdbi.registerArgumentFactory(new OptionalArgumentFactory(configuration.getDatabaseConfiguration().getDriverClass())); jdbi.registerContainerFactory(new ImmutableListContainerFactory()); jdbi.registerContainerFactory(new ImmutableSetContainerFactory()); jdbi.registerContainerFactory(new OptionalContainerFactory()); jdbi.registerArgumentFactory(new JodaArgumentFactory()); final TrackerMotionDAO trackerMotionDAO = jdbi.onDemand(TrackerMotionDAO.class); final ImmutableList<TrackerMotion> oldDataFromPostgres = trackerMotionDAO.getBetween(accountId, startDate.plusHours(12), endDate.plusHours(12).plusDays(1)); trackerMotionDAODynamoDB.setTrackerMotions(accountId, oldDataFromPostgres); System.out.println("Migrate data for account_id: " + accountId + " from " + startDate + " to " + endDate + " succeeded"); }

Target:
protected void run(Bootstrap<SuripuConfiguration> bootstrap, Namespace namespace, SuripuConfiguration configuration) throws Exception { final DateTime startDate = DateTime.parse(namespace.getString("start_date") + " PST", DateTimeFormat.forPattern(DateTimeFormatString.FORMAT_TO_DAY + " z")); final DateTime endDate = DateTime.parse(namespace.getString("end_date") + " PST", DateTimeFormat.forPattern(DateTimeFormatString.FORMAT_TO_DAY + " z")); long accountId = Long.valueOf(namespace.getString("account_id")); final AWSCredentialsProvider awsCredentialsProvider= new DefaultAWSCredentialsProviderChain(); final AmazonDynamoDBClient dynamoDBClient = new AmazonDynamoDBClient(awsCredentialsProvider); dynamoDBClient.setEndpoint(configuration.getMotionDBConfiguration().getEndpoint()); final String tableName = configuration.getMotionDBConfiguration().getKeyStoreTable(); final TrackerMotionDAODynamoDB trackerMotionDAODynamoDB = new TrackerMotionDAODynamoDB(dynamoDBClient, tableName); final ManagedDataSourceFactory managedDataSourceFactory = new ManagedDataSourceFactory(); final ManagedDataSource dataSource = managedDataSourceFactory.build(configuration.getDatabaseConfiguration()); final DBI jdbi = new DBI(dataSource); jdbi.registerArgumentFactory(new OptionalArgumentFactory(configuration.getDatabaseConfiguration().getDriverClass())); jdbi.registerContainerFactory(new ImmutableListContainerFactory()); jdbi.registerContainerFactory(new ImmutableSetContainerFactory()); jdbi.registerContainerFactory(new OptionalContainerFactory()); jdbi.registerArgumentFactory(new JodaArgumentFactory()); final TrackerMotionDAO trackerMotionDAO = jdbi.onDemand(TrackerMotionDAO.class); final ImmutableList<TrackerMotion> oldDataFromPostgres = trackerMotionDAO.getBetween(accountId, startDate, endDate.plusHours(23).plusMinutes(59).plusSeconds(59).plusMillis(999)); trackerMotionDAODynamoDB.setTrackerMotions(accountId, oldDataFromPostgres); System.out.println("Migrate data for account_id: " + accountId + " from " + startDate + " to " + endDate + " succeeded"); }