001/*
002 * JPPF.
003 * Copyright (C) 2005-2018 JPPF Team.
004 * http://www.jppf.org
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019package org.jppf.load.balancer.persistence;
020
021import java.util.List;
022
023/**
024 * Management interface for the load-balancer perisstence store.
025 * <p>All algorithm names used as parameter in the methods of this interface are the readable clear-text algorithm names.
026 * @author Laurent Cohen
027 */
028public interface LoadBalancerPersistenceManagement {
029  /**
030   * @return {@code true} if load-balancer persisted is enabled, {@code false} otherwise.
031   */
032  public boolean isPersistenceEnabled();
033
034  /**
035   * List all the channels that have an entry in the persistence store.
036   * @return a list of channel identifiers, possibly empty, but never {@code null}.
037   * @throws LoadBalancerPersistenceException if any error occurs.
038   */
039  List<String> listAllChannels() throws LoadBalancerPersistenceException;
040
041  /**
042   * List all the algorithms for which the specified channel has an entry in the persistence store.
043   * @param channelID the identifier of the channel for which to list the algorithms.
044   * @return a list of algorithm names, possibly empty, but never {@code null}.
045   * @throws LoadBalancerPersistenceException if any error occurs.
046   */
047  List<String> listAlgorithms(String channelID) throws LoadBalancerPersistenceException;
048  
049  /**
050   * List all the channels that have an entry in the persistence store for the specified algorithm.
051   * @param algorithm the name of the algorithm to lookup.
052   * @return a list of node identifiers, possibly empty, but never {@code null}.
053   * @throws LoadBalancerPersistenceException if any error occurs.
054   */
055  List<String> listAllChannelsWithAlgorithm(String algorithm) throws LoadBalancerPersistenceException;
056
057  /**
058   * Determine whether the specified channel has an entry for the specified algorithm in the persistence store.
059   * @param channelID the identifier of the channel to check.
060   * @param algorithm the name of the algorithm to lookup.
061   * @return {@code true} if the node has an entry for the algorithm, {@code false} otherwise.
062   * @throws LoadBalancerPersistenceException if any error occurs.
063   */
064  boolean hasAlgorithm(String channelID, String algorithm) throws LoadBalancerPersistenceException;
065  
066  /**
067   * Delete all entries in the persistece store.
068   * @throws LoadBalancerPersistenceException if any error occurs.
069   */
070  void deleteAll() throws LoadBalancerPersistenceException;
071
072  /**
073   * Delete all entries for the specified channel.
074   * @param channelID identifier of the channel to delete.
075   * @throws LoadBalancerPersistenceException if any error occurs.
076   */
077  void deleteChannel(String channelID) throws LoadBalancerPersistenceException;
078
079  /**
080   * Delete the specified algorithm state from all the channels that have it.
081   * @param algorithm the name of the algorithm to delete.
082   * @throws LoadBalancerPersistenceException if any error occurs.
083   */
084  void deleteAlgorithm(String algorithm) throws LoadBalancerPersistenceException;
085
086  /**
087   * Delete the specified algorithm state from the specified channel.
088   * @param channelID identifier of the channel from which to delete the algorithm state.
089   * @param algorithm the name of the algorithm to delete.
090   * @throws LoadBalancerPersistenceException if any error occurs.
091   */
092  void delete(String channelID, String algorithm) throws LoadBalancerPersistenceException;
093}