changeset 905:a28637ab1e4f

JobConfigurator
author Devel 2
date Wed, 18 Apr 2018 14:36:26 +0200
parents ede69c8df2fa
children 3ea8aca2c6a9
files stress-tester/src/main/java/com/passus/st/config/JobConfigurator.java stress-tester/src/main/java/com/passus/st/job/JobExecutor.java
diffstat 2 files changed, 46 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stress-tester/src/main/java/com/passus/st/config/JobConfigurator.java	Wed Apr 18 14:36:26 2018 +0200
@@ -0,0 +1,45 @@
+package com.passus.st.config;
+
+import com.passus.commons.Assert;
+import com.passus.config.Configuration;
+import com.passus.config.ConfigurationContext;
+import com.passus.config.validation.Errors;
+
+public abstract class JobConfigurator {
+
+    protected Configuration config;
+
+    public Errors init(Configuration config) {
+        Assert.notNull(config, "config");
+        this.config = config;
+        return null;
+    }
+
+    private void ensureConfigLoaded() {
+        if (config == null) {
+            throw new IllegalStateException("Configuration not loaded.");
+        }
+    }
+
+    public final Errors validate(ConfigurationContext context) {
+        ensureConfigLoaded();
+        return doValidate(context);
+    }
+
+    public abstract Errors doValidate(ConfigurationContext context);
+
+    public final Errors configure(ConfigurationContext context) {
+        ensureConfigLoaded();
+        return doConfigure(context);
+    }
+
+    public abstract Errors doConfigure(ConfigurationContext context);
+
+    public final void destroy(ConfigurationContext context) {
+        ensureConfigLoaded();
+        doDestroy(context);
+    }
+
+    public abstract void doDestroy(ConfigurationContext context);
+
+}
--- a/stress-tester/src/main/java/com/passus/st/job/JobExecutor.java	Wed Apr 18 13:50:02 2018 +0200
+++ b/stress-tester/src/main/java/com/passus/st/job/JobExecutor.java	Wed Apr 18 14:36:26 2018 +0200
@@ -207,7 +207,7 @@
             metricsCollector.setPeriodTime(2_000);
 
             //TODO Na razie pobieramy caly projekt, docelowo powinny byc tworzona kopia parametrow
-            Project project = STApp.PROJECT_MANAGER.load(context.getProjectId());
+            Project project = STApp.PROJECT_MANAGER.init(context.getProjectId());
 
             if (LOGGER.isDebugEnabled()) {
                 LOGGER.debug("Configuring job: {} project id: {}, name: {}",