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 org.eclipse.jetty.http.HttpVersion;
27 import org.eclipse.jetty.servlet.*;
28 import org.eclipse.jetty.util.ssl.*;
29 import org.eclipse.jetty.server.*;
30 import org.apache.log4j.Logger;
33 * The main starting point for the Data Router node
35 public class NodeMain {
39 private static Logger logger = Logger.getLogger("org.onap.dmaap.datarouter.node.NodeMain");
41 private static class wfconfig implements Runnable {
42 private NodeConfigManager ncm;
44 wfconfig(NodeConfigManager ncm) {
48 public synchronized void run() {
52 synchronized void waitforconfig() {
53 ncm.registerConfigTask(this);
54 while (!ncm.isConfigured()) {
55 logger.info("NODE0003 Waiting for Node Configuration");
58 } catch (Exception e) {
59 logger.debug("NodeMain: waitforconfig exception");
62 ncm.deregisterConfigTask(this);
63 logger.info("NODE0004 Node Configuration Data Received");
67 private static Delivery d;
68 private static NodeConfigManager ncm;
71 * Reset the retry timer for a subscription
73 static void resetQueue(String subid, String ip) {
74 d.resetQueue(ncm.getSpoolDir(subid, ip));
78 * Start the data router.
80 * The location of the node configuration file can be set using the
81 * org.onap.dmaap.datarouter.node.ConfigFile system property. By
82 * default, it is "etc/node.properties".
84 public static void main(String[] args) throws Exception {
85 logger.info("NODE0001 Data Router Node Starting");
87 ncm = NodeConfigManager.getInstance();
88 logger.info("NODE0002 I am " + ncm.getMyName());
89 (new wfconfig(ncm)).waitforconfig();
90 d = new Delivery(ncm);
91 LogManager lm = new LogManager(ncm);
92 Server server = new Server();
95 HttpConfiguration http_config = new HttpConfiguration();
96 http_config.setIdleTimeout(2000);
97 http_config.setRequestHeaderSize(2048);
99 ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(http_config));
100 http.setPort(ncm.getHttpPort());
102 // HTTPS configuration
103 SslContextFactory sslContextFactory = new SslContextFactory();
104 sslContextFactory.setKeyStoreType(ncm.getKSType());
105 sslContextFactory.setKeyStorePath(ncm.getKSFile());
106 sslContextFactory.setKeyStorePassword(ncm.getKSPass());
107 sslContextFactory.setKeyManagerPassword(ncm.getKPass());
109 HttpConfiguration https_config = new HttpConfiguration(http_config);
110 https_config.setRequestHeaderSize(8192);
112 ServerConnector https = new ServerConnector(server,
113 new SslConnectionFactory(sslContextFactory,HttpVersion.HTTP_1_1.asString()),
114 new HttpConnectionFactory(https_config));
115 https.setPort(ncm.getHttpsPort());
116 https.setIdleTimeout(500000);
117 https.setAcceptQueueSize(2);
119 /* Skip SSLv3 Fixes */
120 sslContextFactory.addExcludeProtocols("SSLv3");
121 logger.info("Excluded protocols node-" + sslContextFactory.getExcludeProtocols());
122 /* End of SSLv3 Fixes */
124 server.setConnectors(new Connector[]{http, https});
125 ServletContextHandler ctxt = new ServletContextHandler(0);
126 ctxt.setContextPath("/");
127 server.setHandler(ctxt);
128 ctxt.addServlet(new ServletHolder(new NodeServlet()), "/*");
129 logger.info("NODE0005 Data Router Node Activating Service");