package org.exist.storage; import org.exist.storage.cache.Cache; /* * eXist Open Source Native XML Database * Copyright (C) 2001-06 The eXist Project * http://exist-db.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id$ */ public interface CacheManager { public final static String BTREE_CACHE = "BTREE"; public final static String DATA_CACHE = "DATA"; /** * Register a cache, i.e. put it under control of * the cache manager. * * @param cache */ void registerCache(Cache cache); void deregisterCache(Cache cache); /** * Called by a cache if it wants to grow. The cache manager * will either deny the request, for example, if there are no spare * pages left, or calculate a new cache size and call the cache's * {@link org.exist.storage.cache.Cache#resize(int)} method to resize the cache. The amount * of pages by which the cache will grow is determined by the cache's * growthFactor: {@link org.exist.storage.cache.Cache#getGrowthFactor()}. * * @param cache * @return new cache size, or -1 if no free pages available. */ int requestMem(Cache cache); /** * Called from the global major sync event to check if caches can * be shrinked. * * If shrinked, the cache will be reset to the default initial cache size. */ void checkCaches(); /** * Called from the global minor sync event to check if a smaller * cache wants to be resized. If a huge cache is availabe, the method * might decide to shrink this cache by a certain amount to make * room for the smaller cache to grow. */ void checkDistribution(); long getMaxTotal(); long getMaxSingle(); long getCurrentSize(); }