[hornetq-commits] JBoss hornetq SVN: r9003 - in trunk: src/main/org/hornetq/jms/server/impl and 1 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Mar 29 11:51:55 EDT 2010
Author: clebert.suconic at jboss.com
Date: 2010-03-29 11:51:54 -0400 (Mon, 29 Mar 2010)
New Revision: 9003
Added:
trunk/src/main/org/hornetq/jms/persistence/impl/journal/JMSJournalStorageManagerImpl.java
Removed:
trunk/src/main/org/hornetq/jms/persistence/impl/journal/JournalJMSStorageManagerImpl.java
Modified:
trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
trunk/tests/src/org/hornetq/tests/integration/persistence/StorageManagerTestBase.java
Log:
Simple renaming
Copied: trunk/src/main/org/hornetq/jms/persistence/impl/journal/JMSJournalStorageManagerImpl.java (from rev 9000, trunk/src/main/org/hornetq/jms/persistence/impl/journal/JournalJMSStorageManagerImpl.java)
===================================================================
--- trunk/src/main/org/hornetq/jms/persistence/impl/journal/JMSJournalStorageManagerImpl.java (rev 0)
+++ trunk/src/main/org/hornetq/jms/persistence/impl/journal/JMSJournalStorageManagerImpl.java 2010-03-29 15:51:54 UTC (rev 9003)
@@ -0,0 +1,399 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat 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.hornetq.jms.persistence.impl.journal;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.hornetq.api.core.HornetQBuffer;
+import org.hornetq.api.core.HornetQBuffers;
+import org.hornetq.api.core.Pair;
+import org.hornetq.core.config.Configuration;
+import org.hornetq.core.journal.Journal;
+import org.hornetq.core.journal.PreparedTransactionInfo;
+import org.hornetq.core.journal.RecordInfo;
+import org.hornetq.core.journal.SequentialFileFactory;
+import org.hornetq.core.journal.impl.JournalImpl;
+import org.hornetq.core.journal.impl.NIOSequentialFileFactory;
+import org.hornetq.core.replication.ReplicationEndpoint;
+import org.hornetq.core.replication.ReplicationManager;
+import org.hornetq.core.replication.impl.ReplicatedJournal;
+import org.hornetq.core.server.JournalType;
+import org.hornetq.jms.persistence.JMSStorageManager;
+import org.hornetq.jms.persistence.config.PersistedConnectionFactory;
+import org.hornetq.jms.persistence.config.PersistedDestination;
+import org.hornetq.jms.persistence.config.PersistedJNDI;
+import org.hornetq.jms.persistence.config.PersistedType;
+import org.hornetq.utils.IDGenerator;
+
+/**
+ * A JournalJMSStorageManagerImpl
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class JMSJournalStorageManagerImpl implements JMSStorageManager
+{
+
+ // Constants -----------------------------------------------------
+
+ private final byte CF_RECORD = 1;
+
+ private final byte DESTINATION_RECORD = 2;
+
+ private final byte JNDI_RECORD = 3;
+
+ // Attributes ----------------------------------------------------
+
+ private final IDGenerator idGenerator;
+
+ private final String journalDir;
+
+ private final boolean createDir;
+
+ private final Journal jmsJournal;
+
+ private volatile boolean started;
+
+ private Map<String, PersistedConnectionFactory> mapFactories = new ConcurrentHashMap<String, PersistedConnectionFactory>();
+
+ private Map<Pair<PersistedType, String>, PersistedDestination> destinations = new ConcurrentHashMap<Pair<PersistedType, String>, PersistedDestination>();
+
+ private Map<Pair<PersistedType, String>, PersistedJNDI> mapJNDI = new ConcurrentHashMap<Pair<PersistedType, String>, PersistedJNDI>();
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+ public JMSJournalStorageManagerImpl(final IDGenerator idGenerator,
+ final Configuration config,
+ final ReplicationManager replicator)
+ {
+ if (config.getJournalType() != JournalType.NIO && config.getJournalType() != JournalType.ASYNCIO)
+ {
+ throw new IllegalArgumentException("Only NIO and AsyncIO are supported journals");
+ }
+
+ // Will use the same place as the bindings directory from the core journal
+ journalDir = config.getBindingsDirectory();
+
+ if (journalDir == null)
+ {
+ throw new NullPointerException("bindings-dir is null");
+ }
+
+ createDir = config.isCreateBindingsDir();
+
+ SequentialFileFactory bindingsJMS = new NIOSequentialFileFactory(journalDir);
+
+ Journal localJMS = new JournalImpl(1024 * 1024,
+ 2,
+ config.getJournalCompactMinFiles(),
+ config.getJournalCompactPercentage(),
+ bindingsJMS,
+ "hornetq-jms",
+ "jms",
+ 1);
+
+ if (replicator != null)
+ {
+ jmsJournal = new ReplicatedJournal((byte)2, localJMS, replicator);
+ }
+ else
+ {
+ jmsJournal = localJMS;
+ }
+
+ this.idGenerator = idGenerator;
+ }
+
+
+ // Public --------------------------------------------------------
+ /* (non-Javadoc)
+ * @see org.hornetq.jms.persistence.JMSStorageManager#recoverConnectionFactories()
+ */
+ public List<PersistedConnectionFactory> recoverConnectionFactories()
+ {
+ List<PersistedConnectionFactory> cfs = new ArrayList<PersistedConnectionFactory>(mapFactories.size());
+ cfs.addAll(mapFactories.values());
+ return cfs;
+ }
+
+ /* (non-Javadoc)
+ * @see org.hornetq.jms.persistence.JMSStorageManager#storeConnectionFactory(org.hornetq.jms.persistence.PersistedConnectionFactory)
+ */
+ public void storeConnectionFactory(final PersistedConnectionFactory connectionFactory) throws Exception
+ {
+ deleteConnectionFactory(connectionFactory.getName());
+ long id = idGenerator.generateID();
+ connectionFactory.setId(id);
+ jmsJournal.appendAddRecord(id, CF_RECORD, connectionFactory, true);
+ mapFactories.put(connectionFactory.getName(), connectionFactory);
+ }
+
+ public void deleteConnectionFactory(final String cfName) throws Exception
+ {
+ PersistedConnectionFactory oldCF = mapFactories.remove(cfName);
+ if (oldCF != null)
+ {
+ jmsJournal.appendDeleteRecord(oldCF.getId(), false);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.hornetq.jms.persistence.JMSStorageManager#recoverDestinations()
+ */
+ public List<PersistedDestination> recoverDestinations()
+ {
+ List<PersistedDestination> destinations = new ArrayList<PersistedDestination>(this.destinations.size());
+ destinations.addAll(this.destinations.values());
+ return destinations;
+ }
+
+ /* (non-Javadoc)
+ * @see org.hornetq.jms.persistence.JMSStorageManager#storeDestination(org.hornetq.jms.persistence.PersistedDestination)
+ */
+ public void storeDestination(final PersistedDestination destination) throws Exception
+ {
+ deleteDestination(destination.getType(), destination.getName());
+ long id = idGenerator.generateID();
+ destination.setId(id);
+ jmsJournal.appendAddRecord(id, DESTINATION_RECORD, destination, true);
+ destinations.put(new Pair<PersistedType, String>(destination.getType(), destination.getName()), destination);
+ }
+
+ public List<PersistedJNDI> recoverPersistedJNDI() throws Exception
+ {
+ ArrayList<PersistedJNDI> list = new ArrayList<PersistedJNDI>();
+
+ list.addAll(mapJNDI.values());
+
+ return list;
+ }
+
+ public void addJNDI(PersistedType type, String name, String address) throws Exception
+ {
+ Pair<PersistedType, String> key = new Pair<PersistedType, String>(type, name);
+
+ long tx = idGenerator.generateID();
+
+ PersistedJNDI currentJNDI = mapJNDI.get(key);
+ if (currentJNDI != null)
+ {
+ jmsJournal.appendDeleteRecordTransactional(tx, currentJNDI.getId());
+ }
+ else
+ {
+ currentJNDI = new PersistedJNDI(type, name);
+ }
+
+ mapJNDI.put(key, currentJNDI);
+
+ currentJNDI.addJNDI(address);
+
+ long newId = idGenerator.generateID();
+
+ currentJNDI.setId(newId);
+
+ jmsJournal.appendAddRecordTransactional(tx, newId, JNDI_RECORD, currentJNDI);
+
+ jmsJournal.appendCommitRecord(tx, true);
+ }
+
+ public void deleteJNDI(PersistedType type, String name, String address) throws Exception
+ {
+ Pair<PersistedType, String> key = new Pair<PersistedType, String>(type, name);
+
+ long tx = idGenerator.generateID();
+
+ PersistedJNDI currentJNDI = mapJNDI.get(key);
+ if (currentJNDI == null)
+ {
+ return;
+ }
+ else
+ {
+ jmsJournal.appendDeleteRecordTransactional(tx, currentJNDI.getId());
+ }
+
+ currentJNDI.deleteJNDI(address);
+
+ if (currentJNDI.getJndi().size() == 0)
+ {
+ mapJNDI.remove(key);
+ }
+ else
+ {
+ long newId = idGenerator.generateID();
+ currentJNDI.setId(newId);
+ jmsJournal.appendAddRecordTransactional(tx, newId, JNDI_RECORD, currentJNDI);
+ }
+
+ jmsJournal.appendCommitRecord(tx, true);
+ }
+
+
+ public void deleteJNDI(PersistedType type, String name) throws Exception
+ {
+ Pair<PersistedType, String> key = new Pair<PersistedType, String>(type, name);
+
+ PersistedJNDI currentJNDI = mapJNDI.remove(key);
+
+ if (currentJNDI == null)
+ {
+ return;
+ }
+ else
+ {
+ jmsJournal.appendDeleteRecord(currentJNDI.getId(), true);
+ }
+ }
+
+ public void deleteDestination(final PersistedType type, final String name) throws Exception
+ {
+ PersistedDestination destination = destinations.get(new Pair<PersistedType, String>(type, name));
+ if(destination != null)
+ {
+ jmsJournal.appendDeleteRecord(destination.getId(), false);
+ }
+ deleteJNDI(type, name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.hornetq.core.server.HornetQComponent#isStarted()
+ */
+ public boolean isStarted()
+ {
+ return started;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.hornetq.core.server.HornetQComponent#start()
+ */
+ public void start() throws Exception
+ {
+
+ checkAndCreateDir(journalDir, createDir);
+
+ jmsJournal.start();
+
+ started = true;
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.hornetq.jms.persistence.JMSStorageManager#installReplication(org.hornetq.core.replication.ReplicationEndpoint)
+ */
+ public void installReplication(ReplicationEndpoint replicationEndpoint) throws Exception
+ {
+ jmsJournal.loadInternalOnly();
+ replicationEndpoint.registerJournal((byte)2, this.jmsJournal);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.hornetq.core.server.HornetQComponent#stop()
+ */
+ public void stop() throws Exception
+ {
+ this.started = false;
+ jmsJournal.stop();
+ }
+
+ public void load() throws Exception
+ {
+ mapFactories.clear();
+
+ List<RecordInfo> data = new ArrayList<RecordInfo>();
+
+ ArrayList<PreparedTransactionInfo> list = new ArrayList<PreparedTransactionInfo>();
+
+ jmsJournal.load(data, list, null);
+
+ for (RecordInfo record : data)
+ {
+ long id = record.id;
+
+ HornetQBuffer buffer = HornetQBuffers.wrappedBuffer(record.data);
+
+ byte rec = record.getUserRecordType();
+
+ if (rec == CF_RECORD)
+ {
+ PersistedConnectionFactory cf = new PersistedConnectionFactory();
+ cf.decode(buffer);
+ cf.setId(id);
+ mapFactories.put(cf.getName(), cf);
+ }
+ else if(rec == DESTINATION_RECORD)
+ {
+ PersistedDestination destination = new PersistedDestination();
+ destination.decode(buffer);
+ destination.setId(id);
+ destinations.put(new Pair<PersistedType, String>(destination.getType(), destination.getName()), destination);
+ }
+ else if (rec == JNDI_RECORD)
+ {
+ PersistedJNDI jndi = new PersistedJNDI();
+ jndi.decode(buffer);
+ jndi.setId(id);
+ Pair<PersistedType, String> key = new Pair<PersistedType, String>(jndi.getType(), jndi.getName());
+ mapJNDI.put(key, jndi);
+ }
+ else
+ {
+ throw new IllegalStateException("Invalid record type " + rec);
+ }
+
+ }
+
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+
+ private void checkAndCreateDir(final String dir, final boolean create)
+ {
+ File f = new File(dir);
+
+ if (!f.exists())
+ {
+ if (create)
+ {
+ if (!f.mkdirs())
+ {
+ throw new IllegalStateException("Failed to create directory " + dir);
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("Directory " + dir + " does not exist and will not create it");
+ }
+ }
+ }
+
+
+
+ // Inner classes -------------------------------------------------
+
+}
Deleted: trunk/src/main/org/hornetq/jms/persistence/impl/journal/JournalJMSStorageManagerImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/persistence/impl/journal/JournalJMSStorageManagerImpl.java 2010-03-29 15:32:32 UTC (rev 9002)
+++ trunk/src/main/org/hornetq/jms/persistence/impl/journal/JournalJMSStorageManagerImpl.java 2010-03-29 15:51:54 UTC (rev 9003)
@@ -1,398 +0,0 @@
-/*
- * Copyright 2010 Red Hat, Inc.
- * Red Hat 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.hornetq.jms.persistence.impl.journal;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.hornetq.api.core.HornetQBuffer;
-import org.hornetq.api.core.HornetQBuffers;
-import org.hornetq.api.core.Pair;
-import org.hornetq.core.config.Configuration;
-import org.hornetq.core.journal.Journal;
-import org.hornetq.core.journal.PreparedTransactionInfo;
-import org.hornetq.core.journal.RecordInfo;
-import org.hornetq.core.journal.SequentialFileFactory;
-import org.hornetq.core.journal.impl.JournalImpl;
-import org.hornetq.core.journal.impl.NIOSequentialFileFactory;
-import org.hornetq.core.replication.ReplicationEndpoint;
-import org.hornetq.core.replication.ReplicationManager;
-import org.hornetq.core.replication.impl.ReplicatedJournal;
-import org.hornetq.core.server.JournalType;
-import org.hornetq.jms.persistence.JMSStorageManager;
-import org.hornetq.jms.persistence.config.PersistedConnectionFactory;
-import org.hornetq.jms.persistence.config.PersistedDestination;
-import org.hornetq.jms.persistence.config.PersistedJNDI;
-import org.hornetq.jms.persistence.config.PersistedType;
-import org.hornetq.utils.IDGenerator;
-
-/**
- * A JournalJMSStorageManagerImpl
- *
- * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- *
- *
- */
-public class JournalJMSStorageManagerImpl implements JMSStorageManager
-{
-
- // Constants -----------------------------------------------------
-
- private final byte CF_RECORD = 1;
-
- private final byte DESTINATION_RECORD = 2;
-
- private final byte JNDI_RECORD = 3;
-
- // Attributes ----------------------------------------------------
-
- private final IDGenerator idGenerator;
-
- private final String bindingsDir;
-
- private final boolean createBindingsDir;
-
- private final Journal jmsJournal;
-
- private volatile boolean started;
-
- private Map<String, PersistedConnectionFactory> mapFactories = new ConcurrentHashMap<String, PersistedConnectionFactory>();
-
- private Map<Pair<PersistedType, String>, PersistedDestination> destinations = new ConcurrentHashMap<Pair<PersistedType, String>, PersistedDestination>();
-
- private Map<Pair<PersistedType, String>, PersistedJNDI> mapJNDI = new ConcurrentHashMap<Pair<PersistedType, String>, PersistedJNDI>();
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
- public JournalJMSStorageManagerImpl(final IDGenerator idGenerator,
- final Configuration config,
- final ReplicationManager replicator)
- {
- if (config.getJournalType() != JournalType.NIO && config.getJournalType() != JournalType.ASYNCIO)
- {
- throw new IllegalArgumentException("Only NIO and AsyncIO are supported journals");
- }
-
- bindingsDir = config.getBindingsDirectory();
-
- if (bindingsDir == null)
- {
- throw new NullPointerException("bindings-dir is null");
- }
-
- createBindingsDir = config.isCreateBindingsDir();
-
- SequentialFileFactory bindingsJMS = new NIOSequentialFileFactory(bindingsDir);
-
- Journal localJMS = new JournalImpl(1024 * 1024,
- 2,
- config.getJournalCompactMinFiles(),
- config.getJournalCompactPercentage(),
- bindingsJMS,
- "hornetq-jms-config",
- "jms",
- 1);
-
- if (replicator != null)
- {
- jmsJournal = new ReplicatedJournal((byte)2, localJMS, replicator);
- }
- else
- {
- jmsJournal = localJMS;
- }
-
- this.idGenerator = idGenerator;
- }
-
-
- // Public --------------------------------------------------------
- /* (non-Javadoc)
- * @see org.hornetq.jms.persistence.JMSStorageManager#recoverConnectionFactories()
- */
- public List<PersistedConnectionFactory> recoverConnectionFactories()
- {
- List<PersistedConnectionFactory> cfs = new ArrayList<PersistedConnectionFactory>(mapFactories.size());
- cfs.addAll(mapFactories.values());
- return cfs;
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.jms.persistence.JMSStorageManager#storeConnectionFactory(org.hornetq.jms.persistence.PersistedConnectionFactory)
- */
- public void storeConnectionFactory(final PersistedConnectionFactory connectionFactory) throws Exception
- {
- deleteConnectionFactory(connectionFactory.getName());
- long id = idGenerator.generateID();
- connectionFactory.setId(id);
- jmsJournal.appendAddRecord(id, CF_RECORD, connectionFactory, true);
- mapFactories.put(connectionFactory.getName(), connectionFactory);
- }
-
- public void deleteConnectionFactory(final String cfName) throws Exception
- {
- PersistedConnectionFactory oldCF = mapFactories.remove(cfName);
- if (oldCF != null)
- {
- jmsJournal.appendDeleteRecord(oldCF.getId(), false);
- }
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.jms.persistence.JMSStorageManager#recoverDestinations()
- */
- public List<PersistedDestination> recoverDestinations()
- {
- List<PersistedDestination> destinations = new ArrayList<PersistedDestination>(this.destinations.size());
- destinations.addAll(this.destinations.values());
- return destinations;
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.jms.persistence.JMSStorageManager#storeDestination(org.hornetq.jms.persistence.PersistedDestination)
- */
- public void storeDestination(final PersistedDestination destination) throws Exception
- {
- deleteDestination(destination.getType(), destination.getName());
- long id = idGenerator.generateID();
- destination.setId(id);
- jmsJournal.appendAddRecord(id, DESTINATION_RECORD, destination, true);
- destinations.put(new Pair<PersistedType, String>(destination.getType(), destination.getName()), destination);
- }
-
- public List<PersistedJNDI> recoverPersistedJNDI() throws Exception
- {
- ArrayList<PersistedJNDI> list = new ArrayList<PersistedJNDI>();
-
- list.addAll(mapJNDI.values());
-
- return list;
- }
-
- public void addJNDI(PersistedType type, String name, String address) throws Exception
- {
- Pair<PersistedType, String> key = new Pair<PersistedType, String>(type, name);
-
- long tx = idGenerator.generateID();
-
- PersistedJNDI currentJNDI = mapJNDI.get(key);
- if (currentJNDI != null)
- {
- jmsJournal.appendDeleteRecordTransactional(tx, currentJNDI.getId());
- }
- else
- {
- currentJNDI = new PersistedJNDI(type, name);
- }
-
- mapJNDI.put(key, currentJNDI);
-
- currentJNDI.addJNDI(address);
-
- long newId = idGenerator.generateID();
-
- currentJNDI.setId(newId);
-
- jmsJournal.appendAddRecordTransactional(tx, newId, JNDI_RECORD, currentJNDI);
-
- jmsJournal.appendCommitRecord(tx, true);
- }
-
- public void deleteJNDI(PersistedType type, String name, String address) throws Exception
- {
- Pair<PersistedType, String> key = new Pair<PersistedType, String>(type, name);
-
- long tx = idGenerator.generateID();
-
- PersistedJNDI currentJNDI = mapJNDI.get(key);
- if (currentJNDI == null)
- {
- return;
- }
- else
- {
- jmsJournal.appendDeleteRecordTransactional(tx, currentJNDI.getId());
- }
-
- currentJNDI.deleteJNDI(address);
-
- if (currentJNDI.getJndi().size() == 0)
- {
- mapJNDI.remove(key);
- }
- else
- {
- long newId = idGenerator.generateID();
- currentJNDI.setId(newId);
- jmsJournal.appendAddRecordTransactional(tx, newId, JNDI_RECORD, currentJNDI);
- }
-
- jmsJournal.appendCommitRecord(tx, true);
- }
-
-
- public void deleteJNDI(PersistedType type, String name) throws Exception
- {
- Pair<PersistedType, String> key = new Pair<PersistedType, String>(type, name);
-
- PersistedJNDI currentJNDI = mapJNDI.remove(key);
-
- if (currentJNDI == null)
- {
- return;
- }
- else
- {
- jmsJournal.appendDeleteRecord(currentJNDI.getId(), true);
- }
- }
-
- public void deleteDestination(final PersistedType type, final String name) throws Exception
- {
- PersistedDestination destination = destinations.get(new Pair<PersistedType, String>(type, name));
- if(destination != null)
- {
- jmsJournal.appendDeleteRecord(destination.getId(), false);
- }
- deleteJNDI(type, name);
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.server.HornetQComponent#isStarted()
- */
- public boolean isStarted()
- {
- return started;
- }
-
-
- /* (non-Javadoc)
- * @see org.hornetq.core.server.HornetQComponent#start()
- */
- public void start() throws Exception
- {
-
- checkAndCreateDir(bindingsDir, createBindingsDir);
-
- jmsJournal.start();
-
- started = true;
- }
-
-
-
- /* (non-Javadoc)
- * @see org.hornetq.jms.persistence.JMSStorageManager#installReplication(org.hornetq.core.replication.ReplicationEndpoint)
- */
- public void installReplication(ReplicationEndpoint replicationEndpoint) throws Exception
- {
- jmsJournal.loadInternalOnly();
- replicationEndpoint.registerJournal((byte)2, this.jmsJournal);
- }
-
-
- /* (non-Javadoc)
- * @see org.hornetq.core.server.HornetQComponent#stop()
- */
- public void stop() throws Exception
- {
- this.started = false;
- jmsJournal.stop();
- }
-
- public void load() throws Exception
- {
- mapFactories.clear();
-
- List<RecordInfo> data = new ArrayList<RecordInfo>();
-
- ArrayList<PreparedTransactionInfo> list = new ArrayList<PreparedTransactionInfo>();
-
- jmsJournal.load(data, list, null);
-
- for (RecordInfo record : data)
- {
- long id = record.id;
-
- HornetQBuffer buffer = HornetQBuffers.wrappedBuffer(record.data);
-
- byte rec = record.getUserRecordType();
-
- if (rec == CF_RECORD)
- {
- PersistedConnectionFactory cf = new PersistedConnectionFactory();
- cf.decode(buffer);
- cf.setId(id);
- mapFactories.put(cf.getName(), cf);
- }
- else if(rec == DESTINATION_RECORD)
- {
- PersistedDestination destination = new PersistedDestination();
- destination.decode(buffer);
- destination.setId(id);
- destinations.put(new Pair<PersistedType, String>(destination.getType(), destination.getName()), destination);
- }
- else if (rec == JNDI_RECORD)
- {
- PersistedJNDI jndi = new PersistedJNDI();
- jndi.decode(buffer);
- jndi.setId(id);
- Pair<PersistedType, String> key = new Pair<PersistedType, String>(jndi.getType(), jndi.getName());
- mapJNDI.put(key, jndi);
- }
- else
- {
- throw new IllegalStateException("Invalid record type " + rec);
- }
-
- }
-
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
-
- private void checkAndCreateDir(final String dir, final boolean create)
- {
- File f = new File(dir);
-
- if (!f.exists())
- {
- if (create)
- {
- if (!f.mkdirs())
- {
- throw new IllegalStateException("Failed to create directory " + dir);
- }
- }
- else
- {
- throw new IllegalArgumentException("Directory " + dir + " does not exist and will not create it");
- }
- }
- }
-
-
-
- // Inner classes -------------------------------------------------
-
-}
Modified: trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java 2010-03-29 15:32:32 UTC (rev 9002)
+++ trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java 2010-03-29 15:51:54 UTC (rev 9003)
@@ -53,7 +53,7 @@
import org.hornetq.jms.persistence.config.PersistedDestination;
import org.hornetq.jms.persistence.config.PersistedJNDI;
import org.hornetq.jms.persistence.config.PersistedType;
-import org.hornetq.jms.persistence.impl.journal.JournalJMSStorageManagerImpl;
+import org.hornetq.jms.persistence.impl.journal.JMSJournalStorageManagerImpl;
import org.hornetq.jms.persistence.impl.nullpm.NullJMSStorageManagerImpl;
import org.hornetq.jms.server.JMSServerManager;
import org.hornetq.jms.server.config.ConnectionFactoryConfiguration;
@@ -1467,7 +1467,7 @@
{
if (coreConfig.isPersistenceEnabled())
{
- storage = new JournalJMSStorageManagerImpl(new TimeAndCounterIDGenerator(),
+ storage = new JMSJournalStorageManagerImpl(new TimeAndCounterIDGenerator(),
server.getConfiguration(),
server.getReplicationManager());
}
Modified: trunk/tests/src/org/hornetq/tests/integration/persistence/StorageManagerTestBase.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/persistence/StorageManagerTestBase.java 2010-03-29 15:32:32 UTC (rev 9002)
+++ trunk/tests/src/org/hornetq/tests/integration/persistence/StorageManagerTestBase.java 2010-03-29 15:51:54 UTC (rev 9003)
@@ -27,7 +27,7 @@
import org.hornetq.core.server.JournalType;
import org.hornetq.core.server.Queue;
import org.hornetq.jms.persistence.JMSStorageManager;
-import org.hornetq.jms.persistence.impl.journal.JournalJMSStorageManagerImpl;
+import org.hornetq.jms.persistence.impl.journal.JMSJournalStorageManagerImpl;
import org.hornetq.tests.unit.core.server.impl.fakes.FakePostOffice;
import org.hornetq.tests.util.ServiceTestBase;
import org.hornetq.utils.ExecutorFactory;
@@ -144,7 +144,7 @@
configuration.setJournalType(JournalType.ASYNCIO);
- jmsJournal = new JournalJMSStorageManagerImpl(new TimeAndCounterIDGenerator(), configuration, null);
+ jmsJournal = new JMSJournalStorageManagerImpl(new TimeAndCounterIDGenerator(), configuration, null);
jmsJournal.start();
More information about the hornetq-commits
mailing list