You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ra...@apache.org on 2006/10/05 09:19:37 UTC
svn commit: r453123 [1/3] - in /incubator/activemq/trunk/activemq-core/src:
main/java/org/apache/activemq/kaha/ main/java/org/apache/activemq/kaha/impl/
main/java/org/apache/activemq/kaha/impl/container/
main/java/org/apache/activemq/kaha/impl/data/ ma...
Author: rajdavies
Date: Thu Oct 5 00:19:35 2006
New Revision: 453123
URL: http://svn.apache.org/viewvc?view=rev&rev=453123
Log:
work for https://issues.apache.org/activemq/browse/AMQ-876
Modified:
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/ListContainer.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/MapContainer.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/Store.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/IndexRootContainer.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/BaseContainerImpl.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/CachedContainerListIterator.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/ContainerListIterator.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/ListContainerImpl.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/MapContainerImpl.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/data/DataItem.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/data/DataManager.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/data/RedoListener.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/data/StoreDataReader.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/data/StoreDataWriter.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/DiskIndexLinkedList.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/IndexItem.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/IndexLinkedList.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/IndexManager.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/StoreIndexReader.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/StoreIndexWriter.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/VMIndexLinkedList.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/Statements.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/DefaultJDBCAdapter.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaPersistenceAdapter.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaTopicMessageStore.java
incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/impl/CachedListContainerImplTest.java
incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/impl/index/VMIndexLinkedListTest.java
Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/ListContainer.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/ListContainer.java?view=diff&rev=453123&r1=453122&r2=453123
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/ListContainer.java (original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/ListContainer.java Thu Oct 5 00:19:35 2006
@@ -17,6 +17,7 @@
*/
package org.apache.activemq.kaha;
+import java.io.IOException;
import java.util.List;
import java.util.NoSuchElementException;
/**
@@ -115,5 +116,41 @@
* clear any cached values
*/
public void clearCache();
+
+ /**
+ * add an Object to the list but get a StoreEntry of its position
+ * @param object
+ * @return the entry in the Store
+ */
+ public StoreEntry placeLast(Object object);
+
+ /**
+ * insert an Object in first position int the list but get a StoreEntry of its position
+ * @param object
+ * @return the location in the Store
+ */
+ public StoreEntry placeFirst(Object object);
+
+ /**
+ * Advanced feature = must ensure the object written doesn't overwrite other objects in the container
+ * @param entry
+ * @param object
+ */
+ public void update(StoreEntry entry, Object object);
+
+ /**
+ * Retrieve an Object from the Store by its location
+ * @param entry
+ * @return the Object at that entry
+ */
+ public Object get(StoreEntry entry);
+
+ /**
+ * remove the Object at the StoreEntry
+ * @param entry
+ * @return true if successful
+ */
+ public boolean remove(StoreEntry entry);
+
}
Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/MapContainer.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/MapContainer.java?view=diff&rev=453123&r1=453122&r2=453123
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/MapContainer.java (original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/MapContainer.java Thu Oct 5 00:19:35 2006
@@ -142,4 +142,32 @@
* empty the container
*/
public void clear();
+
+ /**
+ * Add an entry to the Store Map
+ * @param key
+ * @param Value
+ * @return the StoreEntry associated with the entry
+ */
+ public StoreEntry place(Object key, Object Value);
+
+ /**
+ * Remove an Entry from ther Map
+ * @param entry
+ */
+ public void remove(StoreEntry entry);
+
+ /**
+ * Get the Key object from it's location
+ * @param keyLocation
+ * @return
+ */
+ public Object getKey(StoreEntry keyLocation);
+
+ /**
+ * Get the value from it's location
+ * @param Valuelocation
+ * @return
+ */
+ public Object getValue(StoreEntry Valuelocation);
}
Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/Store.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/Store.java?view=diff&rev=453123&r1=453122&r2=453123
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/Store.java (original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/Store.java Thu Oct 5 00:19:35 2006
@@ -26,10 +26,19 @@
*/
public interface Store{
+ /**
+ * Byte Marshaller
+ */
public final static Marshaller BytesMarshaller = new BytesMarshaller();
+ /**
+ * Object Marshaller
+ */
public final static Marshaller ObjectMarshaller = new ObjectMarshaller();
+ /**
+ * String Marshaller
+ */
public final static Marshaller StringMarshaller = new StringMarshaller();
/**
* close the store
@@ -61,13 +70,23 @@
public boolean delete() throws IOException;
/**
- * Checks if a MapContainer exists
+ * Checks if a MapContainer exists in the default container
*
* @param id
* @return new MapContainer
* @throws IOException
*/
public boolean doesMapContainerExist(Object id) throws IOException;
+
+ /**
+ * Checks if a MapContainer exists in the named container
+ *
+ * @param id
+ * @param containerName
+ * @return new MapContainer
+ * @throws IOException
+ */
+ public boolean doesMapContainerExist(Object id,String containerName) throws IOException;
/**
* Get a MapContainer with the given id - the MapContainer is created if needed
@@ -87,14 +106,34 @@
* @throws IOException
*/
public MapContainer getMapContainer(Object id,String containerName) throws IOException;
+
+ /**
+ * Get a MapContainer with the given id - the MapContainer is created if needed
+ *
+ * @param id
+ * @param containerName
+ * @param indexType
+ * @return container for the associated id or null if it doesn't exist
+ * @throws IOException
+ */
+ public MapContainer getMapContainer(Object id,String containerName,String indexType) throws IOException;
/**
- * delete a container
+ * delete a container from the default container
*
* @param id
* @throws IOException
*/
public void deleteMapContainer(Object id) throws IOException;
+
+ /**
+ * delete a MapContainer from the name container
+ *
+ * @param id
+ * @param containerName
+ * @throws IOException
+ */
+ public void deleteMapContainer(Object id,String containerName) throws IOException;
/**
* Get a Set of call MapContainer Ids
@@ -105,13 +144,23 @@
public Set getMapContainerIds() throws IOException;
/**
- * Checks if a ListContainer exists
+ * Checks if a ListContainer exists in the default container
*
* @param id
* @return new MapContainer
* @throws IOException
*/
public boolean doesListContainerExist(Object id) throws IOException;
+
+ /**
+ * Checks if a ListContainer exists in the named container
+ *
+ * @param id
+ * @param containerName
+ * @return new MapContainer
+ * @throws IOException
+ */
+ public boolean doesListContainerExist(Object id,String containerName) throws IOException;
/**
* Get a ListContainer with the given id and creates it if it doesn't exist
@@ -131,14 +180,35 @@
* @throws IOException
*/
public ListContainer getListContainer(Object id,String containerName) throws IOException;
+
+ /**
+ * Get a ListContainer with the given id and creates it if it doesn't exist
+ *
+ * @param id
+ * @param containerName
+ * @param indexType
+ * @return container for the associated id or null if it doesn't exist
+ * @throws IOException
+ */
+ public ListContainer getListContainer(Object id,String containerName,String indexType) throws IOException;
/**
- * delete a ListContainer
+ * delete a ListContainer from the default container
*
* @param id
* @throws IOException
*/
public void deleteListContainer(Object id) throws IOException;
+
+ /**
+ * delete a ListContainer from the named container
+ *
+ * @param id
+ * @param containerName
+ * @throws IOException
+ */
+ public void deleteListContainer(Object id,String containerName) throws IOException;
+
/**
* Get a Set of call ListContainer Ids
@@ -157,4 +227,17 @@
* @param maxDataFileLength the maxDataFileLength to set
*/
public void setMaxDataFileLength(long maxDataFileLength);
+
+ /**
+ * @see org.apache.activemq.kaha.IndexTypes
+ * @return the default index type
+ */
+ public String getIndexType();
+
+ /**
+ * Set the default index type
+ * @param type
+ * @see org.apache.activemq.kaha.IndexTypes
+ */
+ public void setIndexType(String type);
}
Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/IndexRootContainer.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/IndexRootContainer.java?view=diff&rev=453123&r1=453122&r2=453123
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/IndexRootContainer.java (original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/IndexRootContainer.java Thu Oct 5 00:19:35 2006
@@ -24,7 +24,9 @@
import org.apache.activemq.kaha.Marshaller;
import org.apache.activemq.kaha.Store;
-import org.apache.activemq.kaha.impl.data.DataItem;
+import org.apache.activemq.kaha.StoreEntry;
+import org.apache.activemq.kaha.StoreLocation;
+import org.apache.activemq.kaha.impl.container.ContainerId;
import org.apache.activemq.kaha.impl.data.DataManager;
import org.apache.activemq.kaha.impl.data.Item;
import org.apache.activemq.kaha.impl.index.IndexItem;
@@ -56,8 +58,8 @@
this.dataManager=dfm;
long nextItem=root.getNextItem();
while(nextItem!=Item.POSITION_NOT_SET){
- IndexItem item=indexManager.getIndex(nextItem);
- DataItem data=item.getKeyDataItem();
+ StoreEntry item=indexManager.getIndex(nextItem);
+ StoreLocation data=item.getKeyDataItem();
Object key=dataManager.readItem(rootMarshaller,data);
map.put(key,item);
list.add(item);
@@ -72,58 +74,66 @@
- IndexItem addRoot(Object key) throws IOException{
+ IndexItem addRoot(IndexManager containerIndexManager,ContainerId key) throws IOException{
if (map.containsKey(key)){
- removeRoot(key);
+ removeRoot(containerIndexManager,key);
}
- DataItem data = dataManager.storeDataItem(rootMarshaller, key);
- IndexItem index = indexManager.createNewIndex();
- index.setKeyData(data);
+ StoreLocation data = dataManager.storeDataItem(rootMarshaller, key);
IndexItem newRoot = indexManager.createNewIndex();
- indexManager.updateIndex(newRoot);
- index.setValueOffset(newRoot.getOffset());
+ newRoot.setKeyData(data);
+ IndexItem containerRoot = containerIndexManager.createNewIndex();
+ containerIndexManager.storeIndex(containerRoot);
+ newRoot.setValueOffset(containerRoot.getOffset());
IndexItem last=list.isEmpty()?null:(IndexItem) list.getLast();
last=last==null?root:last;
long prev=last.getOffset();
- index.setPreviousItem(prev);
- indexManager.updateIndex(index);
- last.setNextItem(index.getOffset());
- indexManager.updateIndex(last);
- map.put(key, index);
- list.add(index);
- return newRoot;
+ newRoot.setPreviousItem(prev);
+ indexManager.storeIndex(newRoot);
+ last.setNextItem(newRoot.getOffset());
+ indexManager.storeIndex(last);
+ map.put(key, newRoot);
+ list.add(newRoot);
+ return containerRoot;
}
- void removeRoot(Object key) throws IOException{
- IndexItem item = (IndexItem) map.remove(key);
- if (item != null){
- dataManager.removeInterestInFile(item.getKeyFile());
- IndexItem rootIndex = indexManager.getIndex(item.getValueOffset());
- indexManager.freeIndex(rootIndex);
- int index=list.indexOf(item);
- IndexItem prev=index>0?(IndexItem) list.get(index-1):root;
+ void removeRoot(IndexManager containerIndexManager,ContainerId key) throws IOException{
+ StoreEntry oldRoot=(StoreEntry)map.remove(key);
+ if(oldRoot!=null){
+ dataManager.removeInterestInFile(oldRoot.getKeyFile());
+ // get the container root
+ IndexItem containerRoot=containerIndexManager.getIndex(oldRoot.getValueOffset());
+ if(containerRoot!=null){
+ containerIndexManager.freeIndex(containerRoot);
+ }
+ int index=list.indexOf(oldRoot);
+ IndexItem prev=index>0?(IndexItem)list.get(index-1):root;
prev=prev==null?root:prev;
- IndexItem next=index<(list.size()-1)?(IndexItem) list.get(index+1):null;
+ IndexItem next=index<(list.size()-1)?(IndexItem)list.get(index+1):null;
if(next!=null){
prev.setNextItem(next.getOffset());
next.setPreviousItem(prev.getOffset());
- indexManager.updateIndex(next);
+ indexManager.updateIndexes(next);
}else{
prev.setNextItem(Item.POSITION_NOT_SET);
}
- indexManager.updateIndex(prev);
- list.remove(item);
+ indexManager.updateIndexes(prev);
+ list.remove(oldRoot);
+ indexManager.freeIndex((IndexItem)oldRoot);
}
}
- IndexItem getRoot(Object key) throws IOException{
- IndexItem index = (IndexItem) map.get(key);
+ IndexItem getRoot(IndexManager containerIndexManager,ContainerId key) throws IOException{
+ StoreEntry index = (StoreEntry) map.get(key);
if (index != null){
- return indexManager.getIndex(index.getValueOffset());
+ return containerIndexManager.getIndex(index.getValueOffset());
}
return null;
+ }
+
+ boolean doesRootExist(Object key){
+ return map.containsKey(key);
}
Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java?view=diff&rev=453123&r1=453122&r2=453123
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java (original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java Thu Oct 5 00:19:35 2006
@@ -1,36 +1,42 @@
/**
- *
+ *
* 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
- *
+ * 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.
+ * 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.apache.activemq.kaha.impl;
import java.io.File;
import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.nio.channels.FileLock;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
+import org.apache.activemq.kaha.IndexTypes;
import org.apache.activemq.kaha.ListContainer;
import org.apache.activemq.kaha.MapContainer;
import org.apache.activemq.kaha.RuntimeStoreException;
import org.apache.activemq.kaha.Store;
+import org.apache.activemq.kaha.StoreLocation;
import org.apache.activemq.kaha.impl.container.BaseContainerImpl;
import org.apache.activemq.kaha.impl.container.ContainerId;
import org.apache.activemq.kaha.impl.container.ListContainerImpl;
import org.apache.activemq.kaha.impl.container.MapContainerImpl;
-import org.apache.activemq.kaha.impl.data.DataItem;
import org.apache.activemq.kaha.impl.data.DataManager;
import org.apache.activemq.kaha.impl.data.RedoListener;
import org.apache.activemq.kaha.impl.index.IndexItem;
@@ -39,35 +45,39 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
+
/**
- * Optimized Store writer
+ * Store Implementation
*
* @version $Revision: 1.1.1.1 $
*/
public class KahaStore implements Store{
-
- private static final String DEFAULT_CONTAINER_NAME = "kaha";
+
+ private static final String LOCK_FILE_NAME="store.lock";
+ private static final String DEFAULT_CONTAINER_NAME="kaha";
+ private final static String PROPERTY_PREFIX="org.apache.activemq.kaha.Store";
+ private final static boolean brokenFileLock="true".equals(System.getProperty(PROPERTY_PREFIX+".broken","false"));
+ private final static boolean disableLocking="true".equals(System.getProperty(PROPERTY_PREFIX+"DisableLocking",
+ "false"));
+ private static Set lockSet;
private static final Log log=LogFactory.getLog(KahaStore.class);
private File directory;
-
- protected IndexRootContainer mapsContainer;
- public IndexRootContainer listsContainer;
+ private IndexRootContainer mapsContainer;
+ private IndexRootContainer listsContainer;
private Map lists=new ConcurrentHashMap();
private Map maps=new ConcurrentHashMap();
-
- private Map dataManagers = new ConcurrentHashMap();
- private Map indexManagers = new ConcurrentHashMap();
- protected IndexManager rootIndexManager; //contains all the root indexes
-
+ private Map dataManagers=new ConcurrentHashMap();
+ private Map indexManagers=new ConcurrentHashMap();
+ private IndexManager rootIndexManager; // contains all the root indexes
private boolean closed=false;
- private String name;
private String mode;
private boolean initialized;
private boolean logIndexChanges=false;
- private long maxDataFileLength = DataManager.MAX_FILE_LENGTH;
+ private long maxDataFileLength=DataManager.MAX_FILE_LENGTH;
+ private FileLock lock;
+ private String indexType=IndexTypes.DISK_INDEX;
public KahaStore(String name,String mode) throws IOException{
- this.name=name;
this.mode=mode;
directory=new File(name);
directory.mkdirs();
@@ -77,33 +87,29 @@
if(!closed){
closed=true;
if(initialized){
-
- for (Iterator iter = indexManagers.values().iterator(); iter.hasNext();) {
- IndexManager im = (IndexManager) iter.next();
+ unlock();
+ for(Iterator iter=indexManagers.values().iterator();iter.hasNext();){
+ IndexManager im=(IndexManager)iter.next();
im.close();
iter.remove();
}
-
- for (Iterator iter = dataManagers.values().iterator(); iter.hasNext();) {
- DataManager dm = (DataManager) iter.next();
+ for(Iterator iter=dataManagers.values().iterator();iter.hasNext();){
+ DataManager dm=(DataManager)iter.next();
dm.close();
iter.remove();
}
-
}
}
}
public synchronized void force() throws IOException{
if(initialized){
-
- for (Iterator iter = indexManagers.values().iterator(); iter.hasNext();) {
- IndexManager im = (IndexManager) iter.next();
+ for(Iterator iter=indexManagers.values().iterator();iter.hasNext();){
+ IndexManager im=(IndexManager)iter.next();
im.force();
}
-
- for (Iterator iter = dataManagers.values().iterator(); iter.hasNext();) {
- DataManager dm = (DataManager) iter.next();
+ for(Iterator iter=dataManagers.values().iterator();iter.hasNext();){
+ DataManager dm=(DataManager)iter.next();
dm.force();
}
}
@@ -112,34 +118,30 @@
public synchronized void clear() throws IOException{
initialize();
for(Iterator i=maps.values().iterator();i.hasNext();){
- BaseContainerImpl container=(BaseContainerImpl) i.next();
+ BaseContainerImpl container=(BaseContainerImpl)i.next();
container.clear();
}
for(Iterator i=lists.values().iterator();i.hasNext();){
- BaseContainerImpl container=(BaseContainerImpl) i.next();
+ BaseContainerImpl container=(BaseContainerImpl)i.next();
container.clear();
}
- lists.clear();
- maps.clear();
}
public synchronized boolean delete() throws IOException{
boolean result=true;
- if (initialized){
+ if(initialized){
clear();
-
for(Iterator iter=indexManagers.values().iterator();iter.hasNext();){
- IndexManager im=(IndexManager) iter.next();
+ IndexManager im=(IndexManager)iter.next();
result&=im.delete();
iter.remove();
}
for(Iterator iter=dataManagers.values().iterator();iter.hasNext();){
- DataManager dm=(DataManager) iter.next();
+ DataManager dm=(DataManager)iter.next();
result&=dm.delete();
iter.remove();
}
}
-
if(directory!=null&&directory.isDirectory()){
File[] files=directory.listFiles();
if(files!=null){
@@ -150,179 +152,200 @@
}
}
}
+ log.info("Kaha Store deleted data directory "+directory);
}
initialized=false;
return result;
}
public boolean doesMapContainerExist(Object id) throws IOException{
+ return doesMapContainerExist(id,DEFAULT_CONTAINER_NAME);
+ }
+
+ public boolean doesMapContainerExist(Object id,String containerName) throws IOException{
initialize();
- return maps.containsKey(id);
+ ContainerId containerId=new ContainerId();
+ containerId.setKey(id);
+ containerId.setDataContainerName(containerName);
+ return maps.containsKey(containerId)||mapsContainer.doesRootExist(containerId);
}
public MapContainer getMapContainer(Object id) throws IOException{
- return getMapContainer(id, DEFAULT_CONTAINER_NAME);
+ return getMapContainer(id,DEFAULT_CONTAINER_NAME);
}
-
- public synchronized MapContainer getMapContainer(Object id, String dataContainerName) throws IOException{
+
+ public MapContainer getMapContainer(Object id,String containerName) throws IOException{
+ return getMapContainer(id,containerName,indexType);
+ }
+
+ public synchronized MapContainer getMapContainer(Object id,String containerName,String indexType)
+ throws IOException{
initialize();
-
- MapContainerImpl result=(MapContainerImpl) maps.get(id);
+ ContainerId containerId=new ContainerId();
+ containerId.setKey(id);
+ containerId.setDataContainerName(containerName);
+ MapContainerImpl result=(MapContainerImpl)maps.get(containerId);
if(result==null){
-
- DataManager dm = getDataManager(dataContainerName);
- IndexManager im = getIndexManager(dm, dataContainerName);
-
- ContainerId containerId = new ContainerId();
- containerId.setKey(id);
- containerId.setDataContainerName(dataContainerName);
-
- IndexItem root=mapsContainer.getRoot(containerId);
- if( root == null ) {
- root=mapsContainer.addRoot(containerId);
- }
- result=new MapContainerImpl(containerId,root,rootIndexManager,im,dm);
- result.expressDataInterest();
- maps.put(containerId.getKey(),result);
-
+ DataManager dm=getDataManager(containerName);
+ IndexManager im=getIndexManager(dm,containerName);
+ IndexItem root=mapsContainer.getRoot(im,containerId);
+ if(root==null){
+ root=mapsContainer.addRoot(im,containerId);
+ }
+ result=new MapContainerImpl(containerId,root,im,dm,indexType);
+ maps.put(containerId,result);
}
return result;
}
public void deleteMapContainer(Object id) throws IOException{
+ deleteMapContainer(id,DEFAULT_CONTAINER_NAME);
+ }
+
+ public void deleteMapContainer(Object id,String containerName) throws IOException{
initialize();
- MapContainerImpl container=(MapContainerImpl) maps.remove(id);
+ ContainerId containerId=new ContainerId();
+ containerId.setKey(id);
+ containerId.setDataContainerName(containerName);
+ MapContainerImpl container=(MapContainerImpl)maps.remove(containerId);
if(container!=null){
container.clear();
- mapsContainer.removeRoot(container.getContainerId());
+ mapsContainer.removeRoot(container.getIndexManager(),containerId);
}
}
public Set getMapContainerIds() throws IOException{
initialize();
- return maps.keySet();
+ Set set = new HashSet();
+ for (Iterator i = mapsContainer.getKeys().iterator(); i.hasNext();) {
+ ContainerId id = (ContainerId)i.next();
+ set.add(id.getKey());
+ }
+ return set;
}
public boolean doesListContainerExist(Object id) throws IOException{
+ return doesListContainerExist(id,DEFAULT_CONTAINER_NAME);
+ }
+
+ public boolean doesListContainerExist(Object id,String containerName) throws IOException{
initialize();
- return lists.containsKey(id);
+ ContainerId containerId=new ContainerId();
+ containerId.setKey(id);
+ containerId.setDataContainerName(containerName);
+ return lists.containsKey(containerId)||listsContainer.doesRootExist(containerId);
}
public ListContainer getListContainer(Object id) throws IOException{
return getListContainer(id,DEFAULT_CONTAINER_NAME);
}
-
- public synchronized ListContainer getListContainer(Object id, String containerName) throws IOException{
+
+ public ListContainer getListContainer(Object id,String containerName) throws IOException{
+ return getListContainer(id,containerName,indexType);
+ }
+
+ public synchronized ListContainer getListContainer(Object id,String containerName,String indexType)
+ throws IOException{
initialize();
-
- ListContainerImpl result=(ListContainerImpl) lists.get(id);
+ ContainerId containerId=new ContainerId();
+ containerId.setKey(id);
+ containerId.setDataContainerName(containerName);
+ ListContainerImpl result=(ListContainerImpl)lists.get(containerId);
if(result==null){
- DataManager dm = getDataManager(containerName);
- IndexManager im = getIndexManager(dm, containerName);
- ContainerId containerId = new ContainerId();
- containerId.setKey(id);
- containerId.setDataContainerName(containerName);
- IndexItem root=listsContainer.getRoot(containerId);
- if( root == null ) {
- root=listsContainer.addRoot(containerId);
- }
- result=new ListContainerImpl(containerId,root,rootIndexManager,im,dm);
- result.expressDataInterest();
- lists.put(containerId.getKey(),result);
+ DataManager dm=getDataManager(containerName);
+ IndexManager im=getIndexManager(dm,containerName);
+
+ IndexItem root=listsContainer.getRoot(im,containerId);
+ if(root==null){
+ root=listsContainer.addRoot(im,containerId);
+ }
+ result=new ListContainerImpl(containerId,root,im,dm,indexType);
+ lists.put(containerId,result);
}
return result;
}
-
-
+
public void deleteListContainer(Object id) throws IOException{
+ deleteListContainer(id,DEFAULT_CONTAINER_NAME);
+ }
+
+ public void deleteListContainer(Object id,String containerName) throws IOException{
initialize();
- ListContainerImpl container=(ListContainerImpl) lists.remove(id);
+ ContainerId containerId=new ContainerId();
+ containerId.setKey(id);
+ containerId.setDataContainerName(containerName);
+ ListContainerImpl container=(ListContainerImpl)lists.remove(containerId);
if(container!=null){
+ listsContainer.removeRoot(container.getIndexManager(),containerId);
container.clear();
- listsContainer.removeRoot(container.getContainerId());
}
}
public Set getListContainerIds() throws IOException{
initialize();
- return lists.keySet();
- }
-
- protected void checkClosed(){
- if(closed){
- throw new RuntimeStoreException("The store is closed");
+ Set set = new HashSet();
+ for (Iterator i = listsContainer.getKeys().iterator(); i.hasNext();) {
+ ContainerId id = (ContainerId)i.next();
+ set.add(id.getKey());
}
+ return set;
}
- public synchronized void initialize() throws IOException{
- if( closed )
- throw new IOException("Store has been closed.");
- if(!initialized){
- initialized=true;
-
- log.info("Kaha Store using data directory " + directory);
- DataManager defaultDM = getDataManager(DEFAULT_CONTAINER_NAME);
- rootIndexManager = getIndexManager(defaultDM, DEFAULT_CONTAINER_NAME);
-
- IndexItem mapRoot=new IndexItem();
- IndexItem listRoot=new IndexItem();
- if(rootIndexManager.isEmpty()){
- mapRoot.setOffset(0);
- rootIndexManager.updateIndex(mapRoot);
- listRoot.setOffset(IndexItem.INDEX_SIZE);
- rootIndexManager.updateIndex(listRoot);
- rootIndexManager.setLength(IndexItem.INDEX_SIZE*2);
- }else{
- mapRoot=rootIndexManager.getIndex(0);
- listRoot=rootIndexManager.getIndex(IndexItem.INDEX_SIZE);
- }
- mapsContainer=new IndexRootContainer(mapRoot,rootIndexManager,defaultDM);
- listsContainer=new IndexRootContainer(listRoot,rootIndexManager,defaultDM);
-
- for (Iterator i = dataManagers.values().iterator(); i.hasNext();){
- DataManager dm = (DataManager) i.next();
- dm.consolidateDataFiles();
- }
- }
+
+
+ /**
+ * @return the listsContainer
+ */
+ public IndexRootContainer getListsContainer(){
+ return this.listsContainer;
}
+
- public DataManager getDataManager(String name) throws IOException {
- DataManager dm = (DataManager) dataManagers.get(name);
- if (dm == null){
- dm = new DataManager(directory,name);
+ /**
+ * @return the mapsContainer
+ */
+ public IndexRootContainer getMapsContainer(){
+ return this.mapsContainer;
+ }
+
+ public DataManager getDataManager(String name) throws IOException{
+ DataManager dm=(DataManager)dataManagers.get(name);
+ if(dm==null){
+ dm=new DataManager(directory,name);
dm.setMaxFileLength(maxDataFileLength);
recover(dm);
dataManagers.put(name,dm);
}
return dm;
}
-
- public IndexManager getIndexManager(DataManager dm, String name) throws IOException {
- IndexManager im = (IndexManager) indexManagers.get(name);
- if( im == null ) {
- im = new IndexManager(directory,name,mode, logIndexChanges?dm:null);
+
+ public IndexManager getIndexManager(DataManager dm,String name) throws IOException{
+ IndexManager im=(IndexManager)indexManagers.get(name);
+ if(im==null){
+ im=new IndexManager(directory,name,mode,logIndexChanges?dm:null);
indexManagers.put(name,im);
}
return im;
}
- private void recover(final DataManager dm) throws IOException {
- dm.recoverRedoItems( new RedoListener() {
- public void onRedoItem(DataItem item, Object o) throws Exception {
- RedoStoreIndexItem redo = (RedoStoreIndexItem) o;
- //IndexManager im = getIndexManager(dm, redo.getIndexName());
- IndexManager im = getIndexManager(dm, dm.getName());
+ private void recover(final DataManager dm) throws IOException{
+ dm.recoverRedoItems(new RedoListener(){
+
+ public void onRedoItem(StoreLocation item,Object o) throws Exception{
+ RedoStoreIndexItem redo=(RedoStoreIndexItem)o;
+ // IndexManager im = getIndexManager(dm, redo.getIndexName());
+ IndexManager im=getIndexManager(dm,dm.getName());
im.redo(redo);
}
});
}
- public boolean isLogIndexChanges() {
+ public boolean isLogIndexChanges(){
return logIndexChanges;
}
- public void setLogIndexChanges(boolean logIndexChanges) {
- this.logIndexChanges = logIndexChanges;
+ public void setLogIndexChanges(boolean logIndexChanges){
+ this.logIndexChanges=logIndexChanges;
}
/**
@@ -333,10 +356,123 @@
}
/**
- * @param maxDataFileLength the maxDataFileLength to set
+ * @param maxDataFileLength
+ * the maxDataFileLength to set
*/
public void setMaxDataFileLength(long maxDataFileLength){
this.maxDataFileLength=maxDataFileLength;
}
+ /**
+ * @see org.apache.activemq.kaha.IndexTypes
+ * @return the default index type
+ */
+ public String getIndexType(){
+ return indexType;
+ }
+
+ /**
+ * Set the default index type
+ *
+ * @param type
+ * @see org.apache.activemq.kaha.IndexTypes
+ */
+ public void setIndexType(String type){
+ if(type==null||(!type.equals(IndexTypes.DISK_INDEX)&&!type.equals(IndexTypes.IN_MEMORY_INDEX))){
+ throw new RuntimeException("Unknown IndexType: "+type);
+ }
+ this.indexType=indexType;
+ }
+
+ public synchronized void initialize() throws IOException{
+ if(closed)
+ throw new IOException("Store has been closed.");
+ if(!initialized){
+ initialized=true;
+ log.info("Kaha Store using data directory "+directory);
+ DataManager defaultDM=getDataManager(DEFAULT_CONTAINER_NAME);
+ rootIndexManager=getIndexManager(defaultDM,DEFAULT_CONTAINER_NAME);
+ IndexItem mapRoot=new IndexItem();
+ IndexItem listRoot=new IndexItem();
+ if(rootIndexManager.isEmpty()){
+ mapRoot.setOffset(0);
+ rootIndexManager.storeIndex(mapRoot);
+ listRoot.setOffset(IndexItem.INDEX_SIZE);
+ rootIndexManager.storeIndex(listRoot);
+ rootIndexManager.setLength(IndexItem.INDEX_SIZE*2);
+ }else{
+ mapRoot=rootIndexManager.getIndex(0);
+ listRoot=rootIndexManager.getIndex(IndexItem.INDEX_SIZE);
+ }
+ lock();
+ mapsContainer=new IndexRootContainer(mapRoot,rootIndexManager,defaultDM);
+ listsContainer=new IndexRootContainer(listRoot,rootIndexManager,defaultDM);
+ for(Iterator i=dataManagers.values().iterator();i.hasNext();){
+ DataManager dm=(DataManager)i.next();
+ dm.consolidateDataFiles();
+ }
+ }
+ }
+
+ private synchronized void lock() throws IOException{
+ if(!disableLocking&&directory!=null&&lock==null){
+ Set set=getVmLockSet();
+ synchronized(set){
+ if(lock==null){
+ if(!set.add(directory.getCanonicalPath())){
+ throw new StoreLockedExcpetion("Kaha Store "+directory.getName()
+ +" is already opened by this application.");
+ }
+ if(!brokenFileLock){
+ lock=rootIndexManager.getLock();
+ if(lock==null){
+ set.remove(directory.getCanonicalPath());
+ throw new StoreLockedExcpetion("Kaha Store "+directory.getName()
+ +" is already opened by another application");
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void unlock() throws IOException{
+ if(!disableLocking&&directory!=null){
+ Set set=getVmLockSet();
+ synchronized(set){
+ if(lock!=null){
+ set.remove(directory.getCanonicalPath());
+ if(lock.isValid()){
+ lock.release();
+ }
+ lock=null;
+ }
+ }
+ }
+ }
+
+ private void checkClosed(){
+ if(closed){
+ throw new RuntimeStoreException("The store is closed");
+ }
+ }
+
+
+
+ static private Set getVmLockSet(){
+ if(lockSet==null){
+ Properties properties=System.getProperties();
+ synchronized(properties){
+ lockSet=(Set)properties.get("org.apache.activemq.kaha.impl.KahaStore");
+ if(lockSet==null){
+ lockSet=new HashSet();
+ }
+ properties.put(PROPERTY_PREFIX,lockSet);
+ }
+ }
+ return lockSet;
+ }
+
+
+
}
Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/BaseContainerImpl.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/BaseContainerImpl.java?view=diff&rev=453123&r1=453122&r2=453123
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/BaseContainerImpl.java (original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/BaseContainerImpl.java Thu Oct 5 00:19:35 2006
@@ -1,85 +1,94 @@
/**
- *
+ *
* 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
- *
+ * 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.
+ * 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.apache.activemq.kaha.impl.container;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-
+import org.apache.activemq.kaha.IndexTypes;
import org.apache.activemq.kaha.RuntimeStoreException;
+import org.apache.activemq.kaha.StoreEntry;
import org.apache.activemq.kaha.impl.data.DataManager;
import org.apache.activemq.kaha.impl.data.Item;
import org.apache.activemq.kaha.impl.index.DiskIndexLinkedList;
import org.apache.activemq.kaha.impl.index.IndexItem;
import org.apache.activemq.kaha.impl.index.IndexLinkedList;
import org.apache.activemq.kaha.impl.index.IndexManager;
+import org.apache.activemq.kaha.impl.index.VMIndexLinkedList;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
/**
* Implementation of a ListContainer
*
* @version $Revision: 1.2 $
*/
public abstract class BaseContainerImpl{
+
private static final Log log=LogFactory.getLog(BaseContainerImpl.class);
protected IndexItem root;
protected IndexLinkedList indexList;
- protected IndexManager rootIndexManager; // IndexManager that contains the root
protected IndexManager indexManager;
protected DataManager dataManager;
protected ContainerId containerId;
protected boolean loaded=false;
protected boolean closed=false;
- protected boolean initialized = false;
- protected final Object mutex=new Object();
+ protected boolean initialized=false;
+ private String indexType;
- protected BaseContainerImpl(ContainerId id,IndexItem root,IndexManager rootIndexManager,IndexManager indexManager,DataManager dataManager){
+ protected BaseContainerImpl(ContainerId id,IndexItem root,IndexManager indexManager,
+ DataManager dataManager,String indexType){
this.containerId=id;
this.root=root;
- this.rootIndexManager = rootIndexManager;
this.indexManager=indexManager;
this.dataManager=dataManager;
-
+ this.indexType = indexType;
+ if (indexType == null || (!indexType.equals(IndexTypes.DISK_INDEX) && !indexType.equals(IndexTypes.IN_MEMORY_INDEX))) {
+ throw new RuntimeException("Unknown IndexType: " + indexType);
+ }
}
public ContainerId getContainerId(){
return containerId;
}
-
- public void init(){
- if (!initialized){
- synchronized(mutex){
- if (!initialized){
- initialized= true;
- if (this.indexList == null){
+
+ public synchronized void init(){
+ if(!initialized){
+ if(!initialized){
+ initialized=true;
+ if(this.indexList==null){
+ if(indexType.equals(IndexTypes.DISK_INDEX)){
this.indexList=new DiskIndexLinkedList(indexManager,root);
+ }else{
+ this.indexList=new VMIndexLinkedList(root);
}
}
}
}
}
+
- public void clear(){
- if (indexList != null){
+ public synchronized void clear(){
+ if(indexList!=null){
indexList.clear();
- }
+ }
}
-
/**
* @return the indexList
*/
@@ -100,16 +109,15 @@
public abstract int size();
-
- protected abstract Object getValue(IndexItem currentItem);
+ protected abstract Object getValue(StoreEntry currentItem);
protected abstract void remove(IndexItem currentItem);
- protected final IndexLinkedList getInternalList(){
+ protected synchronized final IndexLinkedList getInternalList(){
return indexList;
}
- public final void close(){
+ public synchronized final void close(){
unload();
closed=true;
}
@@ -119,7 +127,7 @@
*
* @see org.apache.activemq.kaha.ListContainer#isLoaded()
*/
- public final boolean isLoaded(){
+ public synchronized final boolean isLoaded(){
checkClosed();
return loaded;
}
@@ -133,8 +141,17 @@
checkClosed();
return containerId.getKey();
}
+
+ public DataManager getDataManager(){
+ return dataManager;
+ }
- public final void expressDataInterest() throws IOException{
+
+ public IndexManager getIndexManager(){
+ return indexManager;
+ }
+
+ public synchronized final void expressDataInterest() throws IOException{
long nextItem=root.getNextItem();
while(nextItem!=Item.POSITION_NOT_SET){
IndexItem item=indexManager.getIndex(nextItem);
@@ -147,32 +164,29 @@
protected final void doClear(){
checkClosed();
- synchronized(mutex){
- loaded=true;
- synchronized(mutex){
- List indexList=new ArrayList();
- try{
- long nextItem=root.getNextItem();
- while(nextItem!=Item.POSITION_NOT_SET){
- IndexItem item=new IndexItem();
- item.setOffset(nextItem);
- indexList.add(item);
- nextItem=item.getNextItem();
- }
- root.setNextItem(Item.POSITION_NOT_SET);
- updateIndex(root);
- for(int i=0;i<indexList.size();i++){
- IndexItem item=(IndexItem) indexList.get(i);
- dataManager.removeInterestInFile(item.getKeyFile());
- dataManager.removeInterestInFile(item.getValueFile());
- indexManager.freeIndex(item);
- }
- indexList.clear();
- }catch(IOException e){
- log.error("Failed to clear Container "+getId(),e);
- throw new RuntimeStoreException(e);
- }
+ loaded=true;
+ List indexList=new ArrayList();
+ try{
+ init();
+ long nextItem=root.getNextItem();
+ while(nextItem!=Item.POSITION_NOT_SET){
+ IndexItem item=new IndexItem();
+ item.setOffset(nextItem);
+ indexList.add(item);
+ nextItem=item.getNextItem();
}
+ root.setNextItem(Item.POSITION_NOT_SET);
+ storeIndex(root);
+ for(int i=0;i<indexList.size();i++){
+ IndexItem item=(IndexItem)indexList.get(i);
+ dataManager.removeInterestInFile(item.getKeyFile());
+ dataManager.removeInterestInFile(item.getValueFile());
+ indexManager.freeIndex(item);
+ }
+ indexList.clear();
+ }catch(IOException e){
+ log.error("Failed to clear Container "+getId(),e);
+ throw new RuntimeStoreException(e);
}
}
@@ -185,11 +199,11 @@
if(next!=null){
prev.setNextItem(next.getOffset());
next.setPreviousItem(prev.getOffset());
- updateIndex(next);
+ updateIndexes(next);
}else{
prev.setNextItem(Item.POSITION_NOT_SET);
}
- updateIndex(prev);
+ updateIndexes(prev);
indexManager.freeIndex(key);
}catch(IOException e){
log.error("Failed to delete "+key,e);
@@ -202,18 +216,20 @@
throw new RuntimeStoreException("The store is closed");
}
}
-
- protected void updateIndex(IndexItem item) throws IOException{
- IndexManager im = isRoot(item) ? rootIndexManager : indexManager;
- im.updateIndex(item);
-
+
+ protected void storeIndex(IndexItem item) throws IOException{
+ indexManager.storeIndex(item);
}
- protected final boolean isRoot(IndexItem item){
- // return item != null && root != null && (root == item || root.getOffset() == item.getOffset());
- return item != null && root != null && root == item;
+ protected void updateIndexes(IndexItem item) throws IOException{
+ indexManager.updateIndexes(item);
+ }
+
+ protected final boolean isRoot(StoreEntry item){
+ return item!=null&&root!=null&&(root==item||root.getOffset()==item.getOffset());
+ // return item != null && indexRoot != null && indexRoot == item;
}
-
+
}
Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/CachedContainerListIterator.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/CachedContainerListIterator.java?view=diff&rev=453123&r1=453122&r2=453123
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/CachedContainerListIterator.java (original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/CachedContainerListIterator.java Thu Oct 5 00:19:35 2006
@@ -19,7 +19,7 @@
import java.util.ListIterator;
-import org.apache.activemq.kaha.impl.index.IndexItem;
+import org.apache.activemq.kaha.StoreEntry;
import org.apache.activemq.kaha.impl.index.IndexLinkedList;
/**
@@ -31,7 +31,7 @@
protected IndexLinkedList list;
protected int pos = 0;
protected int nextPos =0;
- protected IndexItem currentItem;
+ protected StoreEntry currentItem;
protected CachedContainerListIterator(ListContainerImpl container,int start){
this.container=container;
Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/ContainerListIterator.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/ContainerListIterator.java?view=diff&rev=453123&r1=453122&r2=453123
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/ContainerListIterator.java (original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/ContainerListIterator.java Thu Oct 5 00:19:35 2006
@@ -19,6 +19,7 @@
import java.util.ListIterator;
+import org.apache.activemq.kaha.StoreEntry;
import org.apache.activemq.kaha.impl.index.IndexItem;
import org.apache.activemq.kaha.impl.index.IndexLinkedList;
@@ -61,7 +62,7 @@
public int nextIndex(){
int result = -1;
if (nextItem != null){
- IndexItem next = list.getNextEntry(nextItem);
+ StoreEntry next = list.getNextEntry(nextItem);
if (next != null){
result = container.getInternalList().indexOf(next);
}
@@ -79,7 +80,7 @@
public int previousIndex(){
int result = -1;
if (nextItem != null){
- IndexItem prev = list.getPrevEntry(nextItem);
+ StoreEntry prev = list.getPrevEntry(nextItem);
if (prev != null){
result = container.getInternalList().indexOf(prev);
}