All Downloads are FREE. Search and download functionalities are using the official Maven repository.

za.co.absa.enceladus.migrationscli.ContinuousMigratorApp.scala Maven / Gradle / Ivy

/*
 * Copyright 2018 ABSA Group Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package za.co.absa.enceladus.migrationscli

import org.mongodb.scala.MongoClient
import za.co.absa.enceladus.migrations.continuous.migrate01.ContinuousMigrator
import za.co.absa.enceladus.migrationscli.cmd.ContinuousMigratorCmdConfig

/**
  * This is a command line tool for running continuous migration from version 0 to version 1
  * on 2 MongoDb databases.
  *
  * Syntax:
  *   java -cp enceladus-migrations-cli.jar za.co.absa.enceladus.migrationscli.ContinuousMigratorApp \
  *     --src-mongodb-url 
  *     --trg-mongodb-url 
  *     --src-database 
  *     --trg-database 
  */
object ContinuousMigratorApp {

  def main(args: Array[String]): Unit = {

    val cmd = ContinuousMigratorCmdConfig(args)

    val mongoClientSrc = MongoClient(cmd.mongoDbUrlSrc)
    val mongoClientTrg = MongoClient(cmd.mongoDbUrlTrg)

    try {
      val dbSrc = mongoClientSrc.getDatabase(cmd.databaseSrc)
      val dbTrg = mongoClientTrg.getDatabase(cmd.databaseTrg)

      val mig = new ContinuousMigrator(dbSrc, dbTrg)

      mig.migrate()
    } finally {
      mongoClientSrc.close()
      mongoClientTrg.close()
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy