<commit_before>package org.ow2.proactive.scheduler.smartproxy.common;

import org.apache.log4j.Logger;
import org.objectweb.proactive.utils.NamedThreadFactory;
import org.ow2.proactive.db.SortParameter;
import org.ow2.proactive.scheduler.common.*;
import org.ow2.proactive.scheduler.common.exception.*;
import org.ow2.proactive.scheduler.common.job.*;
import org.ow2.proactive.scheduler.common.task.*;
import org.ow2.proactive.scheduler.common.usage.JobUsage;
import org.ow2.proactive.scheduler.common.util.logforwarder.AppenderProvider;
import org.ow2.proactive.scheduler.job.SchedulerUserInfo;

import javax.security.auth.login.LoginException;
import java.io.File;
import java.security.KeyException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;

import static com.google.common.base.Strings.isNullOrEmpty;
import static com.google.common.base.Throwables.propagate;
import static com.google.common.base.Throwables.propagateIfInstanceOf;
import static org.ow2.proactive.scheduler.common.SchedulerEvent.*;

/**
 * Asbtract implementation of smart proxy that factorizes code used by all smart proxy implementations.
 * <p>
 * Smart proxy is a proxy to the Scheduler with built-in support for automatic data pushing and
 * pulling in order to provide disconnected mode for the dataspace layer.
 *
 * @author The ProActive Team
 */
public abstract class AbstractSmartProxy<T extends JobTracker> implements Scheduler, SchedulerEventListener {

    private static final Logger log = Logger.getLogger(AbstractSmartProxy.class);

    public static final String GENERIC_INFO_INPUT_FOLDER_PROPERTY_NAME = "client_input_data_folder";
    public static final String GENERIC_INFO_OUTPUT_FOLDER_PROPERTY_NAME = "client_output_data_folder";

    public static final String GENERIC_INFO_PUSH_URL_PROPERTY_NAME = "push_url";
    public static final String GENERIC_INFO_PULL_URL_PROPERTY_NAME = "pull_url";

    public static final int MAX_NB_OF_DATA_TRANSFER_THREADS = 3 * Runtime.getRuntime().availableProcessors();

    private ThreadFactory threadFactory =
            new NamedThreadFactory("SmartProxyDataTransferThread");

    protected final ExecutorService threadPool =
            Executors.newFixedThreadPool(MAX_NB_OF_DATA_TRANSFER_THREADS, threadFactory);

    protected static final SchedulerEvent[] PROXY_SCHED_EVENTS = new SchedulerEvent[]{
            JOB_RUNNING_TO_FINISHED, JOB_PENDING_TO_RUNNING, JOB_PENDING_TO_FINISHED, JOB_PAUSED,
            JOB_RESUMED, TASK_PENDING_TO_RUNNING, KILLED, SHUTDOWN, SHUTTING_DOWN, STOPPED, RESUMED,
            TASK_RUNNING_TO_FINISHED};

    protected T jobTracker;

    protected String schedulerUrl;

    protected String schedulerLogin;

    protected String schedulerPassword;

    protected Set<SchedulerEventListenerExtended> eventListeners =
            Collections.synchronizedSet(new HashSet<SchedulerEventListenerExtended>());

    public AbstractSmartProxy() {
    }

    public AbstractSmartProxy(T jobTracker) {
        this.jobTracker = jobTracker;
    }<commit_msg>Make smartproxy implementations subscribe for TASK_PROGRESS event<commit_after>package org.ow2.proactive.scheduler.smartproxy.common;

import org.apache.log4j.Logger;
import org.objectweb.proactive.utils.NamedThreadFactory;
import org.ow2.proactive.db.SortParameter;
import org.ow2.proactive.scheduler.common.*;
import org.ow2.proactive.scheduler.common.exception.*;
import org.ow2.proactive.scheduler.common.job.*;
import org.ow2.proactive.scheduler.common.task.*;
import org.ow2.proactive.scheduler.common.usage.JobUsage;
import org.ow2.proactive.scheduler.common.util.logforwarder.AppenderProvider;
import org.ow2.proactive.scheduler.job.SchedulerUserInfo;

import javax.security.auth.login.LoginException;
import java.io.File;
import java.security.KeyException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;

import static com.google.common.base.Strings.isNullOrEmpty;
import static com.google.common.base.Throwables.propagate;
import static com.google.common.base.Throwables.propagateIfInstanceOf;
import static org.ow2.proactive.scheduler.common.SchedulerEvent.*;

/**
 * Asbtract implementation of smart proxy that factorizes code used by all smart proxy implementations.
 * <p>
 * Smart proxy is a proxy to the Scheduler with built-in support for automatic data pushing and
 * pulling in order to provide disconnected mode for the dataspace layer.
 *
 * @author The ProActive Team
 */
public abstract class AbstractSmartProxy<T extends JobTracker> implements Scheduler, SchedulerEventListener {

    private static final Logger log = Logger.getLogger(AbstractSmartProxy.class);

    public static final String GENERIC_INFO_INPUT_FOLDER_PROPERTY_NAME = "client_input_data_folder";
    public static final String GENERIC_INFO_OUTPUT_FOLDER_PROPERTY_NAME = "client_output_data_folder";

    public static final String GENERIC_INFO_PUSH_URL_PROPERTY_NAME = "push_url";
    public static final String GENERIC_INFO_PULL_URL_PROPERTY_NAME = "pull_url";

    public static final int MAX_NB_OF_DATA_TRANSFER_THREADS = 3 * Runtime.getRuntime().availableProcessors();

    private ThreadFactory threadFactory =
            new NamedThreadFactory("SmartProxyDataTransferThread");

    protected final ExecutorService threadPool =
            Executors.newFixedThreadPool(MAX_NB_OF_DATA_TRANSFER_THREADS, threadFactory);

    protected static final SchedulerEvent[] PROXY_SCHED_EVENTS = new SchedulerEvent[]{
            JOB_RUNNING_TO_FINISHED, JOB_PENDING_TO_RUNNING, JOB_PENDING_TO_FINISHED, JOB_PAUSED,
            JOB_RESUMED, TASK_PENDING_TO_RUNNING, KILLED, SHUTDOWN, SHUTTING_DOWN, STOPPED, RESUMED,
            TASK_RUNNING_TO_FINISHED, TASK_PROGRESS};

    protected T jobTracker;

    protected String schedulerUrl;

    protected String schedulerLogin;

    protected String schedulerPassword;

    protected Set<SchedulerEventListenerExtended> eventListeners =
            Collections.synchronizedSet(new HashSet<SchedulerEventListenerExtended>());

    public AbstractSmartProxy() {
    }

    public AbstractSmartProxy(T jobTracker) {
        this.jobTracker = jobTracker;
    }
{'fraction_non_alphanumeric': 0.07538003447735464, 'fraction_numerical': 0.0037611659614480487, 'mean_word_length': 5.232421875, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5049744', 'n_tokens_mistral': 1876, 'n_tokens_neox': 1828, 'n_words': 399}