1010import org .apache .logging .log4j .LogManager ;
1111import org .apache .logging .log4j .Logger ;
1212import org .elasticsearch .action .ActionListener ;
13- import org .elasticsearch .action .admin .indices .refresh .RefreshAction ;
14- import org .elasticsearch .action .admin .indices .refresh .RefreshRequest ;
1513import org .elasticsearch .action .support .ThreadedActionListener ;
1614import org .elasticsearch .client .internal .Client ;
1715import org .elasticsearch .core .TimeValue ;
2624import java .util .TreeMap ;
2725import java .util .concurrent .Executor ;
2826
29- import static org .elasticsearch .xpack .core .ClientHelper .SECURITY_ORIGIN ;
30- import static org .elasticsearch .xpack .core .ClientHelper .executeAsyncWithOrigin ;
31-
3227public class SecurityMigrationExecutor extends PersistentTasksExecutor <SecurityMigrationTaskParams > {
3328
3429 private static final Logger logger = LogManager .getLogger (SecurityMigrationExecutor .class );
@@ -88,17 +83,13 @@ private void applyOutstandingMigrations(AllocatedPersistentTask task, int curren
8883 response -> updateMigrationVersion (
8984 migrationEntry .getKey (),
9085 securityIndexManager .getConcreteIndexName (),
91- new ThreadedActionListener <>(this .getExecutor (), ActionListener .wrap (updateResponse -> {
92- refreshSecurityIndex (
93- new ThreadedActionListener <>(
94- this .getExecutor (),
95- ActionListener .wrap (
96- refreshResponse -> applyOutstandingMigrations (task , migrationEntry .getKey (), listener ),
97- listener ::onFailure
98- )
99- )
100- );
101- }, listener ::onFailure ))
86+ new ThreadedActionListener <>(
87+ this .getExecutor (),
88+ ActionListener .wrap (
89+ updateResponse -> applyOutstandingMigrations (task , migrationEntry .getKey (), listener ),
90+ listener ::onFailure
91+ )
92+ )
10293 ),
10394 listener ::onFailure
10495 )
@@ -109,21 +100,6 @@ private void applyOutstandingMigrations(AllocatedPersistentTask task, int curren
109100 }
110101 }
111102
112- /**
113- * Refresh security index to make sure that docs that were migrated are visible to the next migration and to prevent version conflicts
114- * or unexpected behaviour by APIs relying on migrated docs.
115- */
116- private void refreshSecurityIndex (ActionListener <Void > listener ) {
117- RefreshRequest refreshRequest = new RefreshRequest (securityIndexManager .getConcreteIndexName ());
118- executeAsyncWithOrigin (
119- client ,
120- SECURITY_ORIGIN ,
121- RefreshAction .INSTANCE ,
122- refreshRequest ,
123- ActionListener .wrap (response -> listener .onResponse (null ), listener ::onFailure )
124- );
125- }
126-
127103 private void updateMigrationVersion (int migrationVersion , String indexName , ActionListener <Void > listener ) {
128104 client .execute (
129105 UpdateIndexMigrationVersionAction .INSTANCE ,
0 commit comments