public void processRequest(TextCommand command) { if (responseThreadRunnable == null) { synchronized (this) { if (responseThreadRunnable == null) { responseThreadRunnable = new ResponseThreadRunnable(); Thread thread = new Thread( node.threadGroup, responseThreadRunnable, "hz.ascii.service.response.thread"); thread.start(); } } } parallelExecutor.execute(new CommandExecutor(command)); }
public void restart() { synchronized (lifecycleLock) { ThreadContext.get().setCurrentFactory(factory); fireLifecycleEvent(RESTARTING); paused.set(true); final Node node = factory.node; final ILogger logger = getLogger(); List<Record> lsOwnedRecords = new ArrayList<Record>(); for (CMap cmap : node.concurrentMapManager.getCMaps().values()) { if (cmap.isUserMap()) { lsOwnedRecords.addAll(cmap.getMapIndexService().getOwnedRecords()); } } node.onRestart(); node.clientHandlerService.restart(); node.connectionManager.onRestart(); node.clusterManager.onRestart(); node.concurrentMapManager.onRestart(); node.rejoin(); final CountDownLatch latch = new CountDownLatch(lsOwnedRecords.size()); final ParallelExecutor executor = node.executorManager.newParallelExecutor(16); for (final Record ownedRecord : lsOwnedRecords) { executor.execute( new Runnable() { public void run() { try { ConcurrentMapManager.MPut mput = node.concurrentMapManager.new MPut(); mput.merge(ownedRecord); // invalidate record now (skipped invalidation on restart) ownedRecord.invalidate(); latch.countDown(); } catch (Exception e) { logger.log(Level.WARNING, e.getMessage(), e); } } }); } try { latch.await(60, TimeUnit.SECONDS); } catch (InterruptedException ignored) { } paused.set(false); fireLifecycleEvent(RESTARTED); } }