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 ******************************************************************************/
25 package org.onap.dmaap.datarouter.node;
27 import org.eclipse.jetty.servlet.*;
28 import org.eclipse.jetty.util.ssl.*;
29 import org.eclipse.jetty.server.*;
30 import org.eclipse.jetty.server.nio.*;
31 import org.eclipse.jetty.server.ssl.*;
32 import org.apache.log4j.Logger;
35 * The main starting point for the Data Router node
37 public class NodeMain {
41 private static Logger logger = Logger.getLogger("org.onap.dmaap.datarouter.node.NodeMain");
43 private static class wfconfig implements Runnable {
44 private NodeConfigManager ncm;
46 public wfconfig(NodeConfigManager ncm) {
50 public synchronized void run() {
54 public synchronized void waitforconfig() {
55 ncm.registerConfigTask(this);
56 while (!ncm.isConfigured()) {
57 logger.info("NODE0003 Waiting for Node Configuration");
60 } catch (Exception e) {
63 ncm.deregisterConfigTask(this);
64 logger.info("NODE0004 Node Configuration Data Received");
68 private static Delivery d;
69 private static NodeConfigManager ncm;
72 * Reset the retry timer for a subscription
74 public static void resetQueue(String subid, String ip) {
75 d.resetQueue(ncm.getSpoolDir(subid, ip));
79 * Start the data router.
81 * The location of the node configuration file can be set using the
82 * org.onap.dmaap.datarouter.node.ConfigFile system property. By
83 * default, it is "etc/node.properties".
85 public static void main(String[] args) throws Exception {
86 logger.info("NODE0001 Data Router Node Starting");
88 ncm = NodeConfigManager.getInstance();
89 logger.info("NODE0002 I am " + ncm.getMyName());
90 (new wfconfig(ncm)).waitforconfig();
91 d = new Delivery(ncm);
92 LogManager lm = new LogManager(ncm);
93 Server server = new Server();
94 SelectChannelConnector http = new SelectChannelConnector();
95 http.setPort(ncm.getHttpPort());
96 http.setMaxIdleTime(2000);
97 http.setRequestHeaderSize(2048);
98 SslSelectChannelConnector https = new SslSelectChannelConnector();
99 https.setPort(ncm.getHttpsPort());
100 https.setMaxIdleTime(30000);
101 https.setRequestHeaderSize(8192);
102 SslContextFactory cf = https.getSslContextFactory();
104 /**Skip SSLv3 Fixes*/
105 cf.addExcludeProtocols("SSLv3");
106 logger.info("Excluded protocols node-" + cf.getExcludeProtocols());
107 /**End of SSLv3 Fixes*/
109 cf.setKeyStoreType(ncm.getKSType());
110 cf.setKeyStorePath(ncm.getKSFile());
111 cf.setKeyStorePassword(ncm.getKSPass());
112 cf.setKeyManagerPassword(ncm.getKPass());
113 server.setConnectors(new Connector[]{http, https});
114 ServletContextHandler ctxt = new ServletContextHandler(0);
115 ctxt.setContextPath("/");
116 server.setHandler(ctxt);
117 ctxt.addServlet(new ServletHolder(new NodeServlet()), "/*");
118 logger.info("NODE0005 Data Router Node Activating Service");