<commit_before>package org.objectweb.proactive.extra.masterslave.core;

import java.io.Serializable;

import org.apache.log4j.Logger;
import org.objectweb.proactive.Body;
import org.objectweb.proactive.InitActive;
import org.objectweb.proactive.RunActive;
import org.objectweb.proactive.Service;
import org.objectweb.proactive.api.ProActiveObject;
import org.objectweb.proactive.api.ProGroup;
import org.objectweb.proactive.core.config.PAProperties;
import org.objectweb.proactive.core.group.Group;
import org.objectweb.proactive.core.mop.ClassNotReifiableException;
import org.objectweb.proactive.core.util.log.Loggers;
import org.objectweb.proactive.core.util.log.ProActiveLogger;
import org.objectweb.proactive.core.util.wrapper.BooleanWrapper;
import org.objectweb.proactive.extra.masterslave.interfaces.internal.Slave;
import org.objectweb.proactive.extra.masterslave.interfaces.internal.SlaveDeadListener;
import org.objectweb.proactive.extra.masterslave.interfaces.internal.SlaveWatcher;


/**
 * <i><font size="-1" color="#FF0000">**For internal use only** </font></i><br>
 * The Pinger Active Object is responsible for watching slaves'activity. <br>
 * It reports slaves failure to the Master<br>
 * @author fviale
 *
 */
public class AOPinger implements SlaveWatcher, RunActive, InitActive,
    Serializable {

    /**
         *
         */
    private static final long serialVersionUID = -7489033564540496244L;

    /**
    * pinger log4j logger
    */
    protected static Logger logger = ProActiveLogger.getLogger(Loggers.MASTERSLAVE_SLAVES);

    /**
     * Stub on the active object
     */
    protected AOPinger stubOnThis;

    /**
     * is this active object terminated
     */
    protected boolean terminated;

    /**
     * interval when slaves are sent a ping message
     */
    protected long pingPeriod;

    /**
     * Who will be notified when slaves are dead (in general : the master)
     */
    protected SlaveDeadListener listener;

    /**
     * Stub to slave group
     */
    protected Slave slaveGroupStub;

    /**
     * Slave group
     */
    protected Group<Slave> slaveGroup;

    /**
     * for internal use
     */
    private Thread localThread;

    /**
     * ProActive empty constructor
     */
    public AOPinger() {
    }

    /**
     * Creates a pinger with the given listener
     * @param listener object which will be notified when a slave is dead
     */
    public AOPinger(final SlaveDeadListener listener) {
        this.listener = listener;
        terminated = false;
        pingPeriod = Long.parseLong(PAProperties.PA_MASTERSLAVE_PINGPERIOD.getValue());
    }

    /**
     * {@inheritDoc}
     */
    public void addSlaveToWatch(final Slave slave) {
        slaveGroup.add(slave);
    }

    /**
     * {@inheritDoc}
     */
    @SuppressWarnings("unchecked")
    public void initActivity(final Body body) {
        try {
            slaveGroupStub = (Slave) ProGroup.newGroup(AOSlave.class.getName());
            slaveGroup = ProGroup.getGroup(slaveGroupStub);
            stubOnThis = (AOPinger) ProActiveObject.getStubOnThis();
            body.setImmediateService("terminate");
        } catch (ClassNotReifiableException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    /**
     * {@inheritDoc}
     */
    public void removeSlaveToWatch(final Slave slave) {
        slaveGroup.remove(slave);
    }

    /**
     * {@inheritDoc}
     */
    public void runActivity(final Body body) {
        localThread = Thread.currentThread();
        Service service = new Service(body);
        while (!terminated) {
            // we serve everything
            while (service.hasRequestToServe()) {
                service.serveOldest();
            }

            slaveGroupStub.heartBeat();
            try {
                Thread.sleep(pingPeriod);
            } catch (InterruptedException e) {
                // do not print message, pinger is terminating
            }
        }

        body.terminate();
    }
<commit_msg>handles new Exception mechanism (without NFE)<commit_after>package org.objectweb.proactive.extra.masterslave.core;

import java.io.Serializable;
import java.util.Iterator;

import org.apache.log4j.Logger;
import org.objectweb.proactive.Body;
import org.objectweb.proactive.InitActive;
import org.objectweb.proactive.RunActive;
import org.objectweb.proactive.Service;
import org.objectweb.proactive.api.ProActiveObject;
import org.objectweb.proactive.api.ProGroup;
import org.objectweb.proactive.core.config.PAProperties;
import org.objectweb.proactive.core.group.ExceptionInGroup;
import org.objectweb.proactive.core.group.ExceptionListException;
import org.objectweb.proactive.core.group.Group;
import org.objectweb.proactive.core.mop.ClassNotReifiableException;
import org.objectweb.proactive.core.util.log.Loggers;
import org.objectweb.proactive.core.util.log.ProActiveLogger;
import org.objectweb.proactive.core.util.wrapper.BooleanWrapper;
import org.objectweb.proactive.extra.masterslave.interfaces.internal.Slave;
import org.objectweb.proactive.extra.masterslave.interfaces.internal.SlaveDeadListener;
import org.objectweb.proactive.extra.masterslave.interfaces.internal.SlaveWatcher;


/**
 * <i><font size="-1" color="#FF0000">**For internal use only** </font></i><br>
 * The Pinger Active Object is responsible for watching slaves'activity. <br>
 * It reports slaves failure to the Master<br>
 * @author fviale
 *
 */
public class AOPinger implements SlaveWatcher, RunActive, InitActive,
    Serializable {

    /**
         *
         */
    private static final long serialVersionUID = -7489033564540496244L;

    /**
    * pinger log4j logger
    */
    protected static Logger logger = ProActiveLogger.getLogger(Loggers.MASTERSLAVE_SLAVES);

    /**
     * Stub on the active object
     */
    protected AOPinger stubOnThis;

    /**
     * is this active object terminated
     */
    protected boolean terminated;

    /**
     * interval when slaves are sent a ping message
     */
    protected long pingPeriod;

    /**
     * Who will be notified when slaves are dead (in general : the master)
     */
    protected SlaveDeadListener listener;

    /**
     * Stub to slave group
     */
    protected Slave slaveGroupStub;

    /**
     * Slave group
     */
    protected Group<Slave> slaveGroup;

    /**
     * for internal use
     */
    private Thread localThread;

    /**
     * ProActive empty constructor
     */
    public AOPinger() {
    }

    /**
     * Creates a pinger with the given listener
     * @param listener object which will be notified when a slave is dead
     */
    public AOPinger(final SlaveDeadListener listener) {
        this.listener = listener;
        terminated = false;
        pingPeriod = Long.parseLong(PAProperties.PA_MASTERSLAVE_PINGPERIOD.getValue());
    }

    /**
     * {@inheritDoc}
     */
    public void addSlaveToWatch(final Slave slave) {
        slaveGroup.add(slave);
    }

    /**
     * {@inheritDoc}
     */
    @SuppressWarnings("unchecked")
    public void initActivity(final Body body) {
        try {
            slaveGroupStub = (Slave) ProGroup.newGroup(AOSlave.class.getName());
            slaveGroup = ProGroup.getGroup(slaveGroupStub);
            stubOnThis = (AOPinger) ProActiveObject.getStubOnThis();
            body.setImmediateService("terminate");
        } catch (ClassNotReifiableException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    /**
     * {@inheritDoc}
     */
    public void removeSlaveToWatch(final Slave slave) {
        slaveGroup.remove(slave);
    }

    /**
     * {@inheritDoc}
     */
    public void runActivity(final Body body) {
        localThread = Thread.currentThread();
        Service service = new Service(body);
        while (!terminated) {
            // we serve everything
            while (service.hasRequestToServe()) {
                service.serveOldest();
            }
            try {
                slaveGroupStub.heartBeat();
            } catch (Exception e) {
                if (e instanceof ExceptionListException) {
                    ExceptionListException ele = (ExceptionListException) e;
                    synchronized (ele) {
                        Iterator<ExceptionInGroup> it = ele.iterator();
                        while (it.hasNext()) {
                            ExceptionInGroup eig = it.next();
                            stubOnThis.slaveMissing((Slave) eig.getObject());
                        }
                    }
                }
            }
            try {
                Thread.sleep(pingPeriod);
            } catch (InterruptedException e) {
                // do not print message, pinger is terminating
            }
        }

        body.terminate();
    }

{'fraction_non_alphanumeric': 0.10132109270040304, 'fraction_numerical': 0.005821764442454098, 'mean_word_length': 2.410843833524246, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, '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': '1919698', 'n_tokens_mistral': 2570, 'n_tokens_neox': 2492, 'n_words': 537}