<commit_before>/*
 * Copyright 2009-2013 by The Regents of the University of California
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * you may obtain a copy of the License from
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package edu.uci.ics.pregelix.core.driver;

import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import edu.uci.ics.hyracks.api.client.HyracksConnection;
import edu.uci.ics.hyracks.api.client.IHyracksClientConnection;
import edu.uci.ics.hyracks.api.deployment.DeploymentId;
import edu.uci.ics.hyracks.api.exceptions.HyracksException;
import edu.uci.ics.hyracks.api.job.JobFlag;
import edu.uci.ics.hyracks.api.job.JobId;
import edu.uci.ics.hyracks.api.job.JobSpecification;
import edu.uci.ics.pregelix.api.job.PregelixJob;
import edu.uci.ics.pregelix.api.util.BspUtils;
import edu.uci.ics.pregelix.core.base.IDriver;
import edu.uci.ics.pregelix.core.jobgen.JobGen;
import edu.uci.ics.pregelix.core.jobgen.JobGenInnerJoin;
import edu.uci.ics.pregelix.core.jobgen.JobGenOuterJoin;
import edu.uci.ics.pregelix.core.jobgen.JobGenOuterJoinSingleSort;
import edu.uci.ics.pregelix.core.jobgen.JobGenOuterJoinSort;
import edu.uci.ics.pregelix.core.jobgen.clusterconfig.ClusterConfig;
import edu.uci.ics.pregelix.dataflow.util.IterationUtils;

@SuppressWarnings("rawtypes")
public class Driver implements IDriver {
    private static final Log LOG = LogFactory.getLog(Driver.class);
    private IHyracksClientConnection hcc;
    private Class exampleClass;
    private boolean profiling = false;

    public Driver(Class exampleClass) {
        this.exampleClass = exampleClass;
    }

    @Override
    public void runJob(PregelixJob job, String ipAddress, int port) throws HyracksException {
        runJob(job, Plan.OUTER_JOIN, ipAddress, port, false);
    }

    @Override
    public void runJobs(List<PregelixJob> jobs, String ipAddress, int port) throws HyracksException {
        runJobs(jobs, Plan.OUTER_JOIN, ipAddress, port, false);
    }

    @Override
    public void runJob(PregelixJob job, Plan planChoice, String ipAddress, int port, boolean profiling)
            throws HyracksException {
        runJobs(Collections.singletonList(job), planChoice, ipAddress, port, profiling);
    }

    @Override
    public void runJobs(List<PregelixJob> jobs, Plan planChoice, String ipAddress, int port, boolean profiling)
            throws HyracksException {
        try {
            if (jobs.size() <= 0) {
                throw new HyracksException("Please submit at least one job for execution!");
            }
            this.profiling = profiling;
            PregelixJob currentJob = jobs.get(0);
            PregelixJob lastJob = currentJob;
            JobGen jobGen = null;

            /** prepare job -- deploy jars */
            DeploymentId deploymentId = prepareJobs(ipAddress, port);
            LOG.info("job started");

            int lastSnapshotJobIndex = 0;
            int lastSnapshotSuperstep = 0;
            boolean failed = false;
            int retryCount = 0;
            int maxRetryCount = 3;

            do {
                try {
                    for (int i = lastSnapshotJobIndex; i < jobs.size(); i++) {
                        lastJob = currentJob;
                        currentJob = jobs.get(i);

                        /** add hadoop configurations */
                        addHadoopConfiguration(currentJob, ipAddress, port);

                        /** load the data */
                        if (i == 0 || compatible(lastJob, currentJob)) {
                            if (i != 0) {
                                finishJobs(jobGen, deploymentId);
                            }
                            jobGen = selectJobGen(planChoice, currentJob);
                            loadData(currentJob, jobGen, deploymentId);
                        } else {
                            jobGen.reset(currentJob);
                        }

                        /** run loop-body jobs */
                        runLoopBody(deploymentId, currentJob, jobGen, lastSnapshotSuperstep);
                        runClearState(deploymentId, jobGen);
                    }

                    /** finish the jobs */
                    finishJobs(jobGen, deploymentId);
                    hcc.unDeployBinary(deploymentId);
                } catch (IOException ioe) {
                    /** disk failures */
                    //restart from snapshot
                    failed = true;
                    retryCount++;
                    ioe.printStackTrace();
                }
            } while (failed && retryCount < maxRetryCount);
            LOG.info("job finished");
        } catch (Exception e) {
            throw new HyracksException(e);<commit_msg>avoid hidden error message<commit_after>/*
 * Copyright 2009-2013 by The Regents of the University of California
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * you may obtain a copy of the License from
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package edu.uci.ics.pregelix.core.driver;

import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import edu.uci.ics.hyracks.api.client.HyracksConnection;
import edu.uci.ics.hyracks.api.client.IHyracksClientConnection;
import edu.uci.ics.hyracks.api.deployment.DeploymentId;
import edu.uci.ics.hyracks.api.exceptions.HyracksException;
import edu.uci.ics.hyracks.api.job.JobFlag;
import edu.uci.ics.hyracks.api.job.JobId;
import edu.uci.ics.hyracks.api.job.JobSpecification;
import edu.uci.ics.pregelix.api.job.PregelixJob;
import edu.uci.ics.pregelix.api.util.BspUtils;
import edu.uci.ics.pregelix.core.base.IDriver;
import edu.uci.ics.pregelix.core.jobgen.JobGen;
import edu.uci.ics.pregelix.core.jobgen.JobGenInnerJoin;
import edu.uci.ics.pregelix.core.jobgen.JobGenOuterJoin;
import edu.uci.ics.pregelix.core.jobgen.JobGenOuterJoinSingleSort;
import edu.uci.ics.pregelix.core.jobgen.JobGenOuterJoinSort;
import edu.uci.ics.pregelix.core.jobgen.clusterconfig.ClusterConfig;
import edu.uci.ics.pregelix.dataflow.util.IterationUtils;

@SuppressWarnings("rawtypes")
public class Driver implements IDriver {
    private static final Log LOG = LogFactory.getLog(Driver.class);
    private IHyracksClientConnection hcc;
    private Class exampleClass;
    private boolean profiling = false;

    public Driver(Class exampleClass) {
        this.exampleClass = exampleClass;
    }

    @Override
    public void runJob(PregelixJob job, String ipAddress, int port) throws HyracksException {
        runJob(job, Plan.OUTER_JOIN, ipAddress, port, false);
    }

    @Override
    public void runJobs(List<PregelixJob> jobs, String ipAddress, int port) throws HyracksException {
        runJobs(jobs, Plan.OUTER_JOIN, ipAddress, port, false);
    }

    @Override
    public void runJob(PregelixJob job, Plan planChoice, String ipAddress, int port, boolean profiling)
            throws HyracksException {
        runJobs(Collections.singletonList(job), planChoice, ipAddress, port, profiling);
    }

    @Override
    public void runJobs(List<PregelixJob> jobs, Plan planChoice, String ipAddress, int port, boolean profiling)
            throws HyracksException {
        try {
            if (jobs.size() <= 0) {
                throw new HyracksException("Please submit at least one job for execution!");
            }
            this.profiling = profiling;
            PregelixJob currentJob = jobs.get(0);
            PregelixJob lastJob = currentJob;
            JobGen jobGen = null;

            /** prepare job -- deploy jars */
            DeploymentId deploymentId = prepareJobs(ipAddress, port);
            LOG.info("job started");

            int lastSnapshotJobIndex = 0;
            int lastSnapshotSuperstep = 0;
            boolean failed = false;
            int retryCount = 0;
            int maxRetryCount = 3;

            do {
                try {
                    for (int i = lastSnapshotJobIndex; i < jobs.size(); i++) {
                        lastJob = currentJob;
                        currentJob = jobs.get(i);

                        /** add hadoop configurations */
                        addHadoopConfiguration(currentJob, ipAddress, port);

                        /** load the data */
                        if (i == 0 || compatible(lastJob, currentJob)) {
                            if (i != 0) {
                                finishJobs(jobGen, deploymentId);
                            }
                            jobGen = selectJobGen(planChoice, currentJob);
                            loadData(currentJob, jobGen, deploymentId);
                        } else {
                            jobGen.reset(currentJob);
                        }

                        /** run loop-body jobs */
                        runLoopBody(deploymentId, currentJob, jobGen, lastSnapshotSuperstep);
                        runClearState(deploymentId, jobGen);
                    }

                    /** finish the jobs */
                    finishJobs(jobGen, deploymentId);
                    hcc.unDeployBinary(deploymentId);
                } catch (IOException ioe) {
                    /** disk failures */
                    //restart from snapshot
                    failed = true;
                    retryCount++;
                    ioe.printStackTrace();
                }
            } while (failed && retryCount < maxRetryCount);
            LOG.info("job finished");
        } catch (Exception e) {
	    e.printStackTrace();
            throw new HyracksException(e);
{'fraction_non_alphanumeric': 0.09133468774843212, 'fraction_numerical': 0.0035332567794364458, 'mean_word_length': 2.2228864218616566, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 7, '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': '1090534', 'n_tokens_mistral': 3270, 'n_tokens_neox': 3145, 'n_words': 759}