@AfterClass public static void shutdown() throws Exception { pc.releaseExternalResources(); serverThread.setShutdown(true); try { Thread.sleep(500L); } catch (Exception e) {; } }
@Test public void hitTop100WebsitesMin() { ParallelTask pt = pc.prepareHttpGet("") .setConcurrency(1000) .setSaveResponseToTask(true) .setTargetHostsFromLineByLineText(FILEPATH_TOP_100, SOURCE_LOCAL) .execute( new ParallecResponseHandler() { @Override public void onCompleted( ResponseOnSingleTask res, Map<String, Object> responseContext) { logger.info( "Responose Code:" + res.getStatusCode() + " host: " + res.getHost()); } }); logger.info("Result Summary\n{}", PcStringUtils.renderJson(pt.getAggregateResultFullSummary())); pt.saveLogToLocal(); }
@Ignore // @Test public void hitTop100WebsitesViaIps() { List<String> hostNames = PcFileNetworkIoUtils.getListFromLineByLineText(FILEPATH_TOP_100, SOURCE_LOCAL); List<String> hostIps = new ArrayList<String>(); int count = 0; for (String hostName : hostNames) { logger.info("get ip for host # {}", ++count); InetAddress address; try { address = InetAddress.getByName(hostName); hostIps.add(address.getHostAddress()); } catch (UnknownHostException e) { e.printStackTrace(); } } ParallelTask pt = pc.prepareHttpGet("") .setConcurrency(1000) .setTargetHostsFromList(hostIps) // .setTargetHostsFromLineByLineText(FILEPATH_TOP_100, // SOURCE_LOCAL) .execute( new ParallecResponseHandler() { @Override public void onCompleted( ResponseOnSingleTask res, Map<String, Object> responseContext) { logger.info( "Responose Code:" + res.getStatusCode() + " host: " + res.getHost()); } }); logger.info( "Result Summary\n{}", PcStringUtils.renderJson(pt.getAggregateResultCountSummary())); }
@AfterClass public static void shutdown() throws Exception { pc.releaseExternalResources(); }