<commit_before>package org.objectweb.proactive.ic2d.gui.jobmonitor;

import org.objectweb.proactive.core.ProActiveException;
import org.objectweb.proactive.core.body.rmi.RemoteBodyAdapter;
import org.objectweb.proactive.core.descriptor.data.VirtualNode;
import org.objectweb.proactive.core.runtime.ProActiveRuntime;
import org.objectweb.proactive.core.runtime.VMInformation;
import org.objectweb.proactive.core.runtime.rmi.RemoteProActiveRuntime;
import org.objectweb.proactive.core.runtime.rmi.RemoteProActiveRuntimeAdapter;
import org.objectweb.proactive.ic2d.gui.IC2DGUIController;
import org.objectweb.proactive.ic2d.gui.jobmonitor.data.DataAssociation;
import org.objectweb.proactive.ic2d.gui.jobmonitor.data.MonitoredAO;
import org.objectweb.proactive.ic2d.gui.jobmonitor.data.MonitoredHost;
import org.objectweb.proactive.ic2d.gui.jobmonitor.data.MonitoredJVM;
import org.objectweb.proactive.ic2d.gui.jobmonitor.data.MonitoredJob;
import org.objectweb.proactive.ic2d.gui.jobmonitor.data.MonitoredNode;
import org.objectweb.proactive.ic2d.gui.jobmonitor.data.MonitoredVN;

import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

import javax.swing.DefaultListModel;


public class NodeExploration implements JobMonitorConstants {
    private static final String PA_JVM = "PA_JVM";
    private int maxDepth;
    private DataAssociation asso;
    private DefaultListModel skippedObjects;
    private Map aos;
    private Set visitedVM;
    private Map runtimes;
    private IC2DGUIController controller;

    public NodeExploration(DataAssociation asso,
        DefaultListModel skippedObjects, IC2DGUIController controller) {
        this.maxDepth = 10;
        this.asso = asso;
        this.skippedObjects = skippedObjects;
        this.aos = new HashMap();
        this.runtimes = new HashMap();
        this.controller = controller;
    }

    public int getMaxDepth() {
        return maxDepth;
    }

    public void setMaxDepth(int maxDepth) {
        if (maxDepth > 0) {
            this.maxDepth = maxDepth;
        }
    }

    private void log(Throwable e) {
        controller.log(e, false);
    }

    /* url : "//host/object" */
    private ProActiveRuntime resolveURL(String url) {
        try {
            StringTokenizer tokenizer = new StringTokenizer(url, "/");
            String host = tokenizer.nextToken();
            String name = tokenizer.nextToken();

            Registry registry = LocateRegistry.getRegistry(host);
            RemoteProActiveRuntime r = (RemoteProActiveRuntime) registry.lookup(name);
            return new RemoteProActiveRuntimeAdapter(r);
        } catch (Exception e) {
            log(e);
            return null;
        }
    }

    private ProActiveRuntime urlToRuntime(String url) {
        ProActiveRuntime rt = (ProActiveRuntime) runtimes.get(url);
        if (rt != null) {
            return rt;
        }

        rt = resolveURL(url);
        if (rt != null) {
            runtimes.put(url, rt);
        }
<commit_msg>Use a regex to parse the URL<commit_after>package org.objectweb.proactive.ic2d.gui.jobmonitor;

import org.objectweb.proactive.core.ProActiveException;
import org.objectweb.proactive.core.body.rmi.RemoteBodyAdapter;
import org.objectweb.proactive.core.descriptor.data.VirtualNode;
import org.objectweb.proactive.core.runtime.ProActiveRuntime;
import org.objectweb.proactive.core.runtime.VMInformation;
import org.objectweb.proactive.core.runtime.rmi.RemoteProActiveRuntime;
import org.objectweb.proactive.core.runtime.rmi.RemoteProActiveRuntimeAdapter;
import org.objectweb.proactive.ic2d.gui.IC2DGUIController;
import org.objectweb.proactive.ic2d.gui.jobmonitor.data.DataAssociation;
import org.objectweb.proactive.ic2d.gui.jobmonitor.data.MonitoredAO;
import org.objectweb.proactive.ic2d.gui.jobmonitor.data.MonitoredHost;
import org.objectweb.proactive.ic2d.gui.jobmonitor.data.MonitoredJVM;
import org.objectweb.proactive.ic2d.gui.jobmonitor.data.MonitoredJob;
import org.objectweb.proactive.ic2d.gui.jobmonitor.data.MonitoredNode;
import org.objectweb.proactive.ic2d.gui.jobmonitor.data.MonitoredVN;

import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.swing.DefaultListModel;


public class NodeExploration implements JobMonitorConstants {
    private static final String PA_JVM = "PA_JVM";
    private int maxDepth;
    private DataAssociation asso;
    private DefaultListModel skippedObjects;
    private Map aos;
    private Set visitedVM;
    private Map runtimes;
    private IC2DGUIController controller;

    public NodeExploration(DataAssociation asso,
        DefaultListModel skippedObjects, IC2DGUIController controller) {
        this.maxDepth = 10;
        this.asso = asso;
        this.skippedObjects = skippedObjects;
        this.aos = new HashMap();
        this.runtimes = new HashMap();
        this.controller = controller;
    }

    public int getMaxDepth() {
        return maxDepth;
    }

    public void setMaxDepth(int maxDepth) {
        if (maxDepth > 0) {
            this.maxDepth = maxDepth;
        }
    }

    private void log(Throwable e) {
        controller.log(e, false);
    }

    /* url : "//host:port/object" */
    private ProActiveRuntime resolveURL(String url) {
        System.out.println(url);
        Pattern p = Pattern.compile("(.*//)?(.+):?([0-9]*)/(.+)");
        Matcher m = p.matcher(url);
        if (!m.matches()) {
            return null;
        }

        String host = m.group(2);
        String port = m.group(3);
        String object = m.group(4);

        try {
            Registry registry;
            if (!port.equals("")) {
                int portNumber = Integer.parseInt(port);
                registry = LocateRegistry.getRegistry(host, portNumber);
            } else {
                registry = LocateRegistry.getRegistry(host);
            }

            RemoteProActiveRuntime r = (RemoteProActiveRuntime) registry.lookup(object);
            return new RemoteProActiveRuntimeAdapter(r);
        } catch (Exception e) {
            log(e);
            return null;
        }
    }

    private ProActiveRuntime urlToRuntime(String url) {
        ProActiveRuntime rt = (ProActiveRuntime) runtimes.get(url);
        if (rt != null) {
            return rt;
        }

        rt = resolveURL(url);
        if (rt != null) {
            runtimes.put(url, rt);
        }

{'fraction_non_alphanumeric': 0.10073923757066242, 'fraction_numerical': 0.005073199014349905, 'mean_word_length': 3.075605434140579, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2893367', 'n_tokens_mistral': 2092, 'n_tokens_neox': 2044, 'n_words': 392}