use of org.vesalainen.util.concurrent.CachedScheduledThreadPool in project NMEAParser by tvesalainen.
the class N2KGatewayT method test.
@Test
public void test() throws IOException, InterruptedException, ExecutionException {
Path in = Paths.get("C:\\Users\\tkv\\share", "candump.txt");
Path out = Paths.get("C:\\Temp", "can2nmea.txt");
N2KGateway gw = N2KGateway.getInstance("can1", in, out, new CachedScheduledThreadPool());
gw.startAndWait();
}
use of org.vesalainen.util.concurrent.CachedScheduledThreadPool in project NMEAParser by tvesalainen.
the class AISLogFileTest method test1.
@Test
public void test1() throws IOException, InterruptedException {
CachedScheduledThreadPool executor = new CachedScheduledThreadPool();
AISLogFile log = new AISLogFile(path, 80, executor);
log.format("qwertyuiopölkjhgfdasxcvbn");
log.format("qwertyuiopölkjhgfdasxcvbn");
log.format("qwertyuiopölkjhgfdasxcvbn");
log.format("qwertyuiopölkjhgfdasxcvbn");
log.format("qwertyuiopölkjhgfdasxcvbn");
log.flush();
executor.shutdown();
executor.awaitTermination(1, TimeUnit.DAYS);
List<Path> exp = CollectionHelp.create(gz1, path);
assertEquals(exp, log.getPaths());
}
use of org.vesalainen.util.concurrent.CachedScheduledThreadPool in project NMEAParser by tvesalainen.
the class AISServiceT method test1.
@Test
public void test1() throws IOException, InterruptedException {
CachedScheduledThreadPool executor = new CachedScheduledThreadPool();
NMEAService nmeaService = new NMEAService("224.0.0.3", 10110, executor);
Path dir = Paths.get("c:\\temp");
AISService aisService = AISService.getInstance(nmeaService, dir, 10, 1024 * 1024, executor);
nmeaService.start();
while (true) {
Thread.sleep(10000);
System.err.println();
Collection<AISTarget> liveList = aisService.getLiveList();
liveList.forEach((t) -> testAISTarget(t));
}
// aisService.addObserver((s, m, t)->System.err.println(s+" "+m));
// Thread.sleep(100000000);
}
use of org.vesalainen.util.concurrent.CachedScheduledThreadPool in project NMEAParser by tvesalainen.
the class CommandLine method start.
private void start() throws IOException, InterruptedException, JAXBException, Exception {
config("starting NMEA Server");
Path configfile = getArgument("configuration file");
Config config = new Config(configfile);
String address = config.getNmeaMulticastAddress();
int nmeaPort = config.getNmeaMulticastPort();
int httpPort = config.getHttpPort();
config("NMEA Multicast Address=%s", address);
config("NMEA Multicast Port=%s", nmeaPort);
config("HTTP Port=%s", httpPort);
CachedScheduledThreadPool executor = new CachedScheduledThreadPool(64);
config("ThreadPool started %s", executor);
NMEAService nmeaService = new NMEAService(address, nmeaPort, executor);
PropertyServer propertyServer = new PropertyServer(Clock.systemDefaultZone(), config, executor);
nmeaService.addNMEAObserver(propertyServer);
nmeaService.start();
config("NMEA Service started");
JavaUtilLog log = new JavaUtilLog();
// make jetty use java.util.logger
Log.setLog(log);
Server server = new Server(httpPort);
HandlerList handlers = new HandlerList();
ServletContextHandler context = new ServletContextHandler();
context.addServlet(ResourceServlet.class, "/");
ServletHolder holder = new ServletHolder(SseServlet.class);
holder.setAsyncSupported(true);
context.addServlet(holder, "/sse");
context.addServlet(ResourceServlet.class, "*.js");
context.addServlet(ResourceServlet.class, "*.css");
context.addServlet(ResourceServlet.class, "*.gif");
context.addServlet(ResourceServlet.class, "*.png");
context.addServlet(ResourceServlet.class, "*.ico");
context.addServlet(PrefsServlet.class, "/prefs");
context.addServlet(I18nServlet.class, "/i18n");
SessionHandler sessionHandler = new SessionHandler();
context.setSessionHandler(sessionHandler);
handlers.addHandler(context);
server.setHandler(handlers);
server.setSessionIdManager(new DefaultSessionIdManager(server));
ServletContext servletContext = context.getServletContext().getContext("/sse");
servletContext.setAttribute(PropertyServer.class.getName(), propertyServer);
server.start();
executor.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
}
use of org.vesalainen.util.concurrent.CachedScheduledThreadPool in project NMEAParser by tvesalainen.
the class RouterManager method createPool.
private static CachedScheduledThreadPool createPool() {
CachedScheduledThreadPool pool = new CachedScheduledThreadPool(MAX_POOL_SIZE);
pool.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
return pool;
}
Aggregations