private void reloadOperation() { loadOrCreateConfig(); watchServer.reload(daemonConfig); }
@Override public Account verify(String id, Credential credential) { Account account = getAccount(id); if (account != null && verifyCredential(account, credential)) { return account; } return null; }
private void stopOperation() { stopWebServer(); stopWatchServer(); }
private DaemonOperationResult executeRun() throws Exception { if (PidFileUtil.isProcessRunning(pidFile)) { throw new ServiceAlreadyStartedException("Syncany daemon already running."); } PidFileUtil.createPidFile(pidFile); initEventBus(); loadOrCreateConfig(); startWebServer(); startWatchServer(); enterControlLoop(); // This blocks until SHUTDOWN is received! return new DaemonOperationResult(DaemonResultCode.OK); }
@Test public void testExecuteList() throws Exception { when(options.getAction()).thenReturn(DaemonAction.LIST); DaemonOperationResult res = deamonOp.execute(); assertNotNull(res); assertEquals(DaemonResultCode.OK, res.getResultCode()); assertNotNull(res.getWatchList()); }
@Override public DaemonOperationResult execute() throws Exception { logger.log(Level.INFO, "Starting daemon operation with action " + options.getAction() + " ..."); switch (options.getAction()) { case LIST: return executeList(); case ADD: return executeAdd(); case REMOVE: return executeRemove(); case RUN: return executeRun(); default: throw new Exception("Unknown action: " + options.getAction()); } }
private void enterControlLoop() throws IOException, ServiceAlreadyStartedException { logger.log(Level.INFO, "Starting daemon control server ..."); controlServer = new ControlServer(); controlServer.enterLoop(); // This blocks! }
@Override public int execute(String[] operationArgs) throws Exception { DaemonOperationOptions operationOptions = parseOptions(operationArgs); DaemonOperationResult operationResult = new DaemonOperation(operationOptions).execute(); printResults(operationResult); return 0; }
public DaemonOperation() { this(new DaemonOperationOptions(DaemonAction.RUN)); }
public WebServer(DaemonConfigTO daemonConfig) throws Exception { this.webSocketChannelRequestFormatMap = Maps.newConcurrentMap(); initCaches(); initEventBus(); initServer(daemonConfig); }
private DaemonOperationResult executeList() { logger.log(Level.INFO, "Listing daemon-managed folders ..."); loadOrCreateConfig(); return new DaemonOperationResult(DaemonResultCode.OK, daemonConfig.getFolders()); }
private void startWatchServer() throws ConfigException { logger.log(Level.INFO, "Starting watch server ..."); watchServer = new WatchServer(); watchServer.start(daemonConfig); }
@Subscribe public void onConfirmUserInteractionExternalManagementRequest(ConfirmUserInteractionExternalEventResponse response) { userResponse = response; fireUserResponseReady(); }
public void start(DaemonConfigTO daemonConfigTO) { reload(daemonConfigTO); }
private void stopWatchServer() { logger.log(Level.INFO, "Stopping watch server ..."); watchServer.stop(); } }
private String createMessageStr(WebSocketChannel channel, Message message) throws Exception { RequestFormatType requestFormatType = webSocketChannelRequestFormatMap.get(channel); return createMessageStr(message, requestFormatType); }
private void stopWebServer() { if (webServer != null) { logger.log(Level.INFO, "Stopping web server ..."); webServer.stop(); } else { logger.log(Level.INFO, "Not stopping web server (not running)"); } }
@Test(expected = RuntimeException.class) public void testFileNotFound() { ctrlServer.fileNotFound(); }
@Before public void setUp() { options = new DaemonOperationOptions(DaemonAction.ADD); }
@Subscribe public void onGetPasswordUserInteractionExternalManagementRequest(GetPasswordUserInteractionExternalEventResponse response) { userResponse = response; fireUserResponseReady(); }