2362N/A * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * This abstract class implements a weak cache that holds table data, for 0N/A * a table whose data is obtained from a list where a name can be obtained 0N/A * for each item in the list. 0N/A * <p>This object maintains a map between an entry name and its associated 0N/A * SnmpOid index, so that a given entry is always associated to the same 0N/A * <p><b>NOTE: This class is not synchronized, subclasses must implement 0N/A * the appropriate synchronization whwn needed.</b></p> 0N/A * This map associate an entry name with the SnmpOid index that's 0N/A * been allocated for it. 0N/A * The last allocate index. 0N/A * true if the index has wrapped. 0N/A * Returns the key to use as name for the given <var>item</var>. 0N/A * <br>This method is called by {@link #getIndex(Object,List,int,Object)}. 0N/A * The given <var>item</var> is expected to be always associated with 0N/A * @param context The context passed to 0N/A * {@link #updateCachedDatas(Object,List)}. 0N/A * @param rawDatas Raw table datas passed to 0N/A * {@link #updateCachedDatas(Object,List)}. 0N/A * @param rank Rank of the given <var>item</var> in the 0N/A * <var>rawDatas</var> list iterator. 0N/A * @param item The raw data object for which a key name must be determined. 0N/A * Find a new index for the entry corresponding to the 0N/A * given <var>item</var>. 0N/A * <br>This method is called by {@link #getIndex(Object,List,int,Object)} 0N/A * when a new index needs to be allocated for an <var>item</var>. The 0N/A * index returned must not be already in used. 0N/A * @param context The context passed to 0N/A * {@link #updateCachedDatas(Object,List)}. 0N/A * @param rawDatas Raw table datas passed to 0N/A * {@link #updateCachedDatas(Object,List)}. 0N/A * @param rank Rank of the given <var>item</var> in the 0N/A * <var>rawDatas</var> list iterator. 0N/A * @param item The raw data object for which an index must be determined. 0N/A // check we are in the limits of an unsigned32. 0N/A if (++
last >
0x00000000FFFFFFFFL) {
0N/A // If we never wrapped, we can safely return last as new index. 0N/A // We wrapped. We must look for an unused index. 0N/A for (
int i=
1;i <
0x00000000FFFFFFFFL;i++) {
0N/A // Was this index already in use? 0N/A // Have we just used it in a previous iteration? 0N/A // all indexes are in use! we're stuck. 0N/A // // throw new IndexOutOfBoundsException("No index available."); 0N/A // better to return null and log an error. 0N/A * Call {@link #getKey(Object,List,int,Object)} in order to get 0N/A * the item name. Then check whether an index was already allocated 0N/A * for the entry by that name. If yes return it. Otherwise, call 0N/A * {@link #makeIndex(Object,List,int,Object)} to compute a new 0N/A * index for that entry. 0N/A * Finally store the association between 0N/A * the name and index in the context TreeMap. 0N/A * @param context The context passed to 0N/A * {@link #updateCachedDatas(Object,List)}. 0N/A * be an instance of {@link TreeMap}. 0N/A * @param rawDatas Raw table datas passed to 0N/A * {@link #updateCachedDatas(Object,List)}. 0N/A * @param rank Rank of the given <var>item</var> in the 0N/A * <var>rawDatas</var> list iterator. 0N/A * @param item The raw data object for which an index must be determined. 0N/A * Allocate a new {@link TreeMap} to serve as context, then 0N/A * call {@link SnmpListTableCache#updateCachedDatas(Object,List)}, and 0N/A * finally replace the {@link #names} TreeMap by the new allocated 0N/A * @param rawDatas The table datas from which the cached data will be 0N/A * Load a list of raw data from which to build the cached data. 0N/A * This method is called when nothing is found in the request 0N/A * @param userData The request contextual cache allocated by 0N/A * the {@link JvmContextFactory}. 0N/A *The name under which the raw data is to be found/put in 0N/A * the request contextual cache. 0N/A * Get a list of raw data from which to build the cached data. 0N/A * Obtains a list of raw data by first looking it up in the 0N/A * request contextual cache <var>userData</var> under the given 0N/A * <var>key</var>. If nothing is found in the cache, calls 0N/A * {@link #loadRawDatas(Map)} to obtain a new rawData list, 0N/A * and cache the result in <var>userData</var> under <var>key</var>. 0N/A * @param userData The request contextual cache allocated by 0N/A * the {@link JvmContextFactory}. 0N/A * @param key The name under which the raw data is to be found/put in 0N/A * the request contextual cache. 0N/A // Look for memory manager list in request contextual cache. 0N/A // No list in contextual cache, get it from API 0N/A // Put list in cache... 0N/A * Update cahed datas. 0N/A * Obtains a {@link List} of raw datas by calling 0N/A * {@link #getRawDatas(Map,String) getRawDatas((Map)context,getRawDatasKey())}.<br> 0N/A * Then allocate a new {@link TreeMap} to serve as temporary map between 0N/A * names and indexes, and call {@link #updateCachedDatas(Object,List)} 0N/A * with that temporary map as context.<br> 0N/A * Finally replaces the {@link #names} TreeMap by the temporary 0N/A * @param context The request contextual cache allocated by the 0N/A * {@link JvmContextFactory}. 0N/A // Look for memory manager list in request contextual cache.