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 httpConfiguration = new HttpConfiguration();
96 httpConfiguration.setIdleTimeout(2000);
97 httpConfiguration.setRequestHeaderSize(2048);
100 ServerConnector httpServerConnector = new ServerConnector(server, new HttpConnectionFactory(httpConfiguration));
101 httpServerConnector.setPort(ncm.getHttpPort());
103 // HTTPS configuration
104 SslContextFactory sslContextFactory = new SslContextFactory();
105 sslContextFactory.setKeyStoreType(ncm.getKSType());
106 sslContextFactory.setKeyStorePath(ncm.getKSFile());
107 sslContextFactory.setKeyStorePassword(ncm.getKSPass());
108 sslContextFactory.setKeyManagerPassword(ncm.getKPass());
109 /* Skip SSLv3 Fixes */
110 sslContextFactory.addExcludeProtocols("SSLv3");
111 logger.info("Excluded protocols node-" + sslContextFactory.getExcludeProtocols());
112 /* End of SSLv3 Fixes */
114 HttpConfiguration httpsConfiguration = new HttpConfiguration(httpConfiguration);
115 httpsConfiguration.setRequestHeaderSize(8192);
117 SecureRequestCustomizer secureRequestCustomizer = new SecureRequestCustomizer();
118 secureRequestCustomizer.setStsMaxAge(2000);
119 secureRequestCustomizer.setStsIncludeSubDomains(true);
120 httpsConfiguration.addCustomizer(secureRequestCustomizer);
123 ServerConnector httpsServerConnector = new ServerConnector(server,
124 new SslConnectionFactory(sslContextFactory,HttpVersion.HTTP_1_1.asString()),
125 new HttpConnectionFactory(httpsConfiguration));
126 httpsServerConnector.setPort(ncm.getHttpsPort());
127 httpsServerConnector.setIdleTimeout(500000);
128 httpsServerConnector.setAcceptQueueSize(2);
130 server.setConnectors(new Connector[]{httpServerConnector, httpsServerConnector});
131 ServletContextHandler ctxt = new ServletContextHandler(0);
132 ctxt.setContextPath("/");
133 server.setHandler(ctxt);
134 ctxt.addServlet(new ServletHolder(new NodeServlet()), "/*");
135 logger.info("NODE0005 Data Router Node Activating Service");