diff --git a/hsarback/pom.xml b/hsarback/pom.xml
index c383367..02d3cee 100644
--- a/hsarback/pom.xml
+++ b/hsarback/pom.xml
@@ -5,7 +5,7 @@
de.hsadmin
hsar
war
- 4.0.9
+ 4.0.10
HSAdmin Stable Backend Webapp
http://maven.apache.org
@@ -36,12 +36,12 @@
de.hsadmin.core
hsadmin-util
- 4.0.9
+ 4.0.10
de.hsadmin.core
hsadmin-qserv
- 4.0.9
+ 4.0.10
commons-httpclient
diff --git a/hsarback/src/main/java/de/hsadmin/servlets/PacTasksServlet.java b/hsarback/src/main/java/de/hsadmin/servlets/PacTasksServlet.java
deleted file mode 100644
index 1f10503..0000000
--- a/hsarback/src/main/java/de/hsadmin/servlets/PacTasksServlet.java
+++ /dev/null
@@ -1,155 +0,0 @@
-package de.hsadmin.servlets;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.Queue;
-import javax.jms.QueueConnection;
-import javax.jms.QueueConnectionFactory;
-import javax.jms.QueueReceiver;
-import javax.jms.QueueSession;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import de.hsadmin.core.model.TechnicalException;
-import de.hsadmin.core.model.Transaction;
-import de.hsadmin.core.qserv.Processor;
-import de.hsadmin.core.qserv.QueueTask;
-import de.hsadmin.core.util.Config;
-import de.hsadmin.mods.pac.Pac;
-import de.hsadmin.mods.pac.PacProcessorFactory;
-
-public class PacTasksServlet extends HttpServlet
- implements MessageListener, ExceptionListener {
-
- private static final long serialVersionUID = -5701350884034782083L;
-
- private String jmsUser;
- private String jmsPass;
- private QueueConnectionFactory queueConnectionFactory;
- private QueueConnection queueConnection;
- private QueueSession queueSession;
- private boolean isConnected;
- private int messageCount;
- private int errorCount;
-
- @Override
- public void init() throws ServletException {
- isConnected = false;
- messageCount = 0;
- errorCount = 0;
- try {
- connect();
- } catch (NamingException e) {
- throw new ServletException(e);
- }
- }
-
- private void connect() throws NamingException {
- Config config = Config.getInstance();
- jmsUser = config.getProperty("hsadmin.jms.username", "hsadmin");
- jmsPass = config.getProperty("hsadmin.jms.password", "hsadmin-pw");
- InitialContext ctx = new InitialContext();
- Context env = (Context) ctx.lookup("java:comp/env");
- queueConnectionFactory = (QueueConnectionFactory) env.lookup("jms/QueueCF");
- while (!isConnected) {
- try {
- queueConnection = queueConnectionFactory.createQueueConnection(jmsUser, jmsPass);
- queueConnection.setExceptionListener(this);
- queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = (Queue) env.lookup("jms/hsadminSystem-pactasks");
- queueConnection.start();
- QueueReceiver receiver = queueSession.createReceiver(queue);
- receiver.setMessageListener(this);
- isConnected = true;
- } catch (JMSException e) {
- close();
- try {
- Thread.sleep(2000);
- } catch (InterruptedException e1) { }
- }
- }
- }
-
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
- resp.setContentType("text/plain");
- PrintWriter writer = resp.getWriter();
- writer.println("Verbindungsstatus: " + (isConnected ? "OK" : "ERROR"));
- writer.println("Verarbeitete Nachrichten: " + messageCount);
- writer.println("Verarbeitungsfehler: " + errorCount);
- writer.close();
- }
-
- @Override
- public void destroy() {
- close();
- }
-
- private void close() {
- try { if (queueSession != null) queueSession.close(); } catch (JMSException e) { }
- try { if (queueConnection != null) queueConnection.close(); } catch (JMSException e) { }
- isConnected = false;
- }
-
- @Override
- public void onMessage(Message jmsMessage) {
- Transaction transaction = null;
- messageCount++;
- try {
- final TextMessage txtMessage = (TextMessage) jmsMessage;
- final String message = txtMessage.getText();
- System.out.println(message);
- final String[] parts = message.split(":");
- transaction = new Transaction("pactasks");
- transaction.beginTransaction();
- final EntityManager em = transaction.getEntityManager();
- final Query qPac = em.createQuery("SELECT p FROM Pacs p WHERE p.name = :name");
- qPac.setParameter("name", parts[1]);
- final Pac pac = (Pac) qPac.getSingleResult();
- final PacProcessorFactory factory = new PacProcessorFactory();
- Processor proc = null;
- if ("pac.add".equals(parts[0])) {
- proc = factory.createCreateProcessor(em, pac);
- }
- if ("pac.update".equals(parts[0])) {
- proc = factory.createUpdateProcessor(em, pac);
- }
- if ("pac.delete".equals(parts[0])) {
- proc = factory.createDeleteProcessor(em, pac);
- }
- transaction.enqueue(pac.getHiveName(), new QueueTask(pac.owningUser(em), parts[0] + ":" + parts[1], message, proc));
- em.clear();
- em.flush();
- transaction.commitTransaction();
- } catch (Exception e) {
- errorCount++;
- if (transaction != null) transaction.rollbackTransaction();
- throw new TechnicalException(e);
- } finally {
- if (transaction != null) transaction.close();
- }
- }
-
- @Override
- public void onException(JMSException exception) {
- close();
- try { Thread.sleep(10000); } catch (InterruptedException e) { }
- try { connect(); } catch (NamingException e) { }
- }
-
-}
diff --git a/hsarback/src/main/java/de/hsadmin/servlets/QueueStatusReceiverServlet.java b/hsarback/src/main/java/de/hsadmin/servlets/QueueStatusReceiverServlet.java
index eed9ffa..1fad1fe 100644
--- a/hsarback/src/main/java/de/hsadmin/servlets/QueueStatusReceiverServlet.java
+++ b/hsarback/src/main/java/de/hsadmin/servlets/QueueStatusReceiverServlet.java
@@ -2,6 +2,7 @@ package de.hsadmin.servlets;
import java.io.IOException;
import java.io.PrintWriter;
+import java.util.Set;
import javax.jms.ExceptionListener;
import javax.jms.JMSException;
@@ -16,6 +17,8 @@ import javax.jms.QueueSession;
import javax.jms.Session;
import javax.naming.Context;
import javax.naming.InitialContext;
+import javax.naming.NameClassPair;
+import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.persistence.EntityManager;
import javax.servlet.ServletConfig;
@@ -24,9 +27,13 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.activemq.ActiveMQConnection;
+import org.apache.activemq.command.ActiveMQQueue;
+
import de.hsadmin.core.model.TechnicalException;
import de.hsadmin.core.model.TicketValidator;
import de.hsadmin.core.model.Transaction;
+import de.hsadmin.core.qserv.NullProcessor;
import de.hsadmin.core.qserv.Processor;
import de.hsadmin.core.qserv.QueueTask;
import de.hsadmin.core.util.Config;
@@ -66,6 +73,24 @@ public class QueueStatusReceiverServlet extends HttpServlet
jmsUser = config.getProperty("hsadmin.jms.username", "hsadmin");
jmsPass = config.getProperty("hsadmin.jms.password", "hsadmin-pw");
InitialContext ctx = new InitialContext();
+ NamingEnumeration list = ctx.list("java:comp/env/jms");
+ Transaction transaction = new Transaction("anonymous");
+ transaction.beginTransaction();
+ EntityManager entityManager = transaction.getEntityManager();
+ while (list.hasMore()) {
+ NameClassPair pair = list.next();
+ String jndiName = pair.getName();
+ if (jndiName != null && jndiName.startsWith("hsadminSystem-")) {
+ QueueTask task = new QueueTask();
+ task.setProcessor(new NullProcessor());
+ entityManager.persist(task);
+ entityManager.flush();
+ String hive = jndiName.substring(14);
+ transaction.enqueue(hive, task);
+ }
+ }
+ transaction.commitTransaction();
+ transaction.close();
Context env = (Context) ctx.lookup("java:comp/env");
queueConnectionFactory = (QueueConnectionFactory) env.lookup("jms/QueueCF");
int timeoutCounter = 10;
@@ -73,6 +98,9 @@ public class QueueStatusReceiverServlet extends HttpServlet
try {
queueConnection = queueConnectionFactory.createQueueConnection(jmsUser, jmsPass);
queueConnection.setExceptionListener(this);
+ if (queueConnection instanceof ActiveMQConnection) {
+ checkQueues((ActiveMQConnection) queueConnection, new PrintWriter(System.out));
+ }
queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = (Queue) env.lookup("jms/hsadminStatus");
queueConnection.start();
@@ -89,6 +117,19 @@ public class QueueStatusReceiverServlet extends HttpServlet
}
}
+ private void checkQueues(ActiveMQConnection amqConn, PrintWriter writer) {
+ try {
+ writer.print("\n");
+ Set queues = amqConn.getDestinationSource().getQueues();
+ for (ActiveMQQueue queue : queues) {
+ writer.print("Phys: " + queue.getPhysicalName() + " - Qual: " + queue.getQualifiedName() + "\n");
+ }
+ } catch (JMSException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
@@ -97,6 +138,9 @@ public class QueueStatusReceiverServlet extends HttpServlet
writer.println("Verbindungsstatus: " + (isConnected ? "OK" : "ERROR"));
writer.println("Verarbeitete Nachrichten: " + messageCount);
writer.println("Verarbeitungsfehler: " + errorCount);
+ if (queueConnection instanceof ActiveMQConnection) {
+ checkQueues((ActiveMQConnection) queueConnection, writer);
+ }
writer.close();
}
diff --git a/hsarback/src/main/webapp/META-INF/context.xml b/hsarback/src/main/webapp/META-INF/context.xml
index 5d2ca88..808ab2b 100644
--- a/hsarback/src/main/webapp/META-INF/context.xml
+++ b/hsarback/src/main/webapp/META-INF/context.xml
@@ -30,9 +30,4 @@
global="jms/hsadminStatus"
type="javax.jms.Queue"/>
-
-
diff --git a/hsarback/src/main/webapp/META-INF/dev-context.xml b/hsarback/src/main/webapp/META-INF/dev-context.xml
deleted file mode 100644
index 5d2ca88..0000000
--- a/hsarback/src/main/webapp/META-INF/dev-context.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hsarback/src/main/webapp/META-INF/prod-context.xml b/hsarback/src/main/webapp/META-INF/prod-context.xml
deleted file mode 100644
index dd3249c..0000000
--- a/hsarback/src/main/webapp/META-INF/prod-context.xml
+++ /dev/null
@@ -1,598 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hsarback/src/main/webapp/META-INF/test-context.xml b/hsarback/src/main/webapp/META-INF/test-context.xml
deleted file mode 100644
index 5d2ca88..0000000
--- a/hsarback/src/main/webapp/META-INF/test-context.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hsarback/src/main/webapp/WEB-INF/web.xml b/hsarback/src/main/webapp/WEB-INF/web.xml
index a0178f5..7b91d45 100644
--- a/hsarback/src/main/webapp/WEB-INF/web.xml
+++ b/hsarback/src/main/webapp/WEB-INF/web.xml
@@ -22,12 +22,6 @@
1
-
- Queue PacTasks Servlet
- de.hsadmin.servlets.PacTasksServlet
- 1
-
-
XmlRpcServlet
de.hsadmin.remote.HSXmlRpcServlet
@@ -57,11 +51,6 @@
/xmlrpc/*
-
- Queue PacTasks Servlet
- /queuePacTasks
-
-
jdbc/HSAdminDB
javax.sql.DataSource
@@ -99,11 +88,5 @@
Container
Shareable
-
- jms/hsadminSystem-pactasks
- javax.jms.Queue
- Container
- Shareable
-
\ No newline at end of file
diff --git a/qserv-deploy/pom.xml b/qserv-deploy/pom.xml
index 3df226c..e7bf49f 100644
--- a/qserv-deploy/pom.xml
+++ b/qserv-deploy/pom.xml
@@ -3,8 +3,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
de.hsadmin
- hsadmin-qserv
- 4.0.9
+ hsadmin-deploy
+ 4.0.10
jar
HSAdmin-QServ
@@ -20,7 +20,7 @@
de.hsadmin.core
hsadmin-qserv
- 4.0.9
+ 4.0.10
org.apache.activemq
@@ -89,15 +89,6 @@
640
-
- src/deb/etc/keystore
- file
-
- perm
- /etc/hsadmin/qserv
- 640
-
-
src/deb/systemd/hsadmin-qserv.service
file
diff --git a/qserv-deploy/src/deb/etc/keystore b/qserv-deploy/src/deb/etc/keystore
deleted file mode 100644
index dff26bc..0000000
Binary files a/qserv-deploy/src/deb/etc/keystore and /dev/null differ
diff --git a/qserv-deploy/src/deb/systemd/hsadmin-qserv.service b/qserv-deploy/src/deb/systemd/hsadmin-qserv.service
index 9eb40b1..7d39856 100644
--- a/qserv-deploy/src/deb/systemd/hsadmin-qserv.service
+++ b/qserv-deploy/src/deb/systemd/hsadmin-qserv.service
@@ -6,7 +6,7 @@ After=network.target nss-lookup.target
Type=simple
Environment="PATH=/usr/local/bin:/usr/bin:/bin"
Environment="JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64"
-Environment="JAVA_OPTS=-Xbootclasspath/a:/etc/hsadmin/qserv/ -Djavax.net.ssl.keyStore=/etc/hsadmin/qserv/keystore -Djavax.net.ssl.keyStorePassword=password -Djavax.net.ssl.trustStore=/etc/hsadmin/qserv/keystore -Djavax.net.ssl.trustStorePassword=password -Dorg.apache.activemq.SERIALIZABLE_PACKAGES=java.lang,javax.security,java.util,org.apache.activemq,org.fusesource.hawtbuf,com.thoughtworks.xstream.mapper,de.hsadmin.core.qserv,de.hsadmin.mods.cust,de.hsadmin.mods.db,de.hsadmin.mods.dom,de.hsadmin.mods.email,de.hsadmin.mods.pac,de.hsadmin.mods.qstat,de.hsadmin.mods.user"
+Environment="JAVA_OPTS=-Xbootclasspath/a:/etc/hsadmin/qserv/ -Djavax.net.ssl.keyStore=/etc/hsadmin/qserv/keystore -Djavax.net.ssl.keyStorePassword=password -Djavax.net.ssl.trustStore=/etc/hsadmin/qserv/truststore -Djavax.net.ssl.trustStorePassword=password -Dorg.apache.activemq.SERIALIZABLE_PACKAGES=java.lang,javax.security,java.util,org.apache.activemq,org.fusesource.hawtbuf,com.thoughtworks.xstream.mapper,de.hsadmin.core.qserv,de.hsadmin.mods.cust,de.hsadmin.mods.db,de.hsadmin.mods.dom,de.hsadmin.mods.email,de.hsadmin.mods.pac,de.hsadmin.mods.qstat,de.hsadmin.mods.user"
ExecStart=/usr/bin/java $JAVA_OPTS -jar /usr/local/lib/hostsharing/hsadmin/hsadmin-qserv-full.jar /etc/hsadmin/qserv/qserv.properties
StandardOutput=file:/var/log/hostsharing/hsadmin/hsar-qserv.err
StandardError=inherit
diff --git a/qserv/pom.xml b/qserv/pom.xml
index b034fa7..ed4cc6b 100644
--- a/qserv/pom.xml
+++ b/qserv/pom.xml
@@ -4,7 +4,7 @@
4.0.0
de.hsadmin.core
hsadmin-qserv
- 4.0.9
+ 4.0.10
UTF-8
11
@@ -13,7 +13,7 @@
de.hsadmin.core
hsadmin-util
- 4.0.9
+ 4.0.10
commons-lang
diff --git a/qserv/src/main/java/de/hsadmin/core/model/Transaction.java b/qserv/src/main/java/de/hsadmin/core/model/Transaction.java
index 75b87f3..0299433 100644
--- a/qserv/src/main/java/de/hsadmin/core/model/Transaction.java
+++ b/qserv/src/main/java/de/hsadmin/core/model/Transaction.java
@@ -12,7 +12,6 @@ import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.EntityManager;
-import javax.persistence.EntityTransaction;
import javax.persistence.Query;
import org.apache.openjpa.persistence.OpenJPAEntityManager;
@@ -83,20 +82,14 @@ public class Transaction {
taskStore.add(task);
}
- private void sendAll(EntityTransaction transaction) {
- boolean firstHive = true;
+ private void sendAll() {
for (String hive : taskStores.keySet()) {
QueueTaskStore store = taskStores.get(hive);
String queueName = "hsadminSystem-" + hive;
-// queueName = "hsadminSystem-h99"; // FIXME nicht committen !!!
Queue jmsSystemQueue = lookupJMSQueue(queueName);
QueueClient qClient = null;
try {
qClient = new QueueClient(queueConnectionFactory, jmsSystemQueue);
- if (firstHive) {
- firstHive = false;
- transaction.commit();
- }
for (QueueTask task : store.getTasks()) {
qClient.send(task);
}
@@ -107,13 +100,6 @@ public class Transaction {
if (qClient != null) qClient.close();
}
}
- if (firstHive) {
- try {
- transaction.commit();
- } catch (Exception e) {
- throw new TechnicalException(e);
- }
- }
}
public void beginTransaction() {
@@ -122,7 +108,8 @@ public class Transaction {
}
public void commitTransaction() {
- sendAll(entityManager.getTransaction());
+ sendAll();
+ entityManager.getTransaction().commit();
transactionActive = false;
}
diff --git a/qserv/src/main/java/de/hsadmin/core/qserv/QueueServer.java b/qserv/src/main/java/de/hsadmin/core/qserv/QueueServer.java
index 3834263..8f0a356 100644
--- a/qserv/src/main/java/de/hsadmin/core/qserv/QueueServer.java
+++ b/qserv/src/main/java/de/hsadmin/core/qserv/QueueServer.java
@@ -84,7 +84,7 @@ public class QueueServer extends QueueCommons implements MessageListener, Except
}
});
while (!qServ.connect()) {
- Thread.sleep(10000);
+ Thread.sleep(120000);
}
while (true) {
Thread.sleep(10000);
diff --git a/qserv/src/main/java/de/hsadmin/core/qserv/QueueTask.java b/qserv/src/main/java/de/hsadmin/core/qserv/QueueTask.java
index 23cc72c..6ef6086 100644
--- a/qserv/src/main/java/de/hsadmin/core/qserv/QueueTask.java
+++ b/qserv/src/main/java/de/hsadmin/core/qserv/QueueTask.java
@@ -67,6 +67,13 @@ public class QueueTask extends AbstractEntity implements Serializable {
private String exception;
public QueueTask() {
+ this.user = null;
+ this.title = "ping";
+ this.details = null;
+ this.started = new Date();
+ this.finished = null;
+ this.proc = null;
+ this.exception = null;
}
public QueueTask(UnixUser user, String title, String details, Processor proc) {
diff --git a/util/pom.xml b/util/pom.xml
index 4b4b61c..1faf055 100644
--- a/util/pom.xml
+++ b/util/pom.xml
@@ -4,7 +4,7 @@
4.0.0
de.hsadmin.core
hsadmin-util
- 4.0.9
+ 4.0.10
UTF-8
11