Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions server/src/main/java/org/elasticsearch/index/engine/Engine.java
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,21 @@ public interface IndexCommitListener {
* {@link IndexCommitRef} prevents the {@link IndexCommitRef} files to be deleted from disk until the reference is closed. As such,
* the listener must close the reference as soon as it is done with it.
*
* @param shardId the {@link ShardId} of shard
* @param store the index shard store
* @param primaryTerm the shard's primary term value
* @param indexCommitRef a reference on the newly created index commit
* @param additionalFiles the set of filenames that are added by the new commit
* @param shardId the {@link ShardId} of shard
* @param store the index shard store
* @param primaryTerm the shard's primary term value
* @param indexCommitRef a reference on the newly created index commit
* @param additionalFiles the set of filenames that are added by the new commit
* @param extraTransientData extra transient data relevant to the new commit
*/
void onNewCommit(ShardId shardId, Store store, long primaryTerm, IndexCommitRef indexCommitRef, Set<String> additionalFiles);
void onNewCommit(
ShardId shardId,
Store store,
long primaryTerm,
IndexCommitRef indexCommitRef,
Set<String> additionalFiles,
Map<String, String> extraTransientData
);

/**
* This method is invoked after the policy deleted the given {@link IndexCommit}. A listener is never notified of a deleted commit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,14 @@ public void onNewAcquiredCommit(final IndexCommit commit, final Set<String> addi
final IndexCommitRef indexCommitRef = acquireIndexCommitRef(() -> commit);
var primaryTerm = config().getPrimaryTermSupplier().getAsLong();
assert indexCommitRef.getIndexCommit() == commit;
wrappedListener.onNewCommit(shardId, store, primaryTerm, indexCommitRef, additionalFiles);
wrappedListener.onNewCommit(
shardId,
store,
primaryTerm,
indexCommitRef,
additionalFiles,
getCommitExtraTransientData()
);
}

@Override
Expand All @@ -416,7 +423,8 @@ public void onNewCommit(
Store store,
long primaryTerm,
IndexCommitRef indexCommitRef,
Set<String> additionalFiles
Set<String> additionalFiles,
Map<String, String> extraTransientData
) {
final long nextGen = indexCommitRef.getIndexCommit().getGeneration();
final long prevGen = generation.getAndSet(nextGen);
Expand All @@ -427,7 +435,7 @@ public void onNewCommit(
+ prevGen
+ " for shard "
+ shardId;
listener.onNewCommit(shardId, store, primaryTerm, indexCommitRef, additionalFiles);
listener.onNewCommit(shardId, store, primaryTerm, indexCommitRef, additionalFiles, extraTransientData);
}

@Override
Expand Down Expand Up @@ -2980,6 +2988,14 @@ protected Map<String, String> getCommitExtraUserData(final long localCheckpoint)
return Collections.emptyMap();
}

/**
* Allows InternalEngine extenders to return custom key-value pairs for transient information, that is not stored in the commit, to be
* included in the {@link org.elasticsearch.index.engine.Engine.IndexCommitListener}'s new commit invocation.
*/
protected Map<String, String> getCommitExtraTransientData() {
return Collections.emptyMap();
}

final void ensureCanFlush() {
// translog recovery happens after the engine is fully constructed.
// If we are in this stage we have to prevent flushes from this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,8 @@ public void onNewCommit(
Store store,
long primaryTerm,
Engine.IndexCommitRef indexCommitRef,
Set<String> additionalFiles
Set<String> additionalFiles,
Map<String, String> extraTransientData
) {
lastAcquiredPrimaryTerm.set(primaryTerm);
lastAcquiredCommit.set(indexCommitRef);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7419,7 +7419,8 @@ public void onNewCommit(
Store store,
long primaryTerm,
Engine.IndexCommitRef indexCommitRef,
Set<String> additionalFiles
Set<String> additionalFiles,
Map<String, String> extraTransientData
) {
assertNotNull(store);
assertTrue(store.hasReferences());
Expand Down