mirror of https://github.com/apache/activemq.git
splitting kaha.impl into 3 packages per: http://www.nabble.com/Kaha-package-re-rog-tf2218956.html
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@440342 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3fe77a2cf8
commit
86d006ab28
|
@ -21,11 +21,17 @@ import java.io.IOException;
|
|||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.activemq.kaha.Marshaller;
|
||||
import org.apache.activemq.kaha.ObjectMarshaller;
|
||||
import org.apache.activemq.kaha.Store;
|
||||
import org.apache.activemq.kaha.impl.data.DataItem;
|
||||
import org.apache.activemq.kaha.impl.data.DataManager;
|
||||
import org.apache.activemq.kaha.impl.data.Item;
|
||||
import org.apache.activemq.kaha.impl.index.IndexItem;
|
||||
import org.apache.activemq.kaha.impl.index.IndexManager;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,6 +26,16 @@ 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.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;
|
||||
import org.apache.activemq.kaha.impl.index.IndexManager;
|
||||
import org.apache.activemq.kaha.impl.index.RedoStoreIndexItem;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
|
||||
|
@ -41,7 +51,7 @@ public class KahaStore implements Store{
|
|||
private File directory;
|
||||
|
||||
protected IndexRootContainer mapsContainer;
|
||||
protected IndexRootContainer listsContainer;
|
||||
public IndexRootContainer listsContainer;
|
||||
private Map lists=new ConcurrentHashMap();
|
||||
private Map maps=new ConcurrentHashMap();
|
||||
|
||||
|
@ -244,7 +254,7 @@ public class KahaStore implements Store{
|
|||
}
|
||||
}
|
||||
|
||||
protected synchronized void initialize() throws IOException{
|
||||
public synchronized void initialize() throws IOException{
|
||||
if( closed )
|
||||
throw new IOException("Store has been closed.");
|
||||
if(!initialized){
|
||||
|
@ -276,7 +286,7 @@ public class KahaStore implements Store{
|
|||
}
|
||||
}
|
||||
|
||||
protected DataManager getDataManager(String name) throws IOException {
|
||||
public DataManager getDataManager(String name) throws IOException {
|
||||
DataManager dm = (DataManager) dataManagers.get(name);
|
||||
if (dm == null){
|
||||
dm = new DataManager(directory,name);
|
||||
|
@ -287,7 +297,7 @@ public class KahaStore implements Store{
|
|||
return dm;
|
||||
}
|
||||
|
||||
protected IndexManager getIndexManager(DataManager dm, String name) throws IOException {
|
||||
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);
|
||||
|
|
|
@ -15,12 +15,19 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.container;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.activemq.kaha.RuntimeStoreException;
|
||||
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.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
/**
|
||||
|
@ -50,7 +57,7 @@ public abstract class BaseContainerImpl{
|
|||
|
||||
}
|
||||
|
||||
ContainerId getContainerId(){
|
||||
public ContainerId getContainerId(){
|
||||
return containerId;
|
||||
}
|
||||
|
||||
|
@ -67,7 +74,7 @@ public abstract class BaseContainerImpl{
|
|||
}
|
||||
}
|
||||
|
||||
protected void clear(){
|
||||
public void clear(){
|
||||
if (indexList != null){
|
||||
indexList.clear();
|
||||
}
|
||||
|
@ -127,7 +134,7 @@ public abstract class BaseContainerImpl{
|
|||
return containerId.getKey();
|
||||
}
|
||||
|
||||
protected final void expressDataInterest() throws IOException{
|
||||
public final void expressDataInterest() throws IOException{
|
||||
long nextItem=root.getNextItem();
|
||||
while(nextItem!=Item.POSITION_NOT_SET){
|
||||
IndexItem item=indexManager.getIndex(nextItem);
|
|
@ -15,10 +15,13 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.container;
|
||||
|
||||
import java.util.ListIterator;
|
||||
|
||||
import org.apache.activemq.kaha.impl.index.IndexItem;
|
||||
import org.apache.activemq.kaha.impl.index.IndexLinkedList;
|
||||
|
||||
/**
|
||||
* @version $Revision$
|
||||
*/
|
|
@ -15,7 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.container;
|
||||
|
||||
|
||||
/**
|
|
@ -15,7 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.container;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
|
@ -15,7 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.container;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.container;
|
||||
|
||||
import java.io.Externalizable;
|
||||
import java.io.IOException;
|
|
@ -15,7 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.container;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
|
@ -15,7 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.container;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
|
@ -15,10 +15,13 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.container;
|
||||
|
||||
import java.util.ListIterator;
|
||||
|
||||
import org.apache.activemq.kaha.impl.index.IndexItem;
|
||||
import org.apache.activemq.kaha.impl.index.IndexLinkedList;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.2 $
|
||||
*/
|
|
@ -15,7 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.container;
|
||||
|
||||
import java.util.Map;
|
||||
import org.apache.activemq.kaha.MapContainer;
|
|
@ -15,7 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.container;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
@ -23,6 +23,9 @@ import java.util.Iterator;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.activemq.kaha.impl.index.IndexItem;
|
||||
import org.apache.activemq.kaha.impl.index.IndexLinkedList;
|
||||
|
||||
/**
|
||||
* Values collection for the MapContainer
|
||||
*
|
|
@ -15,9 +15,12 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.container;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.activemq.kaha.impl.index.IndexItem;
|
||||
import org.apache.activemq.kaha.impl.index.IndexLinkedList;
|
||||
/**
|
||||
* Values collection iterator for the MapContainer
|
||||
*
|
|
@ -11,7 +11,7 @@
|
|||
* 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;
|
||||
package org.apache.activemq.kaha.impl.container;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -20,10 +20,16 @@ import java.util.Iterator;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
import org.apache.activemq.kaha.ListContainer;
|
||||
import org.apache.activemq.kaha.Marshaller;
|
||||
import org.apache.activemq.kaha.RuntimeStoreException;
|
||||
import org.apache.activemq.kaha.Store;
|
||||
import org.apache.activemq.kaha.impl.data.DataItem;
|
||||
import org.apache.activemq.kaha.impl.data.DataManager;
|
||||
import org.apache.activemq.kaha.impl.data.Item;
|
||||
import org.apache.activemq.kaha.impl.index.IndexItem;
|
||||
import org.apache.activemq.kaha.impl.index.IndexManager;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
/**
|
||||
|
@ -39,7 +45,7 @@ public class ListContainerImpl extends BaseContainerImpl implements ListContaine
|
|||
protected int maximumCacheSize=100;
|
||||
protected IndexItem lastCached;
|
||||
|
||||
protected ListContainerImpl(ContainerId id,IndexItem root,IndexManager rootIndexManager,IndexManager indexManager,
|
||||
public ListContainerImpl(ContainerId id,IndexItem root,IndexManager rootIndexManager,IndexManager indexManager,
|
||||
DataManager dataManager) throws IOException{
|
||||
super(id,root,rootIndexManager,indexManager,dataManager);
|
||||
}
|
|
@ -15,7 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.container;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
@ -29,6 +29,12 @@ import org.apache.activemq.kaha.Marshaller;
|
|||
import org.apache.activemq.kaha.ObjectMarshaller;
|
||||
import org.apache.activemq.kaha.RuntimeStoreException;
|
||||
import org.apache.activemq.kaha.Store;
|
||||
import org.apache.activemq.kaha.impl.data.DataItem;
|
||||
import org.apache.activemq.kaha.impl.data.DataManager;
|
||||
import org.apache.activemq.kaha.impl.data.Item;
|
||||
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.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
/**
|
||||
|
@ -36,14 +42,14 @@ import org.apache.commons.logging.LogFactory;
|
|||
*
|
||||
* @version $Revision: 1.2 $
|
||||
*/
|
||||
final class MapContainerImpl extends BaseContainerImpl implements MapContainer{
|
||||
public final class MapContainerImpl extends BaseContainerImpl implements MapContainer{
|
||||
private static final Log log=LogFactory.getLog(MapContainerImpl.class);
|
||||
protected Map map=new HashMap();
|
||||
protected Map valueToKeyMap=new HashMap();
|
||||
protected Marshaller keyMarshaller= Store.ObjectMarshaller;
|
||||
protected Marshaller valueMarshaller=Store.ObjectMarshaller;
|
||||
|
||||
protected MapContainerImpl(ContainerId id,IndexItem root,IndexManager rootIndexManager,IndexManager indexManager,DataManager dataManager){
|
||||
public MapContainerImpl(ContainerId id,IndexItem root,IndexManager rootIndexManager,IndexManager indexManager,DataManager dataManager){
|
||||
super(id,root,rootIndexManager,indexManager,dataManager);
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.data;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
|
@ -15,20 +15,21 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.data;
|
||||
|
||||
|
||||
/**
|
||||
* A a wrapper for a data in the store
|
||||
*
|
||||
* @version $Revision: 1.2 $
|
||||
*/
|
||||
final class DataItem implements Item{
|
||||
public final class DataItem implements Item{
|
||||
|
||||
private int file=(int) POSITION_NOT_SET;
|
||||
private long offset=POSITION_NOT_SET;
|
||||
private int size;
|
||||
|
||||
DataItem(){}
|
||||
public DataItem(){}
|
||||
|
||||
DataItem(DataItem item) {
|
||||
this.file = item.file;
|
||||
|
@ -43,42 +44,42 @@ final class DataItem implements Item{
|
|||
/**
|
||||
* @return Returns the size.
|
||||
*/
|
||||
int getSize(){
|
||||
public int getSize(){
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param size The size to set.
|
||||
*/
|
||||
void setSize(int size){
|
||||
public void setSize(int size){
|
||||
this.size=size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the offset.
|
||||
*/
|
||||
long getOffset(){
|
||||
public long getOffset(){
|
||||
return offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param offset The offset to set.
|
||||
*/
|
||||
void setOffset(long offset){
|
||||
public void setOffset(long offset){
|
||||
this.offset=offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the file.
|
||||
*/
|
||||
int getFile(){
|
||||
public int getFile(){
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param file The file to set.
|
||||
*/
|
||||
void setFile(int file){
|
||||
public void setFile(int file){
|
||||
this.file=file;
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.data;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
|
@ -28,6 +28,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.activemq.kaha.Marshaller;
|
||||
import org.apache.activemq.kaha.impl.index.RedoStoreIndexItem;
|
||||
import org.apache.activemq.util.IOExceptionSupport;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -36,10 +37,10 @@ import org.apache.commons.logging.LogFactory;
|
|||
*
|
||||
* @version $Revision: 1.1.1.1 $
|
||||
*/
|
||||
final class DataManager{
|
||||
public final class DataManager{
|
||||
|
||||
private static final Log log=LogFactory.getLog(DataManager.class);
|
||||
protected static long MAX_FILE_LENGTH=1024*1024*32;
|
||||
public static long MAX_FILE_LENGTH=1024*1024*32;
|
||||
private final File dir;
|
||||
private final String name;
|
||||
private StoreDataReader reader;
|
||||
|
@ -55,7 +56,7 @@ final class DataManager{
|
|||
Marshaller redoMarshaller = RedoStoreIndexItem.MARSHALLER;
|
||||
private String dataFilePrefix;
|
||||
|
||||
DataManager(File dir, final String name){
|
||||
public DataManager(File dir, final String name){
|
||||
this.dir=dir;
|
||||
this.name=name;
|
||||
this.reader=new StoreDataReader(this);
|
||||
|
@ -117,19 +118,19 @@ final class DataManager{
|
|||
throw new IOException("Could not locate data file "+name+item.getFile());
|
||||
}
|
||||
|
||||
synchronized Object readItem(Marshaller marshaller, DataItem item) throws IOException{
|
||||
public synchronized Object readItem(Marshaller marshaller, DataItem item) throws IOException{
|
||||
return reader.readItem(marshaller,item);
|
||||
}
|
||||
|
||||
synchronized DataItem storeDataItem(Marshaller marshaller, Object payload) throws IOException{
|
||||
public synchronized DataItem storeDataItem(Marshaller marshaller, Object payload) throws IOException{
|
||||
return writer.storeItem(marshaller,payload, DATA_ITEM_TYPE);
|
||||
}
|
||||
|
||||
synchronized DataItem storeRedoItem(Object payload) throws IOException{
|
||||
public synchronized DataItem storeRedoItem(Object payload) throws IOException{
|
||||
return writer.storeItem(redoMarshaller, payload, REDO_ITEM_TYPE);
|
||||
}
|
||||
|
||||
synchronized void recoverRedoItems(RedoListener listener) throws IOException{
|
||||
public synchronized void recoverRedoItems(RedoListener listener) throws IOException{
|
||||
|
||||
// Nothing to recover if there is no current file.
|
||||
if( currentWriteFile == null )
|
||||
|
@ -171,7 +172,7 @@ final class DataManager{
|
|||
}
|
||||
}
|
||||
|
||||
synchronized void close() throws IOException{
|
||||
public synchronized void close() throws IOException{
|
||||
for(Iterator i=fileMap.values().iterator();i.hasNext();){
|
||||
DataFile dataFile=(DataFile) i.next();
|
||||
dataFile.force();
|
||||
|
@ -180,14 +181,14 @@ final class DataManager{
|
|||
fileMap.clear();
|
||||
}
|
||||
|
||||
synchronized void force() throws IOException{
|
||||
public synchronized void force() throws IOException{
|
||||
for(Iterator i=fileMap.values().iterator();i.hasNext();){
|
||||
DataFile dataFile=(DataFile) i.next();
|
||||
dataFile.force();
|
||||
}
|
||||
}
|
||||
|
||||
synchronized boolean delete() throws IOException{
|
||||
public synchronized boolean delete() throws IOException{
|
||||
boolean result=true;
|
||||
for(Iterator i=fileMap.values().iterator();i.hasNext();){
|
||||
DataFile dataFile=(DataFile) i.next();
|
||||
|
@ -197,7 +198,7 @@ final class DataManager{
|
|||
return result;
|
||||
}
|
||||
|
||||
synchronized void addInterestInFile(int file) throws IOException{
|
||||
public synchronized void addInterestInFile(int file) throws IOException{
|
||||
if(file>=0){
|
||||
Integer key=new Integer(file);
|
||||
DataFile dataFile=(DataFile) fileMap.get(key);
|
||||
|
@ -214,7 +215,7 @@ final class DataManager{
|
|||
}
|
||||
}
|
||||
|
||||
synchronized void removeInterestInFile(int file) throws IOException{
|
||||
public synchronized void removeInterestInFile(int file) throws IOException{
|
||||
if(file>=0){
|
||||
Integer key=new Integer(file);
|
||||
DataFile dataFile=(DataFile) fileMap.get(key);
|
||||
|
@ -232,7 +233,7 @@ final class DataManager{
|
|||
}
|
||||
}
|
||||
|
||||
synchronized void consolidateDataFiles() throws IOException{
|
||||
public synchronized void consolidateDataFiles() throws IOException{
|
||||
List purgeList=new ArrayList();
|
||||
for(Iterator i=fileMap.values().iterator();i.hasNext();){
|
||||
DataFile dataFile=(DataFile) i.next();
|
|
@ -15,7 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.data;
|
||||
|
||||
/**
|
||||
* A a wrapper for a data in the store
|
|
@ -15,7 +15,8 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.data;
|
||||
|
||||
|
||||
public interface RedoListener {
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.data;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.IOException;
|
||||
|
@ -26,7 +26,7 @@ import java.io.UTFDataFormatException;
|
|||
*
|
||||
* @version $Revision: 1.1.1.1 $
|
||||
*/
|
||||
final class StoreByteArrayInputStream extends InputStream implements DataInput{
|
||||
public final class StoreByteArrayInputStream extends InputStream implements DataInput{
|
||||
private byte[] buf;
|
||||
private int pos;
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.data;
|
||||
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
@ -26,7 +26,7 @@ import java.io.UTFDataFormatException;
|
|||
*
|
||||
* @version $Revision: 1.1.1.1 $
|
||||
*/
|
||||
final class StoreByteArrayOutputStream extends OutputStream implements DataOutput{
|
||||
public final class StoreByteArrayOutputStream extends OutputStream implements DataOutput{
|
||||
private byte buf[];
|
||||
private int pos;
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.data;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
|
@ -15,7 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.data;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
|
@ -15,7 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.index;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.index;
|
||||
|
||||
import java.io.IOException;
|
||||
/**
|
||||
|
@ -23,7 +23,7 @@ import java.io.IOException;
|
|||
*
|
||||
* @version $Revision$
|
||||
*/
|
||||
class DiskIndexLinkedList implements IndexLinkedList{
|
||||
public class DiskIndexLinkedList implements IndexLinkedList{
|
||||
protected IndexManager indexManager;
|
||||
protected transient IndexItem root;
|
||||
protected transient IndexItem last;
|
||||
|
@ -32,7 +32,7 @@ class DiskIndexLinkedList implements IndexLinkedList{
|
|||
/**
|
||||
* Constructs an empty list.
|
||||
*/
|
||||
DiskIndexLinkedList(IndexManager im,IndexItem header){
|
||||
public DiskIndexLinkedList(IndexManager im,IndexItem header){
|
||||
this.indexManager=im;
|
||||
this.root=header;
|
||||
}
|
|
@ -15,19 +15,22 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.index;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.activemq.kaha.impl.data.DataItem;
|
||||
import org.apache.activemq.kaha.impl.data.Item;
|
||||
/**
|
||||
* A an Item with a relative position and location to other Items in the Store
|
||||
*
|
||||
* @version $Revision: 1.2 $
|
||||
*/
|
||||
class IndexItem implements Item{
|
||||
public class IndexItem implements Item{
|
||||
|
||||
static final int INDEX_SIZE=51;
|
||||
public static final int INDEX_SIZE=51;
|
||||
//used by linked list
|
||||
IndexItem next;
|
||||
IndexItem prev;
|
||||
|
@ -49,7 +52,7 @@ import java.io.IOException;
|
|||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
IndexItem(){}
|
||||
public IndexItem(){}
|
||||
|
||||
void reset(){
|
||||
previousItem=POSITION_NOT_SET;
|
||||
|
@ -63,7 +66,7 @@ import java.io.IOException;
|
|||
active=true;
|
||||
}
|
||||
|
||||
DataItem getKeyDataItem(){
|
||||
public DataItem getKeyDataItem(){
|
||||
DataItem result=new DataItem();
|
||||
result.setOffset(keyOffset);
|
||||
result.setFile(keyFile);
|
||||
|
@ -71,7 +74,7 @@ import java.io.IOException;
|
|||
return result;
|
||||
}
|
||||
|
||||
DataItem getValueDataItem(){
|
||||
public DataItem getValueDataItem(){
|
||||
DataItem result=new DataItem();
|
||||
result.setOffset(valueOffset);
|
||||
result.setFile(valueFile);
|
||||
|
@ -79,13 +82,13 @@ import java.io.IOException;
|
|||
return result;
|
||||
}
|
||||
|
||||
void setValueData(DataItem item){
|
||||
public void setValueData(DataItem item){
|
||||
valueOffset=item.getOffset();
|
||||
valueFile=item.getFile();
|
||||
valueSize=item.getSize();
|
||||
}
|
||||
|
||||
void setKeyData(DataItem item){
|
||||
public void setKeyData(DataItem item){
|
||||
keyOffset=item.getOffset();
|
||||
keyFile=item.getFile();
|
||||
keySize=item.getSize();
|
||||
|
@ -130,7 +133,7 @@ import java.io.IOException;
|
|||
/**
|
||||
* @param newPrevEntry
|
||||
*/
|
||||
void setPreviousItem(long newPrevEntry){
|
||||
public void setPreviousItem(long newPrevEntry){
|
||||
previousItem=newPrevEntry;
|
||||
}
|
||||
|
||||
|
@ -144,14 +147,14 @@ import java.io.IOException;
|
|||
/**
|
||||
* @param newNextEntry
|
||||
*/
|
||||
void setNextItem(long newNextEntry){
|
||||
public void setNextItem(long newNextEntry){
|
||||
nextItem=newNextEntry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return next item
|
||||
*/
|
||||
long getNextItem(){
|
||||
public long getNextItem(){
|
||||
return nextItem;
|
||||
}
|
||||
|
||||
|
@ -172,7 +175,7 @@ import java.io.IOException;
|
|||
/**
|
||||
* @return Returns the keyFile.
|
||||
*/
|
||||
int getKeyFile(){
|
||||
public int getKeyFile(){
|
||||
return keyFile;
|
||||
}
|
||||
|
||||
|
@ -186,7 +189,7 @@ import java.io.IOException;
|
|||
/**
|
||||
* @return Returns the valueFile.
|
||||
*/
|
||||
int getValueFile(){
|
||||
public int getValueFile(){
|
||||
return valueFile;
|
||||
}
|
||||
|
||||
|
@ -200,14 +203,14 @@ import java.io.IOException;
|
|||
/**
|
||||
* @return Returns the valueOffset.
|
||||
*/
|
||||
long getValueOffset(){
|
||||
public long getValueOffset(){
|
||||
return valueOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param valueOffset The valueOffset to set.
|
||||
*/
|
||||
void setValueOffset(long valueOffset){
|
||||
public void setValueOffset(long valueOffset){
|
||||
this.valueOffset=valueOffset;
|
||||
}
|
||||
|
||||
|
@ -228,14 +231,14 @@ import java.io.IOException;
|
|||
/**
|
||||
* @return Returns the offset.
|
||||
*/
|
||||
long getOffset(){
|
||||
public long getOffset(){
|
||||
return offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param offset The offset to set.
|
||||
*/
|
||||
void setOffset(long offset){
|
||||
public void setOffset(long offset){
|
||||
this.offset=offset;
|
||||
}
|
||||
|
|
@ -15,9 +15,9 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.index;
|
||||
|
||||
interface IndexLinkedList{
|
||||
public interface IndexLinkedList{
|
||||
|
||||
/**
|
||||
* @return the root used by the List
|
|
@ -15,12 +15,14 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.index;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import org.apache.activemq.kaha.impl.data.DataManager;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
/**
|
||||
|
@ -28,7 +30,7 @@ import org.apache.commons.logging.LogFactory;
|
|||
*
|
||||
* @version $Revision: 1.1.1.1 $
|
||||
*/
|
||||
final class IndexManager{
|
||||
public final class IndexManager{
|
||||
private static final Log log=LogFactory.getLog(IndexManager.class);
|
||||
private static final String NAME_PREFIX="index-";
|
||||
private final String name;
|
||||
|
@ -39,7 +41,7 @@ final class IndexManager{
|
|||
private LinkedList freeList=new LinkedList();
|
||||
private long length=0;
|
||||
|
||||
IndexManager(File directory,String name,String mode,DataManager redoLog) throws IOException{
|
||||
public IndexManager(File directory,String name,String mode,DataManager redoLog) throws IOException{
|
||||
this.name=name;
|
||||
file=new File(directory,NAME_PREFIX+name);
|
||||
indexFile=new RandomAccessFile(file,mode);
|
||||
|
@ -57,22 +59,22 @@ final class IndexManager{
|
|||
length=offset;
|
||||
}
|
||||
|
||||
synchronized boolean isEmpty(){
|
||||
public synchronized boolean isEmpty(){
|
||||
return freeList.isEmpty()&&length==0;
|
||||
}
|
||||
|
||||
synchronized IndexItem getIndex(long offset) throws IOException{
|
||||
public synchronized IndexItem getIndex(long offset) throws IOException{
|
||||
return reader.readItem(offset);
|
||||
}
|
||||
|
||||
synchronized void freeIndex(IndexItem item) throws IOException{
|
||||
public synchronized void freeIndex(IndexItem item) throws IOException{
|
||||
item.reset();
|
||||
item.setActive(false);
|
||||
writer.storeItem(item);
|
||||
freeList.add(item);
|
||||
}
|
||||
|
||||
synchronized void updateIndex(IndexItem index) throws IOException{
|
||||
public synchronized void updateIndex(IndexItem index) throws IOException{
|
||||
writer.storeItem(index);
|
||||
}
|
||||
|
||||
|
@ -80,7 +82,7 @@ final class IndexManager{
|
|||
writer.redoStoreItem(redo);
|
||||
}
|
||||
|
||||
synchronized IndexItem createNewIndex(){
|
||||
public synchronized IndexItem createNewIndex(){
|
||||
IndexItem result=getNextFreeIndex();
|
||||
if(result==null){
|
||||
// allocate one
|
||||
|
@ -91,20 +93,20 @@ final class IndexManager{
|
|||
return result;
|
||||
}
|
||||
|
||||
synchronized void close() throws IOException{
|
||||
public synchronized void close() throws IOException{
|
||||
if(indexFile!=null){
|
||||
indexFile.close();
|
||||
indexFile=null;
|
||||
}
|
||||
}
|
||||
|
||||
synchronized void force() throws IOException{
|
||||
public synchronized void force() throws IOException{
|
||||
if(indexFile!=null){
|
||||
indexFile.getFD().sync();
|
||||
}
|
||||
}
|
||||
|
||||
synchronized boolean delete() throws IOException{
|
||||
public synchronized boolean delete() throws IOException{
|
||||
freeList.clear();
|
||||
if(indexFile!=null){
|
||||
indexFile.close();
|
||||
|
@ -126,7 +128,7 @@ final class IndexManager{
|
|||
return length;
|
||||
}
|
||||
|
||||
void setLength(long value){
|
||||
public void setLength(long value){
|
||||
this.length=value;
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.index;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
|
@ -15,10 +15,12 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.index;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
|
||||
import org.apache.activemq.kaha.impl.data.StoreByteArrayInputStream;
|
||||
/**
|
||||
* Optimized Store reader
|
||||
*
|
|
@ -15,10 +15,13 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.index;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
|
||||
import org.apache.activemq.kaha.impl.data.DataManager;
|
||||
import org.apache.activemq.kaha.impl.data.StoreByteArrayOutputStream;
|
||||
/**
|
||||
* Optimized Store writer
|
||||
*
|
|
@ -15,7 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.index;
|
||||
|
||||
/**
|
||||
* A linked list used by IndexItems
|
|
@ -20,10 +20,16 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.activemq.kaha.StoreFactory;
|
||||
import org.apache.activemq.kaha.impl.KahaStore;
|
||||
import org.apache.activemq.kaha.impl.container.ContainerId;
|
||||
import org.apache.activemq.kaha.impl.container.ListContainerImpl;
|
||||
import org.apache.activemq.kaha.impl.data.DataManager;
|
||||
import org.apache.activemq.kaha.impl.index.IndexItem;
|
||||
import org.apache.activemq.kaha.impl.index.IndexManager;
|
||||
/**
|
||||
* Junit tests for CachedListContainerImpl
|
||||
*
|
||||
* @version $Revision$
|
||||
* @version $Revision: 439552 $
|
||||
*/
|
||||
public class CachedListContainerImplTest extends TestCase{
|
||||
protected String name;
|
||||
|
|
|
@ -15,12 +15,16 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.kaha.impl;
|
||||
package org.apache.activemq.kaha.impl.index;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.activemq.kaha.impl.index.IndexItem;
|
||||
import org.apache.activemq.kaha.impl.index.IndexLinkedList;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.2 $
|
||||
*/
|
Loading…
Reference in New Issue