1 /*******************************************************************************
2 * ============LICENSE_START==================================================
4 * * ===========================================================================
5 * * Copyright © 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====================================================
20 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 ******************************************************************************/
24 package org.onap.dmaap.datarouter.node;
26 import static java.lang.System.exit;
28 import com.att.eelf.configuration.EELFLogger;
29 import com.att.eelf.configuration.EELFManager;
30 import org.eclipse.jetty.server.Server;
33 * The main starting point for the Data Router node.
35 public class NodeRunner {
37 private static EELFLogger nodeMainLogger = EELFManager.getInstance().getLogger(NodeRunner.class);
38 private static NodeConfigManager nodeConfigManager;
40 private NodeRunner() {
44 * Start the data router.
46 * <p>The location of the node configuration file can be set using the org.onap.dmaap.datarouter.node.properties
47 * system property. By default, it is "/opt/app/datartr/etc/node.properties".
49 public static void main(String[] args) {
50 nodeMainLogger.debug("NODE0001 Data Router Node Starting");
52 nodeConfigManager = NodeConfigManager.getInstance();
53 nodeMainLogger.debug("NODE0002 I am " + nodeConfigManager.getMyName());
54 (new WaitForConfig(nodeConfigManager)).waitForConfig();
55 new LogManager(nodeConfigManager);
57 Server server = NodeServer.getServerInstance();
60 nodeMainLogger.debug("NODE00006 Node Server started-" + server.getState());
61 } catch (Exception e) {
62 nodeMainLogger.error("NODE00006 Jetty failed to start. Reporting will we be unavailable: "
66 nodeMainLogger.debug("NODE00007 Node Server joined");
69 private static class WaitForConfig implements Runnable {
71 private NodeConfigManager localNodeConfigManager;
73 WaitForConfig(NodeConfigManager ncm) {
74 this.localNodeConfigManager = ncm;
77 public synchronized void run() {
81 synchronized void waitForConfig() {
82 localNodeConfigManager.registerConfigTask(this);
83 while (!localNodeConfigManager.isConfigured()) {
84 nodeMainLogger.debug("NODE0003 Waiting for Node Configuration");
87 } catch (Exception exception) {
88 nodeMainLogger.error("NodeMain: waitForConfig exception. Exception Message:- "
89 + exception.toString(), exception);
92 localNodeConfigManager.deregisterConfigTask(this);
93 nodeMainLogger.debug("NODE0004 Node Configuration Data Received");