Issue #1899 - edex-environment is now compatible with qpid 0.18.

- added change history

Change-Id: Ie6a47ed2413a366f1475d2be848ea05569c4e646

Former-commit-id: 0924bfd726 [formerly 0924bfd726 [formerly a38c6c2014c3252b740ba434b44d09adbebb9991]]
Former-commit-id: 86d8e511b5
Former-commit-id: ff64a23deb
This commit is contained in:
Bryan Kowal 2013-04-18 13:57:10 -05:00
parent 2d8b398635
commit af1d6136e4
5 changed files with 188 additions and 67 deletions

View file

@ -34,6 +34,8 @@ import org.apache.commons.configuration.XMLConfiguration;
* Jan 18, 2012 1490 bkowal Added httpdPypiesPort and * Jan 18, 2012 1490 bkowal Added httpdPypiesPort and
* pypiesLoggingPort as configurable * pypiesLoggingPort as configurable
* parameters. * parameters.
* Apr 18, 2013 1899 bkowal Added qpidHttpPort and qpidJmxPort
* as configurable parameters.
* *
* </pre> * </pre>
* *
@ -49,6 +51,8 @@ import org.apache.commons.configuration.XMLConfiguration;
* <databasePort>int</databasePort> * <databasePort>int</databasePort>
* <edexHttpPort>int</edexHttpPort> * <edexHttpPort>int</edexHttpPort>
* <jmsPort>int</jmsPort> * <jmsPort>int</jmsPort>
* <qpidHttpPort>int</qpidHttpPort>
* <qpidJmxPort>int</qpidJmxPort>
* <webPort>int</webPort> * <webPort>int</webPort>
* <confidentialPort>int</confidentialPort> * <confidentialPort>int</confidentialPort>
* <httpdPypiesPort>int</httpdPypiesPort> * <httpdPypiesPort>int</httpdPypiesPort>
@ -62,6 +66,8 @@ public class Wes2BridgeConfiguration {
public static final String XML_DATABASE_PORT = "databasePort"; public static final String XML_DATABASE_PORT = "databasePort";
public static final String XML_EDEX_HTTP_PORT = "edexHttpPort"; public static final String XML_EDEX_HTTP_PORT = "edexHttpPort";
public static final String XML_JMS_PORT = "jmsPort"; public static final String XML_JMS_PORT = "jmsPort";
public static final String XML_QPID_HTTP_PORT = "qpidHttpPort";
public static final String XML_QPID_JMX_PORT = "qpidJmxPort";
public static final String XML_WEB_PORT = "webPort"; public static final String XML_WEB_PORT = "webPort";
public static final String XML_CONFIDENTIAL_PORT = "confidentialPort"; public static final String XML_CONFIDENTIAL_PORT = "confidentialPort";
public static final String XML_HTTPD_PYPIES_PORT = "httpdPypiesPort"; public static final String XML_HTTPD_PYPIES_PORT = "httpdPypiesPort";
@ -77,6 +83,8 @@ public class Wes2BridgeConfiguration {
private int databasePort = -1; private int databasePort = -1;
private int edexHttpPort = -1; private int edexHttpPort = -1;
private int jmsPort = -1; private int jmsPort = -1;
private int qpidHttpPort = -1;
private int qpidJmxPort = -1;
private int webPort = -1; private int webPort = -1;
private int confidentialPort = -1; private int confidentialPort = -1;
private int httpdPypiesPort = -1; private int httpdPypiesPort = -1;
@ -112,6 +120,10 @@ public class Wes2BridgeConfiguration {
this.edexHttpPort = xmlConfiguration this.edexHttpPort = xmlConfiguration
.getInt(XML_SCHEMA.XML_EDEX_HTTP_PORT); .getInt(XML_SCHEMA.XML_EDEX_HTTP_PORT);
this.jmsPort = xmlConfiguration.getInt(XML_SCHEMA.XML_JMS_PORT); this.jmsPort = xmlConfiguration.getInt(XML_SCHEMA.XML_JMS_PORT);
this.qpidHttpPort =
xmlConfiguration.getInt(XML_SCHEMA.XML_QPID_HTTP_PORT);
this.qpidJmxPort =
xmlConfiguration.getInt(XML_SCHEMA.XML_QPID_JMX_PORT);
this.webPort = xmlConfiguration.getInt(XML_SCHEMA.XML_WEB_PORT); this.webPort = xmlConfiguration.getInt(XML_SCHEMA.XML_WEB_PORT);
this.confidentialPort = xmlConfiguration this.confidentialPort = xmlConfiguration
.getInt(XML_SCHEMA.XML_CONFIDENTIAL_PORT); .getInt(XML_SCHEMA.XML_CONFIDENTIAL_PORT);
@ -161,6 +173,22 @@ public class Wes2BridgeConfiguration {
this.jmsPort = jmsPort; this.jmsPort = jmsPort;
} }
public int getQpidHttpPort() {
return qpidHttpPort;
}
public void setQpidHttpPort(int qpidHttpPort) {
this.qpidHttpPort = qpidHttpPort;
}
public int getQpidJmxPort() {
return qpidJmxPort;
}
public void setQpidJmxPort(int qpidJmxPort) {
this.qpidJmxPort = qpidJmxPort;
}
public int getWebPort() { public int getWebPort() {
return webPort; return webPort;
} }

View file

@ -6,5 +6,5 @@ Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: RAYTHEON Bundle-Vendor: RAYTHEON
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: com.raytheon.wes2bridge.common;bundle-version="1.0.0", Require-Bundle: com.raytheon.wes2bridge.common;bundle-version="1.0.0",
org.apache.commons.configuration;bundle-version="1.6.0", org.apache.commons.lang;bundle-version="2.3.0",
org.apache.commons.lang;bundle-version="2.3.0" org.apache.commons.configuration;bundle-version="1.6.0"

View file

@ -0,0 +1,48 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.wes2bridge.manager;
/**
* Identifies XML tag names of interest as constants within the qpid config.xml
* configuration.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 17, 2013 bkowal Initial creation
*
* </pre>
*
* @author bkowal
* @version 1.0
*/
public interface IQpidConfigurationXML {
public static final String XML_BROKER = "broker";
public static final String XML_CONNECTOR = "connector";
public static final String XML_MANAGEMENT = "management";
public static final String XML_JMXPORT = "jmxport";
public static final String XML_HTTP = "http";
public static final String XML_REGISTRY_SERVER = "registryServer";
public static final String XML_PORT = "port";
}

View file

@ -28,10 +28,24 @@ import java.io.BufferedWriter;
import java.io.IOException; import java.io.IOException;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerFactoryConfigurationError;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import com.raytheon.wes2bridge.manager.IQpidConfigurationXML;
import com.raytheon.wes2bridge.common.configuration.Wes2BridgeConfiguration; import com.raytheon.wes2bridge.common.configuration.Wes2BridgeConfiguration;
/** /**
@ -49,6 +63,7 @@ import com.raytheon.wes2bridge.common.configuration.Wes2BridgeConfiguration;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jan 18, 2012 1490 bkowal Pypies is now added to each * Jan 18, 2012 1490 bkowal Pypies is now added to each
* edex-environment instance * edex-environment instance
* Apr 18, 2013 1899 bkowal Updates qpid 0.18 configuration now.
* *
* </pre> * </pre>
* *
@ -57,15 +72,24 @@ import com.raytheon.wes2bridge.common.configuration.Wes2BridgeConfiguration;
*/ */
public class Wes2BridgeManager { public class Wes2BridgeManager {
private static final String AWIPSII = "/awips2"; private static final String AWIPSII = "/awips2";
private static final String AWIPSII_WES2BRIDGE_SCRIPTS = AWIPSII private static final String AWIPSII_WES2BRIDGE_SCRIPTS = AWIPSII
+ "/edex-environment/scripts"; + "/edex-environment/scripts";
private static final String WES2BRIDGE_DIRECTORY = "/usr/local/edex-environment"; private static final String WES2BRIDGE_DIRECTORY = "/usr/local/edex-environment";
private static final int GROUP_INDEX_ONE = 1; private static final int GROUP_INDEX_ONE = 1;
private static final int GROUP_INDEX_TWO = 2; private static final int GROUP_INDEX_TWO = 2;
private static final int EXIT_FAILURE = -1; private static final int EXIT_FAILURE = -1;
private static final int EXIT_SUCCESS = 0; private static final int EXIT_SUCCESS = 0;
private static final String DEFAULT_HDF5_DIRECTORY = "/edex/data/hdf5"; private static final String DEFAULT_HDF5_DIRECTORY = "/edex/data/hdf5";
private Wes2BridgeConfiguration configuration = null; private Wes2BridgeConfiguration configuration = null;
private String wes2BridgeScripts = null; private String wes2BridgeScripts = null;
/** /**
@ -324,49 +348,87 @@ public class Wes2BridgeManager {
bw.close(); bw.close();
} }
public void reconfigureQPID() throws FileNotFoundException, IOException { public void reconfigureQPID() throws FileNotFoundException, IOException,
ParserConfigurationException, SAXException,
TransformerFactoryConfigurationError, TransformerException {
final String srcQpidDirectory = AWIPSII + "/" + "qpid"; final String srcQpidDirectory = AWIPSII + "/" + "qpid";
final String qpidDirectory = WES2BRIDGE_DIRECTORY + "/" final String qpidDirectory = WES2BRIDGE_DIRECTORY + "/"
+ this.configuration.getTestCaseName() + "/" + "qpid"; + this.configuration.getTestCaseName() + "/" + "qpid";
this.updateQpidConf(srcQpidDirectory, qpidDirectory); this.updateQpidConfigXML(srcQpidDirectory, qpidDirectory);
this.updateQPIDD(qpidDirectory); this.updateQPIDD(qpidDirectory);
this.updateQueueCreatorSH(qpidDirectory);
} }
/* Updates qpidd.conf */ /* Updates qpid config.xml */
private void updateQpidConf(String srcQpidDirectory, String qpidDirectory) private void updateQpidConfigXML(String srcQpidDirectory,
throws FileNotFoundException, IOException { String qpidDirectory) throws FileNotFoundException, IOException,
String srcqpidd_conf = srcQpidDirectory + "/etc/qpidd.conf"; ParserConfigurationException, SAXException,
String qpidd_conf = qpidDirectory + "/etc/qpidd.conf"; TransformerFactoryConfigurationError, TransformerException {
String srcconfig_xml = srcQpidDirectory + "/etc/config.xml";
String config_xml = qpidDirectory + "/etc/config.xml";
BufferedReader br = this.getBufferedReader(srcqpidd_conf); DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance()
BufferedWriter bw = this.getBufferedWriter(qpidd_conf); .newDocumentBuilder();
Document document = documentBuilder.parse(srcconfig_xml);
// Get the root broker node.
Node brokerNode = document.getElementsByTagName(
IQpidConfigurationXML.XML_BROKER).item(0);
// Get the connector node.
Node connectorNode = this.getChildNodeByName(brokerNode,
IQpidConfigurationXML.XML_CONNECTOR);
// Get the management node.
Node managementNode = this.getChildNodeByName(brokerNode,
IQpidConfigurationXML.XML_MANAGEMENT);
// Get the jmxport node.
Node jmxPortNode = this.getChildNodeByName(managementNode,
IQpidConfigurationXML.XML_JMXPORT);
// Get the http port node.
Node httpPortNode = this.getChildNodeByName(managementNode,
IQpidConfigurationXML.XML_HTTP);
Node portNode = null;
// Get the connector port node.
portNode = this.getChildNodeByName(connectorNode,
IQpidConfigurationXML.XML_PORT);
portNode.setTextContent(Integer.toString(this.configuration
.getJmsPort()));
// Get the jmxport registryServer node
portNode = this.getChildNodeByName(jmxPortNode,
IQpidConfigurationXML.XML_REGISTRY_SERVER);
portNode.setTextContent(Integer.toString(this.configuration
.getQpidJmxPort()));
// Get the http port node.
portNode = this.getChildNodeByName(httpPortNode,
IQpidConfigurationXML.XML_PORT);
portNode.setTextContent(Integer.toString(this.configuration
.getQpidHttpPort()));
final String line1 = "data-dir=";
final String line2 = "store-dir=";
final String line3 = "pid-dir=";
/* /*
* add the port to qpidd.conf * Write the updated configuration file to its destination.
*/ */
final String line4 = "auth=no"; Transformer transformer = TransformerFactory.newInstance()
.newTransformer();
String line = StringUtils.EMPTY; DOMSource domSource = new DOMSource(document);
while ((line = br.readLine()) != null) { StreamResult streamResult = new StreamResult(new File(config_xml));
if (line.startsWith(line1)) { transformer.transform(domSource, streamResult);
line = line1 + qpidDirectory + "/data";
} else if (line.startsWith(line2)) {
line = line2 + qpidDirectory + "/messageStore";
} else if (line.startsWith(line3)) {
line = line3 + qpidDirectory + "/var/lock";
} else if (line.startsWith(line4)) {
line = line4 + "\nport=" + this.configuration.getJmsPort();
} }
bw.write(line + "\n"); private Node getChildNodeByName(Node parentNode, String childName) {
if (parentNode.hasChildNodes() == false) {
return null;
} }
br.close();
bw.close(); NodeList nodeList = parentNode.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
if (node.getNodeName().equals(childName)) {
return node;
}
}
return null;
} }
private void updateQPIDD(String qpidDirectory) private void updateQPIDD(String qpidDirectory)
@ -378,34 +440,23 @@ public class Wes2BridgeManager {
BufferedWriter bw = this.getBufferedWriter(qpidd); BufferedWriter bw = this.getBufferedWriter(qpidd);
final String line1 = "QPID_HOME="; final String line1 = "QPID_HOME=";
/*
* Need to update the 'ps' command that determines if qpid is running or
* not.
*/
final String line2 = "isRunning=`ps -ef | grep org.apache.qpid.server.Main | grep -c \"PNAME=QPBRKR \"`";
String line = StringUtils.EMPTY; String line = StringUtils.EMPTY;
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
if (line.startsWith(line1)) { if (line.startsWith(line1)) {
line = line1 + qpidDirectory; line = line1 + qpidDirectory;
} } else if (line.contains(line2)) {
StringBuilder stringBuilder = new StringBuilder();
bw.write(line + "\n"); stringBuilder
} .append("isRunning=`ps -ef | grep org.apache.qpid.server.Main | grep QPID_HOME=");
br.close(); stringBuilder.append(qpidDirectory);
bw.close(); stringBuilder.append("| grep -c \"PNAME=QPBRKR \"`");
} line = stringBuilder.toString();
private void updateQueueCreatorSH(String qpidDirectory)
throws FileNotFoundException, IOException {
final String srcqueue = AWIPSII_WES2BRIDGE_SCRIPTS + "/"
+ "queueCreator.sh";
final String queue = qpidDirectory + "/sbin/queueCreator.sh";
BufferedReader br = this.getBufferedReader(srcqueue);
BufferedWriter bw = this.getBufferedWriter(queue);
final String line1 = "port=";
String line = StringUtils.EMPTY;
while ((line = br.readLine()) != null) {
if (line.startsWith(line1)) {
line = line1 + this.configuration.getJmsPort();
} }
bw.write(line + "\n"); bw.write(line + "\n");

View file

@ -19,9 +19,9 @@ AutoReq: no
provides: awips2-edex-environment provides: awips2-edex-environment
requires: awips2-edex-base requires: awips2-edex-base
requires: awips2-postgresql requires: awips2-postgresql
requires: awips2-qpid-server-store requires: qpid-java-broker
requires: awips2-qpid-client requires: qpid-java-client
requires: awips2-qpid-server requires: qpid-java-common
requires: awips2-python requires: awips2-python
requires: awips2-java requires: awips2-java
requires: awips2-psql requires: awips2-psql
@ -112,12 +112,11 @@ if [ $? -ne 0 ]; then
exit 1 exit 1
fi fi
_QPID_VERSION="0.7" _QPID_VERSION="0.18"
RPM_PROJECT="%{_baseline_workspace}/rpms" RPM_PROJECT="%{_baseline_workspace}/rpms"
POSTGRES_INITD="${RPM_PROJECT}/awips2.core/Installer.postgres/scripts/init.d/edex_postgres" POSTGRES_INITD="${RPM_PROJECT}/awips2.core/Installer.postgres/scripts/init.d/edex_postgres"
QPID_INITD="${RPM_PROJECT}/awips2.qpid/${_QPID_VERSION}/SOURCES/qpidd" QPID_INITD="${RPM_PROJECT}/awips2.qpid/${_QPID_VERSION}/SOURCES/qpidd"
QUEUE_SH="${RPM_PROJECT}/awips2.qpid/${_QPID_VERSION}/SOURCES/queueCreator.sh" EDEX_INITD="${RPM_PROJECT}/awips2.edex/Installer.edex/scripts/init.d/edex_camel"
EDEX_INITD="${RPM_PROJECT}/awips2.edex/Installer.edex-base/scripts/init.d/edex_camel"
HTTPD_PYPIES_INITD="${RPM_PROJECT}/awips2.core/Installer.httpd-pypies/configuration/etc/init.d/httpd-pypies" HTTPD_PYPIES_INITD="${RPM_PROJECT}/awips2.core/Installer.httpd-pypies/configuration/etc/init.d/httpd-pypies"
# Copy the startup scripts. # Copy the startup scripts.
@ -131,11 +130,6 @@ cp ${QPID_INITD} \
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
exit 1 exit 1
fi fi
cp ${QUEUE_SH} \
%{_build_root}%{_installation_directory}/edex-environment/scripts
if [ $? -ne 0 ]; then
exit 1
fi
cp ${EDEX_INITD} \ cp ${EDEX_INITD} \
%{_build_root}%{_installation_directory}/edex-environment/scripts %{_build_root}%{_installation_directory}/edex-environment/scripts
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then