List of usage examples for java.util.concurrent Executors newSingleThreadScheduledExecutor
public static ScheduledExecutorService newSingleThreadScheduledExecutor()
From source file:edu.wustl.mir.erl.ihe.xdsi.util.StoreSCU.java
@SuppressWarnings("unchecked") public static void main(String[] args) { long t1, t2;//from ww w .j ava2 s. co m try { CommandLine cl = parseComandLine(args); Device device = new Device("storescu"); Connection conn = new Connection(); device.addConnection(conn); ApplicationEntity ae = new ApplicationEntity("STORESCU"); device.addApplicationEntity(ae); ae.addConnection(conn); StoreSCU main = new StoreSCU(ae); configureTmpFile(main, cl); CLIUtils.configureConnect(main.remote, main.rq, cl); CLIUtils.configureBind(conn, ae, cl); CLIUtils.configure(conn, cl); main.remote.setTlsProtocols(conn.getTlsProtocols()); main.remote.setTlsCipherSuites(conn.getTlsCipherSuites()); configureRelatedSOPClass(main, cl); main.setAttributes(new Attributes()); CLIUtils.addAttributes(main.attrs, cl.getOptionValues("s")); main.setUIDSuffix(cl.getOptionValue("uid-suffix")); main.setPriority(CLIUtils.priorityOf(cl)); List<String> argList = cl.getArgList(); boolean echo = argList.isEmpty(); if (!echo) { System.out.println(rb.getString("scanning")); t1 = System.currentTimeMillis(); main.scanFiles(argList); t2 = System.currentTimeMillis(); int n = main.filesScanned; System.out.println(); if (n == 0) return; System.out.println( MessageFormat.format(rb.getString("scanned"), n, (t2 - t1) / 1000F, (t2 - t1) / n)); } ExecutorService executorService = Executors.newSingleThreadExecutor(); ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); device.setExecutor(executorService); device.setScheduledExecutor(scheduledExecutorService); try { t1 = System.currentTimeMillis(); main.open(); t2 = System.currentTimeMillis(); System.out .println(MessageFormat.format(rb.getString("connected"), main.as.getRemoteAET(), t2 - t1)); if (echo) main.echo(); else { t1 = System.currentTimeMillis(); main.sendFiles(); t2 = System.currentTimeMillis(); } } finally { main.close(); executorService.shutdown(); scheduledExecutorService.shutdown(); } if (main.filesScanned > 0) { float s = (t2 - t1) / 1000F; float mb = main.totalSize / 1048576F; System.out.println(MessageFormat.format(rb.getString("sent"), main.filesSent, mb, s, mb / s)); } } catch (ParseException e) { System.err.println("storescu: " + e.getMessage()); System.err.println(rb.getString("try")); System.exit(2); } catch (Exception e) { System.err.println("storescu: " + e.getMessage()); e.printStackTrace(); System.exit(2); } }
From source file:org.dcm4che.tool.getscu.GetSCU.java
@SuppressWarnings("unchecked") public static void main(String[] args) { try {//from ww w . j a v a2 s.c om CommandLine cl = parseComandLine(args); GetSCU main = new GetSCU(); 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); main.setPriority(CLIUtils.priorityOf(cl)); configureStorageDirectory(main, 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.retrieve(); else for (String arg : argList) main.retrieve(new File(arg)); } finally { main.close(); executorService.shutdown(); scheduledExecutorService.shutdown(); } } catch (ParseException e) { System.err.println("getscu: " + e.getMessage()); System.err.println(rb.getString("try")); System.exit(2); } catch (Exception e) { System.err.println("getscu: " + e.getMessage()); e.printStackTrace(); System.exit(2); } }
From source file:simulation.LoadBalancer.java
public LoadBalancer() { vehicleLists = new ArrayList<>(); generateArrayLists();/*from ww w. j av a2 s.co m*/ pulseGroup = 0; ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); executor.scheduleAtFixedRate(new Runnable() { @Override public void run() { pulseNextGroup(); } }, 5, 2, TimeUnit.SECONDS); }
From source file:com.nebhale.gpxconverter.Application.java
@Bean
ScheduledExecutorService scheduledExecutorService() {
return Executors.newSingleThreadScheduledExecutor();
}
From source file:rc.championship.platform.decoder.lap.publisher.RccLapPublisher.java
@Override protected void start() { super.start(); executor = Executors.newSingleThreadScheduledExecutor(); executor.submit(this); }
From source file:cn.leancloud.diamond.io.watch.WatchService.java
public WatchService(long checkInterval) { service = Executors.newSingleThreadScheduledExecutor(); service.scheduleAtFixedRate(new CheckThread(), checkInterval, checkInterval, TimeUnit.MILLISECONDS); }
From source file:ru.prbb.activeagent.services.AbstractChecker.java
protected AbstractChecker(String host) throws URISyntaxException { uri = new URI(host); mapper = new ObjectMapper(); //mapper.setDateFormat(new SimpleDateFormat("yyyyMMdd")); exec = Executors.newSingleThreadScheduledExecutor(); }
From source file:com.liferay.portal.search.solr.server.LiveServerChecker.java
public LiveServerChecker(final SolrServerFactory solrServerFactory, Long delay) { _solrServerFactory = solrServerFactory; _scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); _scheduledExecutorService.scheduleWithFixedDelay(this, 0, delay, TimeUnit.SECONDS); SolrServletContextListener.registerLiveServerChecker(this); }
From source file:com.bofa.sstradingreport.config.TestConfig.java
@Bean(destroyMethod = "shutdown") public Executor taskScheduler() { return Executors.newSingleThreadScheduledExecutor(); }
From source file:com.mpush.test.client.ConnClientTestMain.java
private static void testConnClient(int count, String userPrefix, int printDelay, boolean sync) throws Exception { Logs.init();//from www . j av a2 s .co m ConnClientBoot boot = new ConnClientBoot(); boot.start().get(); List<ServiceNode> serverList = boot.getServers(); if (serverList.isEmpty()) { boot.stop(); System.out.println("no mpush server."); return; } if (printDelay > 0) { Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate( () -> System.err.println(ConnClientChannelHandler.STATISTICS), 3, printDelay, TimeUnit.SECONDS); } for (int i = 0; i < count; i++) { String clientVersion = "1.0." + i; String osName = "android"; String osVersion = "1.0.1"; String userId = userPrefix + "user-" + i; String deviceId = userPrefix + "test-device-id-" + i; byte[] clientKey = CipherBox.I.randomAESKey(); byte[] iv = CipherBox.I.randomAESIV(); ClientConfig config = new ClientConfig(); config.setClientKey(clientKey); config.setIv(iv); config.setClientVersion(clientVersion); config.setDeviceId(deviceId); config.setOsName(osName); config.setOsVersion(osVersion); config.setUserId(userId); int L = serverList.size(); int index = (int) ((Math.random() % L) * L); ServiceNode node = serverList.get(index); ChannelFuture future = boot.connect(node.getAttr(ATTR_PUBLIC_IP), node.getPort(), config); if (sync) future.awaitUninterruptibly(); } }