Package com.sun.faban.harness.common

Examples of com.sun.faban.harness.common.Run


    }

    private void fetchNextRun(String runId, HttpServletResponse response)
            throws IOException, ClassNotFoundException {

        Run nextRun = null;
        for (;;)
            try {
                nextRun = RunQ.getHandle().fetchNextRun(runId);
                break;
            } catch (RunEntryException e) {
            }

        if (nextRun == null) { // Queue empty
            logger.warning("Fetching run " + runId + ": No longer available!");
            response.setStatus(HttpServletResponse.SC_NO_CONTENT);
            return;
        }

        // Jar up the run.
        File jarFile = null;
        jarFile = jar(nextRun);

        // Send the run jar to the output stream
        long length = jarFile.length();
        int bufferSize = 1024 * 1024 * 128; // 128MB buffer limit
        if (length < bufferSize)
            bufferSize = (int) length;

        byte[] buffer = new byte[bufferSize];

        response.setStatus(HttpServletResponse.SC_OK);
        response.setContentType("application/java-archive");
        OutputStream out = response.getOutputStream();
        FileInputStream jarIn = new FileInputStream(jarFile);
        int readSize = 0;
        while ((readSize = jarIn.read(buffer)) != -1)
            out.write(buffer, 0, readSize);

        out.flush();
        out.close();

        // Update status locally
        nextRun.updateStatus(Run.RECEIVED);

        // Clear tmp file
        jarFile.delete();
    }
View Full Code Here


        FileHelper.recursiveDelete(new File(Config.RUNQ_DIR), runId);
        runqLock.releaseLock();
        uploadTags(runId);

        return new Run(runIdObj.getRunSeq(), benchDesc);
    }
View Full Code Here

                        // Go back and check if still suspended or got killed.
                        continue;
                    }
                }

                Run run = null;
                String runId = null;

                // Poll other hosts in poller mode. Otherwise skip this block.
                if (Config.daemonMode == Config.DaemonModes.POLLER) {
                    NameValuePair<Long> nextLocal = nextRunAge(Long.MIN_VALUE);
                    long runAge = -1;
                    if (nextLocal != null) {
                        runId = nextLocal.name;
                        runAge = nextLocal.value;
                    }
                    File tmpRunDir = null;
                    while ((tmpRunDir = RunRetriever.pollRun(runAge)) != null)
                        try {
                            run = fetchRemoteRun(tmpRunDir);
                            if (run == null)
                                logger.warning("Fetched null remote run");
                            break;

                        } catch (RunEntryException e) {
                            continue; // If we got a bad run, try polling again
                        }
                    if (run == null && nextLocal == null) {
                        // No local run or remote run...
                        runqLock.waitForSignal(10000);
                        continue;
                    }
                }

                boolean remoteRun = true;
                if (run == null)
                    try {
                        try {
                            // runId null if not poller.
                            run = fetchNextRun(runId);
                        } catch (IOException ex) {
                            Logger.getLogger(RunDaemon.class.getName()).log(
                                    Level.SEVERE,
                                    "IOException fetching remote run.", ex);
                        } catch (ClassNotFoundException ex) {
                            Logger.getLogger(RunDaemon.class.getName()).log(
                                    Level.SEVERE, "ClassNotFoundException " +
                                    "fetching remote run.", ex);
                        }
                        remoteRun = false;
                    } catch (RunEntryException e) {
                        // If there is a run entry issue, just skip to the next
                        // run immediately.
                        continue;
                    }
                if (run == null) {
                    runqLock.waitForSignal(10000);
                    continue;
                }

                String benchName = run.getBenchmarkName();
                String runDir = run.getOutDir();

                // Redirect the log to runOutDir/log.xml
                String logFile = runDir + File.separator + Config.LOG_FILE;
                redirectLog(logFile, null);

                logger.info("Starting " + benchName + " run using " + runDir);

                // instantiate, start running the benchmark
                currRun = run;
                gb = new GenericBenchmark(currRun);
                gb.start();

                // We could have done the uploads in GenericBenchmark.
                // But we fetched the remote run here, so we should return it
                // here, too!
                if (remoteRun)
                    try {
                        RunUploader.uploadIfOrigin(run.getRunId());
                    } catch (IOException e) {
                        logger.log(Level.WARNING, "Run upload failed!", e);
                    }

                logger.info(benchName + " Completed/Terminated");
View Full Code Here

                    "from remote, benchmark not deployed. " +
                    "Please deploy before continue");
            logger.log(Level.SEVERE, e.getMessage(), e);
            throw e;
        }
        return new Run(runSeq, benchDesc);
    }
View Full Code Here

TOP

Related Classes of com.sun.faban.harness.common.Run

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.