Skip to content

Commit

Permalink
Merge branch '6.7' into retention-lease-bwc
Browse files Browse the repository at this point in the history
* 6.7:
  Fix CCR HLRC docs
  Introduce forget follower API (elastic#39718)
  6.6.2 release notes.
  Update release notes for 6.7.0
  Add documentation for min_hash filter (elastic#39671)
  Unmute testIndividualActionsTimeout
  Unmute testFollowIndexAndCloseNode
  Use unwrapped cause to determine if node is closing (elastic#39723)
  Don’t ack if unable to remove failing replica (elastic#39584)
  Wipe Snapshots Before Indices in RestTests (elastic#39662) (elastic#39765)
  Bug fix for AnnotatedTextHighlighter (elastic#39525)
  Fix Snapshot BwC with Version 5.6.x (elastic#39737)
  Fix occasional SearchServiceTests failure (elastic#39697)
  Correct date in daterange-aggregation.asciidoc (elastic#39727)
  Add a note to purge the ingest-geoip plugin (elastic#39553)
  • Loading branch information
jasontedor committed Mar 7, 2019
2 parents 10a8554 + fab5c61 commit 329403a
Show file tree
Hide file tree
Showing 56 changed files with 1,991 additions and 220 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
* format of the response is incompatible i.e. it is not a JSON object.
*/
static shouldAddShardFailureCheck(String path) {
return path.startsWith('_cat') == false && path.startsWith('_xpack/ml/datafeeds/') == false
return path.startsWith('_cat') == false && path.startsWith('_xpack/ml/datafeeds/') == false
}

/**
Expand Down Expand Up @@ -293,7 +293,7 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
}

void emitDo(String method, String pathAndQuery, String body,
String catchPart, List warnings, boolean inSetup) {
String catchPart, List warnings, boolean inSetup, boolean skipShardFailures) {
def (String path, String query) = pathAndQuery.tokenize('?')
if (path == null) {
path = '' // Catch requests to the root...
Expand Down Expand Up @@ -345,7 +345,7 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
* section so we have to skip it there. We also omit the assertion
* from APIs that don't return a JSON object
*/
if (false == inSetup && shouldAddShardFailureCheck(path)) {
if (false == inSetup && skipShardFailures == false && shouldAddShardFailureCheck(path)) {
current.println(" - is_false: _shards.failures")
}
}
Expand Down Expand Up @@ -393,7 +393,7 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
pathAndQuery = pathAndQuery.substring(1)
}
emitDo(method, pathAndQuery, body, catchPart, snippet.warnings,
inSetup)
inSetup, snippet.skipShardsFailures)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class SnippetsTask extends DefaultTask {
private static final String WARNING = /warning:(.+)/
private static final String CAT = /(_cat)/
private static final String TEST_SYNTAX =
/(?:$CATCH|$SUBSTITUTION|$SKIP|(continued)|$SETUP|$WARNING) ?/
/(?:$CATCH|$SUBSTITUTION|$SKIP|(continued)|$SETUP|$WARNING|(skip_shard_failures)) ?/

/**
* Action to take on each snippet. Called with a single parameter, an
Expand Down Expand Up @@ -233,6 +233,10 @@ public class SnippetsTask extends DefaultTask {
snippet.warnings.add(it.group(7))
return
}
if (it.group(8) != null) {
snippet.skipShardsFailures = true
return
}
throw new InvalidUserDataException(
"Invalid test marker: $line")
}
Expand Down Expand Up @@ -329,6 +333,7 @@ public class SnippetsTask extends DefaultTask {
String setup = null
boolean curl
List warnings = new ArrayList()
boolean skipShardsFailures = false

@Override
public String toString() {
Expand Down Expand Up @@ -359,6 +364,9 @@ public class SnippetsTask extends DefaultTask {
for (String warning in warnings) {
result += "[warning:$warning]"
}
if (skipShardsFailures) {
result += '[skip_shard_failures]'
}
}
if (testResponse) {
result += '// TESTRESPONSE'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.elasticsearch.client.ccr.FollowInfoResponse;
import org.elasticsearch.client.ccr.FollowStatsRequest;
import org.elasticsearch.client.ccr.FollowStatsResponse;
import org.elasticsearch.client.ccr.ForgetFollowerRequest;
import org.elasticsearch.client.ccr.GetAutoFollowPatternRequest;
import org.elasticsearch.client.ccr.GetAutoFollowPatternResponse;
import org.elasticsearch.client.ccr.PauseFollowRequest;
Expand All @@ -36,6 +37,7 @@
import org.elasticsearch.client.ccr.ResumeFollowRequest;
import org.elasticsearch.client.ccr.UnfollowRequest;
import org.elasticsearch.client.core.AcknowledgedResponse;
import org.elasticsearch.client.core.BroadcastResponse;

import java.io.IOException;
import java.util.Collections;
Expand Down Expand Up @@ -233,6 +235,48 @@ public void unfollowAsync(UnfollowRequest request,
);
}

/**
* Instructs an index acting as a leader index to forget the specified follower index.
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-forget-follower.html">the docs</a> for more details
* on the intended usage of this API.
*
* @param request the request
* @param options the request options (e.g., headers), use {@link RequestOptions#DEFAULT} if the defaults are acceptable.
* @return the response
* @throws IOException if an I/O exception occurs while executing this request
*/
public BroadcastResponse forgetFollower(final ForgetFollowerRequest request, final RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(
request,
CcrRequestConverters::forgetFollower,
options,
BroadcastResponse::fromXContent,
Collections.emptySet());
}

/**
* Asynchronously instructs an index acting as a leader index to forget the specified follower index.
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-forget-follower.html">the docs</a> for more details
* on the intended usage of this API.
*
* @param request the request
* @param options the request options (e.g., headers), use {@link RequestOptions#DEFAULT} if the defaults are acceptable.
*/
public void forgetFollowerAsync(
final ForgetFollowerRequest request,
final RequestOptions options,
final ActionListener<BroadcastResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(
request,
CcrRequestConverters::forgetFollower,
options,
BroadcastResponse::fromXContent,
listener,
Collections.emptySet());
}

/**
* Stores an auto follow pattern.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.elasticsearch.client.ccr.DeleteAutoFollowPatternRequest;
import org.elasticsearch.client.ccr.FollowInfoRequest;
import org.elasticsearch.client.ccr.FollowStatsRequest;
import org.elasticsearch.client.ccr.ForgetFollowerRequest;
import org.elasticsearch.client.ccr.GetAutoFollowPatternRequest;
import org.elasticsearch.client.ccr.PauseFollowRequest;
import org.elasticsearch.client.ccr.PutAutoFollowPatternRequest;
Expand Down Expand Up @@ -80,6 +81,17 @@ static Request unfollow(UnfollowRequest unfollowRequest) {
return new Request(HttpPost.METHOD_NAME, endpoint);
}

static Request forgetFollower(final ForgetFollowerRequest forgetFollowerRequest) throws IOException {
final String endpoint = new RequestConverters.EndpointBuilder()
.addPathPart(forgetFollowerRequest.leaderIndex())
.addPathPartAsIs("_ccr")
.addPathPartAsIs("forget_follower")
.build();
final Request request = new Request(HttpPost.METHOD_NAME, endpoint);
request.setEntity(createEntity(forgetFollowerRequest, REQUEST_BODY_CONTENT_TYPE));
return request;
}

static Request putAutoFollowPattern(PutAutoFollowPatternRequest putAutoFollowPatternRequest) throws IOException {
String endpoint = new RequestConverters.EndpointBuilder()
.addPathPartAsIs("_ccr", "auto_follow")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.elasticsearch.client.ccr;

import org.elasticsearch.client.Validatable;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;

import java.io.IOException;
import java.util.Objects;

/**
* Represents a forget follower request. Note that this an expert API intended to be used only when unfollowing a follower index fails to
* remove the follower retention leases. Please be sure that you understand the purpose this API before using.
*/
public final class ForgetFollowerRequest implements ToXContentObject, Validatable {

private final String followerCluster;

private final String followerIndex;

private final String followerIndexUUID;

private final String leaderRemoteCluster;

private final String leaderIndex;

/**
* The name of the leader index.
*
* @return the name of the leader index
*/
public String leaderIndex() {
return leaderIndex;
}

/**
* Construct a forget follower request.
*
* @param followerCluster the name of the cluster containing the follower index to forget
* @param followerIndex the name of follower index
* @param followerIndexUUID the UUID of the follower index
* @param leaderRemoteCluster the alias of the remote cluster containing the leader index from the perspective of the follower index
* @param leaderIndex the name of the leader index
*/
public ForgetFollowerRequest(
final String followerCluster,
final String followerIndex,
final String followerIndexUUID,
final String leaderRemoteCluster,
final String leaderIndex) {
this.followerCluster = Objects.requireNonNull(followerCluster);
this.followerIndex = Objects.requireNonNull(followerIndex);
this.followerIndexUUID = Objects.requireNonNull(followerIndexUUID);
this.leaderRemoteCluster = Objects.requireNonNull(leaderRemoteCluster);
this.leaderIndex = Objects.requireNonNull(leaderIndex);
}

@Override
public XContentBuilder toXContent(final XContentBuilder builder, final Params params) throws IOException {
builder.startObject();
{
builder.field("follower_cluster", followerCluster);
builder.field("follower_index", followerIndex);
builder.field("follower_index_uuid", followerIndexUUID);
builder.field("leader_remote_cluster", leaderRemoteCluster);
}
builder.endObject();
return builder;
}

}
Loading

0 comments on commit 329403a

Please sign in to comment.