JBoss Cache SVN: r6940 - core/branches/flat/src/main/java/org/jboss/starobrno/config.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-10-14 13:43:22 -0400 (Tue, 14 Oct 2008)
New Revision: 6940
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java
Log:
enabling replication
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java 2008-10-14 17:43:06 UTC (rev 6939)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java 2008-10-14 17:43:22 UTC (rev 6940)
@@ -24,10 +24,10 @@
import org.jboss.cache.Version;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.lock.IsolationLevel;
-import org.jboss.cache.marshall.Marshaller;
import org.jboss.starobrno.config.parsing.JGroupsStackParser;
import org.jboss.starobrno.factories.annotations.NonVolatile;
import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.marshall.ExtendedMarshaller;
import org.w3c.dom.Element;
import java.net.URL;
@@ -45,7 +45,7 @@
{
private static final long serialVersionUID = 5553791890144997466L;
- private Marshaller marshaller;
+ private ExtendedMarshaller marshaller;
private transient JGroupsStackParser jGroupsStackParser = new JGroupsStackParser();
private boolean invocationBatchingEnabled;
@@ -210,12 +210,12 @@
// SETTERS - MAKE SURE ALL SETTERS PERFORM testImmutability()!!!
// ------------------------------------------------------------------------------------------------------------
- public void setCacheMarshaller(Marshaller instance)
+ public void setCacheMarshaller(ExtendedMarshaller instance)
{
marshaller = instance;
}
- public Marshaller getMarshaller()
+ public ExtendedMarshaller getMarshaller()
{
return marshaller;
}
17 years, 2 months
JBoss Cache SVN: r6939 - in core/branches/flat/src/main/java/org/jboss/starobrno/commands: tx and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-10-14 13:43:06 -0400 (Tue, 14 Oct 2008)
New Revision: 6939
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/tx/PrepareCommand.java
Log:
enabling replication
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactory.java 2008-10-14 17:42:46 UTC (rev 6938)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactory.java 2008-10-14 17:43:06 UTC (rev 6939)
@@ -32,6 +32,7 @@
import org.jboss.starobrno.commands.write.PutMapCommand;
import org.jboss.starobrno.commands.write.RemoveCommand;
import org.jboss.starobrno.commands.write.ReplaceCommand;
+import org.jboss.starobrno.commands.remote.ReplicateCommand;
import org.jboss.starobrno.transaction.GlobalTransaction;
import org.jgroups.Address;
@@ -66,4 +67,8 @@
RollbackCommand buildRollbackCommand(GlobalTransaction gtx);
ReplicableCommand fromStream(byte methodId, Object[] args);
+
+ ReplicateCommand buildReplicateCommand(List<ReplicableCommand> toReplicate);
+
+ ReplicateCommand buildReplicateCommand(ReplicableCommand call);
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java 2008-10-14 17:42:46 UTC (rev 6938)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java 2008-10-14 17:43:06 UTC (rev 6939)
@@ -33,6 +33,7 @@
import org.jboss.starobrno.commands.write.PutMapCommand;
import org.jboss.starobrno.commands.write.RemoveCommand;
import org.jboss.starobrno.commands.write.ReplaceCommand;
+import org.jboss.starobrno.commands.remote.ReplicateCommand;
import org.jboss.starobrno.container.DataContainer;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.notifications.Notifier;
@@ -112,6 +113,16 @@
return new RollbackCommand(gtx);
}
+ public ReplicateCommand buildReplicateCommand(List<ReplicableCommand> toReplicate)
+ {
+ return new ReplicateCommand(toReplicate);
+ }
+
+ public ReplicateCommand buildReplicateCommand(ReplicableCommand call)
+ {
+ return new ReplicateCommand(call);
+ }
+
public ReplicableCommand fromStream(byte id, Object[] parameters)
{
ReplicableCommand command;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/tx/PrepareCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/tx/PrepareCommand.java 2008-10-14 17:42:46 UTC (rev 6938)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/tx/PrepareCommand.java 2008-10-14 17:43:06 UTC (rev 6939)
@@ -23,6 +23,7 @@
import org.jboss.starobrno.commands.DataCommand;
import org.jboss.starobrno.commands.ReplicableCommand;
+import org.jboss.starobrno.commands.VisitableCommand;
import org.jboss.starobrno.commands.Visitor;
import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.transaction.GlobalTransaction;
@@ -54,7 +55,7 @@
this.onePhaseCommit = onePhaseCommit;
}
- public void removeModifications(Collection<DataCommand> modificationsToRemove)
+ public void removeModifications(Collection<VisitableCommand> modificationsToRemove)
{
if (modifications != null) modifications.removeAll(modificationsToRemove);
}
17 years, 2 months
JBoss Cache SVN: r6938 - in core/branches/flat/src/main/java/org/jboss/starobrno: cluster and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-10-14 13:42:46 -0400 (Tue, 14 Oct 2008)
New Revision: 6938
Added:
core/branches/flat/src/main/java/org/jboss/starobrno/cluster/
core/branches/flat/src/main/java/org/jboss/starobrno/cluster/ReplicationQueue.java
Removed:
core/branches/flat/src/main/java/org/jboss/starobrno/cluster/ReplicationQueue.java
Log:
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/cluster (from rev 6895, core/branches/flat/src/main/java/org/jboss/cache/cluster)
Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/cluster/ReplicationQueue.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/cluster/ReplicationQueue.java 2008-10-09 09:55:17 UTC (rev 6895)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/cluster/ReplicationQueue.java 2008-10-14 17:42:46 UTC (rev 6938)
@@ -1,184 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.cache.cluster;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.RPCManager;
-import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.ReplicableCommand;
-import org.jboss.cache.commands.remote.ReplicateCommand;
-import org.jboss.starobrno.config.Configuration;
-import org.jboss.starobrno.factories.annotations.Inject;
-import org.jboss.starobrno.factories.annotations.Start;
-import org.jboss.starobrno.factories.annotations.Stop;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * Periodically (or when certain size is exceeded) takes elements and replicates them.
- *
- * @author <a href="mailto:bela@jboss.org">Bela Ban</a> May 24, 2003
- * @version $Revision: 5197 $
- */
-public class ReplicationQueue
-{
-
- private static final Log log = LogFactory.getLog(ReplicationQueue.class);
-
- /**
- * Max elements before we flush
- */
- private long max_elements = 500;
-
- /**
- * Holds the replication jobs: LinkedList<MethodCall>
- */
- final List<ReplicableCommand> elements = new LinkedList<ReplicableCommand>();
-
- /**
- * For periodical replication
- */
- private ScheduledExecutorService scheduledExecutor = null;
- private RPCManager rpcManager;
- private Configuration configuration;
- private boolean enabled;
- private CommandsFactory commandsFactory;
- private static final AtomicInteger counter = new AtomicInteger(0);
-
- public boolean isEnabled()
- {
- return enabled;
- }
-
- @Inject
- private void injectDependencies(RPCManager rpcManager, Configuration configuration, CommandsFactory commandsFactory)
- {
- this.rpcManager = rpcManager;
- this.configuration = configuration;
- this.commandsFactory = commandsFactory;
-
- // this is checked again in Start
- enabled = configuration.isUseReplQueue() && (configuration.getBuddyReplicationConfig() == null || !configuration.getBuddyReplicationConfig().isEnabled());
- }
-
- /**
- * Starts the asynchronous flush queue.
- */
- @Start
- public synchronized void start()
- {
- long interval = configuration.getReplQueueInterval();
- this.max_elements = configuration.getReplQueueMaxElements();
- // check again
- enabled = configuration.isUseReplQueue() && (configuration.getBuddyReplicationConfig() == null || !configuration.getBuddyReplicationConfig().isEnabled());
- if (enabled)
- {
- if (interval > 0)
- {
- if (scheduledExecutor == null)
- {
- scheduledExecutor = Executors.newSingleThreadScheduledExecutor(new ThreadFactory()
- {
- public Thread newThread(Runnable r)
- {
- return new Thread(r, "ReplicationQueue-periodicProcessor-" + counter.getAndIncrement());
- }
- });
- scheduledExecutor.scheduleWithFixedDelay(new Runnable()
- {
- public void run()
- {
- flush();
- }
- }, 500l, interval, TimeUnit.MILLISECONDS);
- }
- }
- }
- }
-
- /**
- * Stops the asynchronous flush queue.
- */
- @Stop
- public synchronized void stop()
- {
- if (scheduledExecutor != null)
- {
- scheduledExecutor.shutdownNow();
- }
- scheduledExecutor = null;
- }
-
-
- /**
- * Adds a new method call.
- */
- public void add(ReplicateCommand job)
- {
- if (job == null)
- throw new NullPointerException("job is null");
- synchronized (elements)
- {
- elements.add(job);
- if (elements.size() >= max_elements)
- flush();
- }
- }
-
- /**
- * Flushes existing method calls.
- */
- public void flush()
- {
- List<ReplicableCommand> toReplicate;
- synchronized (elements)
- {
- if (log.isTraceEnabled())
- log.trace("flush(): flushing repl queue (num elements=" + elements.size() + ")");
- toReplicate = new ArrayList<ReplicableCommand>(elements);
- elements.clear();
- }
-
- if (toReplicate.size() > 0)
- {
- try
- {
-
- ReplicateCommand replicateCommand = commandsFactory.buildReplicateCommand(toReplicate);
- // send to all live nodes in the cluster
- rpcManager.callRemoteMethods(null, replicateCommand, false, configuration.getSyncReplTimeout(), false);
- }
- catch (Throwable t)
- {
- log.error("failed replicating " + toReplicate.size() + " elements in replication queue", t);
- }
- }
- }
-}
\ No newline at end of file
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/cluster/ReplicationQueue.java (from rev 6897, core/branches/flat/src/main/java/org/jboss/cache/cluster/ReplicationQueue.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/cluster/ReplicationQueue.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/cluster/ReplicationQueue.java 2008-10-14 17:42:46 UTC (rev 6938)
@@ -0,0 +1,184 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.cluster;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.factories.annotations.Stop;
+import org.jboss.starobrno.commands.ReplicableCommand;
+import org.jboss.starobrno.commands.CommandsFactory;
+import org.jboss.starobrno.commands.remote.ReplicateCommand;
+import org.jboss.starobrno.RPCManager;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Periodically (or when certain size is exceeded) takes elements and replicates them.
+ *
+ * @author <a href="mailto:bela@jboss.org">Bela Ban</a> May 24, 2003
+ * @version $Revision: 5197 $
+ */
+public class ReplicationQueue
+{
+
+ private static final Log log = LogFactory.getLog(ReplicationQueue.class);
+
+ /**
+ * Max elements before we flush
+ */
+ private long max_elements = 500;
+
+ /**
+ * Holds the replication jobs: LinkedList<MethodCall>
+ */
+ final List<ReplicableCommand> elements = new LinkedList<ReplicableCommand>();
+
+ /**
+ * For periodical replication
+ */
+ private ScheduledExecutorService scheduledExecutor = null;
+ private RPCManager rpcManager;
+ private Configuration configuration;
+ private boolean enabled;
+ private CommandsFactory commandsFactory;
+ private static final AtomicInteger counter = new AtomicInteger(0);
+
+ public boolean isEnabled()
+ {
+ return enabled;
+ }
+
+ @Inject
+ private void injectDependencies(RPCManager rpcManager, Configuration configuration, CommandsFactory commandsFactory)
+ {
+ this.rpcManager = rpcManager;
+ this.configuration = configuration;
+ this.commandsFactory = commandsFactory;
+
+ // this is checked again in Start
+ enabled = configuration.isUseReplQueue() && (configuration.getBuddyReplicationConfig() == null || !configuration.getBuddyReplicationConfig().isEnabled());
+ }
+
+ /**
+ * Starts the asynchronous flush queue.
+ */
+ @Start
+ public synchronized void start()
+ {
+ long interval = configuration.getReplQueueInterval();
+ this.max_elements = configuration.getReplQueueMaxElements();
+ // check again
+ enabled = configuration.isUseReplQueue() && (configuration.getBuddyReplicationConfig() == null || !configuration.getBuddyReplicationConfig().isEnabled());
+ if (enabled)
+ {
+ if (interval > 0)
+ {
+ if (scheduledExecutor == null)
+ {
+ scheduledExecutor = Executors.newSingleThreadScheduledExecutor(new ThreadFactory()
+ {
+ public Thread newThread(Runnable r)
+ {
+ return new Thread(r, "ReplicationQueue-periodicProcessor-" + counter.getAndIncrement());
+ }
+ });
+ scheduledExecutor.scheduleWithFixedDelay(new Runnable()
+ {
+ public void run()
+ {
+ flush();
+ }
+ }, 500l, interval, TimeUnit.MILLISECONDS);
+ }
+ }
+ }
+ }
+
+ /**
+ * Stops the asynchronous flush queue.
+ */
+ @Stop
+ public synchronized void stop()
+ {
+ if (scheduledExecutor != null)
+ {
+ scheduledExecutor.shutdownNow();
+ }
+ scheduledExecutor = null;
+ }
+
+
+ /**
+ * Adds a new method call.
+ */
+ public void add(ReplicateCommand job)
+ {
+ if (job == null)
+ throw new NullPointerException("job is null");
+ synchronized (elements)
+ {
+ elements.add(job);
+ if (elements.size() >= max_elements)
+ flush();
+ }
+ }
+
+ /**
+ * Flushes existing method calls.
+ */
+ public void flush()
+ {
+ List<ReplicableCommand> toReplicate;
+ synchronized (elements)
+ {
+ if (log.isTraceEnabled())
+ log.trace("flush(): flushing repl queue (num elements=" + elements.size() + ")");
+ toReplicate = new ArrayList<ReplicableCommand>(elements);
+ elements.clear();
+ }
+
+ if (toReplicate.size() > 0)
+ {
+ try
+ {
+
+ ReplicateCommand replicateCommand = commandsFactory.buildReplicateCommand(toReplicate);
+ // send to all live nodes in the cluster
+ rpcManager.callRemoteMethods(null, replicateCommand, false, configuration.getSyncReplTimeout(), false);
+ }
+ catch (Throwable t)
+ {
+ log.error("failed replicating " + toReplicate.size() + " elements in replication queue", t);
+ }
+ }
+ }
+}
\ No newline at end of file
17 years, 2 months
JBoss Cache SVN: r6937 - in core/branches/flat/src/main/java/org/jboss/cache: buddyreplication and 12 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-10-14 13:42:25 -0400 (Tue, 14 Oct 2008)
New Revision: 6937
Removed:
core/branches/flat/src/main/java/org/jboss/cache/SuspectException.java
core/branches/flat/src/main/java/org/jboss/cache/cluster/
core/branches/flat/src/main/java/org/jboss/cache/io/
core/branches/flat/src/main/java/org/jboss/cache/lock/TimeoutException.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/NodeData.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/NodeDataExceptionMarker.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/NodeDataMarker.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/UnmarshalledReferences.java
core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferManager.java
core/branches/flat/src/main/java/org/jboss/cache/statetransfer/StateTransferManager.java
core/branches/flat/src/main/java/org/jboss/cache/util/FastCopyHashMap.java
core/branches/flat/src/main/java/org/jboss/cache/util/concurrent/locks/
core/branches/flat/src/main/java/org/jboss/cache/util/reflect/ReflectionUtil.java
Modified:
core/branches/flat/src/main/java/org/jboss/cache/CacheSPI_Legacy.java
core/branches/flat/src/main/java/org/jboss/cache/DataContainer.java
core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java
core/branches/flat/src/main/java/org/jboss/cache/RegionManagerImpl.java
core/branches/flat/src/main/java/org/jboss/cache/UnversionedNode.java
core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/GravitateResult.java
core/branches/flat/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java
core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/lock/IdentityLock.java
core/branches/flat/src/main/java/org/jboss/cache/lock/MVCCLockManager.java
core/branches/flat/src/main/java/org/jboss/cache/lock/NodeLock.java
core/branches/flat/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/Marshaller.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java
core/branches/flat/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessageListener.java
core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferGenerator.java
core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
core/branches/flat/src/main/java/org/jboss/cache/util/Immutables.java
Log:
Modified: core/branches/flat/src/main/java/org/jboss/cache/CacheSPI_Legacy.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/CacheSPI_Legacy.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/CacheSPI_Legacy.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -28,7 +28,7 @@
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.marshall.Marshaller;
-import org.jboss.cache.statetransfer.StateTransferManager;
+import org.jboss.starobrno.statetransfer.StateTransferManager;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.starobrno.factories.ComponentRegistry;
@@ -198,7 +198,7 @@
* From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
* {@link org.jboss.cache.factories.annotations.Inject} annotation.
*
- * @return the current {@link org.jboss.cache.statetransfer.StateTransferManager}
+ * @return the current {@link org.jboss.starobrno.statetransfer.StateTransferManager}
*/
StateTransferManager getStateTransferManager();
Modified: core/branches/flat/src/main/java/org/jboss/cache/DataContainer.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/DataContainer.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/DataContainer.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -1,27 +1,27 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.cache;
-import org.jboss.cache.marshall.NodeData;
+import org.jboss.starobrno.marshall.NodeData;
import java.util.List;
import java.util.Set;
Modified: core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -30,15 +30,16 @@
import org.jboss.cache.jmx.annotations.ManagedAttribute;
import org.jboss.cache.jmx.annotations.ManagedOperation;
import org.jboss.cache.lock.LockManager;
-import org.jboss.cache.lock.TimeoutException;
+import org.jboss.starobrno.lock.TimeoutException;
import org.jboss.cache.marshall.CommandAwareRpcDispatcher;
import org.jboss.cache.marshall.Marshaller;
import org.jboss.cache.remoting.jgroups.ChannelMessageListener;
-import org.jboss.cache.statetransfer.DefaultStateTransferManager;
+import org.jboss.starobrno.statetransfer.DefaultStateTransferManager;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.util.concurrent.ReclosableLatch;
-import org.jboss.cache.util.reflect.ReflectionUtil;
+import org.jboss.starobrno.util.ReflectionUtil;
import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.remoting.SuspectException;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.config.RuntimeConfig;
import org.jboss.starobrno.factories.ComponentRegistry;
Modified: core/branches/flat/src/main/java/org/jboss/cache/RegionManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -28,8 +28,8 @@
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.lock.LockManager;
-import org.jboss.cache.util.concurrent.locks.LockContainer;
-import org.jboss.cache.util.concurrent.locks.ReentrantLockContainer;
+import org.jboss.starobrno.util.concurrent.locks.LockContainer;
+import org.jboss.starobrno.util.concurrent.locks.ReentrantLockContainer;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.config.ConfigurationException;
Deleted: core/branches/flat/src/main/java/org/jboss/cache/SuspectException.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/SuspectException.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/SuspectException.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -1,51 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.cache;
-
-import org.jboss.starobrno.CacheException;
-
-/**
- * Thrown when a member is suspected during remote method invocation
- *
- * @author Bela Ban
- * @version $Id$
- */
-public class SuspectException extends CacheException
-{
-
- private static final long serialVersionUID = -2965599037371850141L;
-
- public SuspectException()
- {
- super();
- }
-
- public SuspectException(String msg)
- {
- super(msg);
- }
-
- public SuspectException(String msg, Throwable cause)
- {
- super(msg, cause);
- }
-}
Modified: core/branches/flat/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/UnversionedNode.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/UnversionedNode.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -24,28 +24,17 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.jboss.cache.AbstractNode.NodeFlags.*;
-import org.jboss.cache.util.FastCopyHashMap;
import org.jboss.cache.util.Immutables;
import org.jboss.cache.util.concurrent.SelfInitializingConcurrentHashMap;
import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.util.FastCopyHashMap;
import org.jboss.starobrno.marshall.MarshalledValue;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
+import java.util.*;
import java.util.Map.Entry;
-import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-/**
- * Basic data node class. Throws {@link UnsupportedOperationException} for version-specific methods like {@link #getVersion()} and
- * {@link #setVersion(org.jboss.cache.optimistic.DataVersion)}, defined in {@link org.jboss.cache.NodeSPI}.
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @since 2.0.0
- */
public class UnversionedNode<K, V> extends AbstractNode<K, V> implements InternalNode<K, V>
{
/**
Modified: core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -39,11 +39,11 @@
import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
import org.jboss.cache.commands.remote.ReplicateCommand;
-import org.jboss.cache.io.ExposedByteArrayOutputStream;
-import org.jboss.cache.lock.TimeoutException;
-import org.jboss.cache.statetransfer.StateTransferManager;
+import org.jboss.starobrno.io.ExposedByteArrayOutputStream;
+import org.jboss.starobrno.lock.TimeoutException;
+import org.jboss.starobrno.statetransfer.StateTransferManager;
import org.jboss.cache.util.concurrent.ConcurrentHashSet;
-import org.jboss.cache.util.reflect.ReflectionUtil;
+import org.jboss.starobrno.util.ReflectionUtil;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.config.BuddyReplicationConfig;
import org.jboss.starobrno.config.BuddyReplicationConfig.BuddyLocatorConfig;
Modified: core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/GravitateResult.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/GravitateResult.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/GravitateResult.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -22,7 +22,7 @@
package org.jboss.cache.buddyreplication;
import org.jboss.cache.Fqn;
-import org.jboss.cache.marshall.NodeData;
+import org.jboss.starobrno.marshall.NodeData;
import java.util.List;
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -34,7 +34,7 @@
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.commands.Visitor;
-import org.jboss.cache.marshall.NodeData;
+import org.jboss.starobrno.marshall.NodeData;
import org.jgroups.Address;
import java.util.LinkedList;
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -24,7 +24,7 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.RPCManager;
import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.cache.cluster.ReplicationQueue;
+import org.jboss.starobrno.cluster.ReplicationQueue;
import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.VisitableCommand;
@@ -142,7 +142,7 @@
if (!sync && replicationQueue != null && !usingBuddyReplication)
{
if (log.isDebugEnabled()) log.debug("Putting call " + call + " on the replication queue.");
- replicationQueue.add(commandsFactory.buildReplicateCommand(call));
+// replicationQueue.add(commandsFactory.buildReplicateCommand(call));
}
else
{
Modified: core/branches/flat/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -54,7 +54,7 @@
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.marshall.Marshaller;
-import org.jboss.cache.statetransfer.StateTransferManager;
+import org.jboss.starobrno.statetransfer.StateTransferManager;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.cache.util.Immutables;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -31,9 +31,9 @@
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.marshall.Marshaller;
-import org.jboss.cache.marshall.NodeData;
-import org.jboss.cache.marshall.NodeDataExceptionMarker;
-import org.jboss.cache.marshall.NodeDataMarker;
+import org.jboss.starobrno.marshall.NodeData;
+import org.jboss.starobrno.marshall.NodeDataMarker;
+import org.jboss.starobrno.marshall.NodeDataExceptionMarker;
import org.jboss.cache.util.Immutables;
import org.jboss.starobrno.CacheException;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -25,7 +25,7 @@
import org.apache.commons.logging.Log;
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
-import org.jboss.cache.io.ByteBuffer;
+import org.jboss.starobrno.io.ByteBuffer;
import org.jboss.cache.lock.StripedLock;
import org.jboss.cache.util.Util;
import org.jboss.starobrno.config.CacheLoaderConfig;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoader.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoader.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -243,7 +243,7 @@
*
* @param os ObjectOutputStream to write state
* @see AbstractCacheLoader#loadEntireState(ObjectOutputStream)
- * @see org.jboss.cache.marshall.NodeData
+ * @see org.jboss.starobrno.marshall.NodeData
*/
void loadEntireState(ObjectOutputStream os) throws Exception;
@@ -263,7 +263,7 @@
*
* @param is ObjectInputStream to read state
* @see AbstractCacheLoader#storeEntireState(ObjectInputStream)
- * @see org.jboss.cache.marshall.NodeData
+ * @see org.jboss.starobrno.marshall.NodeData
*/
void storeEntireState(ObjectInputStream is) throws Exception;
@@ -288,7 +288,7 @@
* @param os ObjectOutputStream to write state
* @see AbstractCacheLoader#loadState(Fqn,ObjectOutputStream)
* @see org.jboss.cache.Region#activate()
- * @see org.jboss.cache.marshall.NodeData
+ * @see org.jboss.starobrno.marshall.NodeData
*/
void loadState(Fqn subtree, ObjectOutputStream os) throws Exception;
@@ -324,7 +324,7 @@
* Fqns should be altered to make them children of
* <code>subtree</code> before they are persisted.
* @see AbstractCacheLoader#storeState(Fqn,ObjectInputStream)
- * @see org.jboss.cache.marshall.NodeData
+ * @see org.jboss.starobrno.marshall.NodeData
*/
void storeState(Fqn subtree, ObjectInputStream is) throws Exception;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -26,7 +26,7 @@
import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.Fqn;
import org.jboss.cache.RegionManager;
-import org.jboss.cache.util.reflect.ReflectionUtil;
+import org.jboss.starobrno.util.ReflectionUtil;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.config.CacheLoaderConfig;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -25,7 +25,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.marshall.NodeData;
+import org.jboss.starobrno.marshall.NodeData;
import org.jboss.starobrno.config.CacheLoaderConfig;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -44,7 +44,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.loader.AbstractCacheLoader;
-import org.jboss.cache.util.reflect.ReflectionUtil;
+import org.jboss.starobrno.util.ReflectionUtil;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.io.File;
Modified: core/branches/flat/src/main/java/org/jboss/cache/lock/IdentityLock.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/lock/IdentityLock.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/lock/IdentityLock.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -26,6 +26,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
+import org.jboss.starobrno.lock.TimeoutException;
import java.util.ArrayList;
import java.util.Collection;
Modified: core/branches/flat/src/main/java/org/jboss/cache/lock/MVCCLockManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/lock/MVCCLockManager.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/lock/MVCCLockManager.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -32,10 +32,10 @@
import org.jboss.cache.NodeSPI;
import org.jboss.cache.invocation.InvocationContextContainer;
import static org.jboss.cache.lock.LockType.READ;
-import org.jboss.cache.util.concurrent.locks.LockContainer;
-import org.jboss.cache.util.concurrent.locks.OwnableReentrantLock;
-import org.jboss.cache.util.concurrent.locks.OwnableReentrantLockContainer;
-import org.jboss.cache.util.concurrent.locks.ReentrantLockContainer;
+import org.jboss.starobrno.util.concurrent.locks.LockContainer;
+import org.jboss.starobrno.util.concurrent.locks.OwnableReentrantLock;
+import org.jboss.starobrno.util.concurrent.locks.OwnableReentrantLockContainer;
+import org.jboss.starobrno.util.concurrent.locks.ReentrantLockContainer;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.Start;
@@ -59,12 +59,12 @@
* READ lock. JBoss Cache's MVCC design doesn't use read locks at all.
* <p/>
* The concept of lock owners is implicit in this implementation and any owners passed in as parameters (where required)
- * will be ignored. See {@link org.jboss.cache.util.concurrent.locks.OwnableReentrantLock} for details on how ownership
+ * will be ignored. See {@link org.jboss.starobrno.util.concurrent.locks.OwnableReentrantLock} for details on how ownership
* is determined.
* <p/>
*
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @see org.jboss.cache.util.concurrent.locks.OwnableReentrantLock
+ * @see org.jboss.starobrno.util.concurrent.locks.OwnableReentrantLock
* @since 3.0
*/
public class MVCCLockManager extends FqnLockManager
Modified: core/branches/flat/src/main/java/org/jboss/cache/lock/NodeLock.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/lock/NodeLock.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/lock/NodeLock.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -22,6 +22,7 @@
package org.jboss.cache.lock;
import org.jboss.cache.Fqn;
+import org.jboss.starobrno.lock.TimeoutException;
import java.util.Collection;
import java.util.Set;
Modified: core/branches/flat/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -31,6 +31,7 @@
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.lock.TimeoutException;
import java.util.List;
Deleted: core/branches/flat/src/main/java/org/jboss/cache/lock/TimeoutException.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/lock/TimeoutException.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/lock/TimeoutException.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -1,66 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.cache.lock;
-
-import org.jboss.starobrno.CacheException;
-
-
-/**
- * Thrown when a timeout occurred. used by operations with timeouts, e.g. lock
- * acquisition, or waiting for responses from all members.
- *
- * @author <a href="mailto:bela@jboss.org">Bela Ban</a>.
- * @version $Revision$
- * <p/>
- * <p><b>Revisions:</b>
- * <p/>
- * <p>Dec 28 2002 Bela Ban: first implementation
- */
-public class TimeoutException extends CacheException
-{
-
- /**
- * The serialVersionUID
- */
- private static final long serialVersionUID = -8096787619908687038L;
-
- public TimeoutException()
- {
- super();
- }
-
- public TimeoutException(String msg)
- {
- super(msg);
- }
-
- public TimeoutException(String msg, Throwable cause)
- {
- super(msg, cause);
- }
-
- @Override
- public String toString()
- {
- return super.toString();
- }
-}
Modified: core/branches/flat/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -25,7 +25,7 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.RegionManager;
-import org.jboss.cache.io.ByteBuffer;
+import org.jboss.starobrno.io.ByteBuffer;
import org.jboss.starobrno.commands.ReplicableCommand;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.factories.annotations.Inject;
Modified: core/branches/flat/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -25,33 +25,19 @@
import org.jboss.cache.Region;
import org.jboss.cache.Region.Status;
import org.jboss.cache.buddyreplication.GravitateResult;
-import org.jboss.cache.util.FastCopyHashMap;
import org.jboss.cache.util.Immutables;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.commands.CommandsFactory;
import org.jboss.starobrno.commands.ReplicableCommand;
import org.jboss.starobrno.factories.annotations.Inject;
-import org.jboss.starobrno.marshall.MarshalledValue;
+import org.jboss.starobrno.marshall.*;
import org.jboss.starobrno.transaction.GlobalTransaction;
+import org.jboss.starobrno.util.FastCopyHashMap;
import org.jgroups.Address;
import org.jgroups.stack.IpAddress;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.IdentityHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
+import java.io.*;
+import java.util.*;
/**
* An enhanced marshaller for RPC calls between CacheImpl instances.
Modified: core/branches/flat/src/main/java/org/jboss/cache/marshall/Marshaller.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/Marshaller.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/Marshaller.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -22,7 +22,7 @@
package org.jboss.cache.marshall;
import org.jboss.cache.Fqn;
-import org.jboss.cache.io.ByteBuffer;
+import org.jboss.starobrno.io.ByteBuffer;
import org.jgroups.blocks.RpcDispatcher;
import java.io.InputStream;
@@ -48,7 +48,7 @@
* is used to marshall {@link org.jboss.cache.commands.ReplicableCommand}s, their parameters and their response values.
* <p/>
* The interface is also used by the {@link org.jboss.cache.loader.CacheLoader} framework to efficiently serialize data to be persisted, as well as
- * the {@link org.jboss.cache.statetransfer.StateTransferManager} when serializing the cache for transferring state en-masse.
+ * the {@link org.jboss.starobrno.statetransfer.StateTransferManager} when serializing the cache for transferring state en-masse.
*
* @author <a href="mailto://manik@jboss.org">Manik Surtani</a>
* @since 2.0.0
Deleted: core/branches/flat/src/main/java/org/jboss/cache/marshall/NodeData.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/NodeData.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/NodeData.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -1,145 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.cache.marshall;
-
-import org.jboss.cache.Fqn;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Serializable representation of the data of a node (FQN and attributes)
- *
- * @author Bela Ban
- * @version $Id$
- */
-// TODO: 3.0.0: remove Externalizable and rely on the CacheMarshaller.
-public class NodeData<K, V> implements Externalizable
-{
- private Fqn fqn = null;
- private Map<K, V> attrs = null;
-
- static final long serialVersionUID = -7571995794010294485L;
-
- public NodeData()
- {
- }
-
- public NodeData(Fqn fqn)
- {
- this.fqn = fqn;
- }
-
- public NodeData(Fqn fqn, Map<K, V> attrs, boolean mapSafe)
- {
- this.fqn = fqn;
- if (mapSafe || attrs == null)
- this.attrs = attrs;
- else
- this.attrs = new HashMap<K, V>(attrs);
- }
-
- public NodeData(String fqn, Map<K, V> attrs, boolean mapSafe)
- {
- this(Fqn.fromString(fqn), attrs, mapSafe);
- }
-
- public Map<K, V> getAttributes()
- {
- return attrs;
- }
-
- public Fqn getFqn()
- {
- return fqn;
- }
-
- public boolean isMarker()
- {
- return false;
- }
-
- public boolean isExceptionMarker()
- {
- return false;
- }
-
- // TODO: 3.0.0: Remove and replace with marshallNodeData/unmarshallNodeData methods in the CacheMarshaller so that we can use the same marshalling framework for Fqns.
- public void writeExternal(ObjectOutput out) throws IOException
- {
- out.writeObject(fqn);
- if (attrs != null)
- {
- out.writeBoolean(true);
- out.writeObject(attrs);
- }
- else
- {
- out.writeBoolean(false);
- }
- }
-
- // TODO: 3.0.0: Remove in and replace with marshallNodeData/unmarshallNodeData methods in the CacheMarshaller so that we can use the same marshalling framework for Fqns.
- @SuppressWarnings("unchecked")
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- {
- fqn = (Fqn) in.readObject();
- if (in.readBoolean())
- {
- attrs = (Map<K, V>) in.readObject();
- }
- }
-
- @Override
- public String toString()
- {
- return "NodeData {fqn: " + fqn + ", attrs=" + attrs + "}";
- }
-
-
- @Override
- public boolean equals(Object o)
- {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- NodeData nodeData = (NodeData) o;
-
- if (attrs != null ? !attrs.equals(nodeData.attrs) : nodeData.attrs != null) return false;
- if (fqn != null ? !fqn.equals(nodeData.fqn) : nodeData.fqn != null) return false;
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- int result;
- result = (fqn != null ? fqn.hashCode() : 0);
- result = 31 * result + (attrs != null ? attrs.hashCode() : 0);
- return result;
- }
-}
Deleted: core/branches/flat/src/main/java/org/jboss/cache/marshall/NodeDataExceptionMarker.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/NodeDataExceptionMarker.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/NodeDataExceptionMarker.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -1,83 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.cache.marshall;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-
-public class NodeDataExceptionMarker extends NodeData
-{
-
- private static final long serialVersionUID = 240199474174502551L;
- private Throwable cause;
- private Object cacheNodeIdentity;
-
- public NodeDataExceptionMarker()
- {
- super();
- }
-
- public NodeDataExceptionMarker(Throwable t, Object node)
- {
- cause = t;
- cacheNodeIdentity = node;
- }
-
- public Throwable getCause()
- {
- return cause;
- }
-
- public Object getCacheNodeIdentity()
- {
- return cacheNodeIdentity;
- }
-
- @Override
- public boolean isExceptionMarker()
- {
- return true;
- }
-
- @Override
- public void writeExternal(ObjectOutput out) throws IOException
- {
- super.writeExternal(out);
- out.writeObject(cause);
- out.writeObject(cacheNodeIdentity);
- }
-
- @Override
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- {
- super.readExternal(in);
- cause = (Throwable) in.readObject();
- cacheNodeIdentity = in.readObject();
- }
-
- @Override
- public String toString()
- {
- return "NodeDataExceptionMarker";
- }
-}
Deleted: core/branches/flat/src/main/java/org/jboss/cache/marshall/NodeDataMarker.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/NodeDataMarker.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/NodeDataMarker.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.cache.marshall;
-
-public class NodeDataMarker extends NodeData
-{
-
- private static final long serialVersionUID = 4851793846346021014L;
-
- @Override
- public boolean isMarker()
- {
- return true;
- }
-
- @Override
- public String toString()
- {
- return "NodeDataMarker";
- }
-}
Deleted: core/branches/flat/src/main/java/org/jboss/cache/marshall/UnmarshalledReferences.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/UnmarshalledReferences.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/UnmarshalledReferences.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -1,73 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.cache.marshall;
-
-import org.jboss.starobrno.CacheException;
-
-import java.util.ArrayList;
-
-/**
- * An efficient array-based list of referenced objects, using the reference id as a subscript for the array.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- */
-public class UnmarshalledReferences
-{
- private final ArrayList<Object> referencedObjects = new ArrayList<Object>();
-
- /**
- * Retrieves an object referenced by an id
- *
- * @param ref reference
- * @return object
- */
- public Object getReferencedObject(int ref)
- {
- if (ref >= referencedObjects.size())
- throw new CacheException("Attempting to look up a ref that hasn't been inserted yet");
- return referencedObjects.get(ref);
- }
-
- /**
- * Adds a referenced object to the list of references
- *
- * @param ref reference id
- * @param o object
- */
- public void putReferencedObject(int ref, Object o)
- {
- int sz = referencedObjects.size();
- // if we are not adding the object to the end of the list, make sure we use a specific position
- if (ref < sz)
- {
- referencedObjects.set(ref, o);
- return;
- }
- else if (ref > sz)
- {
- // if we are adding the reference to a position beyond the end of the list, make sure we expand the list first.
- // this can happen, weirdly enough, since marshallObject() can be called recursively, such as from marshallFqn().
- for (int i = sz; i < ref; i++) referencedObjects.add(null);
- }
- referencedObjects.add(o);
- }
-}
Modified: core/branches/flat/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -24,8 +24,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.io.ByteBuffer;
-import org.jboss.cache.io.ExposedByteArrayOutputStream;
+import org.jboss.starobrno.io.ByteBuffer;
+import org.jboss.starobrno.io.ExposedByteArrayOutputStream;
import org.jboss.cache.util.Util;
import org.jboss.starobrno.factories.ComponentRegistry;
import org.jboss.starobrno.factories.annotations.Inject;
@@ -76,7 +76,7 @@
String replVersionString = configuration.getReplVersionString();
// this will cause the correct marshaller to be created and put in the map of marshallers
- defaultMarshaller = configuration.getMarshaller();
+// defaultMarshaller = configuration.getMarshaller();
if (defaultMarshaller == null)
{
String marshallerClass = configuration.getMarshallerClass();
Modified: core/branches/flat/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessageListener.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessageListener.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessageListener.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -24,9 +24,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.io.ExposedByteArrayOutputStream;
-import org.jboss.cache.statetransfer.DefaultStateTransferManager;
-import org.jboss.cache.statetransfer.StateTransferManager;
+import org.jboss.starobrno.io.ExposedByteArrayOutputStream;
+import org.jboss.starobrno.statetransfer.DefaultStateTransferManager;
+import org.jboss.starobrno.statetransfer.StateTransferManager;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.factories.annotations.Inject;
Modified: core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferGenerator.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferGenerator.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferGenerator.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -29,8 +29,9 @@
import org.jboss.cache.Node;
import org.jboss.cache.Version;
import org.jboss.cache.loader.CacheLoader;
-import org.jboss.cache.marshall.NodeData;
-import org.jboss.cache.marshall.NodeDataExceptionMarker;
+import org.jboss.starobrno.marshall.NodeData;
+import org.jboss.starobrno.marshall.NodeDataExceptionMarker;
+import org.jboss.starobrno.statetransfer.DefaultStateTransferManager;
import java.io.IOException;
import java.io.ObjectOutputStream;
Modified: core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -32,10 +32,10 @@
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
-import org.jboss.cache.marshall.NodeData;
-import org.jboss.cache.marshall.NodeDataExceptionMarker;
-import org.jboss.cache.marshall.NodeDataMarker;
import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.marshall.NodeData;
+import org.jboss.starobrno.marshall.NodeDataMarker;
+import org.jboss.starobrno.marshall.NodeDataExceptionMarker;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.Start;
Deleted: core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferManager.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferManager.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -1,200 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.cache.statetransfer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.RegionManager;
-import org.jboss.cache.loader.CacheLoaderManager;
-import org.jboss.cache.marshall.Marshaller;
-import org.jboss.cache.marshall.NodeData;
-import org.jboss.cache.marshall.NodeDataMarker;
-import org.jboss.starobrno.CacheSPI;
-import org.jboss.starobrno.config.Configuration;
-import org.jboss.starobrno.factories.annotations.Inject;
-import org.jboss.starobrno.factories.annotations.Start;
-
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-
-/**
- * The default state transfer manager to be used when using MVCC locking.
- */
-public class DefaultStateTransferManager implements StateTransferManager
-{
- protected final static Log log = LogFactory.getLog(DefaultStateTransferManager.class);
- protected static final boolean trace = log.isTraceEnabled();
-
- public static final NodeData STREAMING_DELIMITER_NODE = new NodeDataMarker();
-
- public static final String PARTIAL_STATE_DELIMITER = "_PARTIAL_STATE_DELIMITER";
-
- protected CacheSPI cache;
- protected Marshaller marshaller;
- protected RegionManager regionManager;
- protected Configuration configuration;
- private CacheLoaderManager cacheLoaderManager;
- boolean fetchTransientState;
- boolean fetchPersistentState;
- protected long stateRetrievalTimeout;
- protected StateTransferIntegrator integrator;
- protected StateTransferGenerator generator;
-
-
- @Inject
- public void injectDependencies(CacheSPI cache, Marshaller marshaller, RegionManager regionManager, Configuration configuration, CacheLoaderManager cacheLoaderManager, StateTransferIntegrator integrator, StateTransferGenerator generator)
- {
- this.cache = cache;
- this.regionManager = regionManager;
- this.marshaller = marshaller;
- this.configuration = configuration;
- this.cacheLoaderManager = cacheLoaderManager;
- this.integrator = integrator;
- this.generator = generator;
- }
-
- @Start(priority = 14)
- public void start()
- {
- fetchTransientState = configuration.isFetchInMemoryState();
- fetchPersistentState = cacheLoaderManager != null && cacheLoaderManager.isFetchPersistentState();
- stateRetrievalTimeout = configuration.getStateRetrievalTimeout();
- }
-
- public void getState(ObjectOutputStream out, Fqn fqn, long timeout, boolean force, boolean suppressErrors) throws Exception
- {
- throw new UnsupportedOperationException("Implement me properly!");
- /*
-
- // can't give state for regions currently being activated/inactivated
- boolean canProvideState = (!regionManager.isInactive(fqn) && cache.peek(fqn, false) != null);
- if (trace) log.trace("Can provide state? " + canProvideState);
- if (canProvideState && (fetchPersistentState || fetchTransientState))
- {
- marshaller.objectToObjectStream(true, out);
- long startTime = System.currentTimeMillis();
- InternalNode subtreeRoot = fqn.isRoot() ? cache.getRoot().getDelegationTarget() : cache.getNode(fqn).getDelegationTarget();
-
- // we don't need READ locks for MVCC based state transfer!
- if (log.isDebugEnabled())
- log.debug("Generating in-memory (transient) state for subtree " + fqn);
-
- generator.generateState(out, subtreeRoot, fetchTransientState, fetchPersistentState, suppressErrors);
-
- if (log.isDebugEnabled())
- log.debug("Successfully generated state in " + (System.currentTimeMillis() - startTime) + " msec");
- }
- else
- {
- marshaller.objectToObjectStream(false, out);
- Exception e = null;
- if (!canProvideState)
- {
- String exceptionMessage = "Cache instance at " + cache.getLocalAddress() + " cannot provide state for fqn " + fqn + ".";
-
- if (regionManager.isInactive(fqn))
- {
- exceptionMessage += " Region for fqn " + fqn + " is inactive.";
- e = new InactiveRegionException(exceptionMessage);
- }
- // this is not really an exception. Just provide empty state. The exception is just a signal. Yes, lousy. - JBCACHE-1349
- if (cache.peek(fqn, false, false) == null)
- {
- e = new RegionEmptyException();
- }
- }
- if (!fetchPersistentState && !fetchTransientState)
- {
- e = new CacheException("Cache instance at " + cache.getLocalAddress() + " is not configured to provide state");
- }
- marshaller.objectToObjectStream(e, out);
- if (e != null) throw e;
- }
- */
- }
-
- public void setState(ObjectInputStream in, Fqn targetRoot) throws Exception
- {
- throw new UnsupportedOperationException("fix me!");
- /*
- cache.getInvocationContext().getOptionOverrides().setSkipCacheStatusCheck(true);
- NodeSPI target = cache.getNode(targetRoot);
- if (target == null)
- {
- // Create the integration root, but do not replicate
- cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
-
- //needed for BR state transfers
- cache.getInvocationContext().getOptionOverrides().setSkipCacheStatusCheck(true);
- cache.put(targetRoot, null);
- cache.getInvocationContext().getOptionOverrides().setSkipCacheStatusCheck(true);
- target = cache.getNode(targetRoot);
- }
- Object o = marshaller.objectFromObjectStream(in);
- Boolean hasState = (Boolean) o;
- if (hasState)
- {
- setState(in, target);
- }
- else
- {
- throw new CacheException("Cache instance at " + cache.getLocalAddress()
- + " cannot integrate state since state provider could not provide state due to " + marshaller.objectFromObjectStream(in));
- }
- */
- }
-
- /**
- * Set the portion of the cache rooted in <code>targetRoot</code>
- * to match the given state. Updates the contents of <code>targetRoot</code>
- * to reflect those in <code>new_state</code>.
- * <p/>
- * <strong>NOTE:</strong> This method performs no locking of nodes; it
- * is up to the caller to lock <code>targetRoot</code> before calling
- * this method.
- *
- * @param state a serialized byte[][] array where element 0 is the
- * transient state (or null) , and element 1 is the
- * persistent state (or null)
- * @param targetRoot node into which the state should be integrated
- */
- protected void setState(ObjectInputStream state, NodeSPI targetRoot) throws Exception
- {
- long startTime = System.currentTimeMillis();
- /*
- * Vladimir/Manik/Brian (Dec 7,2006)
- *
- * integrator.integrateState(in,targetRoot, cl) will call cache.put for each
- * node read from stream. Having option override below allows nodes read
- * to be directly stored into a tree since we bypass interceptor chain.
- *
- */
- if (log.isDebugEnabled())
- log.debug("starting state integration at node " + targetRoot + ". Fetch Persistent State = " + fetchPersistentState);
- integrator.integrateState(state, targetRoot.getDelegationTarget(), targetRoot.getFqn(), fetchPersistentState);
-
- if (log.isDebugEnabled())
- log.debug("successfully integrated state in " + (System.currentTimeMillis() - startTime) + " msec");
- }
-}
Deleted: core/branches/flat/src/main/java/org/jboss/cache/statetransfer/StateTransferManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/statetransfer/StateTransferManager.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/statetransfer/StateTransferManager.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -1,79 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.cache.statetransfer;
-
-import org.jboss.cache.Fqn;
-
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-
-/**
- * This interface handles requests to generate or integrate state from neighbouring caches in a cluster.
- * <p/>
- * This has existed prior to 3.0.0 as a concrete class. An interface was introduced in 3.0.0 to provide more flexibility
- * in state transfer implementations.
- * <p/>
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @since 3.0
- */
-public interface StateTransferManager
-{
- /**
- * Writes the state for the portion of the tree named by <code>fqn</code> to
- * the provided OutputStream.
- * <p/>
- * <p/>
- *
- * @param out stream to write state to
- * @param fqn Fqn indicating the uppermost node in the
- * portion of the tree whose state should be returned.
- * @param timeout max number of millis this method should wait to acquire
- * any locks, if necessary, on the nodes being transferred
- * @param force if locks are needed and cannot be acquired after
- * <code>timeout</code> millis, should the lock acquisition
- * be forced, and any existing transactions holding locks
- * on the nodes be rolled back?
- * @param suppressErrors if true, all exceptions are logged but not propagated.
- * @throws Exception in event of error
- */
- void getState(ObjectOutputStream out, Fqn fqn, long timeout, boolean force, boolean suppressErrors) throws Exception;
-
- /**
- * Set the portion of the cache rooted in <code>targetRoot</code>
- * to match the given state. Updates the contents of <code>targetRoot</code>
- * to reflect those in <code>new_state</code>.
- * <p/>
- * <strong>NOTE:</strong> This method performs no locking of nodes; it
- * is up to the caller to lock <code>targetRoot</code> before calling
- * this method.
- * <p/>
- * This method will use any {@link ClassLoader} needed as defined by the active {@link org.jboss.cache.Region}
- * in the {@link org.jboss.cache.RegionManager}, pertaining to the targetRoot passed in.
- *
- * @param in an input stream containing the state
- * @param targetRoot fqn of the node into which the state should be integrated
- * @throws Exception In event of error
- */
- void setState(ObjectInputStream in, Fqn targetRoot) throws Exception;
-
-}
Deleted: core/branches/flat/src/main/java/org/jboss/cache/util/FastCopyHashMap.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/util/FastCopyHashMap.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/util/FastCopyHashMap.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -1,836 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.cache.util;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.AbstractCollection;
-import java.util.AbstractMap;
-import java.util.AbstractSet;
-import java.util.Collection;
-import java.util.ConcurrentModificationException;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-/**
- * A HashMap that is optimized for fast shallow copies.
- *
- * @author Jason T. Greene
- */
-public class FastCopyHashMap<K, V> extends AbstractMap<K, V> implements Map<K, V>, Cloneable, Serializable
-{
- /**
- * Marks null keys.
- */
- private static final Object NULL = new Object();
-
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 10929568968762L;
-
- /**
- * Same default as HashMap, must be a power of 2
- */
- private static final int DEFAULT_CAPACITY = 8;
-
- /**
- * MAX_INT - 1
- */
- private static final int MAXIMUM_CAPACITY = 1 << 30;
-
- /**
- * 67%, just like IdentityHashMap
- */
- private static final float DEFAULT_LOAD_FACTOR = 0.67f;
-
- /**
- * The open-addressed table
- */
- private transient Entry<K, V>[] table;
-
- /**
- * The current number of key-value pairs
- */
- private transient int size;
-
- /**
- * The next resize
- */
- private transient int threshold;
-
- /**
- * The user defined load factor which defines when to resize
- */
- private final float loadFactor;
-
- /**
- * Counter used to detect changes made outside of an iterator
- */
- private transient int modCount;
-
- // Cached views
- private transient KeySet keySet;
- private transient Values values;
- private transient EntrySet entrySet;
-
- public FastCopyHashMap(int initialCapacity, float loadFactor)
- {
- if (initialCapacity < 0)
- throw new IllegalArgumentException("Can not have a negative size table!");
-
- if (initialCapacity > MAXIMUM_CAPACITY)
- initialCapacity = MAXIMUM_CAPACITY;
-
- if (!(loadFactor > 0F && loadFactor <= 1F))
- throw new IllegalArgumentException("Load factor must be greater than 0 and less than or equal to 1");
-
- this.loadFactor = loadFactor;
- init(initialCapacity, loadFactor);
- }
-
- @SuppressWarnings("unchecked")
- public FastCopyHashMap(Map<? extends K, ? extends V> map)
- {
- if (map instanceof FastCopyHashMap)
- {
- FastCopyHashMap<? extends K, ? extends V> fast = (FastCopyHashMap<? extends K, ? extends V>) map;
- this.table = (Entry<K, V>[]) fast.table.clone();
- this.loadFactor = fast.loadFactor;
- this.size = fast.size;
- this.threshold = fast.threshold;
- }
- else
- {
- this.loadFactor = DEFAULT_LOAD_FACTOR;
- init(map.size(), this.loadFactor);
- putAll(map);
- }
- }
-
- @SuppressWarnings("unchecked")
- private void init(int initialCapacity, float loadFactor)
- {
- int c = 1;
- for (; c < initialCapacity; c <<= 1) ;
-
- this.table = (Entry<K, V>[]) new Entry[c];
-
- threshold = (int) (c * loadFactor);
- }
-
- public FastCopyHashMap(int initialCapacity)
- {
- this(initialCapacity, DEFAULT_LOAD_FACTOR);
- }
-
- public FastCopyHashMap()
- {
- this(DEFAULT_CAPACITY);
- }
-
- // The normal bit spreader...
- private static final int hash(Object key)
- {
- int h = key.hashCode();
- h ^= (h >>> 20) ^ (h >>> 12);
- return h ^ (h >>> 7) ^ (h >>> 4);
- }
-
- @SuppressWarnings("unchecked")
- private static final <K> K maskNull(K key)
- {
- return key == null ? (K) NULL : key;
- }
-
- private static final <K> K unmaskNull(K key)
- {
- return key == NULL ? null : key;
- }
-
- private int nextIndex(int index, int length)
- {
- index = (index >= length - 1) ? 0 : index + 1;
- return index;
- }
-
- private static final boolean eq(Object o1, Object o2)
- {
- return o1 == o2 || (o1 != null && o1.equals(o2));
- }
-
- private static final int index(int hashCode, int length)
- {
- return hashCode & (length - 1);
- }
-
- public int size()
- {
- return size;
- }
-
- public boolean isEmpty()
- {
- return size == 0;
- }
-
- public V get(Object key)
- {
- key = maskNull(key);
-
- int hash = hash(key);
- int length = table.length;
- int index = index(hash, length);
-
- for (; ;)
- {
- Entry<K, V> e = table[index];
- if (e == null)
- return null;
-
- if (e.hash == hash && eq(key, e.key))
- return e.value;
-
- index = nextIndex(index, length);
- }
- }
-
- public boolean containsKey(Object key)
- {
- key = maskNull(key);
-
- int hash = hash(key);
- int length = table.length;
- int index = index(hash, length);
-
- for (; ;)
- {
- Entry<K, V> e = table[index];
- if (e == null)
- return false;
-
- if (e.hash == hash && eq(key, e.key))
- return true;
-
- index = nextIndex(index, length);
- }
- }
-
- public boolean containsValue(Object value)
- {
- for (Entry<K, V> e : table)
- if (e != null && eq(value, e.value))
- return true;
-
- return false;
- }
-
- public V put(K key, V value)
- {
- key = maskNull(key);
-
- Entry<K, V>[] table = this.table;
- int hash = hash(key);
- int length = table.length;
- int start = index(hash, length);
- int index = start;
-
-
- for (; ;)
- {
- Entry<K, V> e = table[index];
- if (e == null)
- break;
-
- if (e.hash == hash && eq(key, e.key))
- {
- table[index] = new Entry<K, V>(e.key, e.hash, value);
- return e.value;
- }
-
- index = nextIndex(index, length);
- if (index == start)
- throw new IllegalStateException("Table is full!");
- }
-
- modCount++;
- table[index] = new Entry<K, V>(key, hash, value);
- if (++size >= threshold)
- resize(length);
-
- return null;
- }
-
-
- @SuppressWarnings("unchecked")
- private void resize(int from)
- {
- int newLength = from << 1;
-
- // Can't get any bigger
- if (newLength > MAXIMUM_CAPACITY || newLength <= from)
- return;
-
- Entry<K, V>[] newTable = new Entry[newLength];
- Entry<K, V>[] old = table;
-
- for (Entry<K, V> e : old)
- {
- if (e == null)
- continue;
-
- int index = index(e.hash, newLength);
- while (newTable[index] != null)
- index = nextIndex(index, newLength);
-
- newTable[index] = e;
- }
-
- threshold = (int) (loadFactor * newLength);
- table = newTable;
- }
-
- public void putAll(Map<? extends K, ? extends V> map)
- {
- int size = map.size();
- if (size == 0)
- return;
-
- if (size > threshold)
- {
- if (size > MAXIMUM_CAPACITY)
- size = MAXIMUM_CAPACITY;
-
- int length = table.length;
- for (; length < size; length <<= 1) ;
-
- resize(length);
- }
-
- for (Map.Entry<? extends K, ? extends V> e : map.entrySet())
- put(e.getKey(), e.getValue());
- }
-
- public V remove(Object key)
- {
- key = maskNull(key);
-
- Entry<K, V>[] table = this.table;
- int length = table.length;
- int hash = hash(key);
- int start = index(hash, length);
-
- for (int index = start; ;)
- {
- Entry<K, V> e = table[index];
- if (e == null)
- return null;
-
- if (e.hash == hash && eq(key, e.key))
- {
- table[index] = null;
- relocate(index);
- modCount++;
- size--;
- return e.value;
- }
-
- index = nextIndex(index, length);
- if (index == start)
- return null;
- }
-
-
- }
-
- private void relocate(int start)
- {
- Entry<K, V>[] table = this.table;
- int length = table.length;
- int current = nextIndex(start, length);
-
- for (; ;)
- {
- Entry<K, V> e = table[current];
- if (e == null)
- return;
-
- // A Doug Lea variant of Knuth's Section 6.4 Algorithm R.
- // This provides a non-recursive method of relocating
- // entries to their optimal positions once a gap is created.
- int prefer = index(e.hash, length);
- if ((current < prefer && (prefer <= start || start <= current))
- || (prefer <= start && start <= current))
- {
- table[start] = e;
- table[current] = null;
- start = current;
- }
-
- current = nextIndex(current, length);
- }
- }
-
- public void clear()
- {
- modCount++;
- Entry<K, V>[] table = this.table;
- for (int i = 0; i < table.length; i++)
- table[i] = null;
-
- size = 0;
- }
-
- @SuppressWarnings("unchecked")
- public Object clone()
- {
- try
- {
- FastCopyHashMap<K, V> clone = (FastCopyHashMap<K, V>) super.clone();
- clone.table = table.clone();
- clone.entrySet = null;
- clone.values = null;
- clone.keySet = null;
- return clone;
- }
- catch (CloneNotSupportedException e)
- {
- // should never happen
- throw new IllegalStateException(e);
- }
- }
-
- public void printDebugStats()
- {
- int optimal = 0;
- int total = 0;
- int totalSkew = 0;
- int maxSkew = 0;
- for (int i = 0; i < table.length; i++)
- {
- Entry<K, V> e = table[i];
- if (e != null)
- {
-
- total++;
- int target = index(e.hash, table.length);
- if (i == target)
- optimal++;
- else
- {
- int skew = Math.abs(i - target);
- if (skew > maxSkew) maxSkew = skew;
- totalSkew += skew;
- }
-
- }
- }
-
- System.out.println(" Size: " + size);
- System.out.println(" Real Size: " + total);
- System.out.println(" Optimal: " + optimal + " (" + (float) optimal * 100 / total + "%)");
- System.out.println(" Average Distnce: " + ((float) totalSkew / (total - optimal)));
- System.out.println(" Max Distance: " + maxSkew);
- }
-
- public Set<Map.Entry<K, V>> entrySet()
- {
- if (entrySet == null)
- entrySet = new EntrySet();
-
- return entrySet;
- }
-
- public Set<K> keySet()
- {
- if (keySet == null)
- keySet = new KeySet();
-
- return keySet;
- }
-
- public Collection<V> values()
- {
- if (values == null)
- values = new Values();
-
- return values;
- }
-
- @SuppressWarnings("unchecked")
- private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException
- {
- s.defaultReadObject();
-
- int size = s.readInt();
-
- init(size, loadFactor);
-
- for (int i = 0; i < size; i++)
- {
- K key = (K) s.readObject();
- V value = (V) s.readObject();
- putForCreate(key, value);
- }
- }
-
- @SuppressWarnings("unchecked")
- private void putForCreate(K key, V value)
- {
- key = maskNull(key);
-
- Entry<K, V>[] table = this.table;
- int hash = hash(key);
- int length = table.length;
- int index = index(hash, length);
-
- Entry<K, V> e = table[index];
- while (e != null)
- {
- index = nextIndex(index, length);
- e = table[index];
- }
-
- table[index] = new Entry<K, V>(key, hash, value);
- }
-
- private void writeObject(java.io.ObjectOutputStream s) throws IOException
- {
- s.defaultWriteObject();
- s.writeInt(size);
-
- for (Entry<K, V> e : table)
- {
- if (e != null)
- {
- s.writeObject(unmaskNull(e.key));
- s.writeObject(e.value);
- }
- }
- }
-
- private static final class Entry<K, V>
- {
- final K key;
- final int hash;
- final V value;
-
- Entry(K key, int hash, V value)
- {
- this.key = key;
- this.hash = hash;
- this.value = value;
- }
- }
-
- private abstract class FasyCopyHashMapIterator<E> implements Iterator<E>
- {
- private int next = 0;
- private int expectedCount = modCount;
- private int current = -1;
- private boolean hasNext;
- Entry<K, V> table[] = FastCopyHashMap.this.table;
-
- public boolean hasNext()
- {
- if (hasNext == true)
- return true;
-
- Entry<K, V> table[] = this.table;
- for (int i = next; i < table.length; i++)
- {
- if (table[i] != null)
- {
- next = i;
- return hasNext = true;
- }
- }
-
- next = table.length;
- return false;
- }
-
- protected Entry<K, V> nextEntry()
- {
- if (modCount != expectedCount)
- throw new ConcurrentModificationException();
-
- if (!hasNext && !hasNext())
- throw new NoSuchElementException();
-
- current = next++;
- hasNext = false;
-
- return table[current];
- }
-
- @SuppressWarnings("unchecked")
- public void remove()
- {
- if (modCount != expectedCount)
- throw new ConcurrentModificationException();
-
- int current = this.current;
- int delete = current;
-
- if (current == -1)
- throw new IllegalStateException();
-
- // Invalidate current (prevents multiple remove)
- this.current = -1;
-
- // Start were we relocate
- next = delete;
-
- Entry<K, V>[] table = this.table;
- if (table != FastCopyHashMap.this.table)
- {
- FastCopyHashMap.this.remove(table[delete].key);
- table[delete] = null;
- expectedCount = modCount;
- return;
- }
-
-
- int length = table.length;
- int i = delete;
-
- table[delete] = null;
- size--;
-
- for (; ;)
- {
- i = nextIndex(i, length);
- Entry<K, V> e = table[i];
- if (e == null)
- break;
-
- int prefer = index(e.hash, length);
- if ((i < prefer && (prefer <= delete || delete <= i))
- || (prefer <= delete && delete <= i))
- {
- // Snapshot the unseen portion of the table if we have
- // to relocate an entry that was already seen by this iterator
- if (i < current && current <= delete && table == FastCopyHashMap.this.table)
- {
- int remaining = length - current;
- Entry<K, V>[] newTable = (Entry<K, V>[]) new Entry[remaining];
- System.arraycopy(table, current, newTable, 0, remaining);
-
- // Replace iterator's table.
- // Leave table local var pointing to the real table
- this.table = newTable;
- next = 0;
- }
-
- // Do the swap on the real table
- table[delete] = e;
- table[i] = null;
- delete = i;
- }
- }
- }
- }
-
-
- private class KeyIterator extends FasyCopyHashMapIterator<K>
- {
- public K next()
- {
- return unmaskNull(nextEntry().key);
- }
- }
-
- private class ValueIterator extends FasyCopyHashMapIterator<V>
- {
- public V next()
- {
- return nextEntry().value;
- }
- }
-
- private class EntryIterator extends FasyCopyHashMapIterator<Map.Entry<K, V>>
- {
- private class WriteThroughEntry extends SimpleEntry<K, V>
- {
- WriteThroughEntry(K key, V value)
- {
- super(key, value);
- }
-
- public V setValue(V value)
- {
- if (table != FastCopyHashMap.this.table)
- FastCopyHashMap.this.put(getKey(), value);
-
- return super.setValue(value);
- }
- }
-
- public Map.Entry<K, V> next()
- {
- Entry<K, V> e = nextEntry();
- return new WriteThroughEntry(unmaskNull(e.key), e.value);
- }
-
- }
-
- private class KeySet extends AbstractSet<K>
- {
- public Iterator<K> iterator()
- {
- return new KeyIterator();
- }
-
- public void clear()
- {
- FastCopyHashMap.this.clear();
- }
-
- public boolean contains(Object o)
- {
- return containsKey(o);
- }
-
- public boolean remove(Object o)
- {
- int size = size();
- FastCopyHashMap.this.remove(o);
- return size() < size;
- }
-
- public int size()
- {
- return FastCopyHashMap.this.size();
- }
- }
-
- private class Values extends AbstractCollection<V>
- {
- public Iterator<V> iterator()
- {
- return new ValueIterator();
- }
-
- public void clear()
- {
- FastCopyHashMap.this.clear();
- }
-
- public int size()
- {
- return FastCopyHashMap.this.size();
- }
- }
-
- private class EntrySet extends AbstractSet<Map.Entry<K, V>>
- {
- public Iterator<Map.Entry<K, V>> iterator()
- {
- return new EntryIterator();
- }
-
- public boolean contains(Object o)
- {
- if (!(o instanceof Map.Entry))
- return false;
-
- Map.Entry<?, ?> entry = (Map.Entry<?, ?>) o;
- Object value = get(entry.getKey());
- return eq(entry.getValue(), value);
- }
-
- public void clear()
- {
- FastCopyHashMap.this.clear();
- }
-
- public boolean isEmpty()
- {
- return FastCopyHashMap.this.isEmpty();
- }
-
- public int size()
- {
- return FastCopyHashMap.this.size();
- }
- }
-
- protected static class SimpleEntry<K, V> implements Map.Entry<K, V>
- {
- private K key;
- private V value;
-
- SimpleEntry(K key, V value)
- {
- this.key = key;
- this.value = value;
- }
-
- SimpleEntry(Map.Entry<K, V> entry)
- {
- this.key = entry.getKey();
- this.value = entry.getValue();
- }
-
- public K getKey()
- {
- return key;
- }
-
- public V getValue()
- {
- return value;
- }
-
- public V setValue(V value)
- {
- V old = this.value;
- this.value = value;
- return old;
- }
-
- public boolean equals(Object o)
- {
- if (this == o)
- return true;
-
- if (!(o instanceof Map.Entry))
- return false;
- Map.Entry<?, ?> e = (Map.Entry<?, ?>) o;
- return eq(key, e.getKey()) && eq(value, e.getValue());
- }
-
- public int hashCode()
- {
- return hash(key) ^
- (value == null ? 0 : hash(value));
- }
-
- public String toString()
- {
- return getKey() + "=" + getValue();
- }
- }
-}
Modified: core/branches/flat/src/main/java/org/jboss/cache/util/Immutables.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/util/Immutables.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/util/Immutables.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -21,6 +21,8 @@
*/
package org.jboss.cache.util;
+import org.jboss.starobrno.util.FastCopyHashMap;
+
import java.io.Serializable;
import java.lang.reflect.Array;
import java.util.ArrayList;
Deleted: core/branches/flat/src/main/java/org/jboss/cache/util/reflect/ReflectionUtil.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/util/reflect/ReflectionUtil.java 2008-10-14 17:12:01 UTC (rev 6936)
+++ core/branches/flat/src/main/java/org/jboss/cache/util/reflect/ReflectionUtil.java 2008-10-14 17:42:25 UTC (rev 6937)
@@ -1,153 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.cache.util.reflect;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.starobrno.CacheException;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Basic reflection utilities to enhance what the JDK provides.
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @since 2.1.0
- */
-public class ReflectionUtil
-{
- private static final Log log = LogFactory.getLog(ReflectionUtil.class);
-
- /**
- * Returns a set of Methods that contain the given method annotation. This includes all public, protected, package and private
- * methods, as well as those of superclasses. Note that this does *not* include overridden methods.
- *
- * @param c class to inspect
- * @param annotationType the type of annotation to look for
- * @return List of Method objects that require injection.
- */
- public static List<Method> getAllMethods(Class c, Class<? extends Annotation> annotationType)
- {
- List<Method> annotated = new LinkedList<Method>();
- inspectRecursively(c, annotated, annotationType);
- return annotated;
- }
-
- /**
- * Inspects a class and its superclasses (all the way to {@link Object} for method instances that contain a given annotation.
- * This even identifies private, package and protected methods, not just public ones.
- *
- * @param c
- * @param s
- * @param annotationType
- */
- private static void inspectRecursively(Class c, List<Method> s, Class<? extends Annotation> annotationType)
- {
- // Superclass first
- if (!c.equals(Object.class)) inspectRecursively(c.getSuperclass(), s, annotationType);
-
- for (Method m : c.getDeclaredMethods())
- {
- // don't bother if this method has already been overridden by a subclass
- if (!alreadyFound(m, s) && m.isAnnotationPresent(annotationType))
- {
- s.add(m);
- }
- }
- }
-
- /**
- * Tests whether a method has already been found, i.e., overridden.
- *
- * @param m method to inspect
- * @param s collection of methods found
- * @return true a method with the same signature already exists.
- */
- private static boolean alreadyFound(Method m, Collection<Method> s)
- {
- for (Method found : s)
- {
- if (m.getName().equals(found.getName()) &&
- Arrays.equals(m.getParameterTypes(), found.getParameterTypes()))
- return true;
- }
- return false;
- }
-
- public static void setValue(Object instance, String fieldName, Object value)
- {
- try
- {
- Field f = findFieldRecursively(instance.getClass(), fieldName);
- if (f == null)
- throw new NoSuchMethodException("Cannot find field " + fieldName + " on " + instance.getClass() + " or superclasses");
- f.setAccessible(true);
- f.set(instance, value);
- }
- catch (Exception e)
- {
- log.error("Unable to set value!", e);
- }
- }
-
- private static Field findFieldRecursively(Class c, String fieldName)
- {
- Field f = null;
- try
- {
- f = c.getDeclaredField(fieldName);
- }
- catch (NoSuchFieldException e)
- {
- if (!c.equals(Object.class)) f = findFieldRecursively(c.getSuperclass(), fieldName);
- }
- return f;
- }
-
- /**
- * Invokes a method using reflection, in an accessible manner (by using {@link Method#setAccessible(boolean)}
- *
- * @param instance instance on which to execute the method
- * @param method method to execute
- * @param parameters parameters
- */
- public static void invokeAccessibly(Object instance, Method method, Object[] parameters)
- {
- try
- {
- method.setAccessible(true);
- method.invoke(instance, parameters);
- }
- catch (Exception e)
- {
- throw new CacheException("Unable to invoke method " + method + " on object " + //instance +
- (parameters != null ? " with parameters " + Arrays.asList(parameters) : ""), e);
- }
- }
-
-}
17 years, 2 months
JBoss Cache SVN: r6936 - in core/trunk/src/main/docbook/userguide/en: modules and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-14 13:12:01 -0400 (Tue, 14 Oct 2008)
New Revision: 6936
Added:
core/trunk/src/main/docbook/userguide/en/modules/batching.xml
Modified:
core/trunk/src/main/docbook/userguide/en/master.xml
core/trunk/src/main/docbook/userguide/en/modules/basic_api.xml
core/trunk/src/main/docbook/userguide/en/modules/configuration.xml
core/trunk/src/main/docbook/userguide/en/modules/introduction.xml
core/trunk/src/main/docbook/userguide/en/modules/preface.xml
Log:
Updated a PART of the userguide
Modified: core/trunk/src/main/docbook/userguide/en/master.xml
===================================================================
--- core/trunk/src/main/docbook/userguide/en/master.xml 2008-10-14 15:17:56 UTC (rev 6935)
+++ core/trunk/src/main/docbook/userguide/en/master.xml 2008-10-14 17:12:01 UTC (rev 6936)
@@ -14,6 +14,7 @@
<!ENTITY deployment SYSTEM "modules/deployment.xml">
<!ENTITY configuration_reference SYSTEM "modules/configuration_reference.xml">
<!ENTITY jmx_reference SYSTEM "modules/jmx_reference.xml">
+ <!ENTITY batching SYSTEM "modules/batching.xml">
]>
<book lang="en">
<bookinfo>
@@ -98,6 +99,7 @@
&basic_api;
&configuration;
&deployment;
+ &batching;
&compatibility;
</part>
Modified: core/trunk/src/main/docbook/userguide/en/modules/basic_api.xml
===================================================================
--- core/trunk/src/main/docbook/userguide/en/modules/basic_api.xml 2008-10-14 15:17:56 UTC (rev 6935)
+++ core/trunk/src/main/docbook/userguide/en/modules/basic_api.xml 2008-10-14 17:12:01 UTC (rev 6936)
@@ -30,8 +30,8 @@
</para>
<para>
- Reviewing the javadoc for the above interfaces is the best way
- to learn the API. Below we cover some of the main points.
+ Note that the diagram above only depicts some of the more popular API methods. Reviewing the javadoc for the
+ above interfaces is the best way to learn the API. Below, we cover some of the main points.
</para>
</section>
@@ -42,8 +42,7 @@
<literal>Cache</literal>
interface can only be created
via a
- <literal>CacheFactory</literal>
- . (This is unlike JBoss Cache 1.x,
+ <literal>CacheFactory</literal>. (This is unlike JBoss Cache 1.x,
where an instance of the old
<literal>TreeCache</literal>
class could
@@ -136,7 +135,7 @@
simple reads and writes to that node.
</para>
<programlisting role="JAVA"><![CDATA[
- // Let's get ahold of the root node.
+ // Let's get a hold of the root node.
Node rootNode = cache.getRoot();
// Remember, JBoss Cache stores data in a tree structure.
@@ -248,48 +247,18 @@
// under the 'people' section of the tree
// Parse it from a String
- Fqn<String> abc = Fqn.fromString("/people/Smith/Joe/");
+ Fqn abc = Fqn.fromString("/people/Smith/Joe/");
- // Build it directly. Marginally more efficient to construct than parsing
- String[] strings = new String[] { "people", "Smith", "Joe" };
- Fqn<String> abc = new Fqn<String>(strings);
-
// Here we want to use types other than String
- Object[] objs = new Object[]{ "accounts", "NY", new Integer(12345) };
- Fqn<Object> acctFqn = new Fqn<Object>(objs);
+ Fqn acctFqn = Fqn.fromElements("accounts", "NY", new Integer(12345));
]]></programlisting>
<para>Note that</para>
- <programlisting role="JAVA"><![CDATA[Fqn<String> f = new Fqn<String>("/a/b/c");]]></programlisting>
- <para>is
- <emphasis>not</emphasis>
- the same as
+ <programlisting role="JAVA"><![CDATA[Fqn f = Fqn.fromElements("a", "b", "c");]]></programlisting>
+ <para>is the same as
</para>
- <programlisting role="JAVA"><![CDATA[Fqn<String> f = Fqn.fromString("/a/b/c");]]></programlisting>
+ <programlisting role="JAVA"><![CDATA[Fqn f = Fqn.fromString("/a/b/c");]]></programlisting>
- <para>
- The former will result in an Fqn with a single element, called "/a/b/c"
- which hangs directly under the cache root. The latter will result
- in a 3 element Fqn, where "c" idicates a child of "b", which is a child
- of "a", and "a" hangs off the cache root. Another way to
- look at it is that the "/" separarator is only parsed when it forms
- part of a String passed in to
- <literal>Fqn.fromString()</literal>
- and not
- otherwise.
- </para>
-
- <para>
- The JBoss Cache API in the 1.x releases included many overloaded
- convenience methods that took a string in the
- <literal>/a/b/c</literal>
- format in place
- of an
- <literal>Fqn</literal>
- . In the interests of API simplicity, no
- such convenience methods are available in the JBC 2.x API.
- </para>
-
</section>
<section>
@@ -345,9 +314,7 @@
<listitem>
<emphasis>LOCAL</emphasis>
- local, non-clustered cache. Local caches don't join a cluster and don't
- communicate with other caches in a cluster. Therefore their contents don't need to be Serializable;
- however, we recommend making them Serializable, allowing you the flexibility to change the cache mode at
- any time.
+ communicate with other caches in a cluster.
</listitem>
<listitem>
<emphasis>REPL_SYNC</emphasis>
@@ -509,6 +476,16 @@
<listitem>
<para>
+ <literal>@NodeInvalidated</literal>
+ - methods annotated such receive a notification when a node is
+ evicted from memory due to a remote invalidation event. Methods need to accept a parameter type which is assignable from
+ <literal>NodeInvalidatedEvent</literal>
+ .
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
<literal>@NodeActivated</literal>
- methods annotated such receive a notification when a node is
activated. Methods need to accept a parameter type which is assignable from
@@ -583,6 +560,14 @@
</para>
</listitem>
+ <listitem>
+ <para>
+ <literal>@BuddyGroupChanged</literal>
+ - methods annotated such receive a notification when a node changes its buddy group, perhaps due
+ to a buddy falling out of the cluster or a newer, closer buddy joining.
+ Methods need to accept a parameter type which is assignable from <literal>BuddyGroupChangedEvent</literal>.
+ </para>
+ </listitem>
</itemizedlist>
</para>
<para>
@@ -654,34 +639,34 @@
</listitem>
<listitem>
<literal>org.jboss.cache.loader.JdbmCacheLoader</literal>
- - an upcoming open source alternative to the BerkeleyDB.
+ - an open source alternative to the BerkeleyDB.
</listitem>
<listitem>
<literal>org.jboss.cache.loader.tcp.TcpCacheLoader</literal>
- - uses a TCP socket to "persist" data to a remote cluster, using a "far cache" pattern.
- <footnote>
- <para>http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossClusteringPatternFarCache</para>
- </footnote>
+ - uses a TCP socket to "persist" data to a remote cluster, using <ulink url="http://www.jboss.org/community/docs/DOC-10292">a "far cache" pattern</ulink>.
</listitem>
<listitem>
<literal>org.jboss.cache.loader.ClusteredCacheLoader</literal>
- - used as a "read-only" CacheLoader, where other nodes in the cluster are queried for state.
+ - used as a "read-only" cache loader, where other nodes in the cluster are queried for state. Useful when full
+ state transfer is too expensive and it is preferred that state is lazily loaded.
</listitem>
</itemizedlist>
- These CacheLoaders, along with advanced aspects and tuning issues, are discussed in the
- <link linkend="cache_loaders">chapter dedicated to CacheLoaders</link>
- .
+ These cache loaders, along with advanced aspects and tuning issues, are discussed in the
+ <link linkend="cache_loaders">chapter dedicated to cache loaders</link>.
</para>
</section>
<section>
<title>Using Eviction Policies</title>
<para>
- Eviction policies are the counterpart to CacheLoaders. They are necessary to make sure the cache does not run
+ Eviction policies are the counterpart to cache loaders. They are necessary to make sure the cache does not run
out of memory and when the cache starts to fill,
- the eviction algorithm running in a separate thread offloads in-memory state to the CacheLoader and frees up
- memory. Eviction policies can be configured
- on a per-region basis, so different subtrees in the cache could have different eviction preferences.
+ an eviction algorithm running in a separate thread evicts in-memory state and frees up
+ memory. If configured with a cache loader, the state can then be retrieved from the cache loader if needed.
+ </para>
+ <para>
+ Eviction policies can be configured on a per-region basis, so different subtrees in the cache could have
+ different eviction preferences.
JBoss Cache ships with several eviction policies:
<itemizedlist>
@@ -714,8 +699,7 @@
</listitem>
</itemizedlist>
Detailed configuration and implementing custom eviction policies are discussed in the
- <link linkend="eviction_policies">chapter dedicated to eviction policies.</link>
- .
+ <link linkend="eviction_policies">chapter dedicated to eviction policies</link>.
</para>
</section>
</chapter>
Added: core/trunk/src/main/docbook/userguide/en/modules/batching.xml
===================================================================
--- core/trunk/src/main/docbook/userguide/en/modules/batching.xml (rev 0)
+++ core/trunk/src/main/docbook/userguide/en/modules/batching.xml 2008-10-14 17:12:01 UTC (rev 6936)
@@ -0,0 +1,60 @@
+<chapter id="batching">
+ <title>Batching API</title>
+ <section id="batching.intro">
+ <title>Introduction</title>
+ <para>
+ The batching API, introduced in JBoss Cache 3.x, is intended as a mechanism to batch the way calls are replicated
+ independent of JTA transactions.
+ </para>
+ <para>
+ This is useful when you want to batch up replication calls within a scope finer than that of any ongoing JTA transactions.
+ </para>
+ </section>
+ <section id="batching.configuring">
+ <title>Configuring batching</title>
+ <para>
+ To use batching, you need to enable invocation batching in your cache configuration, either on the <literal>Configuration</literal> object:
+ </para>
+ <programlisting role="JAVA"><![CDATA[
+ Configuration.setInvocationBatchingEnabled(true);
+ ]]></programlisting>
+ <para>
+ or in your XML file:
+ </para>
+ <programlisting role="XML"><![CDATA[
+ <invocationBatching enabled="true"/>
+ ]]></programlisting>
+ <para>
+ By default, invocation batching is disabled. Note that you do <emphasis>not</emphasis> have to have a transaction
+ manager defined to use batching.
+ </para>
+ </section>
+
+ <section id="batching.api">
+ <title>Batching API</title>
+ <para>
+ Once you have configured your cache to use batching, you use it by calling <literal>startBatch()</literal>
+ and <literal>endBatch()</literal> on <literal>Cache</literal>. E.g.,
+ </para>
+ <programlisting role="JAVA"><![CDATA[
+ Cache cache = getCache();
+
+ // not using a batch
+ cache.put("/a", "key", "value"); // will replicate immediately
+
+ // using a batch
+ cache.startBatch();
+ cache.put("/a", "key", "value");
+ cache.put("/b", "key", "value");
+ cache.put("/c", "key", "value");
+ cache.endBatch(true); // This will now replicate the modifications since the batch was started.
+
+ cache.startBatch();
+ cache.put("/a", "key", "value");
+ cache.put("/b", "key", "value");
+ cache.put("/c", "key", "value");
+ cache.endBatch(false); // This will "discard" changes made in the batch
+
+ ]]></programlisting>
+ </section>
+</chapter>
\ No newline at end of file
Modified: core/trunk/src/main/docbook/userguide/en/modules/configuration.xml
===================================================================
--- core/trunk/src/main/docbook/userguide/en/modules/configuration.xml 2008-10-14 15:17:56 UTC (rev 6935)
+++ core/trunk/src/main/docbook/userguide/en/modules/configuration.xml 2008-10-14 17:12:01 UTC (rev 6936)
@@ -62,89 +62,45 @@
</para>
<para>
- Here is a simple example configuration file:
+ The simplest example of a configuration XML file, a cache configured to run in LOCAL mode, looks like this:
</para>
<programlisting role="XML"><![CDATA[
+
<?xml version="1.0" encoding="UTF-8"?>
-<!-- ===================================================================== -->
-<!-- -->
-<!-- Sample JBoss Cache Service Configuration -->
-<!-- -->
-<!-- ===================================================================== -->
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
+</jbosscache>
-<server>
-
- <mbean code="org.jboss.cache.jmx.CacheJmxWrapper" name="jboss.cache:service=Cache">
-
- <!-- Configure the TransactionManager -->
- <attribute name="TransactionManagerLookupClass">
- org.jboss.cache.transaction.GenericTransactionManagerLookup
- </attribute>
- <!-- Node locking level : SERIALIZABLE
- REPEATABLE_READ (default)
- READ_COMMITTED
- READ_UNCOMMITTED
- NONE -->
- <attribute name="IsolationLevel">READ_COMMITTED</attribute>
-
- <!-- Lock parent before doing node additions/removes -->
- <attribute name="LockParentForChildInsertRemove">true</attribute>
-
- <!-- Valid modes are LOCAL (default)
- REPL_ASYNC
- REPL_SYNC
- INVALIDATION_ASYNC
- INVALIDATION_SYNC -->
- <attribute name="CacheMode">LOCAL</attribute>
-
- <!-- Max number of milliseconds to wait for a lock acquisition -->
- <attribute name="LockAcquisitionTimeout">15000</attribute>
-
-
- <!-- Specific eviction policy configurations. This is LRU -->
- <attribute name="EvictionConfig">
- <config>
- <attribute name="wakeUpIntervalSeconds">5</attribute>
- <attribute name="policyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
-
- <!-- Cache wide default -->
- <region name="/_default_">
- <attribute name="maxNodes">5000</attribute>
- <attribute name="timeToLiveSeconds">1000</attribute>
- </region>
- </config>
- </attribute>
- </mbean>
-</server>
]]></programlisting>
<para>
- Another, more complete, sample XML file is included in the
+ This file uses sensible defaults for isolation levels, lock acquisition timeouts, locking modes, etc. Another,
+ more complete, sample XML file is included in the
<link linkend="sample_xml_file">configuration reference</link>
section of this book,
along with
<link linkend="configuration_reference">a handy look-up table</link>
explaining the various options.
</para>
+ <section id="configuration.validation">
+ <title>Validating Configuration Files</title>
+ <para>
+ By default JBoss Cache will validate your XML configuration file against an XML schema and throw an
+ exception if the configuration is invalid. This can be overridden with the <literal>-Djbosscache.config.validate=false</literal>
+ JVM parameter. Alternately, you could specify your own schema to validate against, using the
+ <literal>-Djbosscache.config.schemaLocation=url</literal> parameter.
+ </para>
+ <para>
+ By default though, configuration files are validated against the JBoss Cache configuration schema, which is
+ included in the <literal>jbosscache-core.jar</literal> or on <literal>http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd</literal>.
+ Most XML editing tools can be used with this schema to ensure the configuration file you create is correct
+ and valid.
+ </para>
+ </section>
<para>
- For historical reasons, the format of the JBoss Cache configuraton
- file follows that of a JBoss AS Service Archive (SAR) deployment
- descriptor (and still can be used as such
- <link linkend="deployment.microkernel">inside JBoss AS</link>
- ). Because
- of this dual usage, you may see elements in some configuration files
- (such as
- <literal>depends</literal>
- or
- <literal>classpath</literal>
- ) that are
- not relevant outside JBoss AS. These can safely be ignored.
- </para>
-
- <para>
Here's how you tell the
<literal>CacheFactory</literal>
to create
@@ -174,43 +130,13 @@
defaults and can even be used as-is for a quick start.
</para>
- <para>
- Following is an example of programatically creating a
- <literal>Configuration</literal>
- configured to match the one produced
- by the XML example above, and then using it to create a
- <literal>Cache</literal>
- :
- </para>
-
<programlisting role="JAVA"><![CDATA[
Configuration config = new Configuration();
- String tmlc = GenericTransactionManagerLookup.class.getName();
- config.setTransactionManagerLookupClass(tmlc);
+ config.setTransactionManagerLookupClass( GenericTransactionManagerLookup.class.getName() );
config.setIsolationLevel(IsolationLevel.READ_COMMITTED);
config.setCacheMode(CacheMode.LOCAL);
- config.setLockParentForChildInsertRemove(true);
config.setLockAcquisitionTimeout(15000);
- EvictionConfig ec = new EvictionConfig();
- ec.setWakeupIntervalSeconds(5);
- ec.setDefaultEvictionPolicyClass(LRUPolicy.class.getName());
-
- EvictionRegionConfig erc = new EvictionRegionConfig();
- erc.setRegionName("_default_");
-
- LRUConfiguration lru = new LRUConfiguration();
- lru.setMaxNodes(5000);
- lru.setTimeToLiveSeconds(1000);
-
- erc.setEvictionPolicyConfig(lru);
-
- List<EvictionRegionConfig> ercs = new ArrayList<EvictionRegionConfig>();
- ercs.add(erc);
- ec.setEvictionRegionConfigs(erc);
-
- config.setEvictionConfig(ec);
-
CacheFactory factory = new DefaultCacheFactory();
Cache cache = factory.createCache(config);
]]></programlisting>
@@ -247,7 +173,7 @@
class and its
<link linkend="configuration.elements">component parts</link>
are all Java Beans that expose all config elements via simple setters
- and getters. Therefore, any good IOC framework should be able to
+ and getters. Therefore, any good IOC framework such as Spring, Google Guice, JBoss Microcontainer, etc. should be able to
build up a
<literal>Configuration</literal>
from an XML file in
@@ -328,14 +254,14 @@
</listitem>
<listitem>
- <literal>EvictionPolicyConfig</literal>
+ <literal>EvictionAlgorithmConfig</literal>
: implementation-specific
configuration object for the
- <literal>EvictionPolicy</literal>
+ <literal>EvictionAlgorithm</literal>
implementation
being used. What configuration elements are exposed depends on
the needs of the
- <literal>EvictionPolicy</literal>
+ <literal>EvictionAlgorithm</literal>
implementation.
</listitem>
Modified: core/trunk/src/main/docbook/userguide/en/modules/introduction.xml
===================================================================
--- core/trunk/src/main/docbook/userguide/en/modules/introduction.xml 2008-10-14 15:17:56 UTC (rev 6935)
+++ core/trunk/src/main/docbook/userguide/en/modules/introduction.xml 2008-10-14 17:12:01 UTC (rev 6936)
@@ -6,30 +6,38 @@
<title>What is JBoss Cache?</title>
<para>
- JBoss Cache is a tree-structured, clustered, transactional cache. It is
- the backbone for many fundamental JBoss Application Server clustering services, including - in certain
- versions - clustering JNDI, HTTP and EJB sessions.
+ JBoss Cache is a tree-structured, clustered, transactional cache. It can be used in a standalone, non-clustered
+ environment, to cache frequently accessed data in memory thereby removing data retrieval or calculation bottlenecks
+ while providing "enterprise" features such as JTA compatibility, eviction and persistence.
+ </para>
+ <para>
+ JBoss Cache is also a clustered cache, and can be used in a cluster to replicate state providing a high degree
+ of failover. A variety of replication modes are supported, including invalidation and buddy replication, and
+ network communications can either be synchronous or asynchronous.
+ </para>
+ <para>
+ When used in a clustered mode, the cache is an effective mechanism of building high availability, fault
+ tolerance and even load balancing into custom applications and frameworks. For example, the JBoss Application
+ Server makes extensive use of JBoss Cache in clustering services such as HTTP and <ulink url="http://java.sun.com/products/ejb/">EJB</ulink> sessions, as well as
+ providing a distributed entity cache for <ulink url="http://en.wikipedia.org/wiki/Java_Persistence_API">JPA</ulink>.
</para>
<para>
- JBoss Cache can also be used as a standalone transactional and clustered caching library or even an object
- oriented data store. It can even be embedded in other enterprise Java frameworks and application servers
- such as BEA WebLogic or IBM WebSphere, Tomcat, Spring, Hibernate, and many others. It is also very commonly
- used directly by standalone Java applications that do not run from within an application server, to maintain
- clustered state.
+ JBoss Cache can - and often is - used outside of JBoss AS, in other Java EE environments such as Spring, Tomcat,
+ Glassfish, BEA WebLogic, IBM WebSphere, and even in standalone Java programs thanks to its minimal dependency set.
</para>
<section>
- <title>And what is Pojo Cache?</title>
+ <title>And what is POJO Cache?</title>
<para>
- Pojo Cache is an extension of the core JBoss Cache API. Pojo Cache offers additional functionality such as:
+ POJO Cache is an extension of the core JBoss Cache API. POJO Cache offers additional functionality such as:
<itemizedlist>
<listitem>maintaining object references even after replication or persistence.</listitem>
<listitem>fine grained replication, where only modified object fields are replicated.</listitem>
- <listitem>"API-less" clustering model where pojos are simply annotated as being clustered.</listitem>
+ <listitem>"API-less" clustering model where POJOs are simply annotated as being clustered.</listitem>
</itemizedlist>
</para>
<para>
- Pojo Cache has a complete and separate set of documentation, including a user guide, FAQ and tutorial and
- as such, Pojo Cache is not discussed further in this book.
+ POJO Cache has a complete and separate set of documentation, including a user guide, FAQ and tutorial and
+ as such, POJO Cache is not discussed further in this book.
</para>
</section>
@@ -42,6 +50,7 @@
JBoss Cache offers a simple and straightforward API, where data (simple Java objects) can be placed in the
cache and, based on configuration options selected, this data may be one or all of:
<itemizedlist>
+ <listitem>cached in-memory for efficient, threadsafe retrieval.</listitem>
<listitem>replicated to some or all cache instances in a cluster.</listitem>
<listitem>persisted to disk and/or a remote cluster ("far-cache").</listitem>
<listitem>garbage collected from memory when memory runs low, and passivated to disk so state isn't lost.
@@ -51,7 +60,7 @@
<itemizedlist>
<listitem>being able to participate in JTA transactions (works with Java EE compliant TransactionManagers).
</listitem>
- <listitem>attach to JMX servers and provide runtime statistics on the state of the cache.</listitem>
+ <listitem>attach to JMX consoles and provide runtime statistics on the state of the cache.</listitem>
<listitem>allow client code to attach listeners and receive notifications on cache events.</listitem>
</itemizedlist>
</para>
@@ -59,8 +68,7 @@
<para>A cache is organised as a tree, with a single root. Each node in the tree essentially contains a Map,
which acts as a store for key/value pairs. The only requirement placed on objects that are cached is that
they implement
- <literal>java.io.Serializable</literal>
- . Note that this requirement does not exist for Pojo Cache.
+ <literal>java.io.Serializable</literal>.
</para>
<para>JBoss Cache
@@ -81,8 +89,7 @@
anything, resulting in no network traffic.
</para>
- <para>If a caller has no transaction associated with it (and isolation level is not
- NONE - more about this later), we will replicate right after each modification, e.g. in the above
+ <para>If a caller has no transaction associated with it, we will replicate right after each modification, e.g. in the above
case we would send 100 messages, plus an additional message for the
rollback. In this sense, running without a transaction can be thought of as analogous as running with
auto-commit switched on in JDBC terminology, where each operation is committed automatically.
@@ -94,12 +101,19 @@
</para>
<para>
- The cache is also completely thread-safe. It uses a pessimistic locking scheme for nodes in the tree by
- default, with an optimistic locking scheme as a configurable option. With pessimistic locking, the degree
- of concurrency can be tuned using a number of isolation levels, corresponding to database-style
- transaction isolation levels, i.e., SERIALIZABLE, REPEATABLE_READ, READ_COMMITTED, READ_UNCOMMITTED and NONE.
- Concurrency, locking and isolation levels will be discussed later.
+ The cache is also completely thread-safe. It uses multi-versioned concurrency control (MVCC) to ensure thread
+ safety between readers and writers, while maintaining a high degree of concurrency. The specific MVCC implementation
+ used in JBoss Cache allows for readers to be completely free of locks and synchronized blocks, ensuring a very high
+ degree of performance for read-heavy applications.
+ </para>
+ <para>
+ Optimistic and pessimistic locking schemes, from older versions of JBoss Cache, are still available but are
+ deprecated in favour of MVCC, and will be removed in future releases.
</para>
+ <para>
+ The JBoss Cache MVCC implementation supports READ_COMMITTED and REPEATABLE_READ isolation levels, corresponding
+ to their database equivalents.
+ </para>
</section>
<section>
@@ -111,22 +125,19 @@
</para>
<para>
However, there is a way to build JBoss Cache as a Java 1.4.x compatible binary using
- <ulink url="http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossRetro">JBossRetro</ulink>
+ <ulink url="http://www.jboss.org/community/docs/DOC-10738">JBossRetro</ulink>
to retroweave the Java 5.0 binaries. However, Red Hat Inc. does not offer professional support around the
retroweaved
binary at this time and the Java 1.4.x compatible binary is not in the binary distribution. See
- <ulink url="http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossCacheHabaneroJava1.4">this wiki</ulink>
+ <ulink url="http://www.jboss.org/community/docs/DOC-10263">this wiki</ulink>
page for
details on building the retroweaved binary for yourself.
</para>
<para>
In addition to Java 5.0, at a minimum, JBoss Cache has dependencies on
<ulink url="http://www.jgroups.org">JGroups</ulink>
- , and Apache's
- <ulink
- url="http://jakarta.apache.org/commons/logging/">commons-logging
- </ulink>
- . JBoss Cache ships with all dependent libraries necessary to run out of the box.
+ , and Apache's <ulink url="http://jakarta.apache.org/commons/logging/">commons-logging</ulink>.
+ JBoss Cache ships with all dependent libraries necessary to run out of the box.
</para>
</section>
@@ -138,9 +149,6 @@
<ulink url="http://www.gnu.org/copyleft/lesser.html">LGPL license.</ulink>
Commercial development support, production support and training for JBoss Cache is available through
<ulink url="http://www.jboss.com">JBoss, a division of Red Hat Inc.</ulink>
- JBoss Cache is a part of JBoss Professional Open Source
- <ulink url="http://www.jboss.comindex">JEMS</ulink>
- (JBoss Enterprise Middleware Suite).
</para>
</section>
</chapter>
Modified: core/trunk/src/main/docbook/userguide/en/modules/preface.xml
===================================================================
--- core/trunk/src/main/docbook/userguide/en/modules/preface.xml 2008-10-14 15:17:56 UTC (rev 6935)
+++ core/trunk/src/main/docbook/userguide/en/modules/preface.xml 2008-10-14 17:12:01 UTC (rev 6936)
@@ -3,26 +3,26 @@
<para>
This is the official JBoss Cache user guide. Along with its accompanying documents (an FAQ, a tutorial and a
- whole set of documents on PojoCache), this is freely available on the JBoss Cache <ulink url="http://labs.jboss.com/jbosscache">documentation site.</ulink>
+ whole set of documents on POJO Cache), this is freely available on the JBoss Cache <ulink url="http://labs.jboss.com/jbosscache">documentation site.</ulink>
</para>
<para>
When used, JBoss Cache refers to JBoss Cache Core, a tree-structured, clustered, transactional cache.
- Pojo Cache, also a part of the JBoss Cache distribution, is documented separately. (Pojo Cache is a cache that
- deals with Plain Old Java Objects, complete with object relationships, with the ability to cluster such pojos
- while maintaining their relationships. Please see the Pojo Cache documentation for more information about this.)
+ POJO Cache, also a part of the JBoss Cache distribution, is documented separately. (POJO Cache is a cache that
+ deals with Plain Old Java Objects, complete with object relationships, with the ability to cluster such POJOs
+ while maintaining their relationships. Please see the POJO Cache documentation for more information about this.)
</para>
<para>
- This book is targeted at both developers wishing to use JBoss Cache as a clustering and caching library in
- their codebase, as well as people who wish to "OEM" JBoss Cache by building on and extending its features. As
- such,
- this book is split into two major sections - one detailing the "User" API and the other going much deeper into
- specialist topics and the JBoss Cache architecture.
+ This book is targeted at developers wishing to use JBoss Cache as either a standalone in-memory cache,
+ a distributed or replicated cache, a clustering library, or an in-memory database. It is targeted at application
+ developers who wish to use JBoss Cache in their codebase, as well as "OEM" developers who wish to build on and
+ extend JBoss Cache features. As such, this book is split into two major sections - one detailing the "User" API
+ and the other going much deeper into specialist topics and the JBoss Cache architecture.
</para>
<para>
In general, a good knowledge of the Java programming language along with a strong appreciation and understanding
- of transactions and concurrent threads is necessary. No prior knowledge of JBoss Application Server is expected
+ of transactions and concurrent programming is necessary. No prior knowledge of JBoss Application Server is expected
or required.
</para>
@@ -31,10 +31,10 @@
<ulink url="http://jboss.org/index.html?module=bb&op=main&c=29">user forum</ulink>
linked on the JBoss Cache <ulink url="http://labs.jboss.com/jbosscache">website.</ulink> We also provide a mechanism for
tracking bug reports and feature requests on the JBoss Cache <ulink url="http://jira.jboss.com/jira/browse/JBCACHE">JIRA issue tracker.</ulink>
-
+ </para>
+ <para>
If you are interested in the development of JBoss Cache or in translating this documentation into other languages,
- we'd love
- to hear from you. Please post a message on the
+ we'd love to hear from you. Please post a message on the
<ulink url="http://jboss.org/index.html?module=bb&op=main&c=29">user forum</ulink>
or contact us by using the JBoss Cache <ulink url="https://lists.jboss.org/mailman/listinfo/jbosscache-dev">developer mailing list.</ulink>
</para>
@@ -45,4 +45,8 @@
of JBoss Cache you intend to use.
</para>
+ <para>
+ Happy reading!
+ </para>
+
</preface>
\ No newline at end of file
17 years, 2 months
JBoss Cache SVN: r6935 - core/trunk/src/main/docbook/faq/en.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-14 11:17:56 -0400 (Tue, 14 Oct 2008)
New Revision: 6935
Modified:
core/trunk/src/main/docbook/faq/en/master.xml
Log:
Updated FAQs to 3.x
Modified: core/trunk/src/main/docbook/faq/en/master.xml
===================================================================
--- core/trunk/src/main/docbook/faq/en/master.xml 2008-10-14 13:52:34 UTC (rev 6934)
+++ core/trunk/src/main/docbook/faq/en/master.xml 2008-10-14 15:17:56 UTC (rev 6935)
@@ -43,14 +43,14 @@
<para>This is a compilation of the most frequently asked
questions about JBoss Cache. Please report any bugs,
inconsistencies, or omissions you find in this FAQ on the
- <ulink url="http://jboss.org/index.html?module=bb&op=main&c=29">JBoss Cache User Form
+ <ulink url="http://jboss.org/index.html?module=bb&op=main&c=29">JBoss Cache User Forum
</ulink>
.
</para>
<para>
- This FAQ is divided into specific sections, all pertaining to the core JBoss Cache library. PojoCache has a
+ This FAQ is divided into specific sections, all pertaining to the core JBoss Cache library. POJO Cache has a
separate FAQ
- document pertaining to PojoCache specifics.
+ document pertaining to POJO Cache specifics.
</para>
</abstract>
@@ -84,26 +84,22 @@
<ulink url="http://java.sun.com/products/jta/">JTA</ulink>
compliant transaction
manager and make any cache
- interaction transactional. Note that the cache can also be run without
+ interaction transactional, and caches would participate in ongoing JTA transactions. Note that the cache can also be run without
any replication; this is the local mode.
</para>
- <para>JBoss Cache comes in two flavours: Core and Pojo versions. The core library
- (using the
- <literal>org.jboss.cache.Cache</literal>
- interface
- ) is the underlying library that organises data in a tree-like structure and handles all locking,
+ <para>JBoss Cache comes in two flavours: Core and POJO versions. The core library
+ (using the <literal>org.jboss.cache.Cache</literal>
+ interface) is the underlying library that organises data in a tree-like structure and handles all locking,
passivation,
- eviction and replication characteristics of data in the cache. The pojo library (using the
- <literal>org.jboss.cache.pojo.PojoCache</literal>
- interface) is built atop the core library and allows introspection
- of objects in the cache providing transparent coherence by using JBoss AOP. Note that the Pojo version
+ eviction and replication characteristics of data in the cache. The POJO library (using the
+ <literal>org.jboss.cache.pojo.PojoCache</literal> interface) is built atop the core library and allows introspection
+ of objects in the cache providing transparent coherence by using JBoss AOP. Note that the POJO edition
of JBoss Cache
- (referred to as PojoCache) comes with a separate set of documentation (user guide, FAQ, etc.)
+ (often referred to as POJO Cache) comes with a separate set of documentation (user guide, FAQ, etc.)
available on the
<ulink url="http://labs.jboss.com/portal/jbosscache/docs/index.html">JBoss Cache documentation site
- </ulink>
- .
+ </ulink>.
</para>
<para>
@@ -111,30 +107,17 @@
<itemizedlist>
<listitem>
<para>
- <literal>jboss-cache-core</literal>
+ <literal>jbosscache-core</literal>
</para>
contains the core Cache library for users who do not wish to use the additional functionality
- offered by PojoCache.
+ offered by POJO Cache.
</listitem>
<listitem>
<para>
- <literal>jboss-cache-pojo</literal>
+ <literal>jbosscache-pojo</literal>
</para>
- contains the core Cache library as well as the PojoCache extensions and dependencies.
+ contains the core Cache library as well as POJO Cache extensions and dependencies.
</listitem>
- <listitem>
- <para>
- <literal>jboss-cache-all</literal>
- </para>
- contains all of the above, including unit tests and source code.
- </listitem>
- <listitem>
- <para>
- <literal>jboss-cache-core-JDK140</literal>
- </para>
- contains a JDK 1.4 compatible version of the core Cache library. Note that PojoCache is only
- available for JDK 5.0.
- </listitem>
</itemizedlist>
</para>
</answer>
@@ -149,23 +132,21 @@
<para>
JBoss Cache has an active community of developers and contributors. The project was founded by Bela
Ban
- and is currently led by Manik Surtani. Jason Greene is the lead for the PojoCache subsystem, and other
+ and is currently led by Manik Surtani. Jason Greene is the lead for the POJO Cache subsystem, and other
contributors both past and present include Ben Wang, Harald Gliebe, Brian Stansberry, Vladimir
- Blagojevic,
- Mircea Markus, Jimmy Wilson, Galder Zamarreño and Elias Ross.
+ Blagojevic, Mircea Markus, Jimmy Wilson, Galder Zamarreño and Elias Ross.
</para>
</answer>
</qandaentry>
<qandaentry>
<question>
- <para>What is the license for JBoss Cache?</para>
+ <para>What about licensing?</para>
</question>
<answer>
<para>JBoss Cache is licensed under
- <ulink url="http://www.gnu.org/licenses/lgpl.html">LGPL</ulink>
- .
+ <ulink url="http://www.gnu.org/licenses/lgpl.html">LGPL</ulink>, an <ulink url="http://www.opensource.org/">OSI</ulink>-approved open source license.
</para>
</answer>
</qandaentry>
@@ -178,33 +159,22 @@
<answer>
<para>The JBoss Cache
<ulink url="http://www.jboss.com/products/jbosscache/downloads">product download page</ulink>
- has prebuilt binaries as well as source distributions. You can also grab snapshots from the JBoss CVS
- repository (see
- <ulink url="http://wiki.jboss.org/wiki/Wiki.jsp?page=CVSRepository">this wiki page</ulink>
- ) - the module name is
- <emphasis role="bold">JBossCache</emphasis>
+ has prebuilt binaries as well as source distributions. You can also grab snapshots from the JBoss.org subversion
+ repository. See
+ <ulink url="http://www.jboss.org/community/docs/DOC-10259">the JBoss Cache development</ulink>
+ wiki page for details.
</para>
</answer>
</qandaentry>
<qandaentry>
<question>
- <para>How do I build JBoss Cache from CVS sources?</para>
+ <para>How do I build JBoss Cache from sources?</para>
</question>
<answer>
- <para>To build, do
- <literal>sh build.sh
- jar
- </literal>
- . This will produce
- <literal>jboss-cache.jar</literal>
- and
- <literal>pojocache.jar</literal>
- in the
- <literal>dist/lib</literal>
- directory. Note that you will need to
- use JDK 5 to build the distribution.
+ <para>
+ Read the README-Maven.txt file in the source root. Note that you will need a JDK >= 5.0, and Apache Maven >= 2.0.6.
</para>
</answer>
</qandaentry>
@@ -216,20 +186,12 @@
<answer>
<para>
- JBoss Cache is baselined on Java 5.0 and this is the platform on which JBoss Cache is most thoroughly
- tested.
- If, for whatever reason you have to use Java 1.4, you could build a retroweaved version of the core
- cache
+ JBoss Cache is baselined on Java 5 and is tested on Java 5 and 6 VMs. If, for whatever reason you have
+ to use Java 1.4, you could build a retroweaved version of the core cache
library that is Java 1.4 compatible, using the simple instructions on this wiki page
- <ulink url="http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossCacheHabaneroJava1.4">on building and
- running JBoss Cache on Java 1.4.
- </ulink>
- . Note that Red Hat Inc. does not offer commercial support for retroweaved binaries at this stage.
+ <ulink url="http://www.jboss.org/community/docs/DOC-10263">on building and running JBoss Cache on Java 1.4.
+ </ulink>.
</para>
- <para>
- Java 6 should work as well, and we haven't heard of any specific problems of JBoss Cache run under
- Java 6.
- </para>
</answer>
</qandaentry>
@@ -240,7 +202,7 @@
<answer>
<para>
- <code>java -jar jbosscache.jar</code>
+ <literal>java -jar jbosscache-core.jar</literal>
will spit out version details.
</para>
</answer>
@@ -255,11 +217,9 @@
<answer>
<para>
- Of course! Even though JBoss Cache comes integrated with JBoss Application Server as an MBean service,
- it
- can also be run standalone, in any Java EE server such as BEA WebLogic, IBM Websphere or Tomcat. It
- can also run in
- a standalone Java process, completely outside of an application server. See the user guide for more
+ Absolutely! Even though JBoss Cache comes integrated with JBoss Application Server,
+ it can also be used in any other Java EE server such as BEA WebLogic, IBM Websphere or Tomcat. It
+ can also run in a standalone Java process, completely outside of an application server. See the user guide for more
details.
</para>
</answer>
@@ -271,7 +231,7 @@
</question>
<answer>
<para>Look at
- <ulink url="http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossCache200Migration">this wiki page</ulink>
+ <ulink url="http://www.jboss.org/community/docs/DOC-10246">this wiki page</ulink>
for help.
</para>
</answer>
@@ -279,6 +239,28 @@
<qandaentry>
<question>
+ <para>What about from 2.x to 3.x?</para>
+ </question>
+ <answer>
+ <para>
+ JBoss Cache 3.x is API compatible with 2.x, although as far as possible you should refactor your code
+ not to use deprecated methods as these may disappear in future releases of JBoss Cache.
+ </para>
+ <para>
+ JBoss Cache 3.x comes with an all new configuration format. Old 2.x configuration files will still
+ work, although you will get a warning in the logs about this. Again, as far as possible, we recommend
+ migrating your configuration file to the new format. Scripts are provided with the JBoss Cache 3.x
+ distribution to migrate configuration files (see <literal>config2to3.sh</literal> and <literal>config2to3.bat</literal>).
+ </para>
+ <para>
+ Note that to take advantage of some of the new features in JBoss Cache 3.x, you need to be using the
+ new configuration format.
+ </para>
+ </answer>
+ </qandaentry>
+
+ <qandaentry>
+ <question>
<para>Where can I report bugs or problems?</para>
</question>
@@ -287,8 +269,7 @@
<ulink
url="http://jboss.org/index.html?module=bb&op=main&c=29">JBoss Cache
User Forum
- </ulink>
- .
+ </ulink>.
</para>
</answer>
</qandaentry>
@@ -302,97 +283,19 @@
<qandaentry>
<question>
- <para>How do I deploy JBoss Cache as a MBean service?</para>
+ <para>Using JBoss Cache 2 or 3 on JBoss AS 4.x</para>
</question>
<answer>
- <para>To deploy JBoss Cache as an MBean inside JBoss, you can copy the
- configuration xml file over to the
- <literal>deploy</literal>
- directory (from
- <literal>all</literal>
- configuration whereby the
- necessary jars are present). Under the standalone package
- <literal>etc/config-samples</literal>
- directory, there are example
- configuration files for different cache modes that can be used to
- deploy JBoss Cache as well.
+ <para>
+ JBoss AS 4.x ships with JBoss Cache 1.4.x. To make use of new features, performance improvements
+ and bug fixes in newer releases, you can follow some of the steps outlined on <ulink url="http://www.jboss.org/community/docs/DOC-10254">this wiki page</ulink>.
</para>
</answer>
</qandaentry>
<qandaentry>
<question>
- <para>How do I know if my JBoss Cache MBean has been deployed?</para>
- </question>
-
- <answer>
- <para>To verify that your JBoss Cache MBean is deployed correctly,
- you can first check the log output under the command console. Next
- you can verify it from JBoss JMX console. Look for
- <literal>jboss.cache</literal>
- domain.
- </para>
- </answer>
- </qandaentry>
-
- <qandaentry>
- <question>
- <para>How do I access the JBoss Cache MBean?</para>
- </question>
-
- <answer>
- <para>Accessing the JBoss Cache MBean is just like accessing any
- JBoss MBean. Here is a code snippet:
- </para>
-
- <programlisting role="JAVA"><![CDATA[
-
-import org.jboss.mx.util.MBeanServerLocator;
-import org.jboss.mx.util.MBeanProxyExt;
-import org.jboss.cache.TreeCacheMBean;
-import javax.management.MBeanServer;
-...
-
-MBeanServer server;
-TreeCacheMBean cache;
-
-public init() throws Exception
-{
- try
- {
- server = MBeanServerLocator.locateJBoss();
- cache = (TreeCacheMBean) MBeanProxyExt.create(TreeCacheMBean.class,
- "jboss.cache:service=TreeCache", server);
- }
- catch (Exception ex)
- {
- // handle exception
- }
-}
-
-public void myBusinessMethod()
-{
- Object value = cache.get("/my/node", "myKey");
-
- HashMap stuff = new HashMap();
- stuff.put("key1", "value1");
- stuff.put("key2", "value2");
- stuff.put("key3", "value3");
-
- cache.put("/my/new/node", stuff);
-
- cache.remove("/my/node");
-
- ...
-}
-
- ]]></programlisting>
- </answer>
- </qandaentry>
-
- <qandaentry>
- <question>
<para>Can I run multiple JBoss Cache instances on the same VM?</para>
</question>
@@ -417,23 +320,21 @@
<para>Yes. Since Hibernate 3.0 release, you can configure it to use
JBoss Cache as a second level cache. For details,
see Hibernate documentation, and also see
- <ulink url="http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossCacheHibernate">
- http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossCacheHibernate
- </ulink>
+ <ulink url="http://www.jboss.org/community/docs/DOC-10265">this wiki page</ulink>.
</para>
</answer>
</qandaentry>
<qandaentry>
<question>
- <para>What about using Pojo Cache as a Hibernate cache?</para>
+ <para>What about using POJO Cache as a Hibernate cache?</para>
</question>
<answer>
- <para>It is not necessary to use PojoCache for second level
+ <para>It is not necessary to use POJO Cache for second level
cache inside Hibernate because Hibernate
- manages fine-grained fields in Java objects. Using PojoCache won't
- provide any advantage.
+ manages fine-grained fields in Java objects. Using POJO Cache won't
+ provide any advantage, and will be an unnecessary performance drawback.
</para>
</answer>
</qandaentry>
@@ -456,30 +357,22 @@
<qandaentry>
<question>
- <para>In the configuration xml file, there are tags such as
- <literal>class</literal>
- ,
- <literal>MBean</literal>
- , etc. What are
- these?
+ <para>Can I use a schema or DTD to validate my JBoss Cache configuration file?
</para>
</question>
<answer>
- <para>These are tags for deploying JBoss Cache as a JBoss MBean
- service. For consistency, we have kept them in the
- standalone package as well, specifically, the
- <literal>MBean</literal>
- tag. If you run in standalone mode,
- JBoss Cache will ignore these elements.
+ <para>
+ As of JBoss Cache 3.x, yes. An XSD schema is provided in your jbosscache-core.jar file, and is also
+ available online, on <ulink url="http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd">http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd</ulink>.
+ You can configure your IDE, text editor or XML authoring tool to use this schema to validate your file.
</para>
</answer>
</qandaentry>
<qandaentry>
<question>
- <para>What is the difference between the different cache
- modes?
+ <para>What is the difference between the different cache modes?
</para>
</question>
@@ -533,7 +426,10 @@
<answer>
<para>JBoss Cache leverages
<ulink url="http://www.jgroups.org">JGroups</ulink>
- as a replication layer. A user
+ for network communications. A JGroups configuration section is present in your JBoss Cache configuration.
+ </para>
+ <para>
+ A user
can configure the cluster of JBoss Cache instances by sharing the
same cluster name (
<literal>cluster name</literal>
@@ -607,6 +503,13 @@
</qandaentry>
<qandaentry>
+ <question><para>I'm using Buddy Replication. Do I need to have some form of session affinity?</para></question>
+ <answer><para>Session affinity relates to returning to the same cache instance for the same data being used.
+ While this is strictly not a requirement for Buddy Replication, it is greatly recommended to minimize
+ moving state around a cluster.</para></answer>
+ </qandaentry>
+
+ <qandaentry>
<question>
<para>If I have the need for different configuration properties (e.g.,
<literal>CacheMode</literal>
@@ -642,6 +545,10 @@
a single JGroups channel. Please see the User Guide for details on how to configure the JGroups
Multiplexer.
</para>
+ <para>
+ A faster and more efficient approach is to use a shared transport in JGroups. Please see
+ <ulink url="http://www.jgroups.org">the JGroups documentation</ulink> for more details on how to do this.
+ </para>
</answer>
</qandaentry>
@@ -747,16 +654,13 @@
<answer>
<para>JBoss Cache supports any TransactionManager that is
<ulink url="http://java.sun.com/products/jta/">JTA</ulink>
- compliant such as JBossTM or JBossTS. JBoss Cache ships with a
+ compliant such as <ulink url="http://www.jboss.org/jbosstm/">JBoss Transactions</ulink>.
+ </para>
+ <para>
+ While JBoss Cache does ships with a
dummy transaction manager
- (
- <literal>org.jboss.cache.transaction.DummyTransactionManager</literal>
- ) for
- testing purposes only. But note that
- <literal>DummyTransactionManager</literal>
- is not thread safe .i.e.,
- it does not support concurrent transactions. Instead, only one
- transaction is allowed at a time.
+ (<literal>org.jboss.cache.transaction.DummyTransactionManager</literal>), we do <emphasis>not</emphasis>
+ recommend using this for production. It is not thread safe, and is intended for internal testing only.
</para>
</answer>
</qandaentry>
@@ -783,7 +687,11 @@
cache will look up the transaction context from this transaction
manager.
</para>
-
+ <para>
+ The <literal>org.jboss.cache.transaction.GenericTransactionManagerLookup</literal> class that ships
+ with JBoss Cache is able to detect and bind to most popular transaction managers. See the <literal>GenericTransactionManagerLookup</literal>
+ javadocs for more information.
+ </para>
</answer>
</qandaentry>
@@ -814,6 +722,11 @@
to the
user manual.
</para>
+ <para>
+ As of JBoss Cache 3.x, when using the MVCC locking scheme, only <literal>READ_COMMITTED</literal> and
+ <literal>REPEATABLE_READ</literal> are supported. Any other isolation level provided will either be upgraded
+ or downgraded accordingly.
+ </para>
</answer>
</qandaentry>
@@ -823,35 +736,16 @@
</question>
<answer>
- <para>By default JBoss Cache uses pessimistic locking to lock data nodes, based on the isolation level
+ <para>In JBoss Cache 2.x, by default pessimistic locking is used to lock data nodes, based on the isolation level
configured. We also offer optimistic locking to allow for greater concurrency
at
the cost of slight processing overhead and performance. See the documentation for a more detailed
discussion on concurrency and locking in JBoss Cache.
</para>
- </answer>
- </qandaentry>
-
-
- <qandaentry>
- <question>
- <para>How do I enable Optimistic Locking in JBoss Cache?</para>
- </question>
-
- <answer>
- <para>Use the XMl attribute
- <code>NodeLockingScheme</code>
- . Note that
- <code>IsolationLevel</code>
- is ignored if
- <code>NodeLockingScheme</code>
- is set to
- <code>OPTIMISTIC</code>
- . Also note that
- <code>NodeLockingScheme</code>
- defaults to
- <code>PESSIMISTIC</code>
- if omitted.
+ <para>
+ In JBoss Cache 3.x, optimistic and pessimistic locking are deprecated in favour of MVCC (multi-version concurrency
+ control), which is far more efficient than either optimistic or pessimistic locking. For a detailed discussion on
+ our MVCC implementation, see <ulink url="http://jbosscache.blogspot.com/2008/07/mvcc-has-landed.html">this blog entry</ulink> and <ulink url="http://www.jboss.org/community/docs/DOC-10272">this wiki page</ulink>.
</para>
</answer>
</qandaentry>
@@ -859,26 +753,13 @@
<qandaentry>
<question>
- <para>How does the write lock apply to an Fqn node, say,
- "/org/jboss/test"?
- </para>
+ <para>How do I enable Optimistic Locking or MVCC in JBoss Cache?</para>
</question>
<answer>
- <para>First of all, JBoss Cache has a notion of
- <literal>root</literal>
- that serves as a starting point for every navigational operation.
- The default is "/" (since the default separator is "/" for the fqn).
- The locking then is applied to the node under root, for example
- "/org" (no locking "/").
+ <para>
+ Please see the configuration section of the user guide for details.
</para>
-
- <para>Furthermore, let's say when JBoss Cache needs to apply a write
- lock on node "/org/jboss/test", it will first try to obtain read
- lock from the parent nodes recursively (in this example, "/org", and
- "/org/jboss"). Only when it succeeds then it will try to obtain a
- write lock on "/org/jboss/test".
- </para>
</answer>
</qandaentry>
@@ -914,8 +795,7 @@
during the prepare stage internally). That is, it will be a batch
update. However, if the operations are not under transaction
context, then each update will trigger replication. Note that this
- has performance implication if network transport is heavy (it
- usually is).
+ has performance implications if network latency is a problem.
</para>
</answer>
</qandaentry>
@@ -926,7 +806,7 @@
</question>
<answer>
- <para>If you do a cache.removeNode(Fqn.fromString("/myroot")), it will recursively remove
+ <para>If you do a <literal>cache.removeNode("/myroot")</literal>, it will recursively remove
all the entries under "/myroot".
</para>
</answer>
@@ -953,15 +833,7 @@
</question>
<answer>
- <para>Yes, you can. Set the
- <literal>UseInterceptorMbeans</literal>
- configuration attribute to
- <literal>false</literal>
- (this defaults to
- <literal>true</literal>
- ). See the chapter titled
- <emphasis role="bold">Management Information</emphasis>
- in the JBoss Cache user guide for more details.
+ <para>Yes, you can. See the section on configuration in the JBoss Cache user guide.
</para>
</answer>
</qandaentry>
@@ -991,13 +863,16 @@
different cache instances while still participating as a replication
group.
</para>
+ <para>
+ This is on the roadmap though, so do keep an eye on <ulink url="http://jira.jboss.org/jira/browse/JBCACHE-60">JBCACHE-60</ulink> if you are interested.
+ </para>
</answer>
</qandaentry>
<qandaentry>
<question>
<para>Does JBoss Cache handle the concept of application classloading
- inside, say, a J2EE container?
+ inside, say, a Java EE container?
</para>
</question>
@@ -1046,60 +921,11 @@
the user guide for more details.
</para>
- <para>To solve the second kind of issue, the only solution (that we
- know of) is to cache "serialized" byte code and only de-serialize it
- during every object get (and this will be expensive!). That is,
- during a put operation, the object instance will be serialized and
- therefore can be deserialized safely by a "foreign" classloader.
- However, the performance penalty of this approach is quite severe so
- in general another local in-vm version will need to be used as a
- "near-line" cache. Note also that each time the serialized bytes are
- deserialized, a new instance of the object is created.
+ <para>To solve the second kind of issue, you can use the the <literal>UseLazyDeserialization</literal> configuration
+ option in JBoss Cache, which wraps your objects in a <literal>Marshalledvalue</literal> wrapper. The <literal>MarshalledValue</literal>
+ serializes and deserializes your object on demand, ensuring the proper thread local context class loader is used each time.
</para>
-
- <para>To help with this kind of handling, JBoss has a utility class
- called
- <literal>MarshalledValue</literal>
- that wraps around the
- serialized object. Here is a code snippet that illustrates how you
- can create a wrapper around JBoss Cache to handle the classloader
- issue:
- </para>
-
- <programlisting role="JAVA">
- <![CDATA[
-import org.jboss.invocation.MarshalledValue;
-
-public class CacheService
-{
- private Cache cache;
-
- public Object get(Fqn fqn, String key)
- {
- return getUnMarshalledValue(cache.get(fqn, key));
- }
-
- public Object set(Fqn fqn, String key, Object value)
- {
- cache.put(fqn, key, getMarshalledValue(value));
- return value; // only if successful
- }
-
- ...
-
- private Object getUnMarshalledValue(object value)
- {
- // assuming we use the calling thread context classloader
- return ((MarshalledValue)value).get();
- }
-
- private Object getMarshalledValue(Object value)
- {
- return new MarshalledValue(value);
- }
-}
-]]></programlisting>
- </answer>
+ </answer>
</qandaentry>
<qandaentry>
@@ -1113,8 +939,8 @@
<para>Yes. A boolean is passed in to each notification callback identifying whether the callback is
before
or after the event. See the
- <literal>org.jboss.cache.CacheListener</literal>
- interface for details.
+ <literal>org.jboss.cache.notifications.annotations.CacheListener</literal>
+ annotation for details.
</para>
</answer>
</qandaentry>
@@ -1128,13 +954,7 @@
<answer>
<para>
- Either implement
- <literal>org.jboss.cache.CacheListener</literal>
- or extend
- <literal>org.jboss.cache.AbstractCacheListener</literal>
- and override for the events you are interested in. You can then register the listener using the
- <literal>org.jboss.cache.Cache.addCacheListener()</literal>
- API.
+ See the user guide on this subject.
</para>
</answer>
</qandaentry>
@@ -1203,7 +1023,7 @@
<answer>
<para>Yes. JBoss Cache currently supports multiple eviction policies such as LRU, MRU, and FIFO.
Users can also plug in their own eviction policy algorithms. See user
- manual for details.
+ guide for details.
</para>
</answer>
</qandaentry>
@@ -1281,72 +1101,6 @@
<qandaentry>
<question>
- <para>What are the
- <literal>EvictionPolicyConfig</literal>
- tag
- parameters for
- <literal>org.jboss.cache.eviction.LRUPolicy</literal>
- ?
- </para>
- </question>
-
- <answer>
- <para>They are:</para>
-
- <table>
- <title>Parameters</title>
-
- <tgroup cols="2">
- <tbody>
- <row>
- <entry>eventQueueSize</entry>
-
- <entry>A fine-tuning parameter where you can configure the size of the eviction notification
- event queue. Defaults to 200,000.
- </entry>
- </row>
-
- <row>
- <entry>wakeUpIntervalInSeconds</entry>
-
- <entry>Interval where the clean up thread wakes to process
- the sitting queue and sweep away the old data.
- </entry>
- </row>
-
- <row>
- <entry>region</entry>
-
- <entry>A area where each eviction policy parameters are
- specified. Note that it needs a minimum of
- <literal>/_default</literal>
- region.
- </entry>
- </row>
-
- <row>
- <entry>maxNodes</entry>
-
- <entry>Max number of nodes allowed in the eviction queue. 0
- means no limit.
- </entry>
- </row>
-
- <row>
- <entry>timeToLiveInSeconds</entry>
-
- <entry>Age (in seconds) for the node to be evicted in the
- queue. 0 denotes no limit.
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </answer>
- </qandaentry>
-
- <qandaentry>
- <question>
<para>I have turned on the eviction policy, why do I still get "out
of memory" (OOM) exception?
</para>
@@ -1356,18 +1110,15 @@
<para>OOM can happen when the speed of cache access exceeds the
speed of eviction policy handling timer. Eviction policy handler
will wake up every
- <literal>wakeUpIntervalInSeconds</literal>
- seconds to process the eviction event queue. So when the queue size is full, it will create a
+ <literal>wakeUpInterval</literal> milliseconds (or <literal>wakeUpIntervalSeconds</literal> seconds, prior to 3.x)
+ to process the eviction event queue. So when the queue size is full, it will create a
backlog and cause out-of-memory exceptions to happen unless the eviction timer catches
up. To address this problem, in addition to increase the VM heap
size, you can also reduce the
- <literal>wakeUpIntervaleInSeconds</literal>
+ <literal>wakeUpInterval</literal>
so the timer thread
processes the queue more frequently.
</para>
-
- <para>The eviction queue size is configurable.
- </para>
</answer>
</qandaentry>
</qandaset>
@@ -1419,15 +1170,21 @@
<listitem>
<para>
- <literal>org.jboss.cache.loader.BdbjeCacheLoader</literal>
+ <literal>org.jboss.cache.loader.jdbm.JdbmCacheLoader</literal>
+ : this implementation is based on <ulink url="http://jdbm.sourceforge.net/">JDBM</ulink>,
+ an open source file-based transactional persistence engine.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ <literal>org.jboss.cache.loader.bdbje.BdbjeCacheLoader</literal>
: this implementation is based on the
Oracle's Berkeley DB Java Edition database, a fast and efficient
transactional database. It uses a single file for the entire
store. Note that if you use the Berkeley DB cache loader with
JBoss Cache and wish to ship your product, you will have to acquire a
- <ulink url="http://www.sleepycat.com/jeforjbosscache">commercial license from Oracle
- </ulink>
- .
+ <ulink url="http://www.sleepycat.com/jeforjbosscache">commercial license from Oracle</ulink>.
</para>
</listitem>
@@ -1641,7 +1398,7 @@
</question>
<answer>
<para>Troubleshooting section can be found in the following
- <ulink url="http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossCacheTroubleshooting">wiki link</ulink>
+ <ulink url="http://www.jboss.org/community/docs/DOC-10288">wiki link</ulink>
.
</para>
</answer>
17 years, 2 months
JBoss Cache SVN: r6934 - core/branches/2.2.X/src/main/java/org/jboss/cache/loader.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-14 09:52:34 -0400 (Tue, 14 Oct 2008)
New Revision: 6934
Modified:
core/branches/2.2.X/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java
Log:
Added fix for JBCACHE-1426
Modified: core/branches/2.2.X/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java 2008-10-14 13:26:25 UTC (rev 6933)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java 2008-10-14 13:52:34 UTC (rev 6934)
@@ -220,8 +220,9 @@
{
updateNode(name, attributes);
}
- else
- {//the node exists and the attribute map is NOT null
+ else if (attributes != null && !attributes.isEmpty())
+ {
+ //the node exists and the attribute map is NOT null
Map<Object, Object> newAttributes = new HashMap<Object, Object>(treeNode);
newAttributes.putAll(attributes);//creation sequnce important - we need to overwrite old values
updateNode(name, newAttributes);
17 years, 2 months
JBoss Cache SVN: r6933 - core/trunk/src/test/java/org/jboss/cache/loader.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-14 09:26:25 -0400 (Tue, 14 Oct 2008)
New Revision: 6933
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
Log:
Added test for JBCACHE-1426
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-10-14 12:35:58 UTC (rev 6932)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-10-14 13:26:25 UTC (rev 6933)
@@ -8,6 +8,7 @@
import org.jboss.cache.Modification;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.statetransfer.DefaultStateTransferManager;
@@ -34,8 +35,6 @@
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.CountDownLatch;
-import org.jboss.cache.UnitTestCacheFactory;
-import org.testng.annotations.Test;
/**
* Commons tests for all CacheLoaders
@@ -59,23 +58,23 @@
private static final Fqn BUDDY_PLUS_FQN = Fqn.fromRelativeFqn(BUDDY_BASE, FQN);
private static final Fqn BUDDY_PLUS_SUBTREE_FQN = Fqn.fromRelativeFqn(BUDDY_BASE, SUBTREE_FQN);
-
+
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
try
{
CacheSPI<Object, Object> cache =
- (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
+ (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
cacheTL.set(cache);
-
+
Configuration c = cache.getConfiguration();
c.setCacheMode(Configuration.CacheMode.LOCAL);
- c.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
+ c.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
configureCache();
cache.start();
- CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();
- loaderTL.set(loader);
+ CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();
+ loaderTL.set(loader);
postConfigure();
}
catch (Exception e)
@@ -221,6 +220,34 @@
assertEquals("combined", 4, cache.getNode(NODE).getData().size());
}
+ public void testPutNullDataMap() throws Exception
+ {
+ Fqn f = Fqn.fromString("/a");
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+ assert !cache.exists(f);
+ assert !loader.exists(f);
+ cache.put(f, null);
+ Map fromLoader = loader.get(f);
+ assert fromLoader != null : "Node should exist in the loader";
+ assert fromLoader.isEmpty() : "Should not contain any data";
+ }
+
+ public void testPutNullDataMapNodeHasData() throws Exception
+ {
+ Fqn f = Fqn.fromString("/a");
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+ cache.put(f, "key", "value");
+ assert cache.exists(f);
+ assert loader.exists(f);
+ cache.put(f, null);
+ Map fromLoader = loader.get(f);
+ assert fromLoader != null : "Node should exist in the loader";
+ assert fromLoader.size() == 1 : "Should contain original data";
+ }
+
+
public void testShallowMove() throws Exception
{
CacheSPI<Object, Object> cache = cacheTL.get();
@@ -338,7 +365,7 @@
public void testGetNode() throws CacheException
{
CacheSPI<Object, Object> cache = cacheTL.get();
-
+
final String NODE = "/a/b/c";
Node<Object, Object> retval;
cache.removeNode(NODE);
@@ -1530,7 +1557,7 @@
{
CacheLoader loader = loaderTL.get();
-
+
Set set = loader.getChildrenNames(fqn);
if (names != null)
{
@@ -1626,7 +1653,7 @@
{
CacheLoader loader = loaderTL.get();
-
+
List<Modification> mods = createUpdates();
loader.prepare(null, mods, true);
checkModifications(mods);
@@ -1640,7 +1667,7 @@
{
CacheLoader loader = loaderTL.get();
-
+
// Object txnKey = new Object();
TransactionManager mgr = getTransactionManager();
mgr.begin();
@@ -1659,7 +1686,7 @@
*/
public void testTransactionRollback() throws Exception
{
- CacheLoader loader = loaderTL.get();
+ CacheLoader loader = loaderTL.get();
loader.remove(Fqn.fromString("/"));
int num;
try
@@ -1801,7 +1828,7 @@
{
CacheLoader loader = loaderTL.get();
-
+
loader.put(FQN, null, "x");
addDelay();
assertEquals("x", loader.get(FQN).get(null));
17 years, 2 months
JBoss Cache SVN: r6932 - core/branches/2.2.X/src/test/java/org/jboss/cache/loader.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-14 08:35:58 -0400 (Tue, 14 Oct 2008)
New Revision: 6932
Modified:
core/branches/2.2.X/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
Log:
Added test for JBCACHE-1426
Modified: core/branches/2.2.X/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
===================================================================
--- core/branches/2.2.X/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-10-14 12:07:32 UTC (rev 6931)
+++ core/branches/2.2.X/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-10-14 12:35:58 UTC (rev 6932)
@@ -833,10 +833,32 @@
assertEquals("Has key 'one", "one", data.get("one"));
assertEquals("Has key 'two", "two", data.get("two"));
assertEquals("Has key 'three", "three", data.get("three"));
-
+
}
+ public void testPutNullDataMap() throws Exception
+ {
+ Fqn f = Fqn.fromString("/a");
+ assert !cache.exists(f);
+ assert !loader.exists(f);
+ cache.put(f, null);
+ Map fromLoader = loader.get(f);
+ assert fromLoader != null : "Node should exist in the loader";
+ assert fromLoader.isEmpty() : "Should not contain any data";
+ }
+ public void testPutNullDataMapNodeHasData() throws Exception
+ {
+ Fqn f = Fqn.fromString("/a");
+ cache.put(f, "key", "value");
+ assert cache.exists(f);
+ assert loader.exists(f);
+ cache.put(f, null);
+ Map fromLoader = loader.get(f);
+ assert fromLoader != null : "Node should exist in the loader";
+ assert fromLoader.size() == 1 : "Should contain original data";
+ }
+
public void testRemoveData()
{
String key = "/x/y/z/";
17 years, 2 months