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.TitanGraphInitializer;
24 import org.openecomp.sdc.be.config.ConfigurationManager;
25 import org.openecomp.sdc.be.dao.cassandra.schema.SdcSchemaBuilder;
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;
31 public class DataSchemaMenu {
33 private static Logger log = Logger.getLogger(DataSchemaMenu.class.getName());
35 public static void main(String[] args) {
37 String operation = args[0];
39 String appConfigDir = args[1];
41 if (args == null || args.length < 2) {
45 ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
46 ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
48 switch (operation.toLowerCase()) {
49 case "create-cassandra-structures":
50 log.debug("Start create cassandra keyspace, tables and indexes");
51 if (SdcSchemaBuilder.createSchema()) {
52 log.debug("create cassandra keyspace, tables and indexes successfull");
55 log.debug("create cassandra keyspace, tables and indexes failed");
59 case "create-titan-structures":
60 log.debug("Start create titan keyspace");
61 String titanCfg = 2 == args.length ? configurationManager.getConfiguration().getTitanCfgFile() : args[2];
62 if (TitanGraphInitializer.createGraph(titanCfg)) {
63 log.debug("create titan keyspace successfull");
66 log.debug("create titan keyspace failed");
70 case "clean-cassndra":
71 log.debug("Start clean keyspace, tables");
72 if (SdcSchemaBuilder.deleteSchema()) {
73 log.debug(" successfull");
86 private static void usageAndExit() {
91 private static void DataSchemeUsage() {
92 System.out.println("Usage: create-cassandra-structures <configuration dir> ");
93 System.out.println("Usage: create-titan-structures <configuration dir> ");