Skip to content

Commit 509c575

Browse files
committed
Merge branch 'master' into retention-lease-state-file
* master: Integrate retention leases to recovery from remote (elastic#38829)
2 parents 0fe1cbc + 2024e33 commit 509c575

File tree

14 files changed

+989
-96
lines changed

14 files changed

+989
-96
lines changed

server/src/main/java/org/elasticsearch/index/seqno/RetentionLeaseActions.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public void onFailure(final Exception e) {
115115
}
116116

117117
@Override
118-
protected Response shardOperation(final T request, final ShardId shardId) throws IOException {
118+
protected Response shardOperation(final T request, final ShardId shardId) {
119119
throw new UnsupportedOperationException();
120120
}
121121

@@ -136,10 +136,10 @@ protected boolean resolveIndex(final T request) {
136136
public static class Add extends Action<Response> {
137137

138138
public static final Add INSTANCE = new Add();
139-
public static final String NAME = "indices:admin/seq_no/add_retention_lease";
139+
public static final String ACTION_NAME = "indices:admin/seq_no/add_retention_lease";
140140

141141
private Add() {
142-
super(NAME);
142+
super(ACTION_NAME);
143143
}
144144

145145
public static class TransportAction extends TransportRetentionLeaseAction<AddRequest> {
@@ -153,7 +153,7 @@ public TransportAction(
153153
final IndexNameExpressionResolver indexNameExpressionResolver,
154154
final IndicesService indicesService) {
155155
super(
156-
NAME,
156+
ACTION_NAME,
157157
threadPool,
158158
clusterService,
159159
transportService,
@@ -186,10 +186,10 @@ public Response newResponse() {
186186
public static class Renew extends Action<Response> {
187187

188188
public static final Renew INSTANCE = new Renew();
189-
public static final String NAME = "indices:admin/seq_no/renew_retention_lease";
189+
public static final String ACTION_NAME = "indices:admin/seq_no/renew_retention_lease";
190190

191191
private Renew() {
192-
super(NAME);
192+
super(ACTION_NAME);
193193
}
194194

195195
public static class TransportAction extends TransportRetentionLeaseAction<RenewRequest> {
@@ -203,7 +203,7 @@ public TransportAction(
203203
final IndexNameExpressionResolver indexNameExpressionResolver,
204204
final IndicesService indicesService) {
205205
super(
206-
NAME,
206+
ACTION_NAME,
207207
threadPool,
208208
clusterService,
209209
transportService,
@@ -232,10 +232,10 @@ public Response newResponse() {
232232
public static class Remove extends Action<Response> {
233233

234234
public static final Remove INSTANCE = new Remove();
235-
public static final String NAME = "indices:admin/seq_no/remove_retention_lease";
235+
public static final String ACTION_NAME = "indices:admin/seq_no/remove_retention_lease";
236236

237237
private Remove() {
238-
super(NAME);
238+
super(ACTION_NAME);
239239
}
240240

241241
public static class TransportAction extends TransportRetentionLeaseAction<RemoveRequest> {
@@ -249,7 +249,7 @@ public TransportAction(
249249
final IndexNameExpressionResolver indexNameExpressionResolver,
250250
final IndicesService indicesService) {
251251
super(
252-
NAME,
252+
ACTION_NAME,
253253
threadPool,
254254
clusterService,
255255
transportService,

server/src/main/java/org/elasticsearch/index/seqno/RetentionLeaseAlreadyExistsException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
public class RetentionLeaseAlreadyExistsException extends ResourceAlreadyExistsException {
2929

30-
RetentionLeaseAlreadyExistsException(final String id) {
30+
public RetentionLeaseAlreadyExistsException(final String id) {
3131
super("retention lease with ID [" + Objects.requireNonNull(id) + "] already exists");
3232
}
3333

server/src/main/java/org/elasticsearch/index/seqno/RetentionLeaseNotFoundException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
public class RetentionLeaseNotFoundException extends ResourceNotFoundException {
2929

30-
RetentionLeaseNotFoundException(final String id) {
30+
public RetentionLeaseNotFoundException(final String id) {
3131
super("retention lease with ID [" + Objects.requireNonNull(id) + "] not found");
3232
}
3333

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
package org.elasticsearch.xpack.ccr;
8+
9+
import org.elasticsearch.index.Index;
10+
11+
import java.util.Locale;
12+
13+
public class CcrRetentionLeases {
14+
15+
/**
16+
* The retention lease ID used by followers.
17+
*
18+
* @param localClusterName the local cluster name
19+
* @param followerIndex the follower index
20+
* @param remoteClusterAlias the remote cluster alias
21+
* @param leaderIndex the leader index
22+
* @return the retention lease ID
23+
*/
24+
public static String retentionLeaseId(
25+
final String localClusterName,
26+
final Index followerIndex,
27+
final String remoteClusterAlias,
28+
final Index leaderIndex) {
29+
return String.format(
30+
Locale.ROOT,
31+
"%s/%s/%s-following-%s/%s/%s",
32+
localClusterName,
33+
followerIndex.getName(),
34+
followerIndex.getUUID(),
35+
remoteClusterAlias,
36+
leaderIndex.getName(),
37+
leaderIndex.getUUID());
38+
}
39+
40+
}

0 commit comments

Comments
 (0)