001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.activemq.store; 018 019import java.io.IOException; 020import java.util.Map; 021import java.util.Set; 022 023import org.apache.activemq.command.ActiveMQQueue; 024import org.apache.activemq.command.ActiveMQTopic; 025import org.apache.activemq.command.SubscriptionInfo; 026import org.apache.activemq.command.TransactionId; 027import org.apache.activemq.store.amq.AMQTx; 028 029/** 030 * Adapter to the actual persistence mechanism used with ActiveMQ 031 * 032 * 033 */ 034public interface ReferenceStoreAdapter extends PersistenceAdapter { 035 036 /** 037 * Factory method to create a new queue message store with the given 038 * destination name 039 * 040 * @param destination 041 * @return the QueueReferenceStore 042 * @throws IOException 043 */ 044 ReferenceStore createQueueReferenceStore(ActiveMQQueue destination) throws IOException; 045 046 /** 047 * Factory method to create a new topic message store with the given 048 * destination name 049 * 050 * @param destination 051 * @return the TopicRefererenceStore 052 * @throws IOException 053 */ 054 TopicReferenceStore createTopicReferenceStore(ActiveMQTopic destination) throws IOException; 055 056 /** 057 * @return Set of File ids in use 058 * @throws IOException 059 */ 060 Set<Integer> getReferenceFileIdsInUse() throws IOException; 061 062 /** 063 * If the store isn't valid, it can be recoverd at start-up 064 * 065 * @return true if the reference store is in a consistent state 066 */ 067 boolean isStoreValid(); 068 069 /** 070 * called by recover to clear out message references 071 * 072 * @throws IOException 073 */ 074 void clearMessages() throws IOException; 075 076 /** 077 * recover any state 078 * 079 * @throws IOException 080 */ 081 void recoverState() throws IOException; 082 083 /** 084 * Save prepared transactions 085 * 086 * @param map 087 * @throws IOException 088 */ 089 void savePreparedState(Map<TransactionId, AMQTx> map) throws IOException; 090 091 /** 092 * @return saved prepared transactions 093 * @throws IOException 094 */ 095 Map<TransactionId, AMQTx> retrievePreparedState() throws IOException; 096 097 /** 098 * @return the maxDataFileLength 099 */ 100 long getMaxDataFileLength(); 101 102 /** 103 * set the max data length of a reference data log - if used 104 * @param maxDataFileLength 105 */ 106 void setMaxDataFileLength(long maxDataFileLength); 107 108 /** 109 * Recover particular subscription. Used for recovery of durable consumers 110 * @param info 111 * @throws IOException 112 */ 113 void recoverSubscription(SubscriptionInfo info) throws IOException; 114}