refactoring qserv config

This commit is contained in:
Peter Hormanns 2023-09-05 17:42:53 +02:00
parent 221aea2520
commit f4457d5159
9 changed files with 85 additions and 30 deletions

View File

@ -5,7 +5,7 @@
<groupId>de.hsadmin</groupId>
<artifactId>hsar</artifactId>
<packaging>war</packaging>
<version>4.0.16</version>
<version>4.0.17</version>
<name>HSAdmin Stable Backend Webapp</name>
<url>http://maven.apache.org</url>
<properties>
@ -19,12 +19,12 @@
<dependency>
<groupId>de.hsadmin.core</groupId>
<artifactId>hsadmin-util</artifactId>
<version>4.0.16</version>
<version>4.0.17</version>
</dependency>
<dependency>
<groupId>de.hsadmin.core</groupId>
<artifactId>hsadmin-qserv</artifactId>
<version>4.0.16</version>
<version>4.0.17</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>

View File

@ -23,8 +23,9 @@ public class RoleRemote implements IRemote {
Transaction transaction = new Transaction(user);
if (transaction.login(user, ticket)) {
String role = "USER";
String accoutPrefixCustomer = Config.getInstance().getProperty("accountprefix.customer");
String accoutPrefixHostmaster = Config.getInstance().getProperty("accountprefix.hostmaster");
Config config = Config.getInstance();
String accoutPrefixCustomer = config.getProperty("accountprefix.customer");
String accoutPrefixHostmaster = config.getProperty("accountprefix.hostmaster");
Pac pac = transaction.getLoginUser().getPac();
String pacName = pac.getName();
if (accoutPrefixCustomer.equals(pacName)) {

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.hsadmin</groupId>
<artifactId>hsadmin-qserv</artifactId>
<version>4.0.16</version>
<version>4.0.17</version>
<packaging>jar</packaging>
<name>HSAdmin-QServ</name>
@ -17,10 +17,15 @@
</properties>
<dependencies>
<dependency>
<groupId>de.hsadmin.core</groupId>
<artifactId>hsadmin-util</artifactId>
<version>4.0.17</version>
</dependency>
<dependency>
<groupId>de.hsadmin.core</groupId>
<artifactId>hsadmin-qserv</artifactId>
<version>4.0.16</version>
<version>4.0.17</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
@ -79,6 +84,15 @@
<prefix>/usr/local/lib/hostsharing/hsadmin</prefix>
</mapper>
</data>
<data>
<src>src/deb/init/init_hive_mysqldb.sh</src>
<type>file</type>
<mapper>
<type>perm</type>
<prefix>/usr/local/lib/hostsharing/hsadmin/tools/</prefix>
<filemode>754</filemode>
</mapper>
</data>
<data>
<src>src/deb/systemd/hsadmin-qserv.service</src>
<type>file</type>

View File

@ -0,0 +1,50 @@
#!/bin/bash
mysql --defaults-file=/root/.my.cnf mysql <<EOSQL
DROP PROCEDURE IF EXISTS kill_by_user;
DROP PROCEDURE IF EXISTS kill_by_database;
DELIMITER //
CREATE PROCEDURE kill_by_user (IN user_name VARCHAR(64) CHARSET utf8)
BEGIN
DECLARE query_id INT;
DECLARE iteration_complete INT DEFAULT 0;
DECLARE select_cursor CURSOR FOR SELECT id FROM information_schema.processlist WHERE user = user_name;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET iteration_complete=1;
OPEN select_cursor;
cursor_loop: LOOP
FETCH select_cursor INTO query_id;
IF iteration_complete THEN
LEAVE cursor_loop;
END IF;
KILL query_id;
END LOOP;
CLOSE select_cursor;
END
//
CREATE PROCEDURE kill_by_database (IN database_name VARCHAR(64))
BEGIN
DECLARE query_id INT;
DECLARE iteration_complete INT DEFAULT 0;
DECLARE select_cursor CURSOR FOR SELECT id FROM information_schema.processlist WHERE db = database_name;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET iteration_complete=1;
OPEN select_cursor;
cursor_loop: LOOP
FETCH select_cursor INTO query_id;
IF iteration_complete THEN
LEAVE cursor_loop;
END IF;
KILL query_id;
END LOOP;
CLOSE select_cursor;
END
//
DELIMITER ;
EOSQL
echo "installed mysql procedures for hsadmin-qserv"

View File

@ -4,9 +4,11 @@ After=network.target nss-lookup.target
[Service]
Type=simple
WorkingDirectory=/usr/local/lib/hostsharing/hsadmin/qserv
Environment="PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
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=*"
ExecStart=/usr/bin/java $JAVA_OPTS -jar /usr/local/lib/hostsharing/hsadmin/hsadmin-qserv-full.jar /etc/hsadmin/qserv/qserv.properties
ExecStartPre=/bin/bash /usr/local/lib/hostsharing/hsadmin/tools/init_hive_mysqldb.sh
ExecStart=/usr/bin/java $JAVA_OPTS -jar /usr/local/lib/hostsharing/hsadmin/hsadmin-qserv-full.jar
StandardOutput=file:/var/log/hostsharing/hsadmin/hsar-qserv.err
StandardError=inherit
Restart=always

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.hsadmin.core</groupId>
<artifactId>hsadmin-qserv</artifactId>
<version>4.0.16</version>
<version>4.0.17</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>11</java.version>
@ -13,7 +13,7 @@
<dependency>
<groupId>de.hsadmin.core</groupId>
<artifactId>hsadmin-util</artifactId>
<version>4.0.16</version>
<version>4.0.17</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>

View File

@ -37,8 +37,7 @@ public class QueueServer implements MessageListener, ExceptionListener {
/**
* Runs the QueueServer, using the arguments as ConnectionFactory
* and Topic names.
* Runs the QueueServer.
*/
public static void main(String[] args) throws Exception {
final Config config = Config.getInstance();

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.hsadmin.core</groupId>
<artifactId>hsadmin-util</artifactId>
<version>4.0.16</version>
<version>4.0.17</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>11</java.version>

View File

@ -18,16 +18,11 @@ public class Config {
private Config() {
props = new Properties();
initPropertiesFromFile();
}
private void initPropertiesFromFile() {
final String baseName = "hsadmin";
initPropertiesFromFile(baseName);
}
private Config(String baseName) {
props = new Properties();
initPropertiesFromFile(baseName);
}
private void initPropertiesFromFile(final String baseName) {
File file = new File(userDir + "/" + baseName + ".properties");
if (!file.canRead()) {
file = new File(userDir + "/conf/" + baseName + ".properties");
@ -50,7 +45,8 @@ public class Config {
e.printStackTrace();
}
} else {
LOG.severe("reading properties failed: No properties file found");
final String errormsg = "reading properties failed: No properties file found";
LOG.severe(errormsg);
}
}
@ -61,13 +57,6 @@ public class Config {
return instance;
}
public static Config getInstance(String baseName) {
if (instance == null) {
instance = new Config(baseName);
}
return instance;
}
public String getProperty(String propertyName) {
String property = props.getProperty(propertyName);
return property;