<commit_before>/*
 * Copyright 2013 Netherlands eScience Center
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package nl.esciencecenter.xenon.schedulers;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;

/**
 * JobDescription contains a description of a job that can be submitted to a {@link Scheduler}.
 *
 * @version 1.0
 * @since 1.0
 */
public class JobDescription {

    /** The default maximum run time */
    public static final int DEFAULT_MAX_RUN_TIME_IN_MINUTES = 15;

    /** The queue to submit to. */
    private String queueName = null;

    /** The executable to run. */
    private String executable = null;

    /** The name of the job. */
    private String name = null;

    /** The arguments to pass to the executable. */
    private final List<String> arguments = new ArrayList<>(10);

    /** The location file from which to redirect stdin. (optional) */
    private String stdin = null;

    /** The location file which to redirect stdout to. (optional) */
    private String stdout = null;

    /** The location file which to redirect stderr to. (optional) */
    private String stderr = null;

    /** The working directory for the job. */
    private String workingDirectory = null;

    /** The environment variables and their values */
    private final Map<String, String> environment = new HashMap<>(5);

    /** The job options of this job */
    private final Map<String, String> jobOptions = new HashMap<>(5);

    /** The number of nodes to run the job on. */
    private int nodeCount = 1;

    /** The number of processes to start/reserve per node. */
    private int processesPerNode = 1;

    /** The number of threads the executable will use per processes */
    private int threadsPerProcess = -1;

    /** The maximum amount of memory needed (in MB) on each node/process. */
    private int maxMemory = -1;

    /** If true, only a single process is started on the first node aquired, instead of nodeCount * processesPerNode. */
    private boolean startSingleProcess = false;

    /** The maximum run time in minutes. */
    private int maxRuntime = DEFAULT_MAX_RUN_TIME_IN_MINUTES;

    /**
     * Create a JobDescription.
     */
    public JobDescription() {
        // nothing
    }

    /**
     * Create a JobDescription by copying an existing one.
     *
     * @param original
     *            JobDescription to copy
     */
    public JobDescription(JobDescription original) {
        queueName = original.getQueueName();
        executable = original.getExecutable();
        name = original.getName();
        arguments.addAll(original.getArguments());
        stdin = original.getStdin();
        stdout = original.getStdout();
        stderr = original.getStderr();
        workingDirectory = original.getWorkingDirectory();
        environment.putAll(original.getEnvironment());
        jobOptions.putAll(original.getJobOptions());
        nodeCount = original.getNodeCount();
        processesPerNode = original.getProcessesPerNode();
        threadsPerProcess = original.getThreadsPerProcess();
        maxMemory = original.getMaxMemory();
        startSingleProcess = original.isStartSingleProcess();
        maxRuntime = original.getMaxRuntime();
    }

    /**
     * Get the job name.
     *
     * @return the job name.
     */
    public String getName() {
        return name;
    }

    /**
     * Set the number of nodes.
     *
     * @param nodeCount
     *            the number of nodes;
     */
    public void setName(String jobName) {
        this.name = jobName;
    }

    /**
     * Get the number of nodes.
     *
     * @return the number of nodes.
     */
    public int getNodeCount() {
        return nodeCount;
    }

    /**
     * Set the number of nodes.
     *
     * @param nodeCount
     *            the number of nodes;
     */
    public void setNodeCount(int nodeCount) {
        this.nodeCount = nodeCount;
    }

    /**
     * Get the number of processes to start on each node.
     *
     * @return the number of processesPerNode.
     */
    public int getProcessesPerNode() {
        return processesPerNode;
    }

    /**
     * Set the number of processes started on each node.
     *
     * @param processesPerNode
     *            the number of processes started on each node.
     */
    public void setProcessesPerNode(int processesPerNode) {
        this.processesPerNode = processesPerNode;
    }

    /**
     * Get the number of threads needed per process.
     *
     * @return the number of threads per process.
     */
    public int getThreadsPerProcess() {
        return threadsPerProcess;
    }

    /**
     * Set the number of threads needed per process.
     *
     * @param threadsPerProcess
     *            the number of threads needed per process.
     */
    public void setThreadsPerProcess(int processesPerNode) {
        this.threadsPerProcess = processesPerNode;
    }

    /**
     * Get the amount of memory needed for process (in MBytes).
     *
     * @return the amount of memory needed.
     */
    public int getMaxMemory() {
        return maxMemory;
    }

    /**
     * Set the amount of memory needed for process (in MBytes).<commit_msg>Fixed javadoc<commit_after>/*
 * Copyright 2013 Netherlands eScience Center
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package nl.esciencecenter.xenon.schedulers;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;

/**
 * JobDescription contains a description of a job that can be submitted to a {@link Scheduler}.
 *
 * @version 1.0
 * @since 1.0
 */
public class JobDescription {

    /** The default maximum run time */
    public static final int DEFAULT_MAX_RUN_TIME_IN_MINUTES = 15;

    /** The queue to submit to. */
    private String queueName = null;

    /** The executable to run. */
    private String executable = null;

    /** The name of the job. */
    private String name = null;

    /** The arguments to pass to the executable. */
    private final List<String> arguments = new ArrayList<>(10);

    /** The location file from which to redirect stdin. (optional) */
    private String stdin = null;

    /** The location file which to redirect stdout to. (optional) */
    private String stdout = null;

    /** The location file which to redirect stderr to. (optional) */
    private String stderr = null;

    /** The working directory for the job. */
    private String workingDirectory = null;

    /** The environment variables and their values */
    private final Map<String, String> environment = new HashMap<>(5);

    /** The job options of this job */
    private final Map<String, String> jobOptions = new HashMap<>(5);

    /** The number of nodes to run the job on. */
    private int nodeCount = 1;

    /** The number of processes to start/reserve per node. */
    private int processesPerNode = 1;

    /** The number of threads the executable will use per processes */
    private int threadsPerProcess = -1;

    /** The maximum amount of memory needed (in MB) on each node/process. */
    private int maxMemory = -1;

    /** If true, only a single process is started on the first node aquired, instead of nodeCount * processesPerNode. */
    private boolean startSingleProcess = false;

    /** The maximum run time in minutes. */
    private int maxRuntime = DEFAULT_MAX_RUN_TIME_IN_MINUTES;

    /**
     * Create a JobDescription.
     */
    public JobDescription() {
        // nothing
    }

    /**
     * Create a JobDescription by copying an existing one.
     *
     * @param original
     *            JobDescription to copy
     */
    public JobDescription(JobDescription original) {
        queueName = original.getQueueName();
        executable = original.getExecutable();
        name = original.getName();
        arguments.addAll(original.getArguments());
        stdin = original.getStdin();
        stdout = original.getStdout();
        stderr = original.getStderr();
        workingDirectory = original.getWorkingDirectory();
        environment.putAll(original.getEnvironment());
        jobOptions.putAll(original.getJobOptions());
        nodeCount = original.getNodeCount();
        processesPerNode = original.getProcessesPerNode();
        threadsPerProcess = original.getThreadsPerProcess();
        maxMemory = original.getMaxMemory();
        startSingleProcess = original.isStartSingleProcess();
        maxRuntime = original.getMaxRuntime();
    }

    /**
     * Get the job name.
     *
     * @return the job name.
     */
    public String getName() {
        return name;
    }

    /**
     * Set the name of the job.
     *
     * @param name
     *            the name of the job;
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * Get the number of nodes.
     *
     * @return the number of nodes.
     */
    public int getNodeCount() {
        return nodeCount;
    }

    /**
     * Set the number of nodes.
     *
     * @param nodeCount
     *            the number of nodes;
     */
    public void setNodeCount(int nodeCount) {
        this.nodeCount = nodeCount;
    }

    /**
     * Get the number of processes to start on each node.
     *
     * @return the number of processesPerNode.
     */
    public int getProcessesPerNode() {
        return processesPerNode;
    }

    /**
     * Set the number of processes started on each node.
     *
     * @param processesPerNode
     *            the number of processes started on each node.
     */
    public void setProcessesPerNode(int processesPerNode) {
        this.processesPerNode = processesPerNode;
    }

    /**
     * Get the number of threads needed per process.
     *
     * @return the number of threads per process.
     */
    public int getThreadsPerProcess() {
        return threadsPerProcess;
    }

    /**
     * Set the number of threads needed per process.
     *
     * @param threadsPerProcess
     *            the number of threads needed per process.
     */
    public void setThreadsPerProcess(int threadsPerProcess) {
        this.threadsPerProcess = threadsPerProcess;
    }

    /**
     * Get the amount of memory needed for process (in MBytes).
     *
     * @return the amount of memory needed.
     */
    public int getMaxMemory() {
        return maxMemory;
    }

    /**
     * Set the amount of memory needed for process (in MBytes).
{'fraction_non_alphanumeric': 0.09161876983786565, 'fraction_numerical': 0.0037745560607360383, 'mean_word_length': 2.3830528148578063, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1793374', 'n_tokens_mistral': 3128, 'n_tokens_neox': 3035, 'n_words': 1130}