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.database.DatabaseClass;
28 import org.onap.dmaap.dbcapi.logging.*;
29 import org.onap.dmaap.dbcapi.model.Dmaap;
30 import org.onap.dmaap.dbcapi.util.DmaapConfig;
31 import org.onap.dmaap.dbcapi.util.Singleton;
33 import static com.att.eelf.configuration.Configuration.*;
37 public class Main extends BaseLoggingClass {
40 private Properties parameters;
41 private static String provFQDN;
43 public static String getProvFQDN() {
46 public void setProvFQDN(String provFQDN) {
47 Main.provFQDN = provFQDN;
51 public static void main(String[] args) throws Exception {
59 MDC.put(MDC_SERVICE_INSTANCE_ID, "");
61 MDC.put(MDC_SERVER_FQDN, InetAddress.getLocalHost().getHostName());
62 MDC.put(MDC_SERVER_IP_ADDRESS, InetAddress.getLocalHost().getHostAddress());
63 } catch (Exception e) {
66 MDC.put(MDC_INSTANCE_UUID, UUID.randomUUID().toString());
67 MDC.put(MDC_ALERT_SEVERITY, "0");
70 MDC.put(MDC_TARGET_ENTITY, "DCAE");
74 String msg = "This is a sample {} message to demo EELF logging.";
76 appLogger.info( msg, "appLogger.info");
78 auditLogger.auditEvent( msg, "auditLogger.auditEvent");
79 errorLogger.error(DmaapbcLogMessageEnum.MESSAGE_SAMPLE_NOARGS);
80 errorLogger.error(DmaapbcLogMessageEnum.MESSAGE_SAMPLE_ONE_ARG, "errorLogger.error");
81 errorLogger.error(DmaapbcLogMessageEnum.MESSAGE_SAMPLE_TWO_ARGS, new Date().toString(), "errorLogger.error" );
82 metricsLogger.metricsEvent( msg, "metricsLogger.metricsEvent" );
83 debugLogger.debug( msg, "debugLogger.debug");
85 //String log = System.getProperty( "log4j.configuration");
86 //if ( log.isEmpty() ) {
87 // log = "log4j.properties";
89 //PropertyConfigurator.configure( log );
92 appLogger.info("Started.");
93 parameters = DmaapConfig.getConfig();
94 setProvFQDN( parameters.getProperty("ProvFQDN", "ProvFQDN.notset.com"));
97 // for fresh installs, we may come up with no dmaap name so need to have a way for Controller to talk to us
98 Singleton<Dmaap> dmaapholder = DatabaseClass.getDmaap();
99 String name = dmaapholder.get().getDmaapName();
100 if ( name == null || name.isEmpty()) {
101 ApiPerms p = new ApiPerms();
107 new JettyServer( parameters );
108 } catch (Exception e) {
109 errorLogger.error("Unable to start Jetty " + DmaapConfig.getConfigFileName(), e);