Example usage for org.aspectj.apache.bcel.verifier.exc Utility getStackTrace

List of usage examples for org.aspectj.apache.bcel.verifier.exc Utility getStackTrace

Introduction

In this page you can find the example usage for org.aspectj.apache.bcel.verifier.exc Utility getStackTrace.

Prototype

public static String getStackTrace(Throwable t) 

Source Link

Document

This method returns the stack trace of a Throwable instance as a String.

Usage

From source file:br.unb.cic.bionimbuz.services.sched.policy.impl.C99Supercolider.java

/**
 * Run the C99Supercolider Three stages Scheduling Algorithm. The stages
 * are: Stage One: Optimistic Greedy Search - O(rl.size * jobs.size). Stage
 * Two: Limited Discrepancy Search - O((jobs.size * (jobs.size+1))/2) ~
 * O(jobs.size^2) Stage Three: Iterative Widening Beam Search - O(rl.size ^
 * jobs.size)/* www .j  a  v a 2 s .c om*/
 *
 * @param rl List of resources available for scheduling.
 * @param jobs List of jobs that need scheduling.
 * @return An updated ResourceList with all jobs scheduled.
 *
 * @see C99Supercolider.stageOne
 * @see C99Supercolider.stageTwo
 * @see C99Supercolider.stageThree
 */
public ResourceList schedule(ResourceList rl, List<Job> jobs) {
    SearchNode root;

    jobsThis = jobs;

    // lock to ensure that the execution will be finished
    execLock = new ReentrantLock();

    try {
        execLock.lock();
        root = stageOne(rl, new LinkedList<>(jobs));
        System.out.println("best - " + bestList.size());
        for (ResourceList rll : bestList) {
            System.out.println("[" + rll.getFullCost(rs) + "," + rll.getMaxTime(rs) + "];");
        }

        System.out.println("");
        System.out.println("full - " + solutionsList.size());
        for (ResourceList rll : solutionsList) {
            System.out.println("[" + rll.getFullCost(rs) + "," + rll.getMaxTime(rs) + "];");
        }
        //                recursiveSeachNodePrint(root, 0);
        stageTwo(root, new LinkedList<>(jobs));
        System.out.println("");
        System.out.println(
                "___________________________________________________________________________________________");
        System.out.println("");
        System.out.println("best - " + bestList.size());
        for (ResourceList rll : bestList) {
            System.out.println("[" + rll.getFullCost(rs) + "," + rll.getMaxTime(rs) + "];");
        }

        System.out.println("");
        System.out.println("full - " + solutionsList.size());
        for (ResourceList rll : solutionsList) {
            System.out.println("[" + rll.getFullCost(rs) + "," + rll.getMaxTime(rs) + "];");
        }
        System.out.println("");
        System.out.println(
                "___________________________________________________________________________________________");
        System.out.println("");
        //                recursiveSeachNodePrint(root, 0);
        this.jobs = jobs;
        stageThree(root, rl.resources.size());

        //                recursiveSeachNodePrint(root, 0);
    } catch (Exception e) {
        System.out.println("[schedule] exception: " + e.getMessage());
        System.out.println(Utility.getStackTrace(e));
    } finally {
        execLock.unlock();
    }

    return best;
}

From source file:br.unb.cic.bionimbuz.services.sched.policy.impl.C99Supercolider.java

private static void testFailurePronePipelines(List<Workflow> pipelines, List<PluginInfo> resources,
        int maxExecTime, String output) {
    long resNum = resources.size();
    int i = 0;/*from   w  ww .j  a v a 2  s  .com*/
    PrintWriter writer = null;

    // open output file
    try {
        System.out.println("oppening output file");
        writer = new PrintWriter(new FileOutputStream(new File(output), true));
    } catch (FileNotFoundException ex) {
        LOGGER.error("[FileNotFoundException] - " + ex.getMessage());

        ex.printStackTrace();
    }

    for (Workflow pipeline : pipelines) {
        // this if is used to simulate a resumed test
        // negative i means do it from begining
        if (i > -1) {
            C99Supercolider scheduler = new C99Supercolider(resources.size());
            System.out.println("running pipeline " + i + " - " + Calendar.getInstance().getTime().toString());
            boolean finished = false;
            try {
                finished = runPipeline(resources, maxExecTime, scheduler, pipeline);
            } catch (Error e) {
                System.out.println(Utility.getStackTrace(e));
                System.out.println(e.toString());
            } catch (Exception e) {
                System.out.println(Utility.getStackTrace(e));
                System.out.println(e.toString());
            }

            // assemble result data
            String result = "" + i + "\t" + resNum + "\t" + pipeline.getJobs().size() + "\t" + "1\t"
                    + scheduler.s2best + "\t" + scheduler.s3best + "\t" + scheduler.beam + "\t"
                    + scheduler.childNodesCount(pipeline.getJobs().size()) + "\t" + scheduler.searchedNodes
                    + "\t" + scheduler.prunableNodes + "\t" + scheduler.pruned + "\t"
                    + scheduler.removedFromSearch + "\t" + scheduler.bestList.size() + "\t"
                    + scheduler.finalSolutionBeam + "\t" + scheduler.outOfMemory + "\t" + finished + "\t[";
            for (ResourceList rll : scheduler.bestList) {
                result += rll.result(rs) + "; ";
            }
            result += "]\t";
            for (ResourceList rll : scheduler.bestList) {
                result += rll.toString() + "; ";
            }
            result += "]";

            System.out.println("");
            System.out.println("tasks - " + scheduler.jobsThis.size());
            for (Job rll : scheduler.jobsThis) {
                System.out.println(rll.toString());
            }

            // flush test data
            writer.println(result);
            writer.flush();
            System.out.println("finished pipeline " + i + " - " + Calendar.getInstance().getTime().toString());
        }
        i++;
    }
    writer.close();
}

From source file:br.unb.cic.bionimbuz.services.sched.policy.impl.C99Supercolider.java

static boolean runPipeline(List<PluginInfo> resources, int maxExecTime, C99Supercolider s, Workflow p) {

    // convert List<PluginInfo> resources into a ResourceList
    final ResourceList rl = new ResourceList();
    for (PluginInfo info : resources) {
        Resource r = new Resource(info.getId(), info.getFactoryFrequencyCore(), info.getCostPerHour());
        rl.resources.add(r);//  w w w.  ja  va  2s  .c o  m
    }

    // create a thread to run the pipeline
    ExecutorService executor = Executors.newFixedThreadPool(1);
    final Workflow pipeline = p;
    final C99Supercolider scheduler = s;
    Future<?> future = null;
    boolean finished = true;

    try {
        // execute pipeline scheduling
        future = executor.submit(new Runnable() {
            @Override
            public void run() {
                scheduler.schedule(rl, pipeline.getJobs());
                scheduler.outOfMemory = false;
            }
        });
        // reject all further submissions
        executor.shutdown();

        // wait for scheduling to finish or timeout
        future.get(maxExecTime, TimeUnit.SECONDS);
    } catch (OutOfMemoryError e) {
        // OOME: cancel task and wait for it to finish
        System.out.println("OOME");
        future.cancel(true);
        try {
            future.get();
        } catch (InterruptedException ex) {
            LOGGER.error("[InterruptedException] - " + ex.getMessage());

            ex.printStackTrace();
        } catch (ExecutionException ex) {
            LOGGER.error("[ExecutionException] - " + ex.getMessage());

            ex.printStackTrace();
        }
        finished = false;
        scheduler.outOfMemory = true;
        System.out.println("OOME - finished task");
    } catch (InterruptedException e) {
        System.out.println("job was interrupted");
        scheduler.outOfMemory = true;
    } catch (ExecutionException e) {
        System.out.println("caught exception: " + e.toString());
        System.out.println(Utility.getStackTrace(e));
        finished = false;
        scheduler.outOfMemory = true;
    } catch (TimeoutException e) {
        System.out.println("timeout");
        // force scheduler to stop
        executor.shutdownNow();

        scheduler.execLock.lock();
        finished = false;
        scheduler.outOfMemory = false;
        System.out.println("timeout - task finished");
    } finally {
        System.gc();
    }

    return finished;
}