-/*******************************************************************************\r
- * ============LICENSE_START==================================================\r
- * * org.onap.dmaap\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-\r
-\r
-package org.onap.dmaap.datarouter.node;\r
-\r
-import org.eclipse.jetty.servlet.*;\r
-import org.eclipse.jetty.util.ssl.*;\r
-import org.eclipse.jetty.server.*;\r
-import org.eclipse.jetty.server.nio.*;\r
-import org.eclipse.jetty.server.ssl.*;\r
-import org.apache.log4j.Logger;\r
-\r
-/**\r
- * The main starting point for the Data Router node\r
- */\r
-public class NodeMain {\r
- private NodeMain() {}\r
- private static Logger logger = Logger.getLogger("org.onap.dmaap.datarouter.node.NodeMain");\r
- private static class wfconfig implements Runnable {\r
- private NodeConfigManager ncm;\r
- public wfconfig(NodeConfigManager ncm) {\r
- this.ncm = ncm;\r
- }\r
- public synchronized void run() {\r
- notify();\r
- }\r
- public synchronized void waitforconfig() {\r
- ncm.registerConfigTask(this);\r
- while (!ncm.isConfigured()) {\r
- logger.info("NODE0003 Waiting for Node Configuration");\r
- try {\r
- wait();\r
- } catch (Exception e) {\r
- }\r
- }\r
- ncm.deregisterConfigTask(this);\r
- logger.info("NODE0004 Node Configuration Data Received");\r
- }\r
- }\r
- private static Delivery d;\r
- private static NodeConfigManager ncm;\r
- /**\r
- * Reset the retry timer for a subscription\r
- */\r
- public static void resetQueue(String subid, String ip) {\r
- d.resetQueue(ncm.getSpoolDir(subid, ip));\r
- }\r
- /**\r
- * Start the data router.\r
- * <p>\r
- * The location of the node configuration file can be set using the\r
- * org.onap.dmaap.datarouter.node.ConfigFile system property. By\r
- * default, it is "etc/node.properties".\r
- */\r
- public static void main(String[] args) throws Exception {\r
- logger.info("NODE0001 Data Router Node Starting");\r
- IsFrom.setDNSCache();\r
- ncm = NodeConfigManager.getInstance();\r
- logger.info("NODE0002 I am " + ncm.getMyName());\r
- (new wfconfig(ncm)).waitforconfig();\r
- d = new Delivery(ncm);\r
- LogManager lm = new LogManager(ncm);\r
- Server server = new Server();\r
- SelectChannelConnector http = new SelectChannelConnector();\r
- http.setPort(ncm.getHttpPort());\r
- http.setMaxIdleTime(2000);\r
- http.setRequestHeaderSize(2048);\r
- SslSelectChannelConnector https = new SslSelectChannelConnector();\r
- https.setPort(ncm.getHttpsPort());\r
- https.setMaxIdleTime(30000);\r
- https.setRequestHeaderSize(8192);\r
- SslContextFactory cf = https.getSslContextFactory();\r
- \r
- /**Skip SSLv3 Fixes*/\r
- cf.addExcludeProtocols("SSLv3");\r
- logger.info("Excluded protocols node-"+cf.getExcludeProtocols());\r
- /**End of SSLv3 Fixes*/\r
-\r
- cf.setKeyStoreType(ncm.getKSType());\r
- cf.setKeyStorePath(ncm.getKSFile());\r
- cf.setKeyStorePassword(ncm.getKSPass());\r
- cf.setKeyManagerPassword(ncm.getKPass());\r
- server.setConnectors(new Connector[] { http, https });\r
- ServletContextHandler ctxt = new ServletContextHandler(0);\r
- ctxt.setContextPath("/");\r
- server.setHandler(ctxt);\r
- ctxt.addServlet(new ServletHolder(new NodeServlet()), "/*");\r
- logger.info("NODE0005 Data Router Node Activating Service");\r
- server.start();\r
- server.join();\r
- }\r
-}\r
+/*******************************************************************************
+ * ============LICENSE_START==================================================
+ * * org.onap.dmaap
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+
+package org.onap.dmaap.datarouter.node;
+
+import java.util.Arrays;
+import org.apache.log4j.Logger;
+import org.eclipse.jetty.http.HttpVersion;
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.HttpConfiguration;
+import org.eclipse.jetty.server.HttpConnectionFactory;
+import org.eclipse.jetty.server.SecureRequestCustomizer;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.ServerConnector;
+import org.eclipse.jetty.server.SslConnectionFactory;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+import org.eclipse.jetty.util.ssl.SslContextFactory;
+
+/**
+ * The main starting point for the Data Router node
+ */
+public class NodeMain {
+
+ private NodeMain() {
+ }
+
+ private static Logger nodeMainLogger = Logger.getLogger("org.onap.dmaap.datarouter.node.NodeMain");
+
+ private static class WaitForConfig implements Runnable {
+
+ private NodeConfigManager localNodeConfigManager;
+
+ WaitForConfig(NodeConfigManager ncm) {
+ this.localNodeConfigManager = ncm;
+ }
+
+ public synchronized void run() {
+ notify();
+ }
+
+ synchronized void waitForConfig() {
+ localNodeConfigManager.registerConfigTask(this);
+ while (!localNodeConfigManager.isConfigured()) {
+ nodeMainLogger.info("NODE0003 Waiting for Node Configuration");
+ try {
+ wait();
+ } catch (Exception exception) {
+ nodeMainLogger
+ .debug("NodeMain: waitForConfig exception. Exception Message:- " + exception.toString(),
+ exception);
+ }
+ }
+ localNodeConfigManager.deregisterConfigTask(this);
+ nodeMainLogger.info("NODE0004 Node Configuration Data Received");
+ }
+ }
+
+ private static Delivery delivery;
+ private static NodeConfigManager nodeConfigManager;
+
+ /**
+ * Reset the retry timer for a subscription
+ */
+ static void resetQueue(String subid, String ip) {
+ delivery.resetQueue(nodeConfigManager.getSpoolDir(subid, ip));
+ }
+
+ /**
+ * Start the data router.
+ * <p>
+ * The location of the node configuration file can be set using the org.onap.dmaap.datarouter.node.ConfigFile system
+ * property. By default, it is "etc/node.properties".
+ */
+ public static void main(String[] args) throws Exception {
+ nodeMainLogger.info("NODE0001 Data Router Node Starting");
+ IsFrom.setDNSCache();
+ nodeConfigManager = NodeConfigManager.getInstance();
+ nodeMainLogger.info("NODE0002 I am " + nodeConfigManager.getMyName());
+ (new WaitForConfig(nodeConfigManager)).waitForConfig();
+ delivery = new Delivery(nodeConfigManager);
+ Server server = new Server();
+ // HTTP configuration
+ HttpConfiguration httpConfiguration = new HttpConfiguration();
+ httpConfiguration.setRequestHeaderSize(2048);
+
+ // HTTP connector
+ ServletContextHandler ctxt;
+ try (ServerConnector httpServerConnector = new ServerConnector(server,
+ new HttpConnectionFactory(httpConfiguration))) {
+ httpServerConnector.setPort(nodeConfigManager.getHttpPort());
+ httpServerConnector.setIdleTimeout(2000);
+
+ // HTTPS configuration
+ SslContextFactory sslContextFactory = new SslContextFactory();
+ sslContextFactory.setKeyStoreType(nodeConfigManager.getKSType());
+ sslContextFactory.setKeyStorePath(nodeConfigManager.getKSFile());
+ sslContextFactory.setKeyStorePassword(nodeConfigManager.getKSPass());
+ sslContextFactory.setKeyManagerPassword(nodeConfigManager.getKPass());
+ /* Skip SSLv3 Fixes */
+ sslContextFactory.addExcludeProtocols("SSLv3");
+ nodeMainLogger.info("Excluded protocols node-" + Arrays.toString(sslContextFactory.getExcludeProtocols()));
+ /* End of SSLv3 Fixes */
+
+ HttpConfiguration httpsConfiguration = new HttpConfiguration(httpConfiguration);
+ httpsConfiguration.setRequestHeaderSize(8192);
+
+ SecureRequestCustomizer secureRequestCustomizer = new SecureRequestCustomizer();
+ secureRequestCustomizer.setStsMaxAge(2000);
+ secureRequestCustomizer.setStsIncludeSubDomains(true);
+ httpsConfiguration.addCustomizer(secureRequestCustomizer);
+
+ // HTTPS connector
+ try (ServerConnector httpsServerConnector = new ServerConnector(server,
+ new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
+ new HttpConnectionFactory(httpsConfiguration))) {
+ httpsServerConnector.setPort(nodeConfigManager.getHttpsPort());
+ httpsServerConnector.setIdleTimeout(500000);
+ httpsServerConnector.setAcceptQueueSize(2);
+
+ server.setConnectors(new Connector[]{httpServerConnector, httpsServerConnector});
+ }
+ }
+ ctxt = new ServletContextHandler(0);
+ ctxt.setContextPath("/");
+ server.setHandler(ctxt);
+ ctxt.addServlet(new ServletHolder(new NodeServlet()), "/*");
+ nodeMainLogger.info("NODE0005 Data Router Node Activating Service");
+ server.start();
+ server.join();
+ }
+}