@Override protected Set<String> responseParams() { Set<String> responseParams = new HashSet<>(super.responseParams()); responseParams.addAll(Arrays.asList("sql", "flat", "separator", "_score", "_type", "_id", "newLine", "format")); return responseParams; } }
@Override public final void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception { // prepare the request for execution; has the side effect of touching the request parameters final RestChannelConsumer action = prepareRequest(request, client); // validate unconsumed params, but we must exclude params used to format the response // use a sorted set so the unconsumed parameters appear in a reliable sorted order final SortedSet<String> unconsumedParams = request.unconsumedParams().stream().filter(p -> !responseParams().contains(p)).collect(Collectors.toCollection(TreeSet::new)); // validate the non-response params if (!unconsumedParams.isEmpty()) { final Set<String> candidateParams = new HashSet<>(); candidateParams.addAll(request.consumedParams()); candidateParams.addAll(responseParams()); throw new IllegalArgumentException(unrecognized(request, unconsumedParams, candidateParams, "parameter")); } usageCount.increment(); // execute the action action.accept(channel); }
/** * Get the current usage statistics for this node. * * @param localNode * the {@link DiscoveryNode} for this node * @param restActions * whether to include rest action usage in the returned * statistics * @return the {@link NodeUsage} representing the usage statistics for this * node */ public NodeUsage getUsageStats(DiscoveryNode localNode, boolean restActions) { Map<String, Long> restUsageMap; if (restActions) { restUsageMap = new HashMap<>(); handlers.forEach(handler -> { long usageCount = handler.getUsageCount(); if (usageCount > 0) { restUsageMap.put(handler.getName(), usageCount); } }); } else { restUsageMap = null; } return new NodeUsage(localNode, System.currentTimeMillis(), sinceTime, restUsageMap); }
protected abstract void handleRequest(RestRequest request, RestChannel channel, Client client) throws Exception;
@Override public final void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception { // prepare the request for execution; has the side effect of touching the request parameters final RestChannelConsumer action = prepareRequest(request, client); // validate unconsumed params, but we must exclude params used to format the response // use a sorted set so the unconsumed parameters appear in a reliable sorted order final SortedSet<String> unconsumedParams = request.unconsumedParams().stream().filter(p -> !responseParams().contains(p)).collect(Collectors.toCollection(TreeSet::new)); // validate the non-response params if (!unconsumedParams.isEmpty()) { final Set<String> candidateParams = new HashSet<>(); candidateParams.addAll(request.consumedParams()); candidateParams.addAll(responseParams()); throw new IllegalArgumentException(unrecognized(request, unconsumedParams, candidateParams, "parameter")); } usageCount.increment(); // execute the action action.accept(channel); }
/** * Get the current usage statistics for this node. * * @param localNode * the {@link DiscoveryNode} for this node * @param restActions * whether to include rest action usage in the returned * statistics * @return the {@link NodeUsage} representing the usage statistics for this * node */ public NodeUsage getUsageStats(DiscoveryNode localNode, boolean restActions) { Map<String, Long> restUsageMap; if (restActions) { restUsageMap = new HashMap<>(); handlers.forEach(handler -> { long usageCount = handler.getUsageCount(); if (usageCount > 0) { restUsageMap.put(handler.getName(), usageCount); } }); } else { restUsageMap = null; } return new NodeUsage(localNode, System.currentTimeMillis(), sinceTime, restUsageMap); }
@Override public final void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception { // prepare the request for execution; has the side effect of touching the request parameters final RestChannelConsumer action = prepareRequest(request, client); // validate unconsumed params, but we must exclude params used to format the response // use a sorted set so the unconsumed parameters appear in a reliable sorted order final SortedSet<String> unconsumedParams = request.unconsumedParams().stream().filter(p -> !responseParams().contains(p)).collect(Collectors.toCollection(TreeSet::new)); // validate the non-response params if (!unconsumedParams.isEmpty()) { final Set<String> candidateParams = new HashSet<>(); candidateParams.addAll(request.consumedParams()); candidateParams.addAll(responseParams()); throw new IllegalArgumentException(unrecognized(request, unconsumedParams, candidateParams, "parameter")); } // execute the action action.accept(channel); }
@Override protected Set<String> responseParams() { Set<String> responseParams = new HashSet<>(super.responseParams()); responseParams.addAll(Arrays.asList("text", "index", "field", "analyzer", "tokenizer", "filters", "token_filters", "char_filters", "type", "key", "isNameRecognition", "isNumRecognition", "isQuantifierRecognition", "isRealName", "isSkipUserDefine", CrfLibrary.DEFAULT, DicLibrary.DEFAULT, AmbiguityLibrary.DEFAULT, StopLibrary.DEFAULT, SynonymsLibrary.DEFAULT)); return responseParams; } }
/** * Get the current usage statistics for this node. * * @param localNode * the {@link DiscoveryNode} for this node * @param restActions * whether to include rest action usage in the returned * statistics * @return the {@link NodeUsage} representing the usage statistics for this * node */ public NodeUsage getUsageStats(DiscoveryNode localNode, boolean restActions) { Map<String, Long> restUsageMap; if (restActions) { restUsageMap = new HashMap<>(); handlers.forEach(handler -> { long usageCount = handler.getUsageCount(); if (usageCount > 0) { restUsageMap.put(handler.getName(), usageCount); } }); } else { restUsageMap = null; } return new NodeUsage(localNode, System.currentTimeMillis(), sinceTime, restUsageMap); }
@Override public final void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception { // prepare the request for execution; has the side effect of touching the request parameters final RestChannelConsumer action = prepareRequest(request, client); // validate unconsumed params, but we must exclude params used to format the response // use a sorted set so the unconsumed parameters appear in a reliable sorted order final SortedSet<String> unconsumedParams = request.unconsumedParams().stream().filter(p -> !responseParams().contains(p)).collect(Collectors.toCollection(TreeSet::new)); // validate the non-response params if (!unconsumedParams.isEmpty()) { final Set<String> candidateParams = new HashSet<>(); candidateParams.addAll(request.consumedParams()); candidateParams.addAll(responseParams()); throw new IllegalArgumentException(unrecognized(request, unconsumedParams, candidateParams, "parameter")); } usageCount.increment(); // execute the action action.accept(channel); }
@Override protected Set<String> responseParams() { Set<String> responseParams = new HashSet<>(super.responseParams()); responseParams.addAll(Arrays.asList("sql", "flat", "separator", "_score", "_type", "_id", "newLine", "format")); return responseParams; } }