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.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
33 public class EsToCassandraDataMigrationMenu {
35 private static Logger log = LoggerFactory.getLogger(EsToCassandraDataMigrationMenu.class.getName());
37 public static void main(String[] args) {
39 if (args == null || args.length < 2) {
42 String operation = args[0];
44 String appConfigDir = args[1];
45 System.setProperty("config.home", appConfigDir);
46 ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
48 ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
50 AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
51 EsToCassandraDataMigrationConfig.class);
52 DataMigration dataMigration = null;
54 switch (operation.toLowerCase()) {
55 case "es-to-cassndra-migration":
56 dataMigration = (DataMigration) context.getBean("DataMigrationBean");
57 log.debug("Start migration from ES to C* ");
58 if (dataMigration.migrateDataEsToCassandra(appConfigDir, true, true)) {
59 log.debug("migration from ES to C* was finished successfull");
62 log.debug("migration from ES to C* failed");
66 case "es-to-cassndra-migration-export-only":
67 dataMigration = (DataMigration) context.getBean("DataMigrationBean");
68 log.debug("Start migration export only from ES to C* ");
69 if (dataMigration.migrateDataEsToCassandra(appConfigDir, true, false)) {
70 log.debug("migration export only from ES to C* was finished successfull");
73 log.debug("migration export only from ES to C* failed");
77 case "es-to-cassndra-migration-import-only":
78 dataMigration = (DataMigration) context.getBean("DataMigrationBean");
79 log.debug("Start migration import only from ES to C* ");
80 if (dataMigration.migrateDataEsToCassandra(appConfigDir, false, true)) {
81 log.debug("migration import only from ES to C* was finished successfull");
84 log.debug("migration import only from ES to C* failed");
91 } catch (Throwable t) {
97 private static void usageAndExit() {
102 private static void MigrationUsage() {
104 "Usage: es-to-cassndra-migration/es-to-cassndra-migration-import-only/es-to-cassndra-migration-export-only <configuration dir>");