Skip to content
Snippets Groups Projects
Commit 751fa7fe authored by Daniel Hornung's avatar Daniel Hornung
Browse files

STY: Automatic style changes.

parent 3b4068a2
Branches
Tags
2 merge requests!21Release v0.4.0,!15Document server code structure
Pipeline #8363 passed
...@@ -145,9 +145,7 @@ public abstract class BackendTransaction implements Undoable { ...@@ -145,9 +145,7 @@ public abstract class BackendTransaction implements Undoable {
protected abstract void execute(); protected abstract void execute();
/** /** Like execute(), but with benchmarking measurement. */
* Like execute(), but with benchmarking measurement.
*/
public final void executeTransaction() { public final void executeTransaction() {
final long t1 = System.currentTimeMillis(); final long t1 = System.currentTimeMillis();
execute(); execute();
......
...@@ -60,10 +60,9 @@ import org.reflections.Reflections; ...@@ -60,10 +60,9 @@ import org.reflections.Reflections;
* @todo Describe me. * @todo Describe me.
*/ */
public abstract class Job { public abstract class Job {
/** /** All known Job classes, by name (actually lowercase getSimpleName()). */
* All known Job classes, by name (actually lowercase getSimpleName()).
*/
static HashMap<String, Class<? extends Job>> allClasses = null; static HashMap<String, Class<? extends Job>> allClasses = null;
private static List<Class<? extends Job>> loadAlways; private static List<Class<? extends Job>> loadAlways;
private Transaction<? extends TransactionContainer> transaction = null; private Transaction<? extends TransactionContainer> transaction = null;
...@@ -71,7 +70,6 @@ public abstract class Job { ...@@ -71,7 +70,6 @@ public abstract class Job {
private final JobExecutionTime time; private final JobExecutionTime time;
private EntityInterface entity = null; private EntityInterface entity = null;
public abstract JobTarget getTarget(); public abstract JobTarget getTarget();
protected <S, T> HashMap<S, T> getCache(final String name) { protected <S, T> HashMap<S, T> getCache(final String name) {
...@@ -239,8 +237,8 @@ public abstract class Job { ...@@ -239,8 +237,8 @@ public abstract class Job {
/** /**
* Create a Job object with the given parameters. * Create a Job object with the given parameters.
* <p> *
* This static method is used by other classes to create Job objects, instead of the private * <p>This static method is used by other classes to create Job objects, instead of the private
* constructor. * constructor.
* *
* @return The generated Job object. * @return The generated Job object.
...@@ -476,7 +474,6 @@ public abstract class Job { ...@@ -476,7 +474,6 @@ public abstract class Job {
/** /**
* @todo What is a permanent Job? What does "load" mean? * @todo What is a permanent Job? What does "load" mean?
*
* @return A list with the jobs. * @return A list with the jobs.
*/ */
public static List<Job> loadPermanentContainerJobs(Transaction<?> transaction) { public static List<Job> loadPermanentContainerJobs(Transaction<?> transaction) {
......
...@@ -26,9 +26,7 @@ import java.lang.annotation.Retention; ...@@ -26,9 +26,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import org.caosdb.server.transaction.TransactionInterface; import org.caosdb.server.transaction.TransactionInterface;
/** /** Jobs may be annotated with @JobAnnotation(...). */
* Jobs may be annotated with @JobAnnotation(...).
*/
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
public @interface JobAnnotation { public @interface JobAnnotation {
JobExecutionTime time() default JobExecutionTime.CHECK; JobExecutionTime time() default JobExecutionTime.CHECK;
......
...@@ -22,9 +22,7 @@ ...@@ -22,9 +22,7 @@
*/ */
package org.caosdb.server.jobs; package org.caosdb.server.jobs;
/** /** Not really a time (measured in seconds), but rather the execution stage. */
* Not really a time (measured in seconds), but rather the execution stage.
*/
public enum JobExecutionTime { public enum JobExecutionTime {
INIT, INIT,
PRE_CHECK, PRE_CHECK,
......
...@@ -30,9 +30,7 @@ import java.util.Map; ...@@ -30,9 +30,7 @@ import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import org.caosdb.server.entity.EntityInterface; import org.caosdb.server.entity.EntityInterface;
/** /** Keeps track of Jobs, ordered by "time". */
* Keeps track of Jobs, ordered by "time".
*/
public class Schedule { public class Schedule {
private final Map<Integer, List<ScheduledJob>> jobLists = new HashMap<>(); private final Map<Integer, List<ScheduledJob>> jobLists = new HashMap<>();
...@@ -57,9 +55,7 @@ public class Schedule { ...@@ -57,9 +55,7 @@ public class Schedule {
return ret; return ret;
} }
/** /** Run all Jobs with the specified JobExecutionTime. */
* Run all Jobs with the specified JobExecutionTime.
*/
public void runJobs(final JobExecutionTime time) { public void runJobs(final JobExecutionTime time) {
List<ScheduledJob> jobs = this.jobLists.get(time.ordinal()); List<ScheduledJob> jobs = this.jobLists.get(time.ordinal());
if (jobs != null) { if (jobs != null) {
...@@ -90,7 +86,7 @@ public class Schedule { ...@@ -90,7 +86,7 @@ public class Schedule {
/** /**
* Run all scheduled Jobs for the given entity. * Run all scheduled Jobs for the given entity.
* *
* Execution time: Either CHECK or what is given as jobclass' annotation. * <p>Execution time: Either CHECK or what is given as jobclass' annotation.
*/ */
public void runJob(final EntityInterface entity, final Class<? extends Job> jobclass) { public void runJob(final EntityInterface entity, final Class<? extends Job> jobclass) {
List<ScheduledJob> jobs = List<ScheduledJob> jobs =
......
...@@ -54,16 +54,12 @@ public class ScheduledJob { ...@@ -54,16 +54,12 @@ public class ScheduledJob {
return this.job.toString(); return this.job.toString();
} }
/** /** Does not actually start the job, but only sets the startTime. */
* Does not actually start the job, but only sets the startTime.
*/
private void start() { private void start() {
this.startTime = System.currentTimeMillis(); this.startTime = System.currentTimeMillis();
} }
/** /** Calculate and set the runtime, and add the measurement. */
* Calculate and set the runtime, and add the measurement.
*/
private void finish() { private void finish() {
this.runtime += System.currentTimeMillis() - this.startTime; this.runtime += System.currentTimeMillis() - this.startTime;
this.job this.job
...@@ -84,9 +80,7 @@ public class ScheduledJob { ...@@ -84,9 +80,7 @@ public class ScheduledJob {
return this.startTime != -1; return this.startTime != -1;
} }
/** /** Return the state of the inner Job. */
* Return the state of the inner Job.
*/
public JobExecutionTime getExecutionTime() { public JobExecutionTime getExecutionTime() {
return this.job.getExecutionTime(); return this.job.getExecutionTime();
} }
......
...@@ -88,8 +88,8 @@ public abstract class Transaction<C extends TransactionContainer> extends Abstra ...@@ -88,8 +88,8 @@ public abstract class Transaction<C extends TransactionContainer> extends Abstra
/** /**
* Implementation note: Not called in this class, but may be used by subclasses. * Implementation note: Not called in this class, but may be used by subclasses.
* <p> *
* E.g. in {@link Retrieve} and {@link WriteTransaction}. * <p>E.g. in {@link Retrieve} and {@link WriteTransaction}.
*/ */
protected void makeSchedule() throws Exception { protected void makeSchedule() throws Exception {
// load flag jobs // load flag jobs
...@@ -122,28 +122,28 @@ public abstract class Transaction<C extends TransactionContainer> extends Abstra ...@@ -122,28 +122,28 @@ public abstract class Transaction<C extends TransactionContainer> extends Abstra
/** /**
* The main transaction execution method. * The main transaction execution method.
* <p>
* This method calls the following other internal methods and scheduled jobs stored in the {@link
* getSchedule() internal Schedule object}:
* <ul>
* <li> {@link init}
* <li> {@link Schedule.runJobs(INIT)}
* <li> {@link preCheck}
* <li> {@link Schedule.runJobs(PRE_CHECK)}
* <li> {@link check}
* <li> {@link Schedule.runJobs(POST_CHECK)}
* <li> {@link postCheck}
* <li> {@link preTransaction}
* <li> {@link Schedule.runJobs(PRE_TRANSACTION)}
* <li> {@link transaction}: This is typically the main method of a Transaction.
* <li> {@link Schedule.runJobs(POST_TRANSACTION)}
* <li> {@link postTransaction}
* <li> {@link writeHistory}
* <li> {@link commit}
* <li> {@link rollBack}: Only in the case of errors.
* <li> {@link cleanUp}: Always.
* <li> {@link notifyObservers(CLEAN_UP)}: Also always.
* *
* <p>This method calls the following other internal methods and scheduled jobs stored in the
* {@link getSchedule() internal Schedule object}:
*
* <ul>
* <li>{@link init}
* <li>{@link Schedule.runJobs(INIT)}
* <li>{@link preCheck}
* <li>{@link Schedule.runJobs(PRE_CHECK)}
* <li>{@link check}
* <li>{@link Schedule.runJobs(POST_CHECK)}
* <li>{@link postCheck}
* <li>{@link preTransaction}
* <li>{@link Schedule.runJobs(PRE_TRANSACTION)}
* <li>{@link transaction}: This is typically the main method of a Transaction.
* <li>{@link Schedule.runJobs(POST_TRANSACTION)}
* <li>{@link postTransaction}
* <li>{@link writeHistory}
* <li>{@link commit}
* <li>{@link rollBack}: Only in the case of errors.
* <li>{@link cleanUp}: Always.
* <li>{@link notifyObservers(CLEAN_UP)}: Also always.
*/ */
@Override @Override
public final void execute() throws Exception { public final void execute() throws Exception {
...@@ -234,8 +234,8 @@ public abstract class Transaction<C extends TransactionContainer> extends Abstra ...@@ -234,8 +234,8 @@ public abstract class Transaction<C extends TransactionContainer> extends Abstra
/** /**
* Return the internal {@link Schedule} object. * Return the internal {@link Schedule} object.
* <p> *
* The Schedule stores jobs which are also triggered by this transaction (see {@link execute()} * <p>The Schedule stores jobs which are also triggered by this transaction (see {@link execute()}
* for details). * for details).
*/ */
public Schedule getSchedule() { public Schedule getSchedule() {
......
...@@ -37,8 +37,7 @@ public interface TransactionInterface { ...@@ -37,8 +37,7 @@ public interface TransactionInterface {
/** /**
* Append the BackendTransaction t to a RollBackHandler before basically calling {@code * Append the BackendTransaction t to a RollBackHandler before basically calling {@code
* t.execute()}. Except for benchmarking, this method does not interact directly with this * t.execute()}. Except for benchmarking, this method does not interact directly with this object.
* object.
*/ */
public default <K extends BackendTransaction> K execute(K t, Access access) { public default <K extends BackendTransaction> K execute(K t, Access access) {
final RollBackHandler handler = (RollBackHandler) access.getHelper("RollBack"); final RollBackHandler handler = (RollBackHandler) access.getHelper("RollBack");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment