Package org.jdesktop.wonderland.runner

Examples of org.jdesktop.wonderland.runner.StatusWaiter


            // run the snapshot runner using the RunManager
            RunManager.getInstance().start(snapshot, false);

            // wait for the snapshot runner to exit, which it should do
            // as soon as it finishes starting up
            StatusWaiter waiter = new StatusWaiter(snapshot, Status.NOT_RUNNING);
            waiter.waitFor();
        } catch (InterruptedException ie) {
            // not much we can do here...
        } finally {
            synchronized(this) {
                snapshot = null;
View Full Code Here


            return Response.status(Response.Status.BAD_REQUEST).cacheControl(NO_CACHE).build();
        }
       
        if(runner.getStatus() != Status.NOT_RUNNING) {
            try {
                StatusWaiter waiter = RunManager.getInstance().stop(runner, true);
                waiter.waitFor(Status.NOT_RUNNING);
            } catch (InterruptedException ex) {
                LOGGER.warning("Wait for NOT_RUNNING interrupted!\n" +ex.getLocalizedMessage());
            } catch (RunnerException ex) {
                LOGGER.warning("Error stopping server!\n" +ex);
            }           
View Full Code Here

        }
       
        if(runner.getStatus() == Status.NOT_RUNNING) {
            try {
               
                StatusWaiter waiter = RunManager.getInstance().start(runner, true);
                waiter.waitFor(Status.RUNNING);
            } catch (InterruptedException ex) {
                LOGGER.warning("Wait for RUNNING interrupted!\n"+ex);
            } catch( RunnerException ex) {
                LOGGER.warning("Error starting server!\n"+ex);               
            }
View Full Code Here

        if (runner.getStatus() != Status.NOT_RUNNING) {
            if (restart) {
                try {
                    // stop the runner, and wait for it to stop
                    StatusWaiter sw = RunManager.getInstance().stop(runner, true);
                    sw.waitFor();
                } catch (RunnerException re) {
                    logger.log(Level.WARNING, "Error stopping " + runner, re);
                    return new SnapshotResult("Error stopping runner", null);
                } catch (InterruptedException ie) {
                    // just ignore?
View Full Code Here

        Collection<StatusWaiter> waiters = new ArrayList<StatusWaiter>();
       
        try {
            if (action.equalsIgnoreCase("start")) {
                for (Runner r : runners) {
                    StatusWaiter w = rm.start(r, wait);
                    if (w != null) {
                        waiters.add(w);
                    }
                }
            } else if (action.equalsIgnoreCase("stop")) {
                for (Runner r : runners) {
                    StatusWaiter w = rm.stop(r, wait);
                    if (w != null) {
                        waiters.add(w);
                    }
                }
            } else if (action.equalsIgnoreCase("restart")) {
                // first stop everyone
                for (Runner r : runners) {
                    StatusWaiter w = rm.stop(r, true);
                    if (w != null) {
                        waiters.add(w);
                    }
                }
               
                // now wait for all runners to stop
                for (StatusWaiter sw : waiters) {
                    try {
                        sw.waitFor();
                    } catch (InterruptedException ie) {
                        // ignore
                    }
                }
                waiters.clear();
               
                // now start everyone back up
                for (Runner r : runners) {
                    StatusWaiter w = rm.start(r, wait);
                    if (w != null) {
                        waiters.add(w);
                    }
                }
            } else {
View Full Code Here

       
            boolean wait = false;
            if (waitParam != null) {
                wait = Boolean.parseBoolean(waitParam);
            }
            StatusWaiter waiter = null;
           
            if (action.equalsIgnoreCase("start")) {
                waiter = rm.start(r, wait);
            } else if (action.equalsIgnoreCase("stop")) {
                waiter = rm.stop(r, wait);
            } else if (action.equalsIgnoreCase("restart")) {
                // stop the runner and wait for it to stop
                waiter = rm.stop(r, true);
                if (waiter != null) {
                    waiter.waitFor();
                }
               
                // wait for a bit so that everything gets cleaned up
                try {
                    Thread.sleep(ActionResource.getRestartDelay() * 1000);
                } catch (InterruptedException ie) {
                    // oh well
                }

                // restart the runner
                waiter = rm.start(r, wait);
            } else if (action.equalsIgnoreCase("log")) {
                // read the log file
                if (r.getLogFile() != null) {
                    BufferedReader reader = new BufferedReader(
                                                new FileReader(r.getLogFile()));
                    StringBuffer sb = new StringBuffer();
                    String line;
                    while ((line = reader.readLine()) != null) {
                        sb.append(line);
                        sb.append("\n");
                    }

                    ResponseBuilder rb = Response.ok(sb.toString());
                    return rb.build();
                }
            } else {
                throw new RunnerException("Unkown action " + action);     
            }
           
            // if necessary, wait for the runner
            if (waiter != null) {
                waiter.waitFor();
            }
           
            ResponseBuilder rb = Response.ok();
            return rb.build();
        } catch (RunnerException re) {
View Full Code Here

TOP

Related Classes of org.jdesktop.wonderland.runner.StatusWaiter

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.