Skip to content

Commit

Permalink
Database connection pool refactored and used also for requests db
Browse files Browse the repository at this point in the history
- Added new configuration keys into storm.properties. Deprecated others.
- Also moved some timer task out of catalogs into an executor service
  • Loading branch information
enricovianello committed Feb 22, 2021
1 parent c711bb3 commit 7aaa9f9
Show file tree
Hide file tree
Showing 265 changed files with 20,039 additions and 31,438 deletions.
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<name>StoRM Backend server</name>
<groupId>org.italiangrid.storm</groupId>
<artifactId>storm-backend-server</artifactId>
<version>1.11.19</version>
<version>1.12.0</version>

<properties>

Expand All @@ -18,13 +18,13 @@
<nettyVersion>3.5.0.Final</nettyVersion>
<jnaVersion>3.3.0</jnaVersion>
<jettisonVersion>1.1</jettisonVersion>
<commonsDbcpVersion>1.2.1</commonsDbcpVersion>
<commonsDbcpVersion>2.8.0</commonsDbcpVersion>
<commonsIoVersion>2.0.1</commonsIoVersion>
<ini4jVersion>0.5.2</ini4jVersion>
<xmlrpcVersion>3.0</xmlrpcVersion>
<jaxrpcVersion>1.1</jaxrpcVersion>
<jsonVersion>20080701</jsonVersion>
<junitVersion>4.8.1</junitVersion>
<junitVersion>4.13.1</junitVersion>
<commonsCliVersion>1.0</commonsCliVersion>
<commonsDiscoveryVersion>0.2</commonsDiscoveryVersion>
<commonsHttpClientVersion>3.1</commonsHttpClientVersion>
Expand All @@ -35,7 +35,7 @@
<mailVersion>1.4.6</mailVersion>
<jakartaXmlBindVersion>2.3.3</jakartaXmlBindVersion>

<mysqlConnectorVersion>5.1.12</mysqlConnectorVersion>
<mysqlConnectorVersion>8.0.16</mysqlConnectorVersion>

<guavaVersion>18.0</guavaVersion>
<metrics.version>3.1.0</metrics.version>
Expand Down Expand Up @@ -376,8 +376,8 @@
</dependency>

<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
<version>${commonsDbcpVersion}</version>
</dependency>

Expand Down
2 changes: 0 additions & 2 deletions src/main/java/it/grid/storm/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public class Constants {
private static final Logger log = LoggerFactory.getLogger(Constants.class);

public static final Entry BE_VERSION;
public static final Entry NAMESPACE_VERSION;
public static final Entry BE_OS_DISTRIBUTION;
public static final Entry BE_OS_PLATFORM;
public static final Entry BE_OS_KERNEL_RELEASE;
Expand All @@ -49,7 +48,6 @@ private Constants() {}

static {
BE_VERSION = new Entry("BE-Version", Constants.class.getPackage().getImplementationVersion());
NAMESPACE_VERSION = new Entry("Namespace-version", "1.5.0");
BE_OS_DISTRIBUTION = new Entry("BE-OS-Distribution", getDistribution());
Map<String, String> map = getPlatformKernel();
BE_OS_PLATFORM = new Entry(BE_OS_PLATFORM_KEY, map.get(BE_OS_PLATFORM_KEY));
Expand Down
1 change: 1 addition & 0 deletions src/main/java/it/grid/storm/ShutdownHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public void run() {
storm.stopSpaceGC();
storm.stopExpiredAgent();
storm.stopDiskUsageService();
storm.stopRequestGarbageCollector();
GPFSQuotaManager.INSTANCE.shutdown();

log.info("StoRM: Backend successfully stopped.");
Expand Down
88 changes: 48 additions & 40 deletions src/main/java/it/grid/storm/StoRM.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@

import it.grid.storm.asynch.AdvancedPicker;
import it.grid.storm.catalogs.ReservedSpaceCatalog;
import it.grid.storm.catalogs.StoRMDataSource;
import it.grid.storm.catalogs.timertasks.ExpiredPutRequestsAgent;
import it.grid.storm.catalogs.executors.RequestFinalizerService;
import it.grid.storm.catalogs.timertasks.RequestsGarbageCollector;
import it.grid.storm.check.CheckManager;
import it.grid.storm.check.CheckResponse;
import it.grid.storm.check.CheckStatus;
Expand Down Expand Up @@ -72,13 +72,16 @@ public class StoRM {
private boolean isSpaceGCRunning = false;

/*
* Timer object in charge of transit expired put requests from SRM_SPACE_AVAILABLE to
* SRM_FILE_LIFETIME_EXPIRED and from SRM_REQUEST_INPROGRESS to SRM_FAILURE
* Agent in charge of transit expired ptg/ptp/bol requests to final statuses
*/
private final Timer transiter = new Timer();
private TimerTask expiredAgent;
private RequestFinalizerService expiredAgent;
private boolean isExpiredAgentRunning = false;

/* Requests Garbage Collector */
private final Timer rgc = new Timer();
private TimerTask rgcTask;
private boolean isRequestGCRunning = false;

private boolean isDiskUsageServiceEnabled = false;
private DiskUsageService duService;

Expand All @@ -96,7 +99,7 @@ public StoRM() {

config = Configuration.getInstance();
picker = new AdvancedPicker();
spaceCatalog = new ReservedSpaceCatalog();
spaceCatalog = ReservedSpaceCatalog.getInstance();

}

Expand All @@ -108,8 +111,6 @@ public void init() throws BootstrapException {

configureMetricsReporting();

configureStoRMDataSource();

loadNamespaceConfiguration();

HealthDirector.initializeDirector(false);
Expand Down Expand Up @@ -216,11 +217,6 @@ private void performSanityChecks() throws BootstrapException {

}

private void configureStoRMDataSource() {

StoRMDataSource.init();
}

/**
* Method used to start the picker.
*/
Expand All @@ -247,14 +243,6 @@ public synchronized void stopPicker() {
isPickerRunning = false;
}

/**
* @return
*/
public synchronized boolean pickerIsRunning() {

return isPickerRunning;
}

/**
* Method used to start xmlrpcServer.
*
Expand Down Expand Up @@ -382,14 +370,6 @@ public synchronized void stopSpaceGC() {
isSpaceGCRunning = false;
}

/**
* @return
*/
public synchronized boolean spaceGCIsRunning() {

return isSpaceGCRunning;
}

/**
* Starts the internal timer needed to periodically check and transit requests whose pinLifetime
* has expired and are in SRM_SPACE_AVAILABLE, to SRM_FILE_LIFETIME_EXPIRED. Moreover, the
Expand All @@ -405,16 +385,8 @@ public synchronized void startExpiredAgent() {
return;
}

/* Delay time before starting cleaning thread! Set to 1 minute */
final long delay = config.getTransitInitialDelay() * 1000L;
/* Period of execution of cleaning! Set to 1 hour */
final long period = config.getTransitTimeInterval() * 1000L;
/* Expiration time before starting move in-progress requests to failure */
final long inProgressExpirationTime = config.getInProgressPutRequestExpirationTime();

log.debug("Starting Expired Agent.");
expiredAgent = new ExpiredPutRequestsAgent(inProgressExpirationTime);
transiter.scheduleAtFixedRate(expiredAgent, delay, period);
expiredAgent = new RequestFinalizerService(config);
isExpiredAgentRunning = true;
log.debug("Expired Agent started.");
}
Expand All @@ -428,7 +400,7 @@ public synchronized void stopExpiredAgent() {

log.debug("Stopping Expired Agent.");
if (expiredAgent != null) {
expiredAgent.cancel();
expiredAgent.stop();
}
log.debug("Expired Agent stopped.");
isExpiredAgentRunning = false;
Expand Down Expand Up @@ -498,13 +470,48 @@ public synchronized void stopDiskUsageService() {
}
}

public synchronized void startRequestGarbageCollector() {

if (isRequestGCRunning) {
log.debug("Requests Garbage Collector is already running.");
return;
}

/* Delay time before starting cleaning thread */
final long delay = config.getRequestPurgerDelay() * 1000L;
/* Period of execution of cleaning */
final long period = config.getRequestPurgerPeriod() * 1000L;

log.debug("Starting Requests Garbage Collector .");
rgcTask = new RequestsGarbageCollector(rgc, period);
rgc.schedule(rgcTask, delay);
isRequestGCRunning = true;
log.debug("Requests Garbage Collector started.");
}

public synchronized void stopRequestGarbageCollector() {

if (!isRequestGCRunning) {
log.debug("Requests Garbage Collector is not running.");
return;
}

log.debug("Stopping Requests Garbage Collector.");
if (rgcTask != null) {
rgcTask.cancel();
}
log.debug("Requests Garbage Collector stopped.");
isRequestGCRunning = false;
}

public void startServices() throws Exception {

startPicker();
startXmlRpcServer();
startRestServer();
startSpaceGC();
startExpiredAgent();
startRequestGarbageCollector();
startDiskUsageService();
}

Expand All @@ -515,6 +522,7 @@ public void stopServices() {
stopRestServer();
stopSpaceGC();
stopExpiredAgent();
stopRequestGarbageCollector();
stopDiskUsageService();

GPFSQuotaManager.INSTANCE.shutdown();
Expand Down
56 changes: 0 additions & 56 deletions src/main/java/it/grid/storm/acl/AclManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,60 +114,4 @@ FilesystemPermission setGroupPermission(LocalFile localFile, LocalUser localUser
FilesystemPermission setUserPermission(LocalFile localFile, LocalUser localUser,
FilesystemPermission permission) throws IllegalArgumentException;

/**
* @param localFile an existent file
* @throws IllegalArgumentException if received null parameters or the LocalFile object refers to
* a not existent file
*/
void removeHttpsPermissions(LocalFile localFile) throws IllegalArgumentException;

/**
* @param localFile an existent file
* @param localUser
* @param permission
* @throws IllegalArgumentException if received null parameters or the LocalFile object refers to
* a not existent file
*/
void grantHttpsUserPermission(LocalFile localFile, LocalUser localUser,
FilesystemPermission permission) throws IllegalArgumentException;

/**
* @param localFile an existent file
* @param localUser
* @param permission
* @throws IllegalArgumentException if received null parameters or the LocalFile object refers to
* a not existent file
*/
void grantHttpsServiceGroupPermission(LocalFile localFile, FilesystemPermission permission)
throws IllegalArgumentException;

/**
* @param localFile an existent file
* @param localUser
* @param permission
* @throws IllegalArgumentException if received null parameters or the LocalFile object refers to
* a not existent file
*/
void grantHttpsGroupPermission(LocalFile localFile, LocalUser localUser,
FilesystemPermission permission) throws IllegalArgumentException;

/**
* @param localFile an existent file
* @param localUser
* @param permission
* @throws IllegalArgumentException if received null parameters or the LocalFile object refers to
* a not existent file
*/
void grantHttpsServiceUserPermission(LocalFile localFile, FilesystemPermission permission)
throws IllegalArgumentException;

/**
* @param oldLocalFile an existent source file
* @param newLocalFile an existent destination file
* @throws IllegalArgumentException if received null parameters or the LocalFile objects refers to
* not existent files
*/
void moveHttpsPermissions(LocalFile oldLocalFile, LocalFile newLocalFile)
throws IllegalArgumentException;

}
Loading

0 comments on commit 7aaa9f9

Please sign in to comment.