Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
velocity.log
out/
err/
workflow.out
workflow.err
conf/
42 changes: 30 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -56,8 +56,8 @@
</plugin>

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.1</version>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.1</version>
</plugin>

<plugin>
Expand Down Expand Up @@ -90,21 +90,39 @@

<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.18</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.17</version>
</dependency>

<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.9</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>2.0.17</version>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
<version>2.17.0</version>
</dependency>

<dependency>
Expand All @@ -126,10 +144,10 @@
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.11.3</version>
<scope>test</scope>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.11.3</version>
<scope>test</scope>
</dependency>

<dependency>
Expand Down
40 changes: 4 additions & 36 deletions src/main/java/fr/insalyon/creatis/gasw/Gasw.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,15 @@
import fr.insalyon.creatis.gasw.execution.ExecutorFactory;
import fr.insalyon.creatis.gasw.execution.FailOver;
import fr.insalyon.creatis.gasw.plugin.ExecutorPlugin;

import java.util.List;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
*
* @author Rafael Ferreira da Silva
*/
public class Gasw {

Check failure on line 43 in src/main/java/fr/insalyon/creatis/gasw/Gasw.java

View workflow job for this annotation

GitHub Actions / all

This class has only private constructors and may be final

Reports classes that may be made final because they cannot be extended from outside their compilation unit anyway. This is because all their constructors are private, so a subclass could not call the super constructor. ClassWithOnlyPrivateConstructorsShouldBeFinal (Priority: 1, Ruleset: Design) https://docs.pmd-code.org/snapshot/pmd_rules_java_design.html#classwithonlyprivateconstructorsshouldbefinal

Check warning on line 43 in src/main/java/fr/insalyon/creatis/gasw/Gasw.java

View workflow job for this annotation

GitHub Actions / all

Avoid short class names like Gasw

Short Classnames with fewer than e.g. five characters are not recommended. ShortClassName (Priority: 4, Ruleset: Code Style) https://docs.pmd-code.org/snapshot/pmd_rules_java_codestyle.html#shortclassname

private static final Logger logger = Logger.getLogger("fr.insalyon.creatis.gasw");
private static final Logger logger = LoggerFactory.getLogger(Gasw.class);

Check failure on line 44 in src/main/java/fr/insalyon/creatis/gasw/Gasw.java

View workflow job for this annotation

GitHub Actions / all

The constant name 'logger' doesn't match '[A-Z][A-Z_0-9]*'

Configurable naming conventions for field declarations. This rule reports variable declarations which do not match the regex that applies to their specific kind ---e.g. constants (static final), enum constant, final field. Each regex can be configured through properties. By default this rule uses the standard Java naming convention (Camel case), and uses the ALL_UPPER convention for constants and enum constants. FieldNamingConventions (Priority: 1, Ruleset: Code Style) https://docs.pmd-code.org/snapshot/pmd_rules_java_codestyle.html#fieldnamingconventions
private static Gasw instance;
private GaswNotification notification;

Check warning on line 46 in src/main/java/fr/insalyon/creatis/gasw/Gasw.java

View workflow job for this annotation

GitHub Actions / all

Field 'notification' may be declared final

Reports non-final fields whose value never changes once object initialization ends, and hence may be marked final. Note that this rule does not enforce that the field value be deeply immutable itself. An object can still have mutable state, even if all its member fields are declared final. This is referred to as shallow immutability. For more information on mutability, see *Effective Java, 3rd Edition, Item 17: Minimize mutability*. Limitations: We can only check private fields for now. ImmutableField (Priority: 3, Ruleset: Design) https://docs.pmd-code.org/snapshot/pmd_rules_java_design.html#immutablefield

/**
* Gets a default instance of GASW.
Expand All @@ -63,10 +59,7 @@
}

private Gasw() throws GaswException {

try {
PropertyConfigurator.configure(
Gasw.class.getClassLoader().getResource("gaswLog4j.properties"));
logger.info("Initializing GASW.");
GaswConfiguration.getInstance().loadHibernate();

Expand All @@ -77,51 +70,26 @@
}
}

/**
* Sets the client which will receive notifications.
*
* @param client
*/
public synchronized void setNotificationClient(Object client) {

Check warning on line 73 in src/main/java/fr/insalyon/creatis/gasw/Gasw.java

View workflow job for this annotation

GitHub Actions / all

Parameter 'client' is not assigned and could be declared final

Reports method and constructor parameters that can be made final because they are never reassigned within the body of the method. This rule ignores unused parameters so as not to overlap with the rule {% rule java/bestpractices/UnusedFormalParameter %}. It will also ignore the parameters of abstract methods. MethodArgumentCouldBeFinal (Priority: 3, Ruleset: Code Style) https://docs.pmd-code.org/snapshot/pmd_rules_java_codestyle.html#methodargumentcouldbefinal

notification.setClient(client);
}

/**
*
* @param gaswInput
* @return
* @throws GaswException
*/
public synchronized String submit(GaswInput gaswInput) throws GaswException {

Check warning on line 77 in src/main/java/fr/insalyon/creatis/gasw/Gasw.java

View workflow job for this annotation

GitHub Actions / all

Parameter 'gaswInput' is not assigned and could be declared final

Reports method and constructor parameters that can be made final because they are never reassigned within the body of the method. This rule ignores unused parameters so as not to overlap with the rule {% rule java/bestpractices/UnusedFormalParameter %}. It will also ignore the parameters of abstract methods. MethodArgumentCouldBeFinal (Priority: 3, Ruleset: Code Style) https://docs.pmd-code.org/snapshot/pmd_rules_java_codestyle.html#methodargumentcouldbefinal

ExecutorPlugin executor = ExecutorFactory.getExecutor(gaswInput);

Check warning on line 79 in src/main/java/fr/insalyon/creatis/gasw/Gasw.java

View workflow job for this annotation

GitHub Actions / all

Local variable 'executor' could be declared final

A local variable assigned only once can be declared final. LocalVariableCouldBeFinal (Priority: 3, Ruleset: Code Style) https://docs.pmd-code.org/snapshot/pmd_rules_java_codestyle.html#localvariablecouldbefinal
executor.load(gaswInput);
return executor.submit();
}

/**
* Gets the list of output objects of all finished jobs
*
* @return List of output objects of finished jobs.
*/
public synchronized List<GaswOutput> getFinishedJobs() {
return notification.getFinishedJobs();
}

/**
* The client informs GASW that it is waiting for new notifications.
*/
public synchronized void waitForNotification() {
notification.waitForNotification();
}

/**
* Terminates all GASW threads and close the connection with the database.
*
* @throws GaswException
*/
public synchronized void terminate(boolean force) throws GaswException {

Check warning on line 92 in src/main/java/fr/insalyon/creatis/gasw/Gasw.java

View workflow job for this annotation

GitHub Actions / all

Parameter 'force' is not assigned and could be declared final

Reports method and constructor parameters that can be made final because they are never reassigned within the body of the method. This rule ignores unused parameters so as not to overlap with the rule {% rule java/bestpractices/UnusedFormalParameter %}. It will also ignore the parameters of abstract methods. MethodArgumentCouldBeFinal (Priority: 3, Ruleset: Code Style) https://docs.pmd-code.org/snapshot/pmd_rules_java_codestyle.html#methodargumentcouldbefinal
notification.terminate();

if (GaswConfiguration.getInstance().isFailOverEnabled()) {
Expand Down
45 changes: 10 additions & 35 deletions src/main/java/fr/insalyon/creatis/gasw/GaswConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,51 +30,48 @@
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package fr.insalyon.creatis.gasw;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;

import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;

import fr.insalyon.creatis.gasw.bean.Data;
import fr.insalyon.creatis.gasw.bean.DataToReplicate;
import fr.insalyon.creatis.gasw.bean.Job;
import fr.insalyon.creatis.gasw.bean.JobMinorStatus;
import fr.insalyon.creatis.gasw.bean.Node;
import fr.insalyon.creatis.gasw.bean.NodeID;
import fr.insalyon.creatis.gasw.bean.SEEntryPoint;
import fr.insalyon.creatis.gasw.bean.SEEntryPointID;
import fr.insalyon.creatis.gasw.dao.DAOException;
import fr.insalyon.creatis.gasw.dao.DAOFactory;
import fr.insalyon.creatis.gasw.plugin.DatabasePlugin;
import fr.insalyon.creatis.gasw.plugin.ExecutorPlugin;
import fr.insalyon.creatis.gasw.plugin.ListenerPlugin;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.base.util.JSPFProperties;
import net.xeoh.plugins.base.util.PluginManagerUtil;

/**
*
* @author Rafael Ferreira da Silva
*/
public class GaswConfiguration {

Check failure on line 70 in src/main/java/fr/insalyon/creatis/gasw/GaswConfiguration.java

View workflow job for this annotation

GitHub Actions / all

This class has only private constructors and may be final

Reports classes that may be made final because they cannot be extended from outside their compilation unit anyway. This is because all their constructors are private, so a subclass could not call the super constructor. ClassWithOnlyPrivateConstructorsShouldBeFinal (Priority: 1, Ruleset: Design) https://docs.pmd-code.org/snapshot/pmd_rules_java_design.html#classwithonlyprivateconstructorsshouldbefinal

Check warning on line 70 in src/main/java/fr/insalyon/creatis/gasw/GaswConfiguration.java

View workflow job for this annotation

GitHub Actions / all

Possible God Class (WMC=66, ATFD=55, TCC=6.154%)

The God Class rule detects the God Class design flaw using metrics. God classes do too many things, are very big and overly complex. They should be split apart to be more object-oriented. The rule uses the detection strategy described in "Object-Oriented Metrics in Practice". The violations are reported against the entire class. The rule uses metrics to implement its detection strategy. The violation message gives information about the values of these metrics: * WMC: a class complexity measure, see {% jdoc java::lang.java.metrics.JavaMetrics#WEIGHED_METHOD_COUNT %} * ATFD: a measure of how much data external data the class uses, see {% jdoc java::lang.java.metrics.JavaMetrics#ACCESS_TO_FOREIGN_DATA %} * TCC: a measure of how tightly related the methods are, see {% jdoc java::lang.java.metrics.JavaMetrics#TIGHT_CLASS_COHESION %} The rule identifies a god class by looking for classes which have all of the following properties: * High WMC * High ATFD * Low TCC See also the reference: Michele Lanza and Radu Marinescu. *Object-Oriented Metrics in Practice: Using Software Metrics to Characterize, Evaluate, and Improve the Design of Object-Oriented Systems.* Springer, Berlin, 1 edition, October 2006. Page 80. GodClass (Priority: 3, Ruleset: Design) https://docs.pmd-code.org/snapshot/pmd_rules_java_design.html#godclass

private static final Logger logger = Logger.getLogger("fr.insalyon.creatis.gasw");
private static final Logger logger = LoggerFactory.getLogger(GaswConfiguration.class);

Check failure on line 72 in src/main/java/fr/insalyon/creatis/gasw/GaswConfiguration.java

View workflow job for this annotation

GitHub Actions / all

The constant name 'logger' doesn't match '[A-Z][A-Z_0-9]*'

Configurable naming conventions for field declarations. This rule reports variable declarations which do not match the regex that applies to their specific kind ---e.g. constants (static final), enum constant, final field. Each regex can be configured through properties. By default this rule uses the standard Java naming convention (Camel case), and uses the ALL_UPPER convention for constants and enum constants. FieldNamingConventions (Priority: 1, Ruleset: Code Style) https://docs.pmd-code.org/snapshot/pmd_rules_java_codestyle.html#fieldnamingconventions
private static final String configDir = "./conf";

Check failure on line 73 in src/main/java/fr/insalyon/creatis/gasw/GaswConfiguration.java

View workflow job for this annotation

GitHub Actions / all

The constant name 'configDir' doesn't match '[A-Z][A-Z_0-9]*'

Configurable naming conventions for field declarations. This rule reports variable declarations which do not match the regex that applies to their specific kind ---e.g. constants (static final), enum constant, final field. Each regex can be configured through properties. By default this rule uses the standard Java naming convention (Camel case), and uses the ALL_UPPER convention for constants and enum constants. FieldNamingConventions (Priority: 1, Ruleset: Code Style) https://docs.pmd-code.org/snapshot/pmd_rules_java_codestyle.html#fieldnamingconventions
private static final String configFile = "settings.conf";

Check failure on line 74 in src/main/java/fr/insalyon/creatis/gasw/GaswConfiguration.java

View workflow job for this annotation

GitHub Actions / all

The constant name 'configFile' doesn't match '[A-Z][A-Z_0-9]*'

Configurable naming conventions for field declarations. This rule reports variable declarations which do not match the regex that applies to their specific kind ---e.g. constants (static final), enum constant, final field. Each regex can be configured through properties. By default this rule uses the standard Java naming convention (Camel case), and uses the ALL_UPPER convention for constants and enum constants. FieldNamingConventions (Priority: 1, Ruleset: Code Style) https://docs.pmd-code.org/snapshot/pmd_rules_java_codestyle.html#fieldnamingconventions
private static GaswConfiguration instance;
private static boolean strict = true;
private PropertiesConfiguration config;
Expand All @@ -84,7 +81,7 @@
private String simulationID;
// Default Properties
private String defaultExecutor;
private String defaultEnvironment;

Check warning on line 84 in src/main/java/fr/insalyon/creatis/gasw/GaswConfiguration.java

View workflow job for this annotation

GitHub Actions / all

Avoid excessively long variable names like defaultEnvironment

Fields, formal arguments, or local variable names that are too long can make the code difficult to follow. LongVariable (Priority: 3, Ruleset: Code Style) https://docs.pmd-code.org/snapshot/pmd_rules_java_codestyle.html#longvariable
private String defaultBackgroundScript;
private String defaultRequirements;
private int defaultRetryCount;
Expand Down Expand Up @@ -127,7 +124,6 @@
private SessionFactory sessionFactory;

public static GaswConfiguration getInstance() throws GaswException {

if (instance == null) {
instance = new GaswConfiguration();
}
Expand Down Expand Up @@ -231,7 +227,7 @@
config.save();

} catch (ConfigurationException ex) {
logger.error(ex);
logger.error("Error:", ex);
}
}

Expand All @@ -243,11 +239,6 @@
}
}

/**
* Loads GASW plugins.
*
* @throws GaswException
*/
private void loadPlugins() throws GaswException {

final JSPFProperties props = new JSPFProperties();
Expand All @@ -274,19 +265,12 @@

private URI getAndLogPluginUri(String pluginPath, String pluginType) {
URI pluginUri = new File(pluginPath).toURI();
logger.info("Loading " + pluginType + " plugin from " + pluginPath
+ " (loaded URI : " + pluginUri + ")");
logger.info("Loading {} plugin from {} (loaded URI : {})", pluginType, pluginPath, pluginUri);
return pluginUri;
}

/**
* Loads Hibernate properties
*
* @throws GaswException
*/
public void loadHibernate() throws GaswException {

logger.info("Loading database plugin '" + dbPlugin.getName() + "'.");
logger.info("Loading database plugin '{}'.", dbPlugin.getName());
dbPlugin.load();

Configuration cfg = new Configuration();
Expand Down Expand Up @@ -325,10 +309,6 @@
sessionFactory = cfg.buildSessionFactory(serviceRegistry);
}

/**
*
* @throws GaswException
*/
private void loadSEEntryPoints() throws GaswException {
try {
logger.info("Loading SEs entry points.");
Expand All @@ -353,10 +333,10 @@
service.getPath()));

} catch (URISyntaxException ex) {
logger.warn("Unable to read end point from: " + s);
logger.warn("Unable to read end point from: {}", s);
} catch (DAOException ex) {
if (!ex.getMessage().contains("duplicate key value")) {
logger.warn("Unable to save end point: " + ex.getMessage());
logger.warn("Unable to save end point: {}", ex.getMessage());
}
}
}
Expand All @@ -369,20 +349,15 @@
throw new GaswException("Unable to load SEs entry points.");
}
} catch (InterruptedException ex) {
logger.error(ex);
logger.error("Error:", ex);
throw new GaswException(ex);

} catch (IOException ex) {
logger.error(ex);
logger.error("Error:", ex);
throw new GaswException(ex);
}
}

/**
* Terminates all plugins.
*
* @throws GaswException
*/
public void terminate(boolean force) throws GaswException {

for (ExecutorPlugin executorPlugin : executorPlugins) {
Expand Down
Loading
Loading