2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.asdctool.main;
23 import org.openecomp.sdc.asdctool.impl.DataMigration;
24 import org.openecomp.sdc.asdctool.impl.EsToCassandraDataMigrationConfig;
25 import org.openecomp.sdc.be.config.ConfigurationManager;
26 import org.openecomp.sdc.common.api.ConfigurationSource;
27 import org.openecomp.sdc.common.impl.ExternalConfiguration;
28 import org.openecomp.sdc.common.impl.FSConfigurationSource;
29 import org.openecomp.sdc.common.log.wrappers.Logger;
30 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
32 public class EsToCassandraDataMigrationMenu {
34 private static Logger log = Logger.getLogger(EsToCassandraDataMigrationMenu.class.getName());
36 public static void main(String[] args) {
38 if (args == null || args.length < 2) {
41 String operation = args[0];
43 String appConfigDir = args[1];
44 System.setProperty("config.home", appConfigDir);
45 ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
47 ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
49 AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
50 EsToCassandraDataMigrationConfig.class);
51 DataMigration dataMigration = null;
53 switch (operation.toLowerCase()) {
54 case "es-to-cassndra-migration":
55 dataMigration = (DataMigration) context.getBean("DataMigrationBean");
56 log.debug("Start migration from ES to C* ");
57 if (dataMigration.migrateDataESToCassndra(appConfigDir, true, true)) {
58 log.debug("migration from ES to C* was finished successfull");
61 log.debug("migration from ES to C* failed");
65 case "es-to-cassndra-migration-export-only":
66 dataMigration = (DataMigration) context.getBean("DataMigrationBean");
67 log.debug("Start migration export only from ES to C* ");
68 if (dataMigration.migrateDataESToCassndra(appConfigDir, true, false)) {
69 log.debug("migration export only from ES to C* was finished successfull");
72 log.debug("migration export only from ES to C* failed");
76 case "es-to-cassndra-migration-import-only":
77 dataMigration = (DataMigration) context.getBean("DataMigrationBean");
78 log.debug("Start migration import only from ES to C* ");
79 if (dataMigration.migrateDataESToCassndra(appConfigDir, false, true)) {
80 log.debug("migration import only from ES to C* was finished successfull");
83 log.debug("migration import only from ES to C* failed");
90 } catch (Throwable t) {
91 log.info("data migration failed - {}", t);
96 private static void usageAndExit() {
101 private static void MigrationUsage() {
103 "Usage: es-to-cassndra-migration/es-to-cassndra-migration-import-only/es-to-cassndra-migration-export-only <configuration dir>");