/* * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to * this file be licensed under the Apache-2.0 license or a * compatible open source license. * * Modifications Copyright OpenSearch Contributors. See * GitHub history for details. */ package org.opensearch.timeseries; import java.time.Duration; import java.util.Map; /** * Represent a state that needs to maintain its metadata regularly * * */ public interface MaintenanceState { default void maintenance(Map stateToClean, Duration stateTtl) { stateToClean.entrySet().stream().forEach(entry -> { K detectorId = entry.getKey(); V state = entry.getValue(); if (state.expired(stateTtl)) { stateToClean.remove(detectorId); } }); } void maintenance(); }