/** * Walks {@link #rootDir}. * * @return the walked files. * @throws IOException if walking the files fails. */ public ImmutableList<Path> walk() throws IOException { try (Stream<Path> fileStream = Files.walk(rootDir)) { return fileStream.filter(pathFilter).sorted().collect(ImmutableList.toImmutableList()); } } }
public MessageProcessorsConfig withProcessors(final Set<String> availableProcessors) { final List<String> newOrder = new ArrayList<>(); // Check if processor actually exists. processorOrder().stream() .filter(availableProcessors::contains) .forEach(newOrder::add); // Add availableProcessors which are not in the config yet to the end. availableProcessors.stream() .filter(processor -> !newOrder.contains(processor)) .sorted(String.CASE_INSENSITIVE_ORDER) .forEach(newOrder::add); return toBuilder().processorOrder(newOrder).build(); }
private static List<Map.Entry<String, MetricStatsInt>> fiveBiggest(DistributedMetricStatsInt distributedMetricStatsInt, ToIntFunction<MetricStatsInt> biggerCriteria) { Comparator<Map.Entry<String, MetricStatsInt>> comparator = Comparator.comparingInt(a -> biggerCriteria.applyAsInt(a.getValue())); return distributedMetricStatsInt.getForLabels() .entrySet() .stream() .sorted(comparator.reversed()) .limit(5) .collect(MoreCollectors.toList(5)); }
@Admin @Description( "List the currently active config of Neo4j." ) @Procedure( name = "dbms.listConfig", mode = DBMS ) public Stream<ConfigResult> listConfig( @Name( value = "searchString", defaultValue = "" ) String searchString ) { Config config = graph.getDependencyResolver().resolveDependency( Config.class ); String lowerCasedSearchString = searchString.toLowerCase(); return config.getConfigValues().values().stream() .filter( c -> !c.internal() ) .filter( c -> c.name().toLowerCase().contains( lowerCasedSearchString ) ) .map( ConfigResult::new ) .sorted( Comparator.comparing( c -> c.name ) ); }
@Description( "List all constraints in the database." ) @Procedure( name = "db.constraints", mode = READ ) public Stream<ConstraintResult> listConstraints() { SchemaRead schemaRead = tx.schemaRead(); TokenNameLookup tokens = new SilentTokenNameLookup( tx.tokenRead() ); return asList( schemaRead.constraintsGetAll() ) .stream() .map( constraint -> constraint.prettyPrint( tokens ) ) .sorted() .map( ConstraintResult::new ); }
@Description( "List all procedures in the DBMS." ) @Procedure( name = "dbms.procedures", mode = DBMS ) public Stream<ProcedureResult> listProcedures() { securityContext.assertCredentialsNotExpired(); return graph.getDependencyResolver().resolveDependency( Procedures.class ).getAllProcedures().stream() .sorted( Comparator.comparing( a -> a.name().toString() ) ) .map( ProcedureResult::new ); }
public AuthenticationConfig withRealms(final Set<String> availableRealms) { final List<String> newOrder = new ArrayList<>(); // Check if realm actually exists. realmOrder().stream() .filter(availableRealms::contains) .forEach(newOrder::add); // Add availableRealms which are not in the config yet to the end. availableRealms.stream() .filter(realm -> !newOrder.contains(realm)) .sorted(String.CASE_INSENSITIVE_ORDER) .forEach(newOrder::add); return toBuilder().realmOrder(newOrder).build(); }
@GuardedBy("this") private String getAdditionalFailureInfo(long allocated, long delta) { Map<String, Long> queryAllocations = memoryPool.getTaggedMemoryAllocations().get(queryId); String additionalInfo = format("Allocated: %s, Delta: %s", succinctBytes(allocated), succinctBytes(delta)); // It's possible that a query tries allocating more than the available memory // failing immediately before any allocation of that query is tagged if (queryAllocations == null) { return additionalInfo; } String topConsumers = queryAllocations.entrySet().stream() .sorted(comparingByValue(Comparator.reverseOrder())) .limit(3) .collect(toImmutableMap(Entry::getKey, e -> succinctBytes(e.getValue()))) .toString(); return format("%s, Top Consumers: %s", additionalInfo, topConsumers); } }
@Description( "List all user functions in the DBMS." ) @Procedure( name = "dbms.functions", mode = DBMS ) public Stream<FunctionResult> listFunctions() { securityContext.assertCredentialsNotExpired(); return graph.getDependencyResolver().resolveDependency( Procedures.class ).getAllFunctions().stream() .sorted( Comparator.comparing( a -> a.name().toString() ) ) .map( FunctionResult::new ); }
@Nullable private String getContentCodingKey(HttpServletRequest request) { String header = request.getHeader(HttpHeaders.ACCEPT_ENCODING); if (!StringUtils.hasText(header)) { return null; } return Arrays.stream(StringUtils.tokenizeToStringArray(header, ",")) .map(token -> { int index = token.indexOf(';'); return (index >= 0 ? token.substring(0, index) : token).trim().toLowerCase(); }) .filter(this.contentCodings::contains) .sorted() .collect(Collectors.joining(",")); }
@GuardedBy("this") private String getAdditionalFailureInfo(long allocated, long delta) { Map<String, Long> queryAllocations = memoryPool.getTaggedMemoryAllocations().get(queryId); String additionalInfo = format("Allocated: %s, Delta: %s", succinctBytes(allocated), succinctBytes(delta)); // It's possible that a query tries allocating more than the available memory // failing immediately before any allocation of that query is tagged if (queryAllocations == null) { return additionalInfo; } String topConsumers = queryAllocations.entrySet().stream() .sorted(comparingByValue(Comparator.reverseOrder())) .limit(3) .collect(toImmutableMap(Entry::getKey, e -> succinctBytes(e.getValue()))) .toString(); return format("%s, Top Consumers: %s", additionalInfo, topConsumers); } }
private Optional<Event> verifyWindowContiguity(List<Event> newValues, Collector<String> out) { return newValues.stream() .sorted(Comparator.comparingLong(Event::getSequenceNumber)) .reduce((event, event2) -> { if (event2.getSequenceNumber() - 1 != event.getSequenceNumber()) { out.collect("Alert: events in window out ouf order!"); } return event2; }); } }
@Nullable private String getContentCodingKey(ServerWebExchange exchange) { String header = exchange.getRequest().getHeaders().getFirst("Accept-Encoding"); if (!StringUtils.hasText(header)) { return null; } return Arrays.stream(StringUtils.tokenizeToStringArray(header, ",")) .map(token -> { int index = token.indexOf(';'); return (index >= 0 ? token.substring(0, index) : token).trim().toLowerCase(); }) .filter(this.contentCodings::contains) .sorted() .collect(Collectors.joining(",")); }