/** Listens for client requests until stopped. */ public void run() { try { while (listener != null) { try { Socket socket = serverSocket.accept(); if (!paranoid || checkSocket(socket)) { Runner runner = getRunner(); runner.handle(socket); // new Connection (socket); } else socket.close(); } catch (Exception ex) { System.err.println("Exception in XML-RPC listener loop (" + ex + ")."); } catch (Error err) { System.err.println("Error in XML-RPC listener loop (" + err + ")."); } } } catch (Exception exception) { System.err.println("Error accepting XML-RPC connections (" + exception + ")."); } finally { System.err.println("Closing XML-RPC server socket."); try { serverSocket.close(); serverSocket = null; } catch (IOException ignore) { } } }
private Runner getRunner(String path) { Runner runner = runnerRepository.findOneByPath(path); if (runner == null) { runner = new Runner(); runner.setPath(path); return runnerRepository.save(runner); } return runner; }
public synchronized void enqueue(Task task) { queue.add(task); if (runner == null) { runnerRunning = true; runner = new Runner(this); runner.setDaemon(true); runner.start(); } else if (!runnerRunning) { runnerRunning = true; notifyAll(); } }
static long doTest(int id, String name, final Map<String, String> m, final String[] key) { // System.out.print(name + "\t"); Runner runner = new Runner(id, m, key); long startTime = System.currentTimeMillis(); runner.run(); long afterRun = System.currentTimeMillis(); long runTime = (afterRun - startTime); int np = runner.total; if (runner.total == runner.hashCode()) System.out.println("Useless Number" + runner.total); int sz = runner.maxsz; if (sz == runner.hashCode()) System.out.println("Useless Number" + sz); // System.out.print(" m = " + sz); return runTime; }
public void actionPerformed(ActionEvent ae) { if (paths != null && paths.size() > 0) { dialog = new LockDialog(getView(), paths, false, remote); GUIUtils.center(getView(), dialog); dialog.setVisible(true); final CommitData data = dialog.getData(); if (data == null) { return; // null means user canceled } if (getUsername() == null) { verifyLogin(data.getPaths() == null ? null : data.getPaths().get(0)); if (isCanceled()) { return; } } data.setUsername(getUsername()); data.setPassword(getPassword()); data.setOut(new ConsolePrintStream(getView())); getView().getDockableWindowManager().showDockableWindow("subversion"); final OutputPanel panel = SVNPlugin.getOutputPanel(getView()); panel.showConsole(); final Logger logger = panel.getLogger(); logger.log(Level.INFO, jEdit.getProperty("ips.Unlocking_...", "Unlocking ...")); for (Handler handler : logger.getHandlers()) { handler.flush(); } class Runner extends SwingWorker<LockResults, Object> { @Override public LockResults doInBackground() { try { Lock lock = new Lock(); return lock.unlock(data); } catch (Exception e) { data.getOut().printError(e.getMessage()); } finally { data.getOut().close(); } return null; } @Override public boolean cancel(boolean mayInterruptIfRunning) { boolean cancelled = super.cancel(mayInterruptIfRunning); if (cancelled) { data.getOut().printError("Stopped 'Unlock' action."); data.getOut().close(); } else { data.getOut().printError("Unable to stop 'Unlock' action."); } return cancelled; } @Override protected void done() { if (isCancelled()) { return; } try { JPanel results_panel = new AddResultsPanel( get(), AddResultsPanel.UNLOCK, getView(), getUsername(), getPassword()); panel.addTab(jEdit.getProperty("ips.Unlocked", "Unlocked"), results_panel); } catch (Exception e) { // NOPMD // ignored } } } Runner runner = new Runner(); panel.addWorker("Unlock", runner); runner.execute(); } }