<commit_before>package com.hazelcast.stabilizer.agent;

import com.hazelcast.stabilizer.TestCase;
import com.hazelcast.stabilizer.Utils;
import com.hazelcast.stabilizer.agent.workerjvm.WorkerJvmManager;
import com.hazelcast.stabilizer.agent.workerjvm.WorkerJvmSettings;
import com.hazelcast.stabilizer.tests.Failure;
import com.hazelcast.stabilizer.tests.TestSuite;
import com.hazelcast.stabilizer.worker.testcommands.TestCommand;
import org.apache.log4j.Logger;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

public class AgentRemoteService {

    public static final int PORT = 9000;

    public static final String SERVICE_SPAWN_WORKERS = "spawnWorkers";
    public static final String SERVICE_INIT_TESTSUITE = "initTestSuite";
    public static final String SERVICE_TERMINATE_WORKERS = "terminateWorkers";
    public static final String SERVICE_EXECUTE_ALL_WORKERS = "executeOnAllWorkers";
    public static final String SERVICE_EXECUTE_SINGLE_WORKER = "executeOnSingleWorker";
    public static final String SERVICE_ECHO = "echo";
    public static final String SERVICE_PREPARE_FOR_TEST = "prepareForTest";
    public static final String SERVICE_GET_FAILURES = "failures";

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

    private Agent agent;
    private ServerSocket serverSocket;
    private final Executor executor = Executors.newFixedThreadPool(20);

    public AgentRemoteService(Agent agent) {
        this.agent = agent;
    }

    public void start() throws IOException {
        serverSocket = new ServerSocket(PORT, 0, InetAddress.getByName(Utils.getHostAddress()));
        log.info("Started Agent Remote Service on :" + serverSocket.getInetAddress().getHostAddress() + ":" + PORT);
        new AcceptorThread().start();
    }

    private class ClientSocketTask implements Runnable {
        private final Socket clientSocket;

        private ClientSocketTask(Socket clientSocket) {
            this.clientSocket = clientSocket;
        }

        @Override
        public void run() {
            try {
                ObjectOutputStream out = new ObjectOutputStream(clientSocket.getOutputStream());
                out.flush();

                ObjectInputStream in = new ObjectInputStream(clientSocket.getInputStream());
                String service = (String) in.readObject();

                Object result = null;
                try {
                    if (SERVICE_GET_FAILURES.equals(service)) {
                        result = getFailures();
                    } else if (SERVICE_SPAWN_WORKERS.equals(service)) {
                        WorkerJvmSettings settings = (WorkerJvmSettings) in.readObject();
                        spawnWorkers(settings);
                    } else if (SERVICE_INIT_TESTSUITE.equals(service)) {
                        TestSuite testSuite = (TestSuite) in.readObject();
                        byte[] bytes = (byte[]) in.readObject();
                        initTestSuite(testSuite, bytes);
                    } else if (SERVICE_TERMINATE_WORKERS.equals(service)) {
                        terminateWorkers();
                    } else if (SERVICE_EXECUTE_ALL_WORKERS.equals(service)) {
                        TestCommand testCommand = (TestCommand) in.readObject();
                        WorkerJvmManager workerJvmManager = agent.getWorkerJvmManager();
                        workerJvmManager.executeOnAllWorkers(testCommand);
                    } else if (SERVICE_EXECUTE_SINGLE_WORKER.equals(service)) {
                        TestCommand testCommand = (TestCommand) in.readObject();
                        WorkerJvmManager workerJvmManager = agent.getWorkerJvmManager();
                        workerJvmManager.executeOnSingleWorker(testCommand);
                    } else if (SERVICE_ECHO.equals(service)) {
                        String msg = (String) in.readObject();
                        echo(msg);
                    } else if (SERVICE_PREPARE_FOR_TEST.equals(service)) {
                        TestCase recipe = (TestCase) in.readObject();
                        prepareForTest(recipe);
                    } else {
                        throw new RuntimeException("Unknown service:" + service);
                    }
                } catch (Exception e) {
                    log.fatal(e);
                    result = e;
                }

                out.writeObject(result);
                out.flush();
            } catch (Throwable e) {
                log.fatal(e);
            } finally {
                Utils.closeQuietly(clientSocket);
            }
        }<commit_msg>More tweaks in return results<commit_after>package com.hazelcast.stabilizer.agent;

import com.hazelcast.stabilizer.TestCase;
import com.hazelcast.stabilizer.Utils;
import com.hazelcast.stabilizer.agent.workerjvm.WorkerJvmManager;
import com.hazelcast.stabilizer.agent.workerjvm.WorkerJvmSettings;
import com.hazelcast.stabilizer.tests.Failure;
import com.hazelcast.stabilizer.tests.TestSuite;
import com.hazelcast.stabilizer.worker.testcommands.TestCommand;
import org.apache.log4j.Logger;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

public class AgentRemoteService {

    public static final int PORT = 9000;

    public static final String SERVICE_SPAWN_WORKERS = "spawnWorkers";
    public static final String SERVICE_INIT_TESTSUITE = "initTestSuite";
    public static final String SERVICE_TERMINATE_WORKERS = "terminateWorkers";
    public static final String SERVICE_EXECUTE_ALL_WORKERS = "executeOnAllWorkers";
    public static final String SERVICE_EXECUTE_SINGLE_WORKER = "executeOnSingleWorker";
    public static final String SERVICE_ECHO = "echo";
    public static final String SERVICE_PREPARE_FOR_TEST = "prepareForTest";
    public static final String SERVICE_GET_FAILURES = "failures";

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

    private Agent agent;
    private ServerSocket serverSocket;
    private final Executor executor = Executors.newFixedThreadPool(20);

    public AgentRemoteService(Agent agent) {
        this.agent = agent;
    }

    public void start() throws IOException {
        serverSocket = new ServerSocket(PORT, 0, InetAddress.getByName(Utils.getHostAddress()));
        log.info("Started Agent Remote Service on :" + serverSocket.getInetAddress().getHostAddress() + ":" + PORT);
        new AcceptorThread().start();
    }

    private class ClientSocketTask implements Runnable {
        private final Socket clientSocket;

        private ClientSocketTask(Socket clientSocket) {
            this.clientSocket = clientSocket;
        }

        @Override
        public void run() {
            try {
                ObjectOutputStream out = new ObjectOutputStream(clientSocket.getOutputStream());
                out.flush();

                ObjectInputStream in = new ObjectInputStream(clientSocket.getInputStream());
                String service = (String) in.readObject();

                Object result = null;
                try {
                    if (SERVICE_GET_FAILURES.equals(service)) {
                        result = getFailures();
                    } else if (SERVICE_SPAWN_WORKERS.equals(service)) {
                        WorkerJvmSettings settings = (WorkerJvmSettings) in.readObject();
                        spawnWorkers(settings);
                    } else if (SERVICE_INIT_TESTSUITE.equals(service)) {
                        TestSuite testSuite = (TestSuite) in.readObject();
                        byte[] bytes = (byte[]) in.readObject();
                        initTestSuite(testSuite, bytes);
                    } else if (SERVICE_TERMINATE_WORKERS.equals(service)) {
                        terminateWorkers();
                    } else if (SERVICE_EXECUTE_ALL_WORKERS.equals(service)) {
                        TestCommand testCommand = (TestCommand) in.readObject();
                        WorkerJvmManager workerJvmManager = agent.getWorkerJvmManager();
                        result = workerJvmManager.executeOnAllWorkers(testCommand);
                    } else if (SERVICE_EXECUTE_SINGLE_WORKER.equals(service)) {
                        TestCommand testCommand = (TestCommand) in.readObject();
                        WorkerJvmManager workerJvmManager = agent.getWorkerJvmManager();
                        result = workerJvmManager.executeOnSingleWorker(testCommand);
                    } else if (SERVICE_ECHO.equals(service)) {
                        String msg = (String) in.readObject();
                        echo(msg);
                    } else if (SERVICE_PREPARE_FOR_TEST.equals(service)) {
                        TestCase recipe = (TestCase) in.readObject();
                        prepareForTest(recipe);
                    } else {
                        throw new RuntimeException("Unknown service:" + service);
                    }
                } catch (Exception e) {
                    log.fatal(e);
                    result = e;
                }

                out.writeObject(result);
                out.flush();
            } catch (Throwable e) {
                log.fatal(e);
            } finally {
                Utils.closeQuietly(clientSocket);
            }
        }
{'fraction_non_alphanumeric': 0.0836914262328627, 'fraction_numerical': 0.0016369961121342337, 'mean_word_length': 2.2165185916419876, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, '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': '6003056', 'n_tokens_mistral': 2542, 'n_tokens_neox': 2426, 'n_words': 520}