<commit_before>/*
 * ################################################################
 *
 * ProActive: The Java(TM) library for Parallel, Distributed,
 *            Concurrent computing with Security and Mobility
 *
 * Copyright (C) 1997-2005 INRIA/University of Nice-Sophia Antipolis
 * Contact: <EMAIL>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA
 *
 *  Initial developer(s):               The ProActive Team
 *                        http://www.inria.fr/oasis/ProActive/contacts.html
 *  Contributor(s):
 *
 *                  <NAME>
 *                  <NAME>
 *                  <NAME>
 *                  <NAME>
 *
 *
 * ################################################################
 */
package org.objectweb.proactive.examples.nbody.barneshut;

import java.io.Serializable;
import java.net.InetAddress;
import java.net.UnknownHostException;

import org.apache.log4j.Logger;
import org.objectweb.proactive.core.util.log.Loggers;
import org.objectweb.proactive.core.util.log.ProActiveLogger;
import org.objectweb.proactive.examples.nbody.common.Displayer;


public class Domain implements Serializable {
    protected static final Logger logger = ProActiveLogger.getLogger(Loggers.EXAMPLES);

    /** a unique number to differentiate this Domain from the others */
    private int identification;

    /** to display on which host we're running */
    private String hostName = "unknown";

    /** used for synchronization between domains */
    private Maestro maestro;

    /** optional, to have a nice output with java3D */
    private Displayer display;

    /** the planet associed to the domain */
    private Planet rock;

    /** OctTree for this domain */
    private OctTree octTree;

    /**
     * Empty constructor, required by ProActive
     */
    public Domain() {
    }

    /**
     * Creates a container for a Planet, within a region of space.
     * @param i The unique identifier of this Domain
     * @param planet The Planet controlled by this Domain
     * @param oct The OctTree corresponding of this Domain
     */
    public Domain(Integer i, Planet planet, OctTree oct) {
        this.identification = i.intValue();
        this.rock = planet;
        this.octTree = oct;
        try {
            this.hostName = InetAddress.getLocalHost().getHostName();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
    }

    /**
     * Sets some execution-time related variables.
     * @param dp The Displayer used to show on screen the movement of the objects.
     * @param master Maestro used to synchronize the computations.
     */
    public void init(Displayer dp, Maestro master) {
        this.display = dp; // even if Displayer is null
        this.maestro = master;
        maestro.notifyFinished(this.identification, this.rock); // say we're ready to start .
    }

    /**
     * Calculate the force exerted on this body and move it.
     */
    public void moveBody() {
        Force force = this.octTree.computeForce(this.rock);
        this.rock.moveWithForce(force);
    }

    /**
     * Move the body, Draw the planet on the displayer and inform the Maestro
     */
    public void moveAndDraw() {
        this.maestro.notifyFinished(this.identification, this.rock);

        this.moveBody();

        if (this.display == null) { // if no display, only the first Domain outputs message to say recompute is going on
            if (this.identification == 0) {
                logger.info("Compute movement.");
            }
        } else {
            this.display.drawBody((int) this.rock.x, (int) this.rock.y,
                (int) this.rock.z, (int) this.rock.vx, (int) this.rock.vy,
                (int) this.rock.vz, (int) this.rock.mass,
                (int) this.rock.diameter, this.identification, this.hostName);
        }
    }

    /**
     * Method called when the object is redeployed on a new Node (Fault recovery, or migration).
     */
    private void readObject(java.io.ObjectInputStream in)
        throws java.io.IOException, ClassNotFoundException {
        in.defaultReadObject();
        try {
            this.hostName = InetAddress.getLocalHost().getHostName();
        } catch (UnknownHostException e) {
            hostName = "unknown";
            e.printStackTrace();
        }
    }
}
<commit_msg>Fixed a wrong cast double -> int<commit_after>/*
 * ################################################################
 *
 * ProActive: The Java(TM) library for Parallel, Distributed,
 *            Concurrent computing with Security and Mobility
 *
 * Copyright (C) 1997-2005 INRIA/University of Nice-Sophia Antipolis
 * Contact: <EMAIL>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA
 *
 *  Initial developer(s):               The ProActive Team
 *                        http://www.inria.fr/oasis/ProActive/contacts.html
 *  Contributor(s):
 *
 *                  <NAME>
 *                  <NAME>
 *                  <NAME>
 *                  <NAME>
 *
 *
 * ################################################################
 */
package org.objectweb.proactive.examples.nbody.barneshut;

import java.io.Serializable;
import java.net.InetAddress;
import java.net.UnknownHostException;

import org.apache.log4j.Logger;
import org.objectweb.proactive.core.util.log.Loggers;
import org.objectweb.proactive.core.util.log.ProActiveLogger;
import org.objectweb.proactive.examples.nbody.common.Displayer;


public class Domain implements Serializable {
    protected static final Logger logger = ProActiveLogger.getLogger(Loggers.EXAMPLES);

    /** a unique number to differentiate this Domain from the others */
    private int identification;

    /** to display on which host we're running */
    private String hostName = "unknown";

    /** used for synchronization between domains */
    private Maestro maestro;

    /** optional, to have a nice output with java3D */
    private Displayer display;

    /** the planet associed to the domain */
    private Planet rock;

    /** OctTree for this domain */
    private OctTree octTree;

    /**
     * Empty constructor, required by ProActive
     */
    public Domain() {
    }

    /**
     * Creates a container for a Planet, within a region of space.
     * @param i The unique identifier of this Domain
     * @param planet The Planet controlled by this Domain
     * @param oct The OctTree corresponding of this Domain
     */
    public Domain(Integer i, Planet planet, OctTree oct) {
        this.identification = i.intValue();
        this.rock = planet;
        this.octTree = oct;
        try {
            this.hostName = InetAddress.getLocalHost().getHostName();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
    }

    /**
     * Sets some execution-time related variables.
     * @param dp The Displayer used to show on screen the movement of the objects.
     * @param master Maestro used to synchronize the computations.
     */
    public void init(Displayer dp, Maestro master) {
        this.display = dp; // even if Displayer is null
        this.maestro = master;
        maestro.notifyFinished(this.identification, this.rock); // say we're ready to start .
    }

    /**
     * Calculate the force exerted on this body and move it.
     */
    public void moveBody() {
        Force force = this.octTree.computeForce(this.rock);
        this.rock.moveWithForce(force);
    }

    /**
     * Move the body, Draw the planet on the displayer and inform the Maestro
     */
    public void moveAndDraw() {
        this.maestro.notifyFinished(this.identification, this.rock);

        this.moveBody();

        if (this.display == null) { // if no display, only the first Domain outputs message to say recompute is going on
            if (this.identification == 0) {
                logger.info("Compute movement.");
            }
        } else {
            this.display.drawBody(this.rock.x, this.rock.y, this.rock.z,
                this.rock.vx, this.rock.vy, this.rock.vz, (int) this.rock.mass,
                (int) this.rock.diameter, this.identification, this.hostName);
        }
    }

    /**
     * Method called when the object is redeployed on a new Node (Fault recovery, or migration).
     */
    private void readObject(java.io.ObjectInputStream in)
        throws java.io.IOException, ClassNotFoundException {
        in.defaultReadObject();
        try {
            this.hostName = InetAddress.getLocalHost().getHostName();
        } catch (UnknownHostException e) {
            hostName = "unknown";
            e.printStackTrace();
        }
    }
}

{'fraction_non_alphanumeric': 0.11534210790716366, 'fraction_numerical': 0.005425499849291671, 'mean_word_length': 2.5, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '374493', 'n_tokens_mistral': 2739, 'n_tokens_neox': 2601, 'n_words': 907}