diff --git a/activemq-core/src/main/java/org/apache/activemq/kaha/IndexTypes.java b/activemq-core/src/main/java/org/apache/activemq/kaha/IndexTypes.java new file mode 100644 index 0000000000..4a10bd9e91 --- /dev/null +++ b/activemq-core/src/main/java/org/apache/activemq/kaha/IndexTypes.java @@ -0,0 +1,35 @@ +/** + * + * 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 + * + * 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. + */ +package org.apache.activemq.kaha; + +/** + * Types of Indexes used by the Store + * + * @version $Revision: 1.2 $ + */ +public interface IndexTypes{ + + /** + * use in memory indexes + */ + public final static String IN_MEMORY_INDEX= "InMemoryIndex"; + /** + * use disk-based indexes + */ + public final static String DISK_INDEX = "DiskIndex"; +} \ No newline at end of file diff --git a/activemq-core/src/main/java/org/apache/activemq/kaha/StoreEntry.java b/activemq-core/src/main/java/org/apache/activemq/kaha/StoreEntry.java new file mode 100644 index 0000000000..d6180f7826 --- /dev/null +++ b/activemq-core/src/main/java/org/apache/activemq/kaha/StoreEntry.java @@ -0,0 +1,59 @@ +/** + * + * 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 + * + * 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. + */ +package org.apache.activemq.kaha; + +/** +* Entry for Store data +* +* @version $Revision: 1.2 $ +*/ +public interface StoreEntry{ + + public abstract StoreLocation getKeyDataItem(); + + public abstract StoreLocation getValueDataItem(); + + /** + * @return next item + */ + public abstract long getNextItem(); + + /** + * @return Returns the keyFile. + */ + public abstract int getKeyFile(); + + /** + * @return Returns the valueFile. + */ + public abstract int getValueFile(); + + /** + * @return Returns the valueOffset. + */ + public abstract long getValueOffset(); + + /** + * @return Returns the offset. + */ + public abstract long getOffset(); + + public abstract int getKeySize(); + + public abstract int getValueSize(); +} \ No newline at end of file diff --git a/activemq-core/src/main/java/org/apache/activemq/kaha/StoreLocation.java b/activemq-core/src/main/java/org/apache/activemq/kaha/StoreLocation.java new file mode 100644 index 0000000000..2e4d919272 --- /dev/null +++ b/activemq-core/src/main/java/org/apache/activemq/kaha/StoreLocation.java @@ -0,0 +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 + * + * 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. + */ + +package org.apache.activemq.kaha; + +/** + * Location of a data in the Store + * + * @version $Revision: 1.2 $ + */ +public interface StoreLocation{ + + /** + * @return Returns the size. + */ + public int getSize(); + + /** + * @return Returns the offset. + */ + public long getOffset(); + + /** + * @return Returns the file. + */ + public int getFile(); +} \ No newline at end of file diff --git a/activemq-core/src/main/java/org/apache/activemq/kaha/impl/StoreLockedExcpetion.java b/activemq-core/src/main/java/org/apache/activemq/kaha/impl/StoreLockedExcpetion.java new file mode 100644 index 0000000000..08de6576f7 --- /dev/null +++ b/activemq-core/src/main/java/org/apache/activemq/kaha/impl/StoreLockedExcpetion.java @@ -0,0 +1,45 @@ +/** + * + * 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 + * + * 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. + */ +package org.apache.activemq.kaha.impl; + +import java.io.IOException; + + + +/** +* Exception thrown if the store is in use by another application +* +* @version $Revision: 1.1.1.1 $ +*/ +public class StoreLockedExcpetion extends IOException{ + + private static final long serialVersionUID=3857646689671366926L; + + /** + * Default Constructor + */ + public StoreLockedExcpetion(){ + } + + /** + * @param s + */ + public StoreLockedExcpetion(String s){ + super(s); + } +} diff --git a/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/StoreEntryMarshaller.java b/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/StoreEntryMarshaller.java new file mode 100644 index 0000000000..6aacf18381 --- /dev/null +++ b/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/StoreEntryMarshaller.java @@ -0,0 +1,47 @@ +/** + * + * 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 + * + * 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. + */ +package org.apache.activemq.store.kahadaptor; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; +import org.apache.activemq.kaha.Marshaller; +import org.apache.activemq.kaha.impl.index.IndexItem; + + +/** + * Marshall a TopicSubAck + * @version $Revision: 1.10 $ + */ +public class StoreEntryMarshaller implements Marshaller{ + + + public void writePayload(Object object,DataOutput dataOut) throws IOException{ + IndexItem item = (IndexItem)object; + dataOut.writeLong(item.getOffset()); + item.write(dataOut); + + } + + public Object readPayload(DataInput dataIn) throws IOException{ + IndexItem item = new IndexItem(); + item.setOffset(dataIn.readLong()); + item.read(dataIn); + return item; + } +} diff --git a/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/TopicSubAck.java b/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/TopicSubAck.java new file mode 100644 index 0000000000..0d3ef99d27 --- /dev/null +++ b/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/TopicSubAck.java @@ -0,0 +1,74 @@ +/** + * + * 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 + * + * 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. + */ + +package org.apache.activemq.store.kahadaptor; + +import org.apache.activemq.kaha.StoreEntry; + +/** + * Holds information for location of message + * + * @version $Revision: 1.10 $ + */ +public class TopicSubAck{ + + private int count =0; + private StoreEntry storeEntry; + + /** + * @return the count + */ + public int getCount(){ + return this.count; + } + + /** + * @param count the count to set + */ + public void setCount(int count){ + this.count=count; + } + + /** + * @return the value of the count after it's decremented + */ + public int decrementCount() { + return --count; + } + + /** + * @return the value of the count after it's incremented + */ + public int incrementCount() { + return ++count; + } + + + /** + * @return the storeEntry + */ + public StoreEntry getStoreEntry(){ + return this.storeEntry; + } + + + /** + * @param storeEntry the storeEntry to set + */ + public void setStoreEntry(StoreEntry storeEntry){ + this.storeEntry=storeEntry; + } + + +} diff --git a/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/TopicSubAckMarshaller.java b/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/TopicSubAckMarshaller.java new file mode 100644 index 0000000000..ee9280f56e --- /dev/null +++ b/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/TopicSubAckMarshaller.java @@ -0,0 +1,53 @@ +/** + * + * 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 + * + * 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. + */ +package org.apache.activemq.store.kahadaptor; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; +import org.apache.activemq.kaha.Marshaller; +import org.apache.activemq.kaha.impl.index.IndexItem; + + +/** + * Marshall a TopicSubAck + * @version $Revision: 1.10 $ + */ +public class TopicSubAckMarshaller implements Marshaller{ + + + public void writePayload(Object object,DataOutput dataOut) throws IOException{ + TopicSubAck tsa = (TopicSubAck) object; + dataOut.writeInt(tsa.getCount()); + IndexItem item = (IndexItem)tsa.getStoreEntry(); + dataOut.writeLong(item.getOffset()); + item.write(dataOut); + + } + + public Object readPayload(DataInput dataIn) throws IOException{ + TopicSubAck tsa = new TopicSubAck(); + int count = dataIn.readInt(); + tsa.setCount(count); + IndexItem item = new IndexItem(); + item.setOffset(dataIn.readLong()); + item.read(dataIn); + tsa.setStoreEntry(item); + return tsa; + } +}