Skip to content

Commit

Permalink
Removed DBMS configuration duplicated properties
Browse files Browse the repository at this point in the history
  • Loading branch information
enricovianello committed May 11, 2021
1 parent 48c1791 commit edcb3c8
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 149 deletions.
28 changes: 0 additions & 28 deletions etc/storm.properties.template
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,18 @@
############################
### SERVICE PARAMETERS ###
############################
##
## NOTE:
## The SERVICE PARAMETERS are managed also by YAIM.
## So, if you install and configure the service with YAIM, please
## remember that the parameters tagged as YAIM will be overwrite at every
## reconfiguration done with YAIM, so if you want change some parameters
## you should use the YAIM configuration files:
## <siteinfo_dir>/services/ig-se_storm_backend (or equivalent)
##

# ============================
# StoRM Service DNS
# ============================
# hostname with which the service is published
# <!! managed by YAIM; please read the above NOTE !!>
storm.service.FE-public.hostname =


# ============================
# Front End service port
# ============================
# The Front End binding port
# <!! managed by YAIM; please read the above NOTE !!>
storm.service.port = 8444

# ============================
Expand All @@ -44,7 +33,6 @@ storm.service.port = 8444
# These entries are used to check the SURL validity.
# storm.service.SURL.endpoint = srm://<surl-host>:<surl-port>/<surl-service-path>
# Example: Example: srm://storm.cnaf.infn.it:8444/srm/managerv2
# <!! managed by YAIM; please read the above NOTE !!>
storm.service.SURL.endpoint =

# ============================
Expand All @@ -55,27 +43,20 @@ storm.service.SURL.endpoint =
# These entries are used to check the SURL validity.
# storm.service.SURL.default-ports = <surl-port>
# Example: 8444
# <!! managed by YAIM; please read the above NOTE !!>
storm.service.SURL.default-ports =

# ============================
# FE/BE communication RDBMS
# ============================
#
# Parameters to connect to the DB used as channel for the requests.
# <!! managed by YAIM; please read the above NOTE !!>
storm.service.request-db.host =
storm.service.request-db.username =
storm.service.request-db.passwd =

#############################################
############ PROFILE PARAMETERS ############
#############################################
##
## NOTE:
## The PROFILE PARAMETERS are not managed by YAIM in any case,
## so any change must be managed by directly editing this file.
##

# ============================
# StoRM Service Generic Behavior
Expand Down Expand Up @@ -119,17 +100,10 @@ default.storagetype = P
#############################################
############ TUNING PARAMETERS #############
#############################################
##
## NOTE:
## The TUNING PARAMETERS are not managed by YAIM in any case,
## so any change must be managed by directly editing this file.
##


# ============================
# BE-private RDBMS
# ============================
persistence.internal-db.connection-pool = true
persistence.internal-db.connection-pool.maxActive = 50
persistence.internal-db.connection-pool.maxWait = 50

Expand Down Expand Up @@ -207,7 +181,6 @@ tape.recalltable.service.param.takeover=first
# ============================
# srmCopy parameters
# ============================
proxy.home=/opt/storm/backend/tmp
asynch.srmclient.retrytime=60
asynch.srmclient.timeout=180
asynch.srmclient.sleeptime=5
Expand Down Expand Up @@ -292,4 +265,3 @@ storm.service.du.parallelTasks=false
storm.service.du.delaySecs=60
# Interval of execution of the du in seconds. Default: 86400s (24h)
storm.service.du.periodSecs=86400
ß
2 changes: 1 addition & 1 deletion src/main/java/it/grid/storm/catalogs/BoLChunkDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class BoLChunkDAO {
/** String with the name of the class for the DB driver */
private final String driver = Configuration.getInstance().getDBDriver();
/** String referring to the URL of the DB */
private final String url = Configuration.getInstance().getDBURL();
private final String url = Configuration.getInstance().getStormDbURL();
/** String with the password for the DB */
private final String password = Configuration.getInstance().getDBPassword();
/** String with the name for the DB */
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/it/grid/storm/catalogs/CopyChunkDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class CopyChunkDAO {
/* String with the name of the class for the DB driver */
private final String driver = Configuration.getInstance().getDBDriver();
/* String referring to the URL of the DB */
private final String url = Configuration.getInstance().getDBURL();
private final String url = Configuration.getInstance().getStormDbURL();
/* String with the password for the DB */
private final String password = Configuration.getInstance().getDBPassword();
/* String with the name for the DB */
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/it/grid/storm/catalogs/PtGChunkDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public class PtGChunkDAO {
/** String with the name of the class for the DB driver */
private final String driver = Configuration.getInstance().getDBDriver();
/** String referring to the URL of the DB */
private final String url = Configuration.getInstance().getDBURL();
private final String url = Configuration.getInstance().getStormDbURL();
/** String with the password for the DB */
private final String password = Configuration.getInstance().getDBPassword();
/** String with the name for the DB */
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/it/grid/storm/catalogs/PtPChunkDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class PtPChunkDAO {
/* String with the name of the class for the DB driver */
private final String driver = Configuration.getInstance().getDBDriver();
/* String referring to the URL of the DB */
private final String url = Configuration.getInstance().getDBURL();
private final String url = Configuration.getInstance().getStormDbURL();
/* String with the password for the DB */
private final String password = Configuration.getInstance().getDBPassword();
/* String with the name for the DB */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class RequestSummaryDAO {
/** String with the name of the class for the DB driver */
private final String driver = Configuration.getInstance().getDBDriver();
/** String referring to the URL of the DB */
private final String url = Configuration.getInstance().getDBURL();
private final String url = Configuration.getInstance().getStormDbURL();
/** String with the password for the DB */
private final String password = Configuration.getInstance().getDBPassword();
/** String with the name for the DB */
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/it/grid/storm/catalogs/StoRMDataSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public static synchronized void init(){
Configuration conf = Configuration.getInstance();
instance = new StoRMDataSource.Builder()
.driver(conf.getDBDriver())
.url(conf.getDBURL())
.url(conf.getStormDbURL())
.username(conf.getDBUserName())
.password(conf.getDBPassword())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class VolatileAndJiTDAO {
private final String driver = Configuration.getInstance().getDBDriver();

// The URL of the DB
private final String url = Configuration.getInstance().getDBURL();
private final String url = Configuration.getInstance().getStormDbURL();

// The password for the DB
private final String password = Configuration.getInstance().getDBPassword();
Expand Down
121 changes: 19 additions & 102 deletions src/main/java/it/grid/storm/config/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@

import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.lang.ArrayUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.collect.Lists;

Expand All @@ -56,8 +54,6 @@ public class Configuration {
"/etc/storm/backend-server/storm.properties";
public static final int DEFAULT_STORM_CONFIG_REFRESH_RATE = 0;

private static final Logger log = LoggerFactory.getLogger(Configuration.class);

private final ConfigReader cr;

private static Configuration instance;
Expand All @@ -72,10 +68,7 @@ public class Configuration {
private static final String SERVICE_HOSTNAME_KEY = "storm.service.FE-public.hostname";
private static final String SERVICE_PORT_KEY = "storm.service.port";
private static final String LIST_OF_MACHINE_IPS_KEY = "storm.service.FE-list.IPs";
private static final String DB_DRIVER_KEY = "storm.service.request-db.dbms-vendor";
private static final String DB_URL_PROTOCOL = "storm.service.request-db.protocol";
private static final String DB_URL_HOSTNAME = "storm.service.request-db.host";
private static final String DB_URL_DATABASE = "storm.service.request-db.db-name";
private static final String DB_URL_PROPERTIES = "storm.service.request-db.properties";
private static final String DB_USER_NAME_KEY = "storm.service.request-db.username";
private static final String DB_PASSWORD_KEY = "storm.service.request-db.passwd";
Expand All @@ -96,18 +89,10 @@ public class Configuration {
private static final String XMLRPC_MAX_QUEUE_SIZE_KEY = "synchcall.xmlrpc.max_queue_size";
private static final String LIST_OF_DEFAULT_SPACE_TOKEN_KEY = "storm.service.defaultSpaceTokens";
private static final String COMMAND_SERVER_BINDING_PORT_KEY = "storm.commandserver.port";
private static final String BE_PERSISTENCE_DBMS_URL_1KEY = "persistence.internal-db.host";
private static final String BE_PERSISTENCE_DBMS_URL_2KEY = "" + DB_URL_HOSTNAME;
private static final String BE_PERSISTENCE_DB_NAME_KEY = "persistence.internal-db.db-name";
private static final String BE_PERSISTENCEDB_USER_NAME_1KEY = "persistence.internal-db.username";
private static final String BE_PERSISTENCEDB_USER_NAME_2KEY = "" + DB_USER_NAME_KEY;
private static final String BE_PERSISTENCE_DB_PASSWORD_1KEY = "persistence.internal-db.passwd";
private static final String BE_PERSISTENCE_DB_PASSWORD_2KEY = "" + DB_PASSWORD_KEY;
private static final String BE_PERSISTENCE_POOL_DB_MAX_ACTIVE_KEY =
"persistence.internal-db.connection-pool.maxActive";
private static final String BE_PERSISTENCE_POOL_DB_MAX_WAIT_KEY =
"persistence.internal-db.connection-pool.maxWait";
private static final String BE_PERSISTENCE_DB_PROPERTIES = "persistence.internal-db.properties";
private static final String XMLRPC_SERVER_PORT_KEY = "synchcall.xmlrpc.unsecureServerPort";
private static final String LS_MAX_NUMBER_OF_ENTRY_KEY = "synchcall.directoryManager.maxLsEntry";
private static final String LS_ALL_LEVEL_RECURSIVE_KEY =
Expand Down Expand Up @@ -321,31 +306,21 @@ public List<String> getListOfMachineIPs() {
*/
public String getDBDriver() {

if (!cr.getConfiguration().containsKey(DB_DRIVER_KEY)) {
return "com.mysql.cj.jdbc.Driver";
}
String vendor = cr.getConfiguration().getString(DB_DRIVER_KEY);
String driver = "";
if ("mysql".equalsIgnoreCase(vendor)) {
driver = "com.mysql.cj.jdbc.Driver";
} else {
log.error("CONFIG ERROR 'RDBMS Vendor ('{}') unknown.'", vendor);
}
return driver;
return "com.mysql.cj.jdbc.Driver";
}

/**
* Method used by all DAO Objects to get DB URL. If no value is found in the configuration medium,
* then the default value is returned instead.
*/
public String getDBURL() {
public String getStormDbURL() {

String prefix = cr.getConfiguration().getString(DB_URL_PROTOCOL, "jdbc:mysql://");
String host = cr.getConfiguration().getString(DB_URL_HOSTNAME, "localhost");
String name = cr.getConfiguration().getString(DB_URL_DATABASE, "storm_db");
String properties =
cr.getConfiguration().getString(DB_URL_PROPERTIES, "serverTimezone=UTC&autoReconnect=true");
return prefix + host + "/" + name + "?" + properties;
String host = getDBHostname();
String properties = getDBProperties();
if (properties.isEmpty()) {
return "jdbc:mysql://" + host + "/storm_db";
}
return "jdbc:mysql://" + host + "/storm_db?" + properties;
}

/**
Expand All @@ -360,18 +335,28 @@ public String getDBUserName() {

/**
* Method used by all DAO Objects to get the DB password. If no value is found in the
* configuration medium, then the default value is returned instead. Deafult value = "storm"; key
* configuration medium, then the default value is returned instead. Default value = "storm"; key
* searched in medium = "asynch.picker.db.passwd".
*/
public String getDBPassword() {

return cr.getConfiguration().getString(DB_PASSWORD_KEY, "storm");
}

public String getDBHostname() {

return cr.getConfiguration().getString(DB_URL_HOSTNAME, "localhost");
}

/*
* END definition of MANDATORY PROPERTIES
*/

public String getDBProperties() {

return cr.getConfiguration().getString(DB_URL_PROPERTIES, "serverTimezone=UTC&autoReconnect=true");
}

/**
* Method used by all DAOs to establish the reconnection period in _seconds_: after such period
* the DB connection will be closed and re-opened. Beware that after such time expires, the
Expand Down Expand Up @@ -558,69 +543,6 @@ public int getCommandServerBindingPort() {
return cr.getConfiguration().getInt(COMMAND_SERVER_BINDING_PORT_KEY, 4444);
}

/**
* Method used in Persistence Component: it returns the host where the DB resides. If no value is
* found in the configuration medium, then the default value is returned instead.
* key="persistence.db.host"; default value="localhost";
*/
public String getBEPersistenceDBMSUrl() {

if (cr.getConfiguration().containsKey(BE_PERSISTENCE_DBMS_URL_1KEY)) {
return cr.getConfiguration().getString(BE_PERSISTENCE_DBMS_URL_1KEY);
}

if (cr.getConfiguration().containsKey(BE_PERSISTENCE_DBMS_URL_2KEY)) {
return cr.getConfiguration().getString(BE_PERSISTENCE_DBMS_URL_2KEY);
}
return "localhost";
}

/**
* Method used in Persistence Component it returns the name of the DB to use. If no value is found
* in the configuration medium, then the default value is returned instead.
* key="persistence.db.name"; default value="storm_be_ISAM";
*/
public String getBEPersistenceDBName() {

return cr.getConfiguration().getString(BE_PERSISTENCE_DB_NAME_KEY, "storm_be_ISAM");
}

/**
* Method used in Persistence Component it returns the name of the DB user that must be used. If
* no value is found in the configuration medium, then the default value is returned instead.
* key="persistence.db.username"; default value="storm";
*/
public String getBEPersistenceDBUserName() {

if (cr.getConfiguration().containsKey(BE_PERSISTENCEDB_USER_NAME_1KEY)) {
return cr.getConfiguration().getString(BE_PERSISTENCEDB_USER_NAME_1KEY);
}

if (cr.getConfiguration().containsKey(BE_PERSISTENCEDB_USER_NAME_2KEY)) {
return cr.getConfiguration().getString(BE_PERSISTENCEDB_USER_NAME_2KEY);
}

return "storm";
}

/**
* Method used in Persistence Component it returns the password for the DB user that must be used.
* If no value is found in the configuration medium, then the default value is returned instead.
* key="persistence.db.passwd"; default value="storm";
*/
public String getBEPersistenceDBPassword() {

if (cr.getConfiguration().containsKey(BE_PERSISTENCE_DB_PASSWORD_1KEY)) {
return cr.getConfiguration().getString(BE_PERSISTENCE_DB_PASSWORD_1KEY);
}

if (cr.getConfiguration().containsKey(BE_PERSISTENCE_DB_PASSWORD_2KEY)) {
return cr.getConfiguration().getString(BE_PERSISTENCE_DB_PASSWORD_2KEY);
}

return "storm";
}

/**
* Method used in Persistence Component it returns an int indicating the maximum number of active
* connections in the connection pool. It is the maximum number of active connections that can be
Expand All @@ -646,11 +568,6 @@ public int getBEPersistencePoolDBMaxWait() {
return cr.getConfiguration().getInt(BE_PERSISTENCE_POOL_DB_MAX_WAIT_KEY, 50);
}

public String getBEPersistenceDbProperties() {

return cr.getConfiguration().getString(BE_PERSISTENCE_DB_PROPERTIES, "serverTimezone=UTC&autoReconnect=true");
}

/**
* Method used by the Synch Component to set the binding port for the _unsecure_ xmlrpc server in
* the BE. If no value is found in the configuration medium, then the default value is returned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private void init(DataBaseStrategy db, int maxActive, int maxWait) {

String connectionString = db.getConnectionString();
connectionPoolDatasource.setUrl(connectionString);
log.debug("connection string: {}", connectionString);
log.debug("Database connection string: {}", connectionString);
connectionPoolDatasource.setUser(db.getDbUsr());
connectionPoolDatasource.setPassword(db.getDbPwd());

Expand Down
Loading

0 comments on commit edcb3c8

Please sign in to comment.