List of usage examples for java.util.concurrent Executors newSingleThreadScheduledExecutor
public static ScheduledExecutorService newSingleThreadScheduledExecutor()
From source file:org.dcm4che.tool.findscu.FindSCU.java
@SuppressWarnings("unchecked") public static void main(String[] args) { try {//from w w w. ja va2 s .c o m CommandLine cl = parseComandLine(args); FindSCU main = new FindSCU(); CLIUtils.configureConnect(main.remote, main.rq, cl); CLIUtils.configureBind(main.conn, main.ae, cl); CLIUtils.configure(main.conn, cl); main.remote.setTlsProtocols(main.conn.getTlsProtocols()); main.remote.setTlsCipherSuites(main.conn.getTlsCipherSuites()); configureServiceClass(main, cl); configureKeys(main, cl); configureOutput(main, cl); configureCancel(main, cl); main.setPriority(CLIUtils.priorityOf(cl)); ExecutorService executorService = Executors.newSingleThreadExecutor(); ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); main.device.setExecutor(executorService); main.device.setScheduledExecutor(scheduledExecutorService); try { main.open(); List<String> argList = cl.getArgList(); if (argList.isEmpty()) main.query(); else for (String arg : argList) main.query(new File(arg)); } finally { main.close(); executorService.shutdown(); scheduledExecutorService.shutdown(); } } catch (ParseException e) { System.err.println("findscu: " + e.getMessage()); System.err.println(rb.getString("try")); System.exit(2); } catch (Exception e) { System.err.println("findscu: " + e.getMessage()); e.printStackTrace(); System.exit(2); } }
From source file:SingleThreadRequestExecutor.java
private SingleThreadRequestExecutor() { executor = Executors.newSingleThreadScheduledExecutor(); }
From source file:org.wso2.carbon.integrator.core.handler.EndpointHolder.java
private EndpointHolder() { //retry interval 2 hour long interval = 2; ScheduledExecutorService globalExecutorService = Executors.newSingleThreadScheduledExecutor(); globalExecutorService.scheduleAtFixedRate(this, interval, interval, TimeUnit.HOURS); }
From source file:rc.championship.platform.decoder.lap.publisher.JaxRSLapPublisher.java
@Override protected void start() { super.start(); targets = new CopyOnWriteArrayList<>(); reloadTargetsFromProperties();/* w ww . jav a 2 s .com*/ executor = Executors.newSingleThreadScheduledExecutor(); executor.submit(this); }
From source file:io.pravega.segmentstore.server.host.stat.AutoScaleProcessorTest.java
@Before public void setup() { executor = Executors.newSingleThreadExecutor(); maintenanceExecutor = Executors.newSingleThreadScheduledExecutor(); }
From source file:net.i2cat.netconf.utils.TimerKeepAlive.java
public TimerKeepAlive(INetconfSession netconfSession) { this.netconfSession = netconfSession; timer = Executors.newSingleThreadScheduledExecutor(); }
From source file:org.libreoffice.impressremote.communication.TcpServersFinder.java
public TcpServersFinder(Context aContext) { mContext = aContext;//from w w w . j a v a 2 s . c o m mServers = new HashMap<String, Server>(); mSearchService = Executors.newSingleThreadScheduledExecutor(); }
From source file:org.kaaproject.kaa.client.logging.DefaultLogCollectorTest.java
@BeforeClass public static void beforeSuite() { executorContext = Mockito.mock(ExecutorContext.class); executor = Executors.newSingleThreadScheduledExecutor(); Mockito.when(executorContext.getApiExecutor()).thenReturn(new AbstractExecutorService() { @Override//from w w w .ja v a 2 s. c o m public void execute(Runnable command) { command.run(); } @Override public List<Runnable> shutdownNow() { // TODO Auto-generated method stub return null; } @Override public void shutdown() { // TODO Auto-generated method stub } @Override public boolean isTerminated() { // TODO Auto-generated method stub return false; } @Override public boolean isShutdown() { // TODO Auto-generated method stub return false; } @Override public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { // TODO Auto-generated method stub return false; } }); Mockito.when(executorContext.getCallbackExecutor()).thenReturn(executor); Mockito.when(executorContext.getScheduledExecutor()).thenReturn(executor); }
From source file:com.meltmedia.dropwizard.etcd.json.EtcdWatchServiceRule.java
@Override public Statement apply(Statement base, Description description) { return new Statement() { @Override//from w w w . j a v a2 s . com public void evaluate() throws Throwable { ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); ObjectMapper mapper = new ObjectMapper(); try { try { clientSupplier.get().deleteDir(directory).recursive().send().get(); } catch (Exception e) { System.out.printf("could not delete %s from service rule", directory); e.printStackTrace(); } service = WatchService.builder().withEtcdClient(clientSupplier).withDirectory(directory) .withExecutor(executor).withMapper(mapper).withMetricRegistry(new MetricRegistry()) .withWatchTimeout(10, TimeUnit.MILLISECONDS).build(); service.start(); try { base.evaluate(); } finally { try { service.stop(); } catch (Throwable ioe) { ioe.printStackTrace(System.err); } service = null; } } catch (Exception e) { e.printStackTrace(); throw e; } finally { executor.shutdown(); } } }; }
From source file:com.taobao.tddl.jdbc.atom.config.DiamondDbPasswdManager.java
public void init() { configFactory = new DefaultConfigDataHandlerFactory(); Map<String, String> config = new HashMap<String, String>(); config.put("group", TAtomConstants.DEFAULT_DIAMOND_GROUP); passwdHandler = configFactory.getConfigDataHandlerWithListenerListCE(passwdConfDataId, passwdConfListener, Executors.newSingleThreadScheduledExecutor(), config); }