private List<ServiceInformation> fetchServices(ServiceNodeDiscoverer serviceNodeDiscoverer, Cluster cluster) { List<String> availableServices = serviceNodeDiscoverer.getServices(); return availableServices.parallelStream() .filter(ServiceConfigurations::contains) .map(serviceName -> ParallelStreamUtil.execute( () -> fetchService(serviceNodeDiscoverer, cluster, serviceName), forkJoinPool)) .collect(toList()); }
public static <T> T execute(Supplier<T> supplier, Executor executor) { Stopwatch stopwatch = Stopwatch.createStarted(); LOG.debug("execute start"); try { CompletableFuture<T> resultFuture = CompletableFuture.supplyAsync(supplier, executor); return resultFuture.get(); } catch (InterruptedException e) { throw new RuntimeException(e); } catch (ExecutionException e) { handleExecutionException(e); // shouldn't reach here throw new IllegalStateException("Shouldn't reach here"); } finally { LOG.debug("execute complete - elapsed: {} ms", stopwatch.elapsed(TimeUnit.MILLISECONDS)); stopwatch.stop(); } }
private Response deploy(Topology topology, SecurityContext securityContext) { String asUser = WSUtils.getUserFromSecurityContext(securityContext); try { ParallelStreamUtil.runAsync(() -> actionsService.deployTopology(topology, asUser), forkJoinPool); return WSUtils.respondEntity(topology, OK); } catch (TopologyAlreadyExistsOnCluster ex) { return ex.getResponse(); } }
ParallelStreamUtil.runAsync(() -> runTestInBackground(topologyActions, topology, history, testRunSourceMap, testRunProcessorMap, testRunRulesProcessorMap, testRunSinkMap, expectedOutputRecordsMap, finalDurationSecs), forkJoinPool);
long errorCount = ParallelStreamUtil.execute(() -> componentIds.parallelStream().mapToLong(componentId -> { Map componentStats = getComponentInfo(topologyId, componentId, asUser);
@Override public TimeSeriesComponentMetric getTopologyStats(TopologyLayout topology, long from, long to, String asUser) { String stormTopologyName = StormTopologyUtil.findOrGenerateTopologyName(client, topology.getId(), topology.getName(), asUser); Map<String, Map<Long, Double>> stats = ParallelStreamUtil.execute(() -> Arrays.asList(STATS_METRICS_SOURCE) .parallelStream() .collect(toMap(m -> m.name(), m -> queryTopologyMetrics(stormTopologyName, m, from, to))), FORK_JOIN_POOL); return buildTimeSeriesComponentMetric(topology.getName(), stats); }
topologyComponents.addAll(catalogService.listTopologySinks(queryParams)); Map<String, TopologyTimeSeriesMetrics.TimeSeriesComponentMetric> topologyMetrics = ParallelStreamUtil.execute(() -> topologyComponents.parallelStream() .map(c -> {
@Override public TimeSeriesComponentMetric getComponentStats(TopologyLayout topology, Component component, long from, long to, String asUser) { String stormTopologyName = StormTopologyUtil.findOrGenerateTopologyName(client, topology.getId(), topology.getName(), asUser); String stormComponentName = getComponentName(component); StormMappedMetric[] stats; if (component instanceof Source) { stats = STATS_METRICS_SOURCE; } else { stats = STATS_METRICS; } // empty map if time-series DB is not set to the namespace Map<String, Map<Long, Double>> componentStats = ParallelStreamUtil.execute(() -> Arrays.asList(stats) .parallelStream() .collect(toMap(m -> m.name(), m -> queryComponentMetrics(stormTopologyName, stormComponentName, m, from, to))), FORK_JOIN_POOL); return buildTimeSeriesComponentMetric(component.getName(), componentStats); }
List<CatalogResourceUtil.TopologyDashboardResponse> responses = ParallelStreamUtil.execute(() -> topologies.parallelStream() .map(Unchecked.function(t ->