org.codelibs.elasticsearch.taste.common.Refreshable Maven / Gradle / Ivy
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.codelibs.elasticsearch.taste.common;
import java.util.Collection;
/**
*
* Implementations of this interface have state that can be periodically refreshed. For example, an
* implementation instance might contain some pre-computed information that should be periodically refreshed.
* The {@link #refresh(Collection)} method triggers such a refresh.
*
*
*
* All Taste components implement this. In particular,
* {@link org.codelibs.elasticsearch.taste.recommender.Recommender}s do. Callers may want to call
* {@link #refresh(Collection)} periodically to re-compute information throughout the system and bring it up
* to date, though this operation may be expensive.
*
*/
public interface Refreshable {
/**
*
* Triggers "refresh" -- whatever that means -- of the implementation. The general contract is that any
* {@link Refreshable} should always leave itself in a consistent, operational state, and that the refresh
* atomically updates internal state from old to new.
*
*
* @param alreadyRefreshed
* {@link org.codelibs.elasticsearch.taste.common.Refreshable}s that are known to have already been
* refreshed as a result of an initial call to a {@link #refresh(Collection)} method on some
* object. This ensure that objects in a refresh dependency graph aren't refreshed twice
* needlessly.
*/
void refresh(Collection alreadyRefreshed);
}