2222import org .elasticsearch .gateway .GatewayService ;
2323import org .elasticsearch .threadpool .ThreadPool ;
2424import org .elasticsearch .xpack .security .audit .index .IndexAuditTrail ;
25- import org .elasticsearch .xpack .security .support .IndexLifecycleManager ;
25+ import org .elasticsearch .xpack .security .support .SecurityIndexManager ;
2626
2727import java .util .Arrays ;
2828import java .util .Collections ;
4646 */
4747public class SecurityLifecycleService extends AbstractComponent implements ClusterStateListener {
4848
49- public static final String INTERNAL_SECURITY_INDEX = IndexLifecycleManager .INTERNAL_SECURITY_INDEX ;
49+ public static final String INTERNAL_SECURITY_INDEX = SecurityIndexManager .INTERNAL_SECURITY_INDEX ;
5050 public static final String SECURITY_INDEX_NAME = ".security" ;
5151
5252 private static final Version MIN_READ_VERSION = Version .V_5_0_0 ;
@@ -55,7 +55,7 @@ public class SecurityLifecycleService extends AbstractComponent implements Clust
5555 private final ThreadPool threadPool ;
5656 private final IndexAuditTrail indexAuditTrail ;
5757
58- private final IndexLifecycleManager securityIndex ;
58+ private final SecurityIndexManager securityIndex ;
5959
6060 public SecurityLifecycleService (Settings settings , ClusterService clusterService ,
6161 ThreadPool threadPool , Client client ,
@@ -64,7 +64,7 @@ public SecurityLifecycleService(Settings settings, ClusterService clusterService
6464 this .settings = settings ;
6565 this .threadPool = threadPool ;
6666 this .indexAuditTrail = indexAuditTrail ;
67- this .securityIndex = new IndexLifecycleManager (settings , client , SECURITY_INDEX_NAME );
67+ this .securityIndex = new SecurityIndexManager (settings , client , SECURITY_INDEX_NAME );
6868 clusterService .addListener (this );
6969 clusterService .addLifecycleListener (new LifecycleListener () {
7070 @ Override
@@ -110,69 +110,10 @@ public void doRun() {
110110 }
111111 }
112112
113- IndexLifecycleManager securityIndex () {
113+ public SecurityIndexManager securityIndex () {
114114 return securityIndex ;
115115 }
116116
117- /**
118- * Returns {@code true} if the security index exists
119- */
120- public boolean isSecurityIndexExisting () {
121- return securityIndex .indexExists ();
122- }
123-
124- /**
125- * Returns <code>true</code> if the security index does not exist or it exists and has the current
126- * value for the <code>index.format</code> index setting
127- */
128- public boolean isSecurityIndexUpToDate () {
129- return securityIndex .isIndexUpToDate ();
130- }
131-
132- /**
133- * Returns <code>true</code> if the security index exists and all primary shards are active
134- */
135- public boolean isSecurityIndexAvailable () {
136- return securityIndex .isAvailable ();
137- }
138-
139- /**
140- * Returns <code>true</code> if the security index does not exist or the mappings are up to date
141- * based on the version in the <code>_meta</code> field
142- */
143- public boolean isSecurityIndexMappingUpToDate () {
144- return securityIndex ().isMappingUpToDate ();
145- }
146-
147- /**
148- * Test whether the effective (active) version of the security mapping meets the
149- * <code>requiredVersion</code>.
150- *
151- * @return <code>true</code> if the effective version passes the predicate, or the security
152- * mapping does not exist (<code>null</code> version). Otherwise, <code>false</code>.
153- */
154- public boolean checkSecurityMappingVersion (Predicate <Version > requiredVersion ) {
155- return securityIndex .checkMappingVersion (requiredVersion );
156- }
157-
158- /**
159- * Adds a listener which will be notified when the security index health changes. The previous and
160- * current health will be provided to the listener so that the listener can determine if any action
161- * needs to be taken.
162- */
163- public void addSecurityIndexHealthChangeListener (BiConsumer <ClusterIndexHealth , ClusterIndexHealth > listener ) {
164- securityIndex .addIndexHealthChangeListener (listener );
165- }
166-
167- /**
168- * Adds a listener which will be notified when the security index out of date value changes. The previous and
169- * current value will be provided to the listener so that the listener can determine if any action
170- * needs to be taken.
171- */
172- void addSecurityIndexOutOfDateListener (BiConsumer <Boolean , Boolean > listener ) {
173- securityIndex .addIndexOutOfDateListener (listener );
174- }
175-
176117 // this is called in a lifecycle listener beforeStop on the cluster service
177118 private void close () {
178119 if (indexAuditTrail != null ) {
@@ -193,29 +134,13 @@ static boolean securityIndexMappingUpToDate(ClusterState clusterState, Logger lo
193134 }
194135
195136 private static boolean checkMappingVersions (ClusterState clusterState , Logger logger , Predicate <Version > versionPredicate ) {
196- return IndexLifecycleManager .checkIndexMappingVersionMatches (SECURITY_INDEX_NAME , clusterState , logger , versionPredicate );
137+ return SecurityIndexManager .checkIndexMappingVersionMatches (SECURITY_INDEX_NAME , clusterState , logger , versionPredicate );
197138 }
198139
199140 public static List <String > indexNames () {
200141 return Collections .unmodifiableList (Arrays .asList (SECURITY_INDEX_NAME , INTERNAL_SECURITY_INDEX ));
201142 }
202143
203- /**
204- * Prepares the security index by creating it if it doesn't exist or updating the mappings if the mappings are
205- * out of date. After any tasks have been executed, the runnable is then executed.
206- */
207- public void prepareIndexIfNeededThenExecute (final Consumer <Exception > consumer , final Runnable andThen ) {
208- securityIndex .prepareIndexIfNeededThenExecute (consumer , andThen );
209- }
210-
211- /**
212- * Checks if the security index is out of date with the current version. If the index does not exist
213- * we treat the index as up to date as we expect it to be created with the current format.
214- */
215- public boolean isSecurityIndexOutOfDate () {
216- return securityIndex .isIndexUpToDate () == false ;
217- }
218-
219144 /**
220145 * Is the move from {@code previousHealth} to {@code currentHealth} a move from an unhealthy ("RED") index state to a healthy
221146 * ("non-RED") state.
0 commit comments