本文整理了Java中org.elasticsearch.common.collect.Tuple.v1()
方法的一些代码示例,展示了Tuple.v1()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tuple.v1()
方法的具体详情如下:
包路径:org.elasticsearch.common.collect.Tuple
类名称:Tuple
方法名:v1
暂无
代码示例来源:origin: floragunncom/search-guard
@Override
public String[] provide(String[] original, Object localRequest, boolean supportsReplace) {
//CCS
if((localRequest instanceof FieldCapabilitiesRequest || localRequest instanceof SearchRequest)
&& (request instanceof FieldCapabilitiesRequest || request instanceof SearchRequest)) {
assert supportsReplace: localRequest.getClass().getName()+" does not support replace";
final Tuple<Boolean, String[]> ccsResult = handleCcs((Replaceable) localRequest);
if(ccsResult.v1() == Boolean.TRUE) {
if(ccsResult.v2() == null || ccsResult.v2().length == 0) {
returnEmpty.set(true);
}
original = ccsResult.v2();
}
}
if(returnEmpty.get()) {
if(log.isTraceEnabled()) {
log.trace("CCS return empty indices for local node");
}
} else {
final Resolved iResolved = resolveIndexPatterns(original);
if(log.isTraceEnabled()) {
log.trace("Resolved patterns {} for {} ({}) to {}", original, localRequest.getClass().getSimpleName(), request.getClass().getSimpleName(), iResolved);
}
resolvedBuilder.add(iResolved);
resolvedBuilder.addTypes(resolveTypes(localRequest));
}
return IndicesProvider.NOOP;
}
}, false);
代码示例来源:origin: NLPchina/elasticsearch-sql
String generatedFieldName = functionStr.v1();
String returnCommand = ";return " + generatedFieldName +";" ;
String newScript = functionStr.v2() + returnCommand;
functionStr = new Tuple<>(generatedFieldName, newScript);
代码示例来源:origin: floragunncom/search-guard
final Map<String, Set<String>> dlsQueries = dlsFls.v1();
final Map<String, Set<String>> flsFields = dlsFls.v2();
代码示例来源:origin: NLPchina/elasticsearch-sql
if (!first) {
paramers.add(new KVValue(newFunctions.v1()));
} else {
if(newFunctions.v1().toLowerCase().contains("if")){
paramers.add(new KVValue(newFunctions.v1()));
}else {
paramers.add(new KVValue(alias));
paramers.add(new KVValue(newFunctions.v2()));
finalMethodName = "script";
代码示例来源:origin: org.elasticsearch/elasticsearch
private void setStdDeviationBounds(Tuple<Double, Double> bounds) {
this.stdDeviationBoundLower = bounds.v1();
this.stdDeviationBoundUpper = bounds.v2();
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* This configures the maximum script compilations per five minute window.
*
* @param newRate the new expected maximum number of compilations per five minute window
*/
void setMaxCompilationRate(Tuple<Integer, TimeValue> newRate) {
this.rate = newRate;
// Reset the counter to allow new compilations
this.scriptsPerTimeWindow = rate.v1();
this.compilesAllowedPerNano = ((double) rate.v1()) / newRate.v2().nanos();
}
代码示例来源:origin: org.elasticsearch/elasticsearch
private void setStdDeviationBoundsAsString(Tuple<String, String> boundsAsString) {
this.valueAsString.put(Fields.STD_DEVIATION_BOUNDS_AS_STRING + "_lower", boundsAsString.v1());
this.valueAsString.put(Fields.STD_DEVIATION_BOUNDS_AS_STRING + "_upper", boundsAsString.v2());
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
protected synchronized void done() {
done = true;
listeners.forEach(t -> notifyListener(t.v1(), t.v2()));
// release references to any listeners as we no longer need them and will live
// much longer than the listeners in most cases
listeners.clear();
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* @return a list of describing each permit that wasn't released yet. The description consist of the debugInfo supplied
* when the permit was acquired plus a stack traces that was captured when the permit was request.
*/
List<String> getActiveOperations() {
return issuedPermits.values().stream().map(
t -> t.v1() + "\n" + ExceptionsHelper.formatStackTrace(t.v2()))
.collect(Collectors.toList());
}
代码示例来源:origin: org.elasticsearch/elasticsearch
static InetSocketAddress parseSeedAddress(String remoteHost) {
final Tuple<String, Integer> hostPort = parseHostPort(remoteHost);
final String host = hostPort.v1();
assert hostPort.v2() != null : remoteHost;
final int port = hostPort.v2();
InetAddress hostAddress;
try {
hostAddress = InetAddress.getByName(host);
} catch (UnknownHostException e) {
throw new IllegalArgumentException("unknown host [" + host + "]", e);
}
return new InetSocketAddress(hostAddress, port);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
protected void addCustomXContentFields(XContentBuilder builder, Params params) throws IOException {
builder.startObject("upgraded_indices");
for (Map.Entry<String, Tuple<Version, String>> entry : versions.entrySet()) {
builder.startObject(entry.getKey());
builder.field("upgrade_version", entry.getValue().v1());
builder.field("oldest_lucene_segment_version", entry.getValue().v2());
builder.endObject();
}
builder.endObject();
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Check whether there have been too many compilations within the last minute, throwing a circuit breaking exception if so.
* This is a variant of the token bucket algorithm: https://en.wikipedia.org/wiki/Token_bucket
*
* It can be thought of as a bucket with water, every time the bucket is checked, water is added proportional to the amount of time that
* elapsed since the last time it was checked. If there is enough water, some is removed and the request is allowed. If there is not
* enough water the request is denied. Just like a normal bucket, if water is added that overflows the bucket, the extra water/capacity
* is discarded - there can never be more water in the bucket than the size of the bucket.
*/
void checkCompilationLimit() {
long now = System.nanoTime();
long timePassed = now - lastInlineCompileTime;
lastInlineCompileTime = now;
scriptsPerTimeWindow += (timePassed) * compilesAllowedPerNano;
// It's been over the time limit anyway, readjust the bucket to be level
if (scriptsPerTimeWindow > rate.v1()) {
scriptsPerTimeWindow = rate.v1();
}
// If there is enough tokens in the bucket, allow the request and decrease the tokens by 1
if (scriptsPerTimeWindow >= 1) {
scriptsPerTimeWindow -= 1.0;
} else {
// Otherwise reject the request
throw new CircuitBreakingException("[script] Too many dynamic script compilations within, max: [" +
rate.v1() + "/" + rate.v2() +"]; please use indexed, or scripts with parameters instead; " +
"this limit can be changed by the [" + SCRIPT_MAX_COMPILATIONS_RATE.getKey() + "] setting");
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Lookup a value from the registry by name while checking that the name matches the ParseField.
*
* @param name The name of the thing to look up.
* @return The value being looked up or null if it wasn't found.
* @throws ParsingException if the named thing isn't in the registry or the name was deprecated and deprecated names aren't supported.
*/
public T lookupReturningNullIfNotFound(String name, DeprecationHandler deprecationHandler) {
Tuple<ParseField, T> parseFieldAndValue = registry.get(name);
if (parseFieldAndValue == null) {
return null;
}
ParseField parseField = parseFieldAndValue.v1();
T value = parseFieldAndValue.v2();
boolean match = parseField.match(name, deprecationHandler);
//this is always expected to match, ParseField is useful for deprecation warnings etc. here
assert match : "ParseField did not match registered name [" + name + "][" + registryName + "]";
return value;
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
public void setRetries(Tuple<Long, Long> retries) {
if (retries != null) {
setBulkRetries(retries.v1());
setSearchRetries(retries.v2());
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeVInt(versions.size());
for(Map.Entry<String, Tuple<Version, String>> entry : versions.entrySet()) {
out.writeString(entry.getKey());
Version.writeVersion(entry.getValue().v1(), out);
out.writeString(entry.getValue().v2());
}
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Registers this instance to listen to updates on the cluster settings.
*/
public void listenForUpdates(ClusterSettings clusterSettings) {
clusterSettings.addAffixUpdateConsumer(
RemoteClusterAware.REMOTE_CLUSTERS_PROXY,
RemoteClusterAware.REMOTE_CLUSTERS_SEEDS,
(key, value) -> updateRemoteCluster(key, value.v2(), value.v1()),
(namespace, value) -> {});
clusterSettings.addAffixUpdateConsumer(
RemoteClusterAware.SEARCH_REMOTE_CLUSTERS_PROXY,
RemoteClusterAware.SEARCH_REMOTE_CLUSTERS_SEEDS,
(key, value) -> updateRemoteCluster(key, value.v2(), value.v1()),
(namespace, value) -> {});
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeVInt(versions.size());
for(Map.Entry<String, Tuple<Version, String>> entry : versions.entrySet()) {
out.writeString(entry.getKey());
Version.writeVersion(entry.getValue().v1(), out);
out.writeString(entry.getValue().v2());
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
private void notifyListeners(final long globalCheckpoint, final IndexShardClosedException e) {
assert Thread.holdsLock(this) : Thread.currentThread();
assertNotification(globalCheckpoint, e);
final Map<GlobalCheckpointListener, Tuple<Long, ScheduledFuture<?>>> listenersToNotify;
if (globalCheckpoint != UNASSIGNED_SEQ_NO) {
listenersToNotify =
listeners
.entrySet()
.stream()
.filter(entry -> entry.getValue().v1() <= globalCheckpoint)
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
listenersToNotify.keySet().forEach(listeners::remove);
} else {
listenersToNotify = new HashMap<>(listeners);
listeners.clear();
}
if (listenersToNotify.isEmpty() == false) {
executor.execute(() ->
listenersToNotify
.forEach((listener, t) -> {
/*
* We do not want to interrupt any timeouts that fired, these will detect that the listener has been
* notified and not trigger the timeout.
*/
FutureUtils.cancel(t.v2());
notifyListener(listener, globalCheckpoint, e);
}));
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
private static Range parseIpRangeFromCidr(final XContentParser parser) throws IOException {
final Tuple<InetAddress, Integer> cidr = InetAddresses.parseCidr(parser.text());
// create the lower value by zeroing out the host portion, upper value by filling it with all ones.
byte[] lower = cidr.v1().getAddress();
byte[] upper = lower.clone();
for (int i = cidr.v2(); i < 8 * lower.length; i++) {
int m = 1 << 7 - (i & 7);
lower[i >> 3] &= ~m;
upper[i >> 3] |= m;
}
try {
return new Range(RangeType.IP, InetAddress.getByAddress(lower), InetAddress.getByAddress(upper), true, true);
} catch (UnknownHostException bogus) {
throw new AssertionError(bogus);
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
private void respondIfFinished() {
if (counter.decrementAndGet() != 0) {
return;
}
List<TaskResponse> results = new ArrayList<>();
List<TaskOperationFailure> exceptions = new ArrayList<>();
for (Tuple<TaskResponse, Exception> response : responses.asList()) {
if (response.v1() == null) {
assert response.v2() != null;
exceptions.add(new TaskOperationFailure(clusterService.localNode().getId(), tasks.get(taskIndex).getId(),
response.v2()));
} else {
assert response.v2() == null;
results.add(response.v1());
}
}
listener.onResponse(new NodeTasksResponse(clusterService.localNode().getId(), results, exceptions));
}
};
内容来源于网络,如有侵权,请联系作者删除!