<commit_before>package madgik.exareme.master.app.cluster.mini;

import madgik.exareme.common.art.entity.EntityName;
import madgik.exareme.master.app.cluster.ExaremeCluster;
import madgik.exareme.master.client.AdpDBClient;
import madgik.exareme.master.client.AdpDBClientFactory;
import madgik.exareme.master.client.AdpDBClientProperties;
import madgik.exareme.master.engine.AdpDBManager;
import madgik.exareme.master.engine.AdpDBManagerFactory;
import madgik.exareme.utils.net.NetUtil;
import madgik.exareme.worker.art.container.ContainerProxy;
import madgik.exareme.worker.art.executionPlan.parser.expression.Container;
import madgik.exareme.worker.art.manager.ArtManager;
import madgik.exareme.worker.art.manager.ArtManagerFactory;
import madgik.exareme.worker.art.manager.ArtManagerProperties;
import madgik.exareme.worker.art.registry.ArtRegistryLocator;
import madgik.exareme.worker.art.security.DevelopmentContainerSecurityManager;
import org.apache.log4j.Logger;

import java.io.File;
import java.rmi.RemoteException;

/**
 * env.properties
 * run_level=testing
 *
 * @author alex
 */
public class ExaremeMiniCluster implements ExaremeCluster {
    private static final Logger log = Logger.getLogger(ExaremeMiniCluster.class);
    // configuration
    String dbsPath;
    private int port;
    private int dtport;
    private boolean running;
    // master
    private ArtManager master;
    private AdpDBManager manager;
    // workers
    private int nworkers;
    private ArtManager[] workers;

    public ExaremeMiniCluster(int port, int dtport, int nworkers) {
        if (System.getSecurityManager() == null) {
            System.setSecurityManager(new DevelopmentContainerSecurityManager());
        }
        String relMadisPath = System.getProperty("user.dir") + "//exareme-tools/madis/src/mterm.py";
        if (System.getenv("EXAREME_MADIS") != null) {
            log.info("**--" + System.getenv("EXAREME_MADIS"));
        } else if (new File(relMadisPath).exists()) {
            log.info("Relative madis Path : " + relMadisPath);
            System.setProperty("EXAREME_PYTHON", "python");
            System.setProperty("EXAREME_MADIS", relMadisPath);
            System.setProperty("MADIS_PATH", relMadisPath);
            log.info("**--" + System.getProperty("EXAREME_MADIS"));
            log.info("**--" + relMadisPath);


        } else
            throw new RuntimeException("Provide valid engine path.(" + relMadisPath + ").");
        this.port = port;
        this.dtport = dtport;
        this.nworkers = nworkers;
        this.master = null;
        this.workers = null;
        this.running = false;
        this.dbsPath = null;<commit_msg>improved path discovery of madis<commit_after>package madgik.exareme.master.app.cluster.mini;

import madgik.exareme.common.art.entity.EntityName;
import madgik.exareme.master.app.cluster.ExaremeCluster;
import madgik.exareme.master.client.AdpDBClient;
import madgik.exareme.master.client.AdpDBClientFactory;
import madgik.exareme.master.client.AdpDBClientProperties;
import madgik.exareme.master.engine.AdpDBManager;
import madgik.exareme.master.engine.AdpDBManagerFactory;
import madgik.exareme.utils.net.NetUtil;
import madgik.exareme.worker.art.container.ContainerProxy;
import madgik.exareme.worker.art.executionPlan.parser.expression.Container;
import madgik.exareme.worker.art.manager.ArtManager;
import madgik.exareme.worker.art.manager.ArtManagerFactory;
import madgik.exareme.worker.art.manager.ArtManagerProperties;
import madgik.exareme.worker.art.registry.ArtRegistryLocator;
import madgik.exareme.worker.art.security.DevelopmentContainerSecurityManager;
import org.apache.log4j.Logger;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.rmi.RemoteException;

/**
 * env.properties
 * run_level=testing
 *
 * @author alex
 */
public class ExaremeMiniCluster implements ExaremeCluster {
    private static final Logger log = Logger.getLogger(ExaremeMiniCluster.class);
    // configuration
    String dbsPath;
    private int port;
    private int dtport;
    private boolean running;
    // master
    private ArtManager master;
    private AdpDBManager manager;
    // workers
    private int nworkers;
    private ArtManager[] workers;

    public ExaremeMiniCluster(int port, int dtport, int nworkers) {
        if (System.getSecurityManager() == null) {
            System.setSecurityManager(new DevelopmentContainerSecurityManager());
        }
        Path madisPath =  Paths
            .get(System.getProperty("user.dir") + "/../exareme-tools/madis/src/mterm.py");
        if(!Files.exists(madisPath)){
            madisPath = Paths.get(System.getProperty("user.dir") + "/exareme-tools/madis/src/mterm.py");
        }
        String relMadisPath = madisPath.toString();
        if (System.getenv("EXAREME_MADIS") != null) {
            log.info("**--" + System.getenv("EXAREME_MADIS"));
        } else if (new File(relMadisPath).exists()) {
            log.info("Relative madis Path : " + relMadisPath);
            System.setProperty("EXAREME_PYTHON", "python");
            System.setProperty("EXAREME_MADIS", relMadisPath);
            System.setProperty("MADIS_PATH", relMadisPath);
            log.info("**--" + System.getProperty("EXAREME_MADIS"));
            log.info("**--" + relMadisPath);


        } else
            throw new RuntimeException("Provide valid engine path.(" + relMadisPath + ").");
        this.port = port;
        this.dtport = dtport;
        this.nworkers = nworkers;
        this.master = null;
        this.workers = null;
        this.running = false;
        this.dbsPath = null;
{'fraction_non_alphanumeric': 0.11665198237885463, 'fraction_numerical': 0.0003524229074889868, 'mean_word_length': 3.501189532117367, 'pattern_counts': {'":': 0, '<': 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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3114704', 'n_tokens_mistral': 1797, 'n_tokens_neox': 1784, 'n_words': 297}