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 final EELFLogger nodeMainLogger = EELFManager.getInstance().getLogger(NodeRunner.class);
39 private NodeRunner() {
43 * Start the data router.
45 * <p>The location of the node configuration file can be set using the org.onap.dmaap.datarouter.node.properties
46 * system property. By default, it is "/opt/app/datartr/etc/node.properties".
48 public static void main(String[] args) {
49 nodeMainLogger.debug("NODE0001 Data Router Node Starting");
51 NodeConfigManager nodeConfigManager = NodeConfigManager.getInstance();
52 nodeMainLogger.debug("NODE0002 I am " + nodeConfigManager.getMyName());
53 (new WaitForConfig(nodeConfigManager)).waitForConfig();
54 new LogManager(nodeConfigManager);
56 Server server = NodeServer.getServerInstance(nodeConfigManager);
59 nodeMainLogger.debug("NODE0006 Node Server started-" + server.getState());
60 } catch (Exception e) {
61 nodeMainLogger.error("NODE0006 Jetty failed to start. Reporting will we be unavailable: "
65 nodeMainLogger.debug("NODE0007 Node Server joined");
68 private static class WaitForConfig implements Runnable {
70 private final NodeConfigManager localNodeConfigManager;
72 WaitForConfig(NodeConfigManager ncm) {
73 this.localNodeConfigManager = ncm;
76 public synchronized void run() {
80 synchronized void waitForConfig() {
81 localNodeConfigManager.registerConfigTask(this);
82 while (!localNodeConfigManager.isConfigured()) {
83 nodeMainLogger.debug("NODE0003 Waiting for Node Configuration");
86 } catch (Exception exception) {
87 nodeMainLogger.error("NodeMain: waitForConfig exception. Exception Message:- "
88 + exception, exception);
91 localNodeConfigManager.deregisterConfigTask(this);
92 nodeMainLogger.debug("NODE0004 Node Configuration Data Received");