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.onap.dmaap.dbcapi.server;
22 import java.net.InetAddress;
23 import java.util.Properties;
24 import java.util.UUID;
26 import org.onap.dmaap.dbcapi.authentication.ApiPerms;
27 import org.onap.dmaap.dbcapi.authentication.ApiPolicy;
28 import org.onap.dmaap.dbcapi.database.DatabaseClass;
29 import org.onap.dmaap.dbcapi.logging.*;
30 import org.onap.dmaap.dbcapi.model.Dmaap;
31 import org.onap.dmaap.dbcapi.util.DmaapConfig;
32 import org.onap.dmaap.dbcapi.util.Singleton;
34 import static com.att.eelf.configuration.Configuration.*;
38 public class Main extends BaseLoggingClass {
41 private Properties parameters;
42 private static String provFQDN;
44 public static String getProvFQDN() {
47 public void setProvFQDN(String provFQDN) {
48 Main.provFQDN = provFQDN;
52 public static void main(String[] args) throws Exception {
60 MDC.put(MDC_SERVICE_INSTANCE_ID, "");
62 MDC.put(MDC_SERVER_FQDN, InetAddress.getLocalHost().getHostName());
63 MDC.put(MDC_SERVER_IP_ADDRESS, InetAddress.getLocalHost().getHostAddress());
64 } catch (Exception e) {
67 MDC.put(MDC_INSTANCE_UUID, UUID.randomUUID().toString());
68 MDC.put(MDC_ALERT_SEVERITY, "0");
71 MDC.put(MDC_TARGET_ENTITY, "DCAE");
75 String msg = "This is a sample {} message to demo EELF logging.";
77 appLogger.info( msg, "appLogger.info");
79 auditLogger.auditEvent( msg, "auditLogger.auditEvent");
80 errorLogger.error(DmaapbcLogMessageEnum.MESSAGE_SAMPLE_NOARGS);
81 errorLogger.error(DmaapbcLogMessageEnum.MESSAGE_SAMPLE_ONE_ARG, "errorLogger.error");
82 errorLogger.error(DmaapbcLogMessageEnum.MESSAGE_SAMPLE_TWO_ARGS, new Date().toString(), "errorLogger.error" );
83 metricsLogger.metricsEvent( msg, "metricsLogger.metricsEvent" );
84 debugLogger.debug( msg, "debugLogger.debug");
86 //String log = System.getProperty( "log4j.configuration");
87 //if ( log.isEmpty() ) {
88 // log = "log4j.properties";
90 //PropertyConfigurator.configure( log );
93 appLogger.info("Started.");
94 parameters = DmaapConfig.getConfig();
95 setProvFQDN( parameters.getProperty("ProvFQDN", "ProvFQDN.notset.com"));
98 // for fresh installs, we may come up with no dmaap name so need to have a way for Controller to talk to us
99 Singleton<Dmaap> dmaapholder = DatabaseClass.getDmaap();
100 String name = dmaapholder.get().getDmaapName();
101 ApiPolicy apiPolicy = new ApiPolicy();
102 if ( apiPolicy.getUseAuthClass() && (name == null || name.isEmpty())) {
103 ApiPerms p = new ApiPerms();
109 new JettyServer( parameters );
110 } catch (Exception e) {
111 errorLogger.error("Unable to start Jetty " + DmaapConfig.getConfigFileName(), e);