}
@Override
public synchronized void start() throws Exception {
super.start();
Store store = getStateStore();
boolean empty = store.getMapContainerIds().isEmpty();
stateMap = store.getMapContainer("state", STORE_STATE);
stateMap.load();
storeValid=true;
if (!empty) {
AtomicBoolean status = (AtomicBoolean)stateMap.get(STORE_STATE);
if (status != null) {
storeValid = status.get();
}
if (storeValid) {
//check what version the indexes are at
Integer indexVersion = (Integer) stateMap.get(INDEX_VERSION_NAME);
if (indexVersion==null || indexVersion.intValue() < INDEX_VERSION.intValue()) {
storeValid = false;
LOG.warn("Indexes at an older version - need to regenerate");
}
}
if (storeValid) {
if (stateMap.containsKey(RECORD_REFERENCES)) {
recordReferences = (Map<Integer, AtomicInteger>)stateMap.get(RECORD_REFERENCES);
}
}
}
stateMap.put(STORE_STATE, new AtomicBoolean());
stateMap.put(INDEX_VERSION_NAME, INDEX_VERSION);
durableSubscribers = store.getListContainer("durableSubscribers");
durableSubscribers.setMarshaller(new CommandMarshaller());
preparedTransactions = store.getMapContainer("transactions", TRANSACTIONS, false);
// need to set the Marshallers here
preparedTransactions.setKeyMarshaller(Store.COMMAND_MARSHALLER);
preparedTransactions.setValueMarshaller(new AMQTxMarshaller(wireFormat));
}