iterates over index and executes correct policy
This commit is contained in:
parent
eba5afefb7
commit
a26a5969dd
|
@ -5,6 +5,8 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.xpack.indexlifecycle;
|
package org.elasticsearch.xpack.indexlifecycle;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.apache.lucene.util.SetOnce;
|
import org.apache.lucene.util.SetOnce;
|
||||||
import org.elasticsearch.cluster.ClusterChangedEvent;
|
import org.elasticsearch.cluster.ClusterChangedEvent;
|
||||||
|
@ -26,6 +28,7 @@ import org.elasticsearch.xpack.watcher.trigger.schedule.IntervalSchedule.Interva
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.Clock;
|
import java.time.Clock;
|
||||||
|
import java.util.SortedMap;
|
||||||
|
|
||||||
import static org.elasticsearch.xpack.indexlifecycle.IndexLifecycle.NAME;
|
import static org.elasticsearch.xpack.indexlifecycle.IndexLifecycle.NAME;
|
||||||
|
|
||||||
|
@ -61,14 +64,16 @@ public class IndexLifecycleInitialisationService extends AbstractComponent
|
||||||
public void triggered(SchedulerEngine.Event event) {
|
public void triggered(SchedulerEngine.Event event) {
|
||||||
if (event.getJobName().equals(NAME)) {
|
if (event.getJobName().equals(NAME)) {
|
||||||
logger.error("Job triggered: " + event.getJobName() + ", " + event.getScheduledTime() + ", " + event.getTriggeredTime());
|
logger.error("Job triggered: " + event.getJobName() + ", " + event.getScheduledTime() + ", " + event.getTriggeredTime());
|
||||||
// clusterService.state().getMetaData().getIndices().valuesIt()
|
IndexLifecycleMetadata indexLifecycleMetadata = clusterService.state().metaData().custom(IndexLifecycleMetadata.TYPE);
|
||||||
// .forEachRemaining((idxMeta) -> {
|
SortedMap<String, LifecyclePolicy> policies = indexLifecycleMetadata.getPolicies();
|
||||||
// if (LIFECYCLE_TIMESERIES_NAME_SETTING.get(idxMeta.getSettings())
|
clusterService.state().getMetaData().getIndices().valuesIt().forEachRemaining((idxMeta) -> {
|
||||||
// != null) {
|
String policyName = IndexLifecycle.LIFECYCLE_TIMESERIES_NAME_SETTING.get(idxMeta.getSettings());
|
||||||
// // get policy by name
|
if (Strings.isNullOrEmpty(policyName) == false) {
|
||||||
// // idxMeta.getIndex(), idxMeta.getCreationDate(),client
|
logger.error("Checking index for next action: " + idxMeta.getIndex().getName() + " (" + policyName + ")");
|
||||||
// }
|
LifecyclePolicy policy = policies.get(policyName);
|
||||||
// });
|
policy.execute(idxMeta, client);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
package org.elasticsearch.xpack.indexlifecycle;
|
package org.elasticsearch.xpack.indexlifecycle;
|
||||||
|
|
||||||
import org.elasticsearch.cluster.AbstractDiffable;
|
import org.elasticsearch.cluster.AbstractDiffable;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.collect.Tuple;
|
import org.elasticsearch.common.collect.Tuple;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
|
@ -16,6 +17,7 @@ import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
|
import org.elasticsearch.xpack.security.InternalClient;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -78,4 +80,7 @@ public class LifecyclePolicy extends AbstractDiffable<LifecyclePolicy> implement
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void execute(IndexMetaData idxMeta, InternalClient client) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue