<commit_before>/***
 * Fractal ADL Parser
 * Copyright (C) 2002-2004 France Telecom R&D
 *
 * 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 of the License, or (at your option) 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
 *
 * Contact: <EMAIL>
 *
 * Author: <NAME>
 */
package org.objectweb.proactive.examples.pi;

import java.util.HashMap;

import org.objectweb.fractal.api.control.BindingController;
import org.objectweb.proactive.core.group.Group;
import org.objectweb.proactive.core.group.ProActiveGroup;


public class PiBBPWrapper extends PiBBP implements Runnable, BindingController {
    
    HashMap nameToComputer = new HashMap(); // map between binding names and Components 
    
    public PiBBPWrapper() {
    }

    public void run() {
        nbDecimals_ = 1000;                 // FIXME : this should be a parameter somewhere.  
        piComputer.setScale(nbDecimals_);
        try {
            computeOnGroup(piComputer);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public String[] listFc() {
        return new String[] { "computation" };
    }

    public Object lookupFc(final String cItf) {
        return  nameToComputer.get(cItf);
    }

    public void bindFc(final String cItf, final Object sItf) {
        System.out.println("Adding bind called " + cItf + 
                " between " + this.getClass().getName() +
                " and " + sItf.getClass().getName()); 
        if (piComputer == null)
            try {
                piComputer = (PiComp) ProActiveGroup.newGroup(PiComp.class.getName());
            } catch (Exception e) {
                e.printStackTrace();
            }
        if (cItf.startsWith("computation")) {
            Group group = ProActiveGroup.getGroup(piComputer);
            group.add(sItf);
        }
    }

    public void unbindFc(final String cItf) {
        Group group = ProActiveGroup.getGroup(piComputer);
        Object piComp = nameToComputer.remove(cItf) ;
        group.remove(piComp);
    }
}
<commit_msg>Master component for pi application with multicast client interface<commit_after>/***
 * Fractal ADL Parser
 * Copyright (C) 2002-2004 France Telecom R&D
 *
 * 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 of the License, or (at your option) 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
 *
 * Contact: <EMAIL>
 *
 * Author: <NAME>
 */
package org.objectweb.proactive.examples.pi;

import java.util.HashMap;
import java.util.List;

import org.objectweb.fractal.api.control.BindingController;
import org.objectweb.proactive.core.group.Group;
import org.objectweb.proactive.core.group.ProActiveGroup;


public class PiBBPWrapper extends PiBBP implements MasterComputation, BindingController {
    
    HashMap nameToComputer = new HashMap(); // map between binding names and Components 
    PiCompMultiCast clientMultiCast;
    public PiBBPWrapper() {
    }

   

    public String[] listFc() {
        return new String[] { "multicastDispatcher" };
    }

    public Object lookupFc(final String cItf) {
    	if(cItf.compareTo("multicastDispatcher")==0)
    		return clientMultiCast;
    	return null;
    }

    public void bindFc(final String cItf, final Object sItf) {

        if (cItf.startsWith("multicastDispatcher")) {
           clientMultiCast=(PiCompMultiCast)sItf;
        }
    }

    public void unbindFc(final String cItf) {
    	if (cItf.startsWith("multicastDispatcher")) {
            clientMultiCast=null;
         }
    }

	public void startComputation(List<Interval> params) {
			
		long timeAtBeginningOfComputation = System.currentTimeMillis();
		   
		   
		List<Result> results=clientMultiCast.compute(params);
		
		System.out.println("Intervals sent to the computers...\n");

        Result total = PiUtil.conquerPIList(results);

        
        
        long timeAtEndOfComputation = System.currentTimeMillis();

        //*************************************************************
        // * results
        // *************************************************************/
        System.out.println("\nComputation finished ...");
        System.out.println("Computed PI value is : " +
            total.getNumericalResult().toString());
        System.out.println("Time waiting for result : " +
            (timeAtEndOfComputation - timeAtBeginningOfComputation) + " ms");
        System.out.println("Cumulated time from all computers is : " +
            total.getComputationTime() + " ms");
        System.out.println("Ratio for " + results.size() +
            " processors is : " +
            (((double) total.getComputationTime() / ((double) (timeAtEndOfComputation -
            timeAtBeginningOfComputation))) * 100) + " %");
        
        System.out.println(total.getNumericalResult().toString());
		
		
		
		
		
		
		
		
	}
}

{'fraction_non_alphanumeric': 0.11264559068219634, 'fraction_numerical': 0.008985024958402662, 'mean_word_length': 2.8262253341820496, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3953048', 'n_tokens_mistral': 1745, 'n_tokens_neox': 1619, 'n_words': 501}