JBoss Cache SVN: r7279 - core/trunk/src/test/java/org/jboss/cache/buddyreplication.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-12-10 22:12:21 -0500 (Wed, 10 Dec 2008)
New Revision: 7279
Modified:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
Log:
reduced timeout for buddies
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2008-12-10 16:55:29 UTC (rev 7278)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2008-12-11 03:12:21 UTC (rev 7279)
@@ -137,7 +137,7 @@
BuddyReplicationConfig brc = new BuddyReplicationConfig();
if (buddyPoolName != null) brc.setBuddyPoolName(buddyPoolName);
brc.setEnabled(true);
- brc.setBuddyCommunicationTimeout(500000);
+// brc.setBuddyCommunicationTimeout(500000);
brc.setDataGravitationRemoveOnFind(removeOnFind);
brc.setDataGravitationSearchBackupTrees(true);
brc.setAutoDataGravitation(useDataGravitation);
16 years, 1 month
JBoss Cache SVN: r7278 - in core/branches/flat/src/main/java/org/jboss/starobrno: util and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-12-10 11:55:29 -0500 (Wed, 10 Dec 2008)
New Revision: 7278
Added:
core/branches/flat/src/main/java/org/jboss/starobrno/util/BeanUtils.java
core/branches/flat/src/main/java/org/jboss/starobrno/util/FileLookup.java
core/branches/flat/src/main/java/org/jboss/starobrno/util/ImmutableListCopy.java
core/branches/flat/src/main/java/org/jboss/starobrno/util/SimpleImmutableEntry.java
core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/BoundedExecutors.java
core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/ConcurrentHashSet.java
core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/ReclosableLatch.java
core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/SelfInitializingConcurrentHashMap.java
core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/WithinThreadExecutor.java
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeCacheImpl.java
Log:
Fixed eviction in tree adapter
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeCacheImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeCacheImpl.java 2008-12-10 16:43:27 UTC (rev 7277)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeCacheImpl.java 2008-12-10 16:55:29 UTC (rev 7278)
@@ -166,9 +166,59 @@
public void evict(Fqn fqn, boolean recursive)
{
- //TODO: Autogenerated. Implement me properly
+ boolean removeFromParent;
+ if (recursive)
+ {
+ childFirstEvict(fqn);
+ removeFromParent = true;
+ }
+ else
+ {
+ removeFromParent = evictNode((NodeImpl) getNode(fqn), false);
+ }
+
+ if (!fqn.isRoot() && removeFromParent)
+ {
+ Node parent = getNode(fqn.getParent());
+ parent.removeChild(fqn.getLastElement());
+ }
}
+ private void childFirstEvict(Fqn fqn)
+ {
+ Node n = getNode(fqn);
+ if (n != null)
+ {
+ for (Object childName : n.getChildrenNames())
+ {
+ childFirstEvict(Fqn.fromRelativeElements(fqn, childName));
+ }
+ }
+ evictNode((NodeImpl) n, true);
+ }
+
+ /**
+ * Returns true if the node was completely removed; false if just the data was evicted.
+ *
+ * @param node
+ * @param recursive
+ * @return
+ */
+ private boolean evictNode(NodeImpl node, boolean recursive)
+ {
+ boolean retval = false;
+ if (node != null)
+ {
+ if (recursive || node.getChildrenNames().isEmpty())
+ {
+ cache.evict(node.structureKey);
+ retval = true;
+ }
+ cache.evict(node.dataKey);
+ }
+ return retval;
+ }
+
public void evict(Fqn fqn)
{
startAtomic();
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/util/BeanUtils.java (from rev 7261, core/branches/flat/src/main/java/org/jboss/cache/util/BeanUtils.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/BeanUtils.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/BeanUtils.java 2008-12-10 16:55:29 UTC (rev 7278)
@@ -0,0 +1,131 @@
+/*
+ * 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.util;
+
+import java.lang.reflect.Method;
+import java.util.Locale;
+
+/**
+ * Simple JavaBean manipulation helper methods
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 2.1.0
+ */
+public class BeanUtils
+{
+ /**
+ * Retrieves a setter name based on a field name passed in
+ *
+ * @param fieldName field name to find setter for
+ * @return name of setter method
+ */
+ public static String setterName(String fieldName)
+ {
+ StringBuilder sb = new StringBuilder("set");
+ if (fieldName != null && fieldName.length() > 0)
+ {
+ sb.append(fieldName.substring(0, 1).toUpperCase(Locale.ENGLISH));
+ if (fieldName.length() > 1)
+ {
+ sb.append(fieldName.substring(1));
+ }
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Returns a getter for a given class
+ *
+ * @param componentClass class to find getter for
+ * @return name of getter method
+ */
+ public static String getterName(Class componentClass)
+ {
+ if (componentClass == null) return null;
+ StringBuilder sb = new StringBuilder("get");
+ sb.append(componentClass.getSimpleName());
+ return sb.toString();
+ }
+
+ /**
+ * Returns a setter for a given class
+ *
+ * @param componentClass class to find setter for
+ * @return name of getter method
+ */
+ public static String setterName(Class componentClass)
+ {
+ if (componentClass == null) return null;
+ StringBuilder sb = new StringBuilder("set");
+ sb.append(componentClass.getSimpleName());
+ return sb.toString();
+ }
+
+
+ /**
+ * Returns a Method object corresponding to a getter that retrieves an instance of componentClass from target.
+ *
+ * @param target class that the getter should exist on
+ * @param componentClass component to get
+ * @return Method object, or null of one does not exist
+ */
+ public static Method getterMethod(Class target, Class componentClass)
+ {
+ try
+ {
+ return target.getMethod(getterName(componentClass));
+ }
+ catch (NoSuchMethodException e)
+ {
+ //if (log.isTraceEnabled()) log.trace("Unable to find method " + getterName(componentClass) + " in class " + target);
+ return null;
+ }
+ catch (NullPointerException e)
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Returns a Method object corresponding to a setter that sets an instance of componentClass from target.
+ *
+ * @param target class that the setter should exist on
+ * @param componentClass component to set
+ * @return Method object, or null of one does not exist
+ */
+ public static Method setterMethod(Class target, Class componentClass)
+ {
+ try
+ {
+ return target.getMethod(setterName(componentClass), componentClass);
+ }
+ catch (NoSuchMethodException e)
+ {
+ //if (log.isTraceEnabled()) log.trace("Unable to find method " + setterName(componentClass) + " in class " + target);
+ return null;
+ }
+ catch (NullPointerException e)
+ {
+ return null;
+ }
+ }
+}
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/util/BeanUtils.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/util/FileLookup.java (from rev 7261, core/branches/flat/src/main/java/org/jboss/cache/util/FileLookup.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/FileLookup.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/FileLookup.java 2008-12-10 16:55:29 UTC (rev 7278)
@@ -0,0 +1,109 @@
+/*
+ * 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.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * Holds the logic of looking up a file, in the following sequence:
+ * <ol>
+ * <li> try to load it with the curent thread's context ClassLoader</li>
+ * <li> if fails, the system ClassLoader</li>
+ * <li> if fails, try to load it as a file from the disck </li>
+ * </ol>
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+public class FileLookup
+{
+ private static final Log log = LogFactory.getLog(FileLookup.class);
+
+ /**
+ * Looks up the file, see : {@link FileLookup}.
+ *
+ * @param filename might be the name of the file (too look it up in the class path) or an url to a file.
+ * @return an input stream to the file or null if nothing found through all lookup steps.
+ */
+ public InputStream lookupFile(String filename)
+ {
+ InputStream is = getAsInputStreamFromClassLoader(filename);
+ if (is == null)
+ {
+ if (log.isDebugEnabled())
+ log.debug("Unable to find configuration file " + filename + " in classpath; searching for this file on the filesystem instead.");
+ try
+ {
+ is = new FileInputStream(filename);
+ }
+ catch (FileNotFoundException e)
+ {
+ return null;
+ }
+ }
+ return is;
+ }
+
+ protected InputStream getAsInputStreamFromClassLoader(String filename)
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ InputStream is = cl == null ? null : cl.getResourceAsStream(filename);
+ if (is == null)
+ {
+ // check system class loader
+ is = getClass().getClassLoader().getResourceAsStream(filename);
+ }
+ return is;
+ }
+
+ public URL lookupFileLocation(String filename)
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ URL u = cl == null ? null : cl.getResource(filename);
+ if (u == null)
+ {
+ // check system class loader
+ u = getClass().getClassLoader().getResource(filename);
+ }
+ if (u == null)
+ {
+ File f = new File(filename);
+ if (f.exists()) try
+ {
+ u = f.toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ // what do we do here?
+ }
+ }
+ return u;
+ }
+}
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/util/FileLookup.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/util/ImmutableListCopy.java (from rev 7261, core/branches/flat/src/main/java/org/jboss/cache/util/ImmutableListCopy.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/ImmutableListCopy.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/ImmutableListCopy.java 2008-12-10 16:55:29 UTC (rev 7278)
@@ -0,0 +1,474 @@
+/*
+ * 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.util;
+
+import net.jcip.annotations.Immutable;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.lang.reflect.Array;
+import java.util.*;
+
+/**
+ * A lightweight, read-only copy of a List. Typically used in place of the common idiom:
+ * <code>
+ * return Collections.unmodifiableList(new ArrayList( myInternalList ));
+ * </code>
+ * <p/>
+ * a it is far more efficient than making a defensive copy and then wrapping the defensive copy in a read-only wrapper.
+ * <p/>
+ * Also used whenever a read-only reference List is needed (such as in Fqns).
+ * <p/>
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+@Immutable
+public class ImmutableListCopy<E> extends AbstractList<E> implements Externalizable, Immutables.Immutable
+{
+ private static final long serialVersionUID = 10929568968966L;
+ private E[] elements;
+ private int size;
+
+ /**
+ * Constructs a new ImmutableListCopy.
+ * Required by Serialization.
+ */
+ public ImmutableListCopy()
+ {
+ }
+
+ /**
+ * Only one copy constructor since the list is immutable.
+ *
+ * @param c collection to copy from
+ */
+ @SuppressWarnings("unchecked")
+ public ImmutableListCopy(Collection<? extends E> c)
+ {
+ size = c.size();
+ Object[] el = new Object[size]; // no room for growth;
+ el = c.toArray(el);
+ elements = (E[]) el;
+ }
+
+ /**
+ * Assumes that the array passed in is "safe", i.e., is not referenced from elsewhere. Use with care!
+ *
+ * @param array to reference
+ */
+ public ImmutableListCopy(E[] array)
+ {
+ size = array.length;
+ elements = array;
+ }
+
+ /**
+ * Utility constructors to allow combining collections
+ *
+ * @param collection1 collection to copy from
+ * @param collection2 collection to copy from
+ */
+ @SuppressWarnings("unchecked")
+ public ImmutableListCopy(Collection<? extends E> collection1, Collection<? extends E> collection2)
+ {
+ size = collection1.size() + collection2.size();
+ elements = (E[]) new Object[size]; // no room for growth;
+ Object[] c1 = new Object[collection1.size()];
+ Object[] c2 = new Object[collection2.size()];
+ c1 = collection1.toArray(c1);
+ c2 = collection2.toArray(c2);
+ System.arraycopy(c1, 0, elements, 0, c1.length);
+ System.arraycopy(c2, 0, elements, c1.length, c2.length);
+ }
+
+ @Override
+ public final int size()
+ {
+ return size;
+ }
+
+ @Override
+ public final boolean isEmpty()
+ {
+ return size == 0;
+ }
+
+ @Override
+ public final boolean contains(Object o)
+ {
+ return indexOf(o) >= 0;
+ }
+
+ @Override
+ public final Iterator<E> iterator()
+ {
+ return new ImmutableIterator();
+ }
+
+ @Override
+ public final Object[] toArray()
+ {
+ Object[] result = new Object[size];
+ System.arraycopy(elements, 0, result, 0, size);
+ return result;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public final <T> T[] toArray(T[] a)
+ {
+ if (a.length < size)
+ {
+ a = (T[]) Array.newInstance(a.getClass().getComponentType(), size);
+ }
+ System.arraycopy(elements, 0, a, 0, size);
+ if (a.length > size) a[size] = null;
+ return a;
+ }
+
+ @Override
+ public final boolean add(E o)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public final boolean remove(Object o)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public final boolean addAll(Collection<? extends E> c)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public final boolean addAll(int index, Collection<? extends E> c)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public final boolean removeAll(Collection<?> c)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public final boolean retainAll(Collection<?> c)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public final E get(int index)
+ {
+ if (index >= size || index < 0) throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
+ return elements[index];
+ }
+
+ @Override
+ public final int indexOf(Object o)
+ {
+ if (o == null)
+ {
+ for (int i = 0; i < size; i++)
+ {
+ if (elements[i] == null) return i;
+ }
+ }
+ else
+ {
+ for (int i = 0; i < size; i++)
+ {
+ if (o.equals(elements[i])) return i;
+ }
+ }
+ return -1;
+ }
+
+ @Override
+ public final int lastIndexOf(Object o)
+ {
+ if (o == null)
+ {
+ for (int i = size - 1; i >= 0; i--)
+ {
+ if (elements[i] == null) return i;
+ }
+ }
+ else
+ {
+ for (int i = size - 1; i >= 0; i--)
+ {
+ if (o.equals(elements[i])) return i;
+ }
+ }
+ return -1;
+ }
+
+ @Override
+ public final ListIterator<E> listIterator()
+ {
+ return new ImmutableIterator();
+ }
+
+ @Override
+ public final ListIterator<E> listIterator(int index)
+ {
+ return new ImmutableIterator(index);
+ }
+
+ @Override
+ public final List<E> subList(int fromIndex, int toIndex)
+ {
+ return new ImmutableSubList<E>(fromIndex, toIndex);
+ }
+
+ /**
+ * Format:
+ * - entry array size (int)
+ * - elements (Object)
+ *
+ * @param out stream to write to
+ * @throws IOException
+ */
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ out.writeInt(size);
+ for (E e : elements) out.writeObject(e);
+ }
+
+ /**
+ * See {@link #writeExternal(java.io.ObjectOutput)} for serialization format
+ *
+ * @param in stream
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ @SuppressWarnings("unchecked")
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ size = in.readInt();
+ elements = (E[]) new Object[size];
+ for (int i = 0; i < size; i++) elements[i] = (E) in.readObject();
+ }
+
+ private class ImmutableIterator implements ListIterator<E>
+ {
+ int cursor = 0;
+
+ ImmutableIterator(int index)
+ {
+ if (index < 0 || index > size()) throw new IndexOutOfBoundsException("Index: " + index);
+ cursor = index;
+ }
+
+ ImmutableIterator()
+ {
+ }
+
+ public boolean hasNext()
+ {
+ return cursor != size;
+ }
+
+ public E next()
+ {
+ try
+ {
+ return get(cursor++);
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ throw new NoSuchElementException();
+ }
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean hasPrevious()
+ {
+ return cursor != 0;
+ }
+
+ public E previous()
+ {
+ try
+ {
+ return get(--cursor);
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ throw new NoSuchElementException();
+ }
+ }
+
+ public int nextIndex()
+ {
+ return cursor;
+ }
+
+ public int previousIndex()
+ {
+ return cursor - 1;
+ }
+
+ public void set(E o)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void add(E o)
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ private class ImmutableSubList<E> extends AbstractList<E>
+ {
+ private int offset;
+ private int size;
+
+ ImmutableSubList(int fromIndex, int toIndex)
+ {
+ if (fromIndex < 0 || toIndex > ImmutableListCopy.this.size || fromIndex > toIndex)
+ throw new IllegalArgumentException("fromIndex(" + fromIndex + "), toIndex(" + toIndex + "), size (" + ImmutableListCopy.this.size + "), List=" + ImmutableListCopy.this.toString());
+ offset = fromIndex;
+ size = toIndex - fromIndex;
+ }
+
+ @SuppressWarnings("unchecked")
+ public final E get(int index)
+ {
+ if (index < 0 || index >= size) throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
+ return (E) ImmutableListCopy.this.get(index + offset);
+ }
+
+ public final int size()
+ {
+ return size;
+ }
+
+ @Override
+ protected final void removeRange(int fromIndex, int toIndex)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public final boolean addAll(Collection<? extends E> c)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public final boolean addAll(int index, Collection<? extends E> c)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public final Iterator<E> iterator()
+ {
+ return listIterator();
+ }
+
+ @Override
+ public final ListIterator<E> listIterator(final int index)
+ {
+ if (index < 0 || (index != 0 && index >= size))
+ throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
+
+ return new ListIterator<E>()
+ {
+ private ListIterator i = ImmutableListCopy.this.listIterator(index + offset);
+
+ public boolean hasNext()
+ {
+ return nextIndex() < size;
+ }
+
+ @SuppressWarnings("unchecked")
+ public E next()
+ {
+ if (hasNext())
+ return (E) i.next();
+ else
+ throw new NoSuchElementException();
+ }
+
+ public boolean hasPrevious()
+ {
+ return previousIndex() >= 0;
+ }
+
+ @SuppressWarnings("unchecked")
+ public E previous()
+ {
+ if (hasPrevious())
+ return (E) i.previous();
+ else
+ throw new NoSuchElementException();
+ }
+
+ public int nextIndex()
+ {
+ return i.nextIndex() - offset;
+ }
+
+ public int previousIndex()
+ {
+ return i.previousIndex() - offset;
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void set(E o)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void add(E o)
+ {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+ @Override
+ public final List<E> subList(int fromIndex, int toIndex)
+ {
+ return new ImmutableSubList<E>(offset + fromIndex, offset + toIndex);
+ }
+ }
+}
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/util/ImmutableListCopy.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/util/SimpleImmutableEntry.java (from rev 7261, core/branches/flat/src/main/java/org/jboss/cache/util/SimpleImmutableEntry.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/SimpleImmutableEntry.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/SimpleImmutableEntry.java 2008-12-10 16:55:29 UTC (rev 7278)
@@ -0,0 +1,88 @@
+/*
+ * 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.util;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Map.Entry;
+
+/**
+ * Where is Java 1.6?
+ */
+public class SimpleImmutableEntry<K, V> implements Map.Entry<K, V>, Serializable
+{
+ private static final long serialVersionUID = -6092752114794052323L;
+
+ private final K key;
+
+ private final V value;
+
+ public SimpleImmutableEntry(Entry<K, V> me)
+ {
+ key = me.getKey();
+ value = me.getValue();
+ }
+
+ public SimpleImmutableEntry(K key, V value)
+ {
+ this.key = key;
+ this.value = value;
+ }
+
+ public K getKey()
+ {
+ return key;
+ }
+
+ public V getValue()
+ {
+ return value;
+ }
+
+ public V setValue(V arg0)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (!(o instanceof Map.Entry))
+ return false;
+ Map.Entry e2 = (Map.Entry) o;
+ return (getKey() == null ? e2.getKey() == null : getKey().equals(e2.getKey()))
+ && (getValue() == null ? e2.getValue() == null : getValue().equals(e2.getValue()));
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return (getKey() == null ? 0 : getKey().hashCode()) ^
+ (getValue() == null ? 0 : getValue().hashCode());
+ }
+
+ @Override
+ public String toString()
+ {
+ return key + "=" + value;
+ }
+}
\ No newline at end of file
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/util/SimpleImmutableEntry.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/BoundedExecutors.java (from rev 7261, core/branches/flat/src/main/java/org/jboss/cache/util/concurrent/BoundedExecutors.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/BoundedExecutors.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/BoundedExecutors.java 2008-12-10 16:55:29 UTC (rev 7278)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.util.concurrent;
+
+import java.util.concurrent.*;
+
+/**
+ * Similar to JDK {@link java.util.concurrent.Executors} except that the factory methods here allow you to specify the
+ * size of the blocking queue that backs the executor.
+ *
+ * @author Manik Surtani (<a href="mailto:manik AT jboss DOT org">manik AT jboss DOT org</a>)
+ * @since 3.0
+ */
+public class BoundedExecutors
+{
+ /**
+ * Creates a thread pool that reuses a fixed set of threads
+ * operating off a shared bounded queue. If any thread
+ * terminates due to a failure during execution prior to shutdown,
+ * a new one will take its place if needed to execute subsequent
+ * tasks.
+ *
+ * @param nThreads the number of threads in the pool
+ * @param boundedQueueSize size of the bounded queue
+ * @return the newly created thread pool
+ */
+ public static ExecutorService newFixedThreadPool(int nThreads, int boundedQueueSize)
+ {
+ return new ThreadPoolExecutor(nThreads, nThreads,
+ 0L, TimeUnit.MILLISECONDS,
+ new LinkedBlockingQueue<Runnable>(boundedQueueSize));
+ }
+
+ /**
+ * Creates a thread pool that reuses a fixed set of threads
+ * operating off a shared bounded queue, using the provided
+ * ThreadFactory to create new threads when needed.
+ *
+ * @param nThreads the number of threads in the pool
+ * @param threadFactory the factory to use when creating new threads
+ * @param boundedQueueSize size of the bounded queue
+ * @return the newly created thread pool
+ */
+ public static ExecutorService newFixedThreadPool(int nThreads, ThreadFactory threadFactory, int boundedQueueSize)
+ {
+ return new ThreadPoolExecutor(nThreads, nThreads,
+ 0L, TimeUnit.MILLISECONDS,
+ new LinkedBlockingQueue<Runnable>(boundedQueueSize),
+ threadFactory);
+ }
+}
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/BoundedExecutors.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/ConcurrentHashSet.java (from rev 7261, core/branches/flat/src/main/java/org/jboss/cache/util/concurrent/ConcurrentHashSet.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/ConcurrentHashSet.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/ConcurrentHashSet.java 2008-12-10 16:55:29 UTC (rev 7278)
@@ -0,0 +1,144 @@
+/*
+ * 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.util.concurrent;
+
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * A simple Set implementation backed by a {@link java.util.concurrent.ConcurrentHashMap} to deal with the fact that the
+ * JDK does not have a proper concurrent Set implementation that uses efficient lock striping.
+ * <p/>
+ * Note that values are stored as keys in the underlying Map, with a static dummy object as value.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 2.0.0
+ */
+public class ConcurrentHashSet<E> extends AbstractSet<E>
+{
+ protected ConcurrentHashMap<E, Object> map;
+ private static final Object DUMMY = new Object();
+
+ public ConcurrentHashSet()
+ {
+ map = new ConcurrentHashMap<E, Object>();
+ }
+
+ /**
+ * @param concurrencyLevel passed in to the underlying CHM. See {@link java.util.concurrent.ConcurrentHashMap#ConcurrentHashMap(int, float, int)} javadocs for details.
+ */
+ public ConcurrentHashSet(int concurrencyLevel)
+ {
+ map = new ConcurrentHashMap<E, Object>(16, 0.75f, concurrencyLevel);
+ }
+
+ /**
+ * Params passed in to the underlying CHM. See {@link java.util.concurrent.ConcurrentHashMap#ConcurrentHashMap(int, float, int)} javadocs for details.
+ */
+ public ConcurrentHashSet(int initSize, float loadFactor, int concurrencyLevel)
+ {
+ map = new ConcurrentHashMap<E, Object>(initSize, loadFactor, concurrencyLevel);
+ }
+
+
+ @Override
+ public int size()
+ {
+ return map.size();
+ }
+
+ @Override
+ public boolean isEmpty()
+ {
+ return map.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o)
+ {
+ return map.containsKey(o);
+ }
+
+ @Override
+ public Iterator<E> iterator()
+ {
+ return map.keySet().iterator();
+ }
+
+ @Override
+ public Object[] toArray()
+ {
+ return map.keySet().toArray();
+ }
+
+ @Override
+ public <T> T[] toArray(T[] a)
+ {
+ return map.keySet().toArray(a);
+ }
+
+ @Override
+ public boolean add(E o)
+ {
+ Object v = map.put(o, DUMMY);
+ return v == null;
+ }
+
+ @Override
+ public boolean remove(Object o)
+ {
+ Object v = map.remove(o);
+ return v != null;
+ }
+
+ @Override
+ public boolean containsAll(Collection<?> c)
+ {
+ return map.keySet().containsAll(c);
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends E> c)
+ {
+ throw new UnsupportedOperationException("Not supported in this implementation since additional locking is required and cannot directly be delegated to multiple calls to ConcurrentHashMap");
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c)
+ {
+ throw new UnsupportedOperationException("Not supported in this implementation since additional locking is required and cannot directly be delegated to multiple calls to ConcurrentHashMap");
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c)
+ {
+ throw new UnsupportedOperationException("Not supported in this implementation since additional locking is required and cannot directly be delegated to multiple calls to ConcurrentHashMap");
+ }
+
+ @Override
+ public void clear()
+ {
+ map.clear();
+ }
+}
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/ConcurrentHashSet.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/ReclosableLatch.java (from rev 7261, core/branches/flat/src/main/java/org/jboss/cache/util/concurrent/ReclosableLatch.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/ReclosableLatch.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/ReclosableLatch.java 2008-12-10 16:55:29 UTC (rev 7278)
@@ -0,0 +1,87 @@
+/*
+ * 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.util.concurrent;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.AbstractQueuedSynchronizer;
+
+/**
+ * A better impl of {@link org.jboss.cache.util.ThreadGate}, that uses an {@link java.util.concurrent.locks.AbstractQueuedSynchronizer}.
+ * <p/>
+ * This implementation allows you to create a latch with a default state (open or closed), and repeatedly open or close
+ * the latch.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public class ReclosableLatch extends AbstractQueuedSynchronizer
+{
+ // the following states are used in the AQS.
+ private static final int OPEN_STATE = 0, CLOSED_STATE = 1;
+
+ public ReclosableLatch()
+ {
+ setState(CLOSED_STATE);
+ }
+
+ public ReclosableLatch(boolean defaultOpen)
+ {
+ setState(defaultOpen ? OPEN_STATE : CLOSED_STATE);
+ }
+
+ @Override
+ public final int tryAcquireShared(int ignored)
+ {
+ // return 1 if we allow the requestor to proceed, -1 if we want the requestor to block.
+ return getState() == OPEN_STATE ? 1 : -1;
+ }
+
+ @Override
+ public final boolean tryReleaseShared(int state)
+ {
+ // used as a mechanism to set the state of the Sync.
+ setState(state);
+ return true;
+ }
+
+ public final void open()
+ {
+ // do not use setState() directly since this won't notify parked threads.
+ releaseShared(OPEN_STATE);
+ }
+
+ public final void close()
+ {
+ // do not use setState() directly since this won't notify parked threads.
+ releaseShared(CLOSED_STATE);
+ }
+
+ public final void await() throws InterruptedException
+ {
+ acquireSharedInterruptibly(1); // the 1 is a dummy value that is not used.
+ }
+
+ public final boolean await(long time, TimeUnit unit) throws InterruptedException
+ {
+ return tryAcquireSharedNanos(1, unit.toNanos(time)); // the 1 is a dummy value that is not used.
+ }
+}
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/ReclosableLatch.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/SelfInitializingConcurrentHashMap.java (from rev 7261, core/branches/flat/src/main/java/org/jboss/cache/util/concurrent/SelfInitializingConcurrentHashMap.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/SelfInitializingConcurrentHashMap.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/SelfInitializingConcurrentHashMap.java 2008-12-10 16:55:29 UTC (rev 7278)
@@ -0,0 +1,166 @@
+/*
+ * 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.util.concurrent;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * Primarily used to hold child maps for nodes. Underlying CHM is null initially, and once threads start
+ * writing to this map, the CHM is initialized.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public class SelfInitializingConcurrentHashMap<K, V> implements ConcurrentMap<K, V>
+{
+ private volatile ConcurrentMap<K, V> delegate;
+
+ // -------------- initialization methods and helpers ----------------------
+ private ConcurrentMap<K, V> getDelegate()
+ {
+ if (delegate == null) init();
+ return delegate;
+ }
+
+ private synchronized void init()
+ {
+ // Reminiscent of DCL but the delegate here is volatile so construction reordering should not affect.
+ if (delegate == null) delegate = new ConcurrentHashMap<K, V>(1, 0.75f, 4);
+ }
+
+ // -------------- Public API methods that will trigger initialization ----------------------
+
+ public final V put(K key, V value)
+ {
+ return getDelegate().put(key, value);
+ }
+
+ public final V remove(Object key)
+ {
+ return getDelegate().remove(key);
+ }
+
+ public final void putAll(Map<? extends K, ? extends V> m)
+ {
+ getDelegate().putAll(m);
+ }
+
+ public final V putIfAbsent(K key, V value)
+ {
+ return getDelegate().putIfAbsent(key, value);
+ }
+
+ public final boolean replace(K key, V oldValue, V newValue)
+ {
+ return getDelegate().replace(key, oldValue, newValue);
+ }
+
+ public final V replace(K key, V value)
+ {
+ return getDelegate().replace(key, value);
+ }
+
+ // -------------- Public API methods that won't trigger initialization ----------------------
+
+ public final boolean remove(Object key, Object value)
+ {
+ return delegate != null && delegate.remove(key, value);
+ }
+
+ public final int size()
+ {
+ return delegate == null ? 0 : delegate.size();
+ }
+
+ public final boolean isEmpty()
+ {
+ return delegate == null || delegate.isEmpty();
+ }
+
+ public final boolean containsKey(Object key)
+ {
+ return delegate != null && delegate.containsKey(key);
+ }
+
+ public final boolean containsValue(Object value)
+ {
+ return delegate != null && delegate.containsValue(value);
+ }
+
+ public final V get(Object key)
+ {
+ return delegate == null ? null : delegate.get(key);
+ }
+
+ public final void clear()
+ {
+ if (delegate != null) delegate.clear();
+ }
+
+ public final Set<K> keySet()
+ {
+ if (delegate == null || delegate.isEmpty()) return Collections.emptySet();
+ return delegate.keySet();
+ }
+
+ public final Collection<V> values()
+ {
+ if (delegate == null || delegate.isEmpty()) return Collections.emptySet();
+ return delegate.values();
+ }
+
+ public final Set<Entry<K, V>> entrySet()
+ {
+ if (delegate == null || delegate.isEmpty()) return Collections.emptySet();
+ return delegate.entrySet();
+ }
+
+ @Override
+ public String toString()
+ {
+ return "SelfInitializingConcurrentHashMap{" +
+ "delegate=" + delegate +
+ '}';
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ SelfInitializingConcurrentHashMap that = (SelfInitializingConcurrentHashMap) o;
+ return !(delegate != null ? !delegate.equals(that.delegate) : that.delegate != null);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result;
+ result = (delegate != null ? delegate.hashCode() : 0);
+ return result;
+ }
+}
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/SelfInitializingConcurrentHashMap.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/WithinThreadExecutor.java (from rev 7261, core/branches/flat/src/main/java/org/jboss/cache/util/concurrent/WithinThreadExecutor.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/WithinThreadExecutor.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/WithinThreadExecutor.java 2008-12-10 16:55:29 UTC (rev 7278)
@@ -0,0 +1,150 @@
+/*
+ * 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.util.concurrent;
+
+import org.jboss.starobrno.CacheException;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.*;
+
+/**
+ * An executor that works within the current thread.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @see <a href="http://jcip.net/">Java Concurrency In Practice</a>
+ * @since 3.0
+ */
+public class WithinThreadExecutor implements ExecutorService
+{
+ boolean shutDown = false;
+
+ public void execute(Runnable command)
+ {
+ command.run();
+ }
+
+ public void shutdown()
+ {
+ shutDown = true;
+ }
+
+ public List<Runnable> shutdownNow()
+ {
+ shutDown = true;
+ return Collections.emptyList();
+ }
+
+ public boolean isShutdown()
+ {
+ return shutDown;
+ }
+
+ public boolean isTerminated()
+ {
+ return shutDown;
+ }
+
+ public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
+ {
+ return shutDown;
+ }
+
+ public <T> Future<T> submit(Callable<T> task)
+ {
+ try
+ {
+ final T resp = task.call();
+ return new Future<T>()
+ {
+
+ public boolean cancel(boolean mayInterruptIfRunning)
+ {
+ return false;
+ }
+
+ public boolean isCancelled()
+ {
+ return false;
+ }
+
+ public boolean isDone()
+ {
+ return true;
+ }
+
+ public T get() throws InterruptedException, ExecutionException
+ {
+ return resp;
+ }
+
+ public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
+ {
+ return resp;
+ }
+ };
+ }
+ catch (Exception e)
+ {
+ throw new CacheException(e);
+ }
+ }
+
+ public <T> Future<T> submit(Runnable task, T result)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Future<?> submit(Runnable task)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @SuppressWarnings("unchecked")
+ // unchecked on purpose due to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6267833
+ public List invokeAll(Collection tasks) throws InterruptedException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @SuppressWarnings("unchecked")
+ // unchecked on purpose due to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6267833
+ public List invokeAll(Collection tasks, long timeout, TimeUnit unit) throws InterruptedException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @SuppressWarnings("unchecked")
+ // unchecked on purpose due to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6267833
+ public Object invokeAny(Collection tasks) throws InterruptedException, ExecutionException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @SuppressWarnings("unchecked")
+ // unchecked on purpose due to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6267833
+ public Object invokeAny(Collection tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
+ {
+ throw new UnsupportedOperationException();
+ }
+}
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/WithinThreadExecutor.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
16 years, 1 month
JBoss Cache SVN: r7277 - in core/branches/flat/src: main/java/org/jboss/cache/buddyreplication and 36 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-12-10 11:43:27 -0500 (Wed, 10 Dec 2008)
New Revision: 7277
Removed:
core/branches/flat/src/main/java/org/jboss/cache/Fqn.java
core/branches/flat/src/main/java/org/jboss/cache/FqnComparator.java
core/branches/flat/src/main/java/org/jboss/cache/StringFqn.java
core/branches/flat/src/main/java/org/jboss/cache/batch/
core/branches/flat/src/main/java/org/jboss/cache/util/BeanUtils.java
core/branches/flat/src/main/java/org/jboss/cache/util/BitEncodedIntegerSet.java
core/branches/flat/src/main/java/org/jboss/cache/util/FileLookup.java
core/branches/flat/src/main/java/org/jboss/cache/util/ImmutableListCopy.java
core/branches/flat/src/main/java/org/jboss/cache/util/Immutables.java
core/branches/flat/src/main/java/org/jboss/cache/util/MinMapUtil.java
core/branches/flat/src/main/java/org/jboss/cache/util/SimpleImmutableEntry.java
core/branches/flat/src/main/java/org/jboss/cache/util/ThreadGate.java
core/branches/flat/src/main/java/org/jboss/cache/util/concurrent/
core/branches/flat/src/main/java/org/jboss/cache/util/reflect/
core/branches/flat/src/main/java/org/jboss/cache/xml/
Modified:
core/branches/flat/src/main/java/org/jboss/cache/AbstractNode.java
core/branches/flat/src/main/java/org/jboss/cache/AbstractNodeFactory.java
core/branches/flat/src/main/java/org/jboss/cache/CacheSPI_Legacy.java
core/branches/flat/src/main/java/org/jboss/cache/Cache_Legacy.java
core/branches/flat/src/main/java/org/jboss/cache/DataContainer.java
core/branches/flat/src/main/java/org/jboss/cache/InternalNode.java
core/branches/flat/src/main/java/org/jboss/cache/InvocationContext.java
core/branches/flat/src/main/java/org/jboss/cache/Modification.java
core/branches/flat/src/main/java/org/jboss/cache/Node.java
core/branches/flat/src/main/java/org/jboss/cache/NodeFactory.java
core/branches/flat/src/main/java/org/jboss/cache/NodeSPI.java
core/branches/flat/src/main/java/org/jboss/cache/RPCManager.java
core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java
core/branches/flat/src/main/java/org/jboss/cache/Region.java
core/branches/flat/src/main/java/org/jboss/cache/RegionImpl.java
core/branches/flat/src/main/java/org/jboss/cache/RegionManager.java
core/branches/flat/src/main/java/org/jboss/cache/RegionManagerImpl.java
core/branches/flat/src/main/java/org/jboss/cache/RegionRegistry.java
core/branches/flat/src/main/java/org/jboss/cache/UnversionedNode.java
core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyGroup.java
core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java
core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/GravitateResult.java
core/branches/flat/src/main/java/org/jboss/cache/commands/CommandsFactory.java
core/branches/flat/src/main/java/org/jboss/cache/commands/CommandsFactoryImpl.java
core/branches/flat/src/main/java/org/jboss/cache/commands/DataCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/read/AbstractDataCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/read/ExistsCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/remote/AssignToBuddyGroupCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/AbstractVersionedDataCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/MoveCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutForExternalReadCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/BuddyRegionAwareEvictionInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor_Legacy.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
core/branches/flat/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java
core/branches/flat/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractDelegatingCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/AsyncCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoaderAop.java
core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java
core/branches/flat/src/main/java/org/jboss/cache/loader/ChainingCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/ClusteredCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/FileCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderOld.java
core/branches/flat/src/main/java/org/jboss/cache/loader/LocalDelegatingCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/ReadOnlyDelegatingCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/SingletonStoreCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/s3/S3CacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/tcp/TcpCacheServer.java
core/branches/flat/src/main/java/org/jboss/cache/lock/IdentityLock.java
core/branches/flat/src/main/java/org/jboss/cache/lock/LockManager.java
core/branches/flat/src/main/java/org/jboss/cache/lock/LockMap.java
core/branches/flat/src/main/java/org/jboss/cache/lock/LockUtil.java
core/branches/flat/src/main/java/org/jboss/cache/lock/MVCCLockManager.java
core/branches/flat/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.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/lock/StripedLock.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/CommandAwareRpcDispatcher.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/Marshaller.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/RegionalizedMethodCall.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/RegionalizedReturnValue.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/statetransfer/StateTransferIntegrator.java
core/branches/flat/src/main/java/org/jboss/cache/transaction/AbstractTransactionContext.java
core/branches/flat/src/main/java/org/jboss/cache/transaction/MVCCTransactionContext.java
core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionContext.java
core/branches/flat/src/main/java/org/jboss/cache/util/Caches.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/AssignToBuddyGroupCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/DataGravitationCleanupCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/InvalidateCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionConfig.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/CacheConfigsXmlParser.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/ConfigFilesConvertor.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigHelper.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParser.java
core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContextImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionCacheManager.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionEvent.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/RemoveOnEvictActionPolicy.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentRegistry.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/RuntimeConfigAwareFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/TxInterceptor.java
core/branches/flat/src/main/java/org/jboss/starobrno/loader/AsyncCacheLoader.java
core/branches/flat/src/main/java/org/jboss/starobrno/loader/CacheLoader.java
core/branches/flat/src/main/java/org/jboss/starobrno/lock/StripedLock.java
core/branches/flat/src/main/java/org/jboss/starobrno/marshall/CommandAwareRpcDispatcher.java
core/branches/flat/src/main/java/org/jboss/starobrno/marshall/NodeData.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/NotifierImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/EventImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/remoting/ChannelMessageListener.java
core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManagerImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/statetransfer/DefaultStateTransferManager.java
core/branches/flat/src/main/java/org/jboss/starobrno/statetransfer/StateTransferManager.java
core/branches/flat/src/main/java/org/jboss/starobrno/tree/Fqn.java
core/branches/flat/src/main/java/org/jboss/starobrno/util/Immutables.java
core/branches/flat/src/test/java/org/jboss/starobrno/eviction/EvictionWatcher.java
core/branches/flat/src/test/java/org/jboss/starobrno/eviction/FIFOPolicyTest.java
core/branches/flat/src/test/java/org/jboss/starobrno/notifications/NotifierTest.java
Log:
Reduced class duplication in cache and starobrno packages
Modified: core/branches/flat/src/main/java/org/jboss/cache/AbstractNode.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/AbstractNode.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/AbstractNode.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -25,6 +25,7 @@
import static org.jboss.cache.AbstractNode.NodeFlags.RESIDENT;
import org.jboss.cache.lock.IdentityLock;
import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.starobrno.tree.Fqn;
import java.util.Map;
import java.util.Set;
Modified: core/branches/flat/src/main/java/org/jboss/cache/AbstractNodeFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/AbstractNodeFactory.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/AbstractNodeFactory.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -28,6 +28,7 @@
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.factories.ComponentRegistry;
import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.tree.Fqn;
import java.util.Map;
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-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/CacheSPI_Legacy.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -28,11 +28,12 @@
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.marshall.Marshaller;
-import org.jboss.starobrno.statetransfer.StateTransferManager;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.starobrno.factories.ComponentRegistry;
import org.jboss.starobrno.notifications.Notifier;
+import org.jboss.starobrno.statetransfer.StateTransferManager;
+import org.jboss.starobrno.tree.Fqn;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
Modified: core/branches/flat/src/main/java/org/jboss/cache/Cache_Legacy.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/Cache_Legacy.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/Cache_Legacy.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -24,6 +24,7 @@
import net.jcip.annotations.ThreadSafe;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.tree.Fqn;
import org.jgroups.Address;
import java.util.List;
Modified: core/branches/flat/src/main/java/org/jboss/cache/DataContainer.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/DataContainer.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/DataContainer.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -22,6 +22,7 @@
package org.jboss.cache;
import org.jboss.starobrno.marshall.NodeData;
+import org.jboss.starobrno.tree.Fqn;
import java.util.List;
import java.util.Set;
Deleted: core/branches/flat/src/main/java/org/jboss/cache/Fqn.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/Fqn.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/Fqn.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -1,679 +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 net.jcip.annotations.Immutable;
-import org.jboss.cache.annotations.Compat;
-import org.jboss.cache.util.Immutables;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * A Fully Qualified Name (Fqn) is a list of names (typically Strings but can be any Object),
- * which represent a path to a particular {@link Node} or sometimes a {@link Region} in a {@link Cache_Legacy}.
- * <p/>
- * This name can be absolute (i.e., relative from the root node - {@link #ROOT}), or relative to any node in the cache. Reading the
- * documentation on each API call that makes use of {@link org.jboss.cache.Fqn}s will tell you whether the API expects a
- * relative or absolute Fqn.
- * <p/>
- * For instance, using this class to fetch a particular node might look like
- * this. (Here data on "Joe" is kept under the "Smith" surname node, under
- * the "people" tree.)
- * <pre>
- * Fqn<String> abc = Fqn.fromString("/people/Smith/Joe/");
- * Node joesmith = Cache.getRoot().getChild(abc);
- * </pre>
- * Alternatively, the same Fqn could be constructed using a List<Object> or varargs:
- * <pre>
- * Fqn<String> abc = Fqn.fromElements("people", "Smith", "Joe");
- * </pre>
- * This is a bit more efficient to construct.
- * <p/>
- * Note that<br>
- * <p/>
- * <code>Fqn<String> f = Fqn.fromElements("/a/b/c");</code>
- * <p/>
- * is <b>not</b> the same as
- * <p/>
- * <code>Fqn<String> f = Fqn.fromString("/a/b/c");</code>
- * <p/>
- * The former will result in a single Fqn, called "/a/b/c" which hangs directly under Fqn.ROOT.
- * <p/>
- * The latter will result in 3 Fqns, called "a", "b" and "c", where "c" is a child of "b", "b" is a child of "a", and "a" hangs off Fqn.ROOT.
- * <p/>
- * Another way to look at it is that the "/" separarator is only parsed when it forms
- * part of a String passed in to Fqn.fromString() and not otherwise.
- * <p/>
- * <B>Best practices</B>: Always creating Fqns - even when using some factory methods - can be expensive in the long run,
- * and as far as possible we recommend that client code holds on to their Fqn references and reuse them. E.g.:
- * <code>
- * // BAD!!
- * for (int i=0; i<someBigNumber; i++)
- * {
- * cache.get(Fqn.fromString("/a/b/c"), "key" + i);
- * }
- * </code>
- * instead, do:
- * <code>
- * // Much better
- * Fqn f = Fqn.fromString("/a/b/c");
- * for (int i=0; i<someBigNumber; i++)
- * {
- * cache.get(f, "key" + i);
- * }
- * </code>
- *
- * @version $Revision$
- */
-@Immutable
-@Compat(notes = "The generics, while originally intended to be removed in 3.0, have been retained for backward compat.")
-public class Fqn<E> implements Comparable<Fqn<?>>, Externalizable
-{
- /**
- * Separator between FQN elements.
- */
- public static final String SEPARATOR = "/";
-
- protected List<E> elements;
- private transient int hash_code = 0;
- protected int size = 0;
-
- /**
- * Immutable root Fqn.
- */
- public static final Fqn ROOT = new Fqn();
-
- /**
- * A cached string representation of this Fqn, used by toString to it isn't calculated again every time.
- */
- protected String stringRepresentation;
-
- // ----------------- START: Private constructors for use by factory methods only. ----------------------
-
- /**
- * Public to satisfy Externalization. // TODO: Remove this ctor as well as Externalization!!
- */
- public Fqn()
- {
- elements = Collections.emptyList();
- size = 0;
- }
-
- // --- deprecated compat stuff
-
- /**
- * Constructs a FQN from a list of names.
- *
- * @param names List of names
- * @deprecated use {@link #fromList(java.util.List)} instead. This constructor will be removed in 3.0.0.
- */
- @Deprecated
- @Compat
- public Fqn(List<? extends E> names)
- {
- // the list is unsafe - may be referenced externally
- this(names, false);
- }
-
- /**
- * Constructs a Fqn from an array of names.
- *
- * @param names Names that comprose this Fqn
- * @deprecated use {@link #fromElements(Object[])} instead. This constructor will be removed in 3.0.0.
- */
- @Deprecated
- @Compat
- public Fqn(E... names)
- {
- // safe - the list is created here.
- this(Arrays.asList(names), true);
- }
-
- /**
- * Constructs a Fqn from a base and relative Fqn.
- *
- * @param base parent Fqn
- * @param relative Sub-Fqn relative to the parent
- * @deprecated use {@link #fromRelativeFqn(Fqn, Fqn)} instead. This constructor will be removed in 3.0.0.
- */
- @Deprecated
- @Compat
- public Fqn(Fqn<? extends E> base, Fqn<? extends E> relative)
- {
- this(base, relative.elements);
- }
-
- /**
- * Constructs a Fqn from a base and two relative names.
- *
- * @param base parent Fqn
- * @param childNames elements that denote the path to the Fqn, under the parent
- * @deprecated use {@link #fromRelativeElements(Fqn, Object[])} instead. This constructor will be removed in 3.0.0.
- */
- @Deprecated
- @Compat
- public Fqn(Fqn<? extends E> base, E... childNames)
- {
- this(base, Arrays.asList(childNames));
- }
-
- // --- end deprecated stuff
-
- /**
- * If safe is false, Collections.unmodifiableList() is used to wrap the list passed in. This is an optimisation so
- * Fqn.fromString(), probably the most frequently used factory method, doesn't end up needing to use the unmodifiableList()
- * since it creates the list internally.
- *
- * @param names List of names
- * @param safe whether this list is referenced externally (safe = false) or not (safe = true).
- * @deprecated use {@link #fromList(java.util.List)} instead. The boolean "safety" hint is calculated internally. This constructor will be removed in 3.0.0.
- */
- @Deprecated
- @Compat(notes = "Not truly deprecated, this constructor should really be protected and not public. Marked as deprecated for anyone using it as a public API.")
- @SuppressWarnings("unchecked")
- protected Fqn(List<? extends E> names, boolean safe)
- {
- if (names != null)
- {
- // if not safe make a defensive copy
- elements = safe ? (List<E>) names : Immutables.immutableListCopy(names);
- size = elements.size();
- }
- else
- {
- elements = Collections.emptyList();
- size = 0;
- }
- }
-
- protected Fqn(Fqn<? extends E> base, List<? extends E> relative)
- {
- elements = Immutables.immutableListMerge(base.elements, relative);
- size = elements.size();
- }
-
- // ----------------- END: Private constructors for use by factory methods only. ----------------------
-
- /**
- * Retrieves an Fqn that represents the list of elements passed in.
- *
- * @param names list of elements that comprise the Fqn
- * @return an Fqn
- * @since 2.2.0
- */
- @SuppressWarnings("unchecked")
- public static <T> Fqn<T> fromList(List<? extends T> names)
- {
- return new Fqn<T>(names, false);
- }
-
- /**
- * Retrieves an Fqn that represents the list of elements passed in.
- *
- * @param names list of elements that comprise the Fqn
- * @param safe if true, the list passed in is not defensively copied but used directly. <b>Use with care.</b> Make sure
- * you know what you are doing before you pass in a <tt>true</tt> value to <tt>safe</tt>, as it can have adverse effects on
- * performance or correctness. The defensive copy of list elements is not just for safety but also for performance as
- * an appropriare List implementation is used, which works well with Fqn operations.
- * @return an Fqn
- */
- @SuppressWarnings("unchecked")
- public static <T> Fqn<T> fromList(List<? extends T> names, boolean safe)
- {
- return new Fqn<T>(names, safe);
- }
-
- /**
- * Retrieves an Fqn that represents the array of elements passed in.
- *
- * @param elements array of elements that comprise the Fqn
- * @return an Fqn
- * @since 2.2.0
- */
- public static <T> Fqn<T> fromElements(T... elements)
- {
- return new Fqn<T>(Arrays.asList(elements), true);
- }
-
- /**
- * Retrieves an Fqn that represents the absolute Fqn of the relative Fqn passed in.
- *
- * @param base base Fqn
- * @param relative relative Fqn
- * @return an Fqn
- * @since 2.2.0
- */
- public static <T> Fqn<T> fromRelativeFqn(Fqn<? extends T> base, Fqn<? extends T> relative)
- {
- return new Fqn<T>(base, relative.elements);
- }
-
- /**
- * Retrieves an Fqn that represents the List<Object> of elements passed in, relative to the base Fqn.
- *
- * @param base base Fqn
- * @param relativeElements relative List<Object> of elements
- * @return an Fqn
- * @since 2.2.0
- */
- public static <T> Fqn<T> fromRelativeList(Fqn<? extends T> base, List<? extends T> relativeElements)
- {
- return new Fqn<T>(base, relativeElements);
- }
-
- /**
- * Retrieves an Fqn that represents the array of elements passed in, relative to the base Fqn.
- *
- * @param base base Fqn
- * @param relativeElements relative elements
- * @return an Fqn
- * @since 2.2.0
- */
- public static <T> Fqn<T> fromRelativeElements(Fqn<? extends T> base, T... relativeElements)
- {
- return new Fqn<T>(base, Arrays.asList(relativeElements));
- }
-
- /**
- * Returns a new Fqn from a string, where the elements are deliminated by
- * one or more separator ({@link #SEPARATOR}) characters.<br><br>
- * Example use:<br>
- * <pre>
- * Fqn.fromString("/a/b/c/");
- * </pre><br>
- * is equivalent to:<br>
- * <pre>
- * Fqn.fromElements("a", "b", "c");
- * </pre>
- *
- * @param stringRepresentation String representation of the Fqn
- * @return an Fqn<String> constructed from the string representation passed in
- */
- @SuppressWarnings("unchecked")
- public static Fqn<String> fromString(String stringRepresentation)
- {
- if (stringRepresentation == null || stringRepresentation.equals(SEPARATOR) || stringRepresentation.equals(""))
- return root();
-
- String toMatch = stringRepresentation.startsWith(SEPARATOR) ? stringRepresentation.substring(1) : stringRepresentation;
- Object[] el = toMatch.split(SEPARATOR);
- return new Fqn(Immutables.immutableListWrap(el), true);
- }
-
- /**
- * Retrieves an Fqn read from an object input stream, typically written to using {@link #writeExternal(java.io.ObjectOutput)}.
- *
- * @param in input stream
- * @return an Fqn
- * @throws IOException in the event of a problem reading the stream
- * @throws ClassNotFoundException in the event of classes that comprise the element list of this Fqn not being found
- * @since 2.2.0
- */
- public static Fqn<?> fromExternalStream(ObjectInput in) throws IOException, ClassNotFoundException
- {
- Fqn<?> f = new Fqn<Object>();
- f.readExternal(in);
- return f;
- }
-
-
- /**
- * Obtains an ancestor of the current Fqn. Literally performs <code>elements.subList(0, generation)</code>
- * such that if
- * <code>
- * generation == Fqn.size()
- * </code>
- * then the return value is the Fqn itself (current generation), and if
- * <code>
- * generation == Fqn.size() - 1
- * </code>
- * then the return value is the same as
- * <code>
- * Fqn.getParent()
- * </code>
- * i.e., just one generation behind the current generation.
- * <code>
- * generation == 0
- * </code>
- * would return Fqn.ROOT.
- *
- * @param generation the generation of the ancestor to retrieve
- * @return an ancestor of the current Fqn
- */
- public Fqn<E> getAncestor(int generation)
- {
- if (generation == 0) return root();
- return getSubFqn(0, generation);
- }
-
- /**
- * Obtains a sub-Fqn from the given Fqn. Literally performs <code>elements.subList(startIndex, endIndex)</code>
- *
- * @param startIndex starting index
- * @param endIndex end index
- * @return a subFqn
- */
- public Fqn<E> getSubFqn(int startIndex, int endIndex)
- {
- List<E> el = elements.subList(startIndex, endIndex);
- return new Fqn<E>(el, true);
- }
-
- /**
- * @return the number of elements in the Fqn. The root node contains zero.
- */
- public int size()
- {
- return size;
- }
-
- /**
- * @param n index of the element to return
- * @return Returns the nth element in the Fqn.
- */
- public Object get(int n)
- {
- return elements.get(n);
- }
-
- /**
- * @return the last element in the Fqn.
- * @see #getLastElementAsString
- */
- public Object getLastElement()
- {
- if (isRoot()) return null;
- return elements.get(size - 1);
- }
-
- /**
- * @param element element to find
- * @return true if the Fqn contains this element, false otherwise.
- */
- public boolean hasElement(Object element)
- {
- return elements.indexOf(element) != -1;
- }
-
- /**
- * Returns true if obj is a Fqn with the same elements.
- */
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj)
- {
- return true;
- }
- if (!(obj instanceof Fqn))
- {
- return false;
- }
- Fqn<?> other = (Fqn<?>) obj;
- return size == other.size() && elements.equals(other.elements);
- }
-
- /**
- * Returns a hash code with Fqn elements.
- */
- @Override
- public int hashCode()
- {
- if (hash_code == 0)
- {
- hash_code = calculateHashCode();
- }
- return hash_code;
- }
-
- /**
- * Returns this Fqn as a string, prefixing the first element with a {@link Fqn#SEPARATOR} and
- * joining each subsequent element with a {@link Fqn#SEPARATOR}.
- * If this is the root Fqn, returns {@link Fqn#SEPARATOR}.
- * Example:
- * <pre>
- * new Fqn(new Object[] { "a", "b", "c" }).toString(); // "/a/b/c"
- * Fqn.ROOT.toString(); // "/"
- * </pre>
- */
- @Override
- public String toString()
- {
- if (stringRepresentation == null)
- {
- stringRepresentation = getStringRepresentation(elements);
- }
- return stringRepresentation;
- }
-
- public void writeExternal(ObjectOutput out) throws IOException
- {
- out.writeShort(size);
- for (Object element : elements)
- {
- out.writeObject(element);
- }
- }
-
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- {
- size = in.readShort();
- this.elements = new ArrayList<E>(size);
- for (int i = 0; i < size; i++) elements.add((E) in.readObject());
- }
-
-
- /**
- * Returns true if this Fqn is child of parentFqn.
- * Example usage:
- * <pre>
- * Fqn<String> f1 = Fqn.fromString("/a/b");
- * Fqn<String> f2 = Fqn.fromString("/a/b/c");
- * assertTrue(f1.isChildOf(f2));
- * assertFalse(f1.isChildOf(f1));
- * assertFalse(f2.isChildOf(f1));
- * </pre>
- *
- * @param parentFqn candidate parent to test against
- * @return true if the target is a child of parentFqn
- */
- public boolean isChildOf(Fqn<? super E> parentFqn)
- {
- return parentFqn.size() != size && isChildOrEquals(parentFqn);
- }
-
-
- /**
- * Returns true if this Fqn is a <i>direct</i> child of a given Fqn.
- *
- * @param parentFqn parentFqn to compare with
- * @return true if this is a direct child, false otherwise.
- */
- public boolean isDirectChildOf(Fqn<? super E> parentFqn)
- {
- return size == parentFqn.size() + 1 && isChildOf(parentFqn);
- }
-
- /**
- * Returns true if this Fqn is equals or the child of parentFqn.
- * Example usage:
- * <pre>
- * Fqn<String> f1 = Fqn.fromString("/a/b");
- * Fqn<String> f2 = Fqn.fromString("/a/b/c");
- * assertTrue(f1.isChildOrEquals(f2));
- * assertTrue(f1.isChildOrEquals(f1));
- * assertFalse(f2.isChildOrEquals(f1));
- * </pre>
- *
- * @param parentFqn candidate parent to test against
- * @return true if this Fqn is equals or the child of parentFqn.
- */
- public boolean isChildOrEquals(Fqn<? super E> parentFqn)
- {
- List<? super E> parentList = parentFqn.elements;
- if (parentList.size() > size)
- {
- return false;
- }
- for (int i = parentList.size() - 1; i >= 0; i--)
- {
- if (!parentList.get(i).equals(elements.get(i)))
- {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Calculates a hash code by summing the hash code of all elements.
- *
- * @return a calculated hashcode
- */
- protected int calculateHashCode()
- {
- int hashCode = 19;
- for (Object o : elements) hashCode = 31 * hashCode + (o == null ? 0 : o.hashCode());
- if (hashCode == 0) hashCode = 0xDEADBEEF; // degenerate case
- return hashCode;
- }
-
- protected String getStringRepresentation(List<E> elements)
- {
- StringBuilder builder = new StringBuilder();
- for (Object e : elements)
- {
- // incase user element 'e' does not implement equals() properly, don't rely on their implementation.
- if (!SEPARATOR.equals(e) && !"".equals(e))
- {
- builder.append(SEPARATOR);
- builder.append(e);
- }
- }
- return builder.length() == 0 ? SEPARATOR : builder.toString();
- }
-
-
- /**
- * Returns the parent of this Fqn.
- * The parent of the root node is {@link #ROOT}.
- * Examples:
- * <pre>
- * Fqn<String> f1 = Fqn.fromString("/a");
- * Fqn<String> f2 = Fqn.fromString("/a/b");
- * assertEquals(f1, f2.getParent());
- * assertEquals(Fqn.ROOT, f1.getParent().getParent());
- * assertEquals(Fqn.ROOT, Fqn.ROOT.getParent());
- * </pre>
- *
- * @return the parent Fqn
- */
- public Fqn<E> getParent()
- {
- switch (size)
- {
- case 0:
- case 1:
- return root();
- default:
- return new Fqn(elements.subList(0, size - 1), true);
- }
- }
-
- public static final <T> Fqn<T> root() // declared final so compilers can optimise and in-line.
- {
- return ROOT;
- }
-
- /**
- * Returns true if this is a root Fqn.
- *
- * @return true if the Fqn is Fqn.ROOT.
- */
- public boolean isRoot()
- {
- return size == 0;
- }
-
- /**
- * If this is the root, returns {@link Fqn#SEPARATOR}.
- *
- * @return a String representation of the last element that makes up this Fqn.
- */
- public String getLastElementAsString()
- {
- if (isRoot())
- {
- return SEPARATOR;
- }
- else
- {
- Object last = getLastElement();
- if (last instanceof String)
- return (String) last;
- else
- return String.valueOf(getLastElement());
- }
- }
-
- /**
- * Peeks into the elements that build up this Fqn. The list returned is
- * read-only, to maintain the immutable nature of Fqn.
- *
- * @return an unmodifiable list
- */
- public List<E> peekElements()
- {
- return elements;
- }
-
- /**
- * Compares this Fqn to another using {@link FqnComparator}.
- */
- public int compareTo(Fqn<?> fqn)
- {
- return FqnComparator.INSTANCE.compare(this, fqn);
- }
-
- /**
- * Creates a new Fqn whose ancestor has been replaced with the new ancestor passed in.
- *
- * @param oldAncestor old ancestor to replace
- * @param newAncestor nw ancestor to replace with
- * @return a new Fqn with ancestors replaced.
- */
- public Fqn<E> replaceAncestor(Fqn<E> oldAncestor, Fqn<E> newAncestor)
- {
- if (!isChildOf(oldAncestor))
- throw new IllegalArgumentException("Old ancestor must be an ancestor of the current Fqn!");
- Fqn<E> subFqn = this.getSubFqn(oldAncestor.size(), size());
- return Fqn.fromRelativeFqn(newAncestor, subFqn);
- }
-}
\ No newline at end of file
Deleted: core/branches/flat/src/main/java/org/jboss/cache/FqnComparator.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/FqnComparator.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/FqnComparator.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -1,121 +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 net.jcip.annotations.Immutable;
-
-import java.io.Serializable;
-import java.util.Comparator;
-
-/**
- * Compares the order of two FQN.
- * Sorts by name, then by depth, e.g.
- * <pre>
- * aaa/bbb
- * xxx
- * xxx/ccc
- * </pre>
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @author Steve Woodcock (<a href="mailto:stevew@jofti.com">stevew(a)jofti.com</a>)
- */
-@Immutable
-public class FqnComparator implements Comparator<Fqn>, Serializable
-{
- public static final FqnComparator INSTANCE = new FqnComparator();
-
- /**
- * Returns -1 if the first comes before; 0 if they are the same; 1 if the
- * second Fqn comes before. <code>null</code> always comes first.
- */
- public int compare(Fqn fqn1, Fqn fqn2)
- {
- int s1 = fqn1.size();
- int s2 = fqn2.size();
-
- if (s1 == 0)
- {
- return (s2 == 0) ? 0 : -1;
- }
-
- if (s2 == 0)
- {
- return 1;
- }
-
-// if (fqn1.getClass().equals(StringFqn.class) && fqn2.getClass().equals(StringFqn.class))
-// {
-// StringFqn sfqn1 = (StringFqn) fqn1;
-// StringFqn sfqn2 = (StringFqn) fqn2;
-// return sfqn1.stringRepresentation.compareTo(sfqn2.stringRepresentation);
-// }
- int size = Math.min(s1, s2);
-
- for (int i = 0; i < size; i++)
- {
- Object e1 = fqn1.get(i);
- Object e2 = fqn2.get(i);
- if (e1 == e2)
- {
- continue;
- }
- if (e1 == null)
- {
- return 0;
- }
- if (e2 == null)
- {
- return 1;
- }
- if (!e1.equals(e2))
- {
- int c = compareElements(e1, e2);
- if (c != 0)
- {
- return c;
- }
- }
- }
-
- return s1 - s2;
- }
-
- /**
- * Compares two Fqn elements.
- * If e1 and e2 are the same class and e1 implements Comparable,
- * returns e1.compareTo(e2).
- * Otherwise, returns e1.toString().compareTo(e2.toString()).
- */
- private int compareElements(Object e1, Object e2)
- {
- if (e1.getClass() == e2.getClass() && e1 instanceof Comparable)
- {
- return ((Comparable<Object>) e1).compareTo(e2);
- }
- else
- {
- return e1.toString().compareTo(e2.toString());
- }
- }
-
-
-}
Modified: core/branches/flat/src/main/java/org/jboss/cache/InternalNode.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/InternalNode.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/InternalNode.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,6 +23,7 @@
import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.starobrno.tree.Fqn;
import java.util.Map;
import java.util.Set;
Modified: core/branches/flat/src/main/java/org/jboss/cache/InvocationContext.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/InvocationContext.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/InvocationContext.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -29,8 +29,9 @@
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
-import org.jboss.cache.util.Immutables;
import org.jboss.starobrno.config.Option;
+import org.jboss.starobrno.tree.Fqn;
+import org.jboss.starobrno.util.Immutables;
import javax.transaction.Transaction;
import java.util.Collections;
Modified: core/branches/flat/src/main/java/org/jboss/cache/Modification.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/Modification.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/Modification.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -22,6 +22,8 @@
package org.jboss.cache;
+import org.jboss.starobrno.tree.Fqn;
+
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
Modified: core/branches/flat/src/main/java/org/jboss/cache/Node.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/Node.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/Node.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -22,6 +22,7 @@
package org.jboss.cache;
import net.jcip.annotations.ThreadSafe;
+import org.jboss.starobrno.tree.Fqn;
import java.util.Map;
import java.util.Set;
Modified: core/branches/flat/src/main/java/org/jboss/cache/NodeFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/NodeFactory.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/NodeFactory.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -22,6 +22,8 @@
package org.jboss.cache;
+import org.jboss.starobrno.tree.Fqn;
+
import java.util.Map;
/**
Modified: core/branches/flat/src/main/java/org/jboss/cache/NodeSPI.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/NodeSPI.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/NodeSPI.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -24,6 +24,7 @@
import net.jcip.annotations.NotThreadSafe;
import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.starobrno.tree.Fqn;
import java.util.Map;
import java.util.Set;
Modified: core/branches/flat/src/main/java/org/jboss/cache/RPCManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/RPCManager.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/RPCManager.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -22,6 +22,7 @@
package org.jboss.cache;
import org.jboss.cache.commands.ReplicableCommand;
+import org.jboss.starobrno.tree.Fqn;
import org.jgroups.Address;
import org.jgroups.Channel;
import org.jgroups.blocks.RspFilter;
Modified: core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -30,32 +30,26 @@
import org.jboss.cache.jmx.annotations.ManagedAttribute;
import org.jboss.cache.jmx.annotations.ManagedOperation;
import org.jboss.cache.lock.LockManager;
-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.starobrno.statetransfer.DefaultStateTransferManager;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.util.concurrent.ReclosableLatch;
-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;
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.lock.TimeoutException;
import org.jboss.starobrno.notifications.Notifier;
+import org.jboss.starobrno.remoting.SuspectException;
+import org.jboss.starobrno.statetransfer.DefaultStateTransferManager;
import org.jboss.starobrno.transaction.TransactionTable;
-import org.jgroups.Address;
-import org.jgroups.Channel;
-import org.jgroups.ChannelException;
-import org.jgroups.ChannelFactory;
-import org.jgroups.ExtendedMembershipListener;
-import org.jgroups.JChannel;
-import org.jgroups.StateTransferException;
-import org.jgroups.View;
+import org.jboss.starobrno.tree.Fqn;
+import org.jboss.starobrno.util.ReflectionUtil;
+import org.jboss.starobrno.util.concurrent.ReclosableLatch;
+import org.jgroups.*;
import org.jgroups.blocks.GroupRequest;
import org.jgroups.blocks.RspFilter;
import org.jgroups.protocols.TP;
@@ -65,13 +59,7 @@
import javax.transaction.TransactionManager;
import java.text.NumberFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-import java.util.Vector;
+import java.util.*;
import java.util.concurrent.TimeUnit;
/**
Modified: core/branches/flat/src/main/java/org/jboss/cache/Region.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/Region.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/Region.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -25,6 +25,7 @@
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.config.EvictionCacheConfig;
import org.jboss.starobrno.eviction.EvictionEvent;
+import org.jboss.starobrno.tree.Fqn;
/**
* Defines characteristics such as class loading and eviction of {@link org.jboss.cache.Node}s belonging to a Region in a {@link Cache_Legacy}.
Modified: core/branches/flat/src/main/java/org/jboss/cache/RegionImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/RegionImpl.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/RegionImpl.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,13 +23,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.starobrno.util.Util;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.config.EvictionAlgorithmConfig;
import org.jboss.starobrno.config.EvictionCacheConfig;
import org.jboss.starobrno.eviction.EvictionAction;
+import org.jboss.starobrno.eviction.EvictionAlgorithm;
import org.jboss.starobrno.eviction.EvictionEvent;
-import org.jboss.starobrno.eviction.EvictionAlgorithm;
+import org.jboss.starobrno.tree.Fqn;
+import org.jboss.starobrno.util.Util;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
Modified: core/branches/flat/src/main/java/org/jboss/cache/RegionManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/RegionManager.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/RegionManager.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -24,6 +24,7 @@
import org.jboss.cache.annotations.Compat;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.config.EvictionConfig;
+import org.jboss.starobrno.tree.Fqn;
import java.util.List;
Modified: core/branches/flat/src/main/java/org/jboss/cache/RegionManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -28,16 +28,17 @@
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.lock.LockManager;
-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.EvictionCacheConfig;
import org.jboss.starobrno.config.EvictionConfig;
-import org.jboss.starobrno.config.EvictionCacheConfig;
import org.jboss.starobrno.factories.annotations.Destroy;
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.tree.Fqn;
+import org.jboss.starobrno.util.concurrent.locks.LockContainer;
+import org.jboss.starobrno.util.concurrent.locks.ReentrantLockContainer;
import org.jgroups.Address;
import java.util.ArrayList;
Modified: core/branches/flat/src/main/java/org/jboss/cache/RegionRegistry.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/RegionRegistry.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/RegionRegistry.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -22,6 +22,7 @@
package org.jboss.cache;
import org.jboss.starobrno.factories.annotations.NonVolatile;
+import org.jboss.starobrno.tree.Fqn;
import java.util.concurrent.ConcurrentHashMap;
Deleted: core/branches/flat/src/main/java/org/jboss/cache/StringFqn.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/StringFqn.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/StringFqn.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -1,130 +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.cache.annotations.Experimental;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * An optimisation of Fqn that does more efficient equals() and hashcode() computations. This is returned by default when
- * the factory method {@link Fqn#fromString(String)} is used, or when any of the other factory methods on {@link Fqn} are
- * passed only String elements.
- * <p/>
- * <b>Note</b> that the "/" character is illegal in any Fqn String element and if encountered may be used to split Fqn elements.
- * Expect indeterminate behaviour until proper String escaping is in place.
- * <p/>
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @since 2.2.0
- */
-// TODO: 3.0.0: Implement proper String escaping.
-@Experimental
-public final class StringFqn extends Fqn
-{
- protected StringFqn()
- {
- super();
- stringRepresentation = SEPARATOR;
- }
-
- @SuppressWarnings("unchecked")
- protected StringFqn(StringFqn base, List<String> elements)
- {
- super(base, (List) elements);
- String elementStringRep = getStringRepresentation((List) elements);
- stringRepresentation = base.isRoot() ? elementStringRep : base.stringRepresentation + elementStringRep;
- }
-
- protected StringFqn(StringFqn base, StringFqn relative)
- {
- super(base, relative.elements);
- if (base.isRoot())
- {
- if (relative.isRoot())
- stringRepresentation = SEPARATOR;
- else
- stringRepresentation = relative.stringRepresentation;
- }
- else
- {
- if (relative.isRoot())
- stringRepresentation = base.stringRepresentation;
- else
- stringRepresentation = base.stringRepresentation + relative.stringRepresentation;
- }
- }
-
- @SuppressWarnings("unchecked")
- protected StringFqn(List<String> stringElements)
- {
- super((List) stringElements, false);
- stringRepresentation = getStringRepresentation(elements);
- }
-
- protected StringFqn(String stringRep)
- {
- this(Arrays.asList(stringRep.split("/")));
- }
-
- @Override
- public boolean equals(Object other)
- {
- if (other == this) return true;
- if (other == null) return false;
- if (other.getClass().equals(StringFqn.class))
- {
- return stringRepresentation.equals(((StringFqn) other).stringRepresentation);
- }
- else
- {
- return super.equals(other);
- }
- }
-
- @Override
- protected int calculateHashCode()
- {
- return stringRepresentation.hashCode();
- }
-
- @Override
- @SuppressWarnings(value = "unchecked")
- public boolean isChildOrEquals(Fqn parentFqn)
- {
- if (parentFqn.getClass().equals(StringFqn.class))
- {
- StringFqn stringParentFqn = (StringFqn) parentFqn;
- return stringRepresentation.startsWith(stringParentFqn.stringRepresentation);
- }
- else
- {
- return super.isChildOrEquals(parentFqn);
- }
- }
-
- public String getStringRepresentation()
- {
- return stringRepresentation;
- }
-}
Modified: core/branches/flat/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/UnversionedNode.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/UnversionedNode.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -24,11 +24,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.jboss.cache.AbstractNode.NodeFlags.*;
-import org.jboss.cache.util.Immutables;
-import org.jboss.cache.util.concurrent.SelfInitializingConcurrentHashMap;
import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.marshall.MarshalledValue;
+import org.jboss.starobrno.tree.Fqn;
import org.jboss.starobrno.util.FastCopyHashMap;
-import org.jboss.starobrno.marshall.MarshalledValue;
+import org.jboss.starobrno.util.Immutables;
+import org.jboss.starobrno.util.concurrent.SelfInitializingConcurrentHashMap;
import java.util.*;
import java.util.Map.Entry;
@@ -269,7 +270,7 @@
@Override
public void addChild(InternalNode<K, V> child, boolean safe)
{
- Fqn<?> childFqn = child.getFqn();
+ Fqn childFqn = child.getFqn();
if (safe || childFqn.isDirectChildOf(fqn))
{
children().put(childFqn.getLastElement(), child);
@@ -441,8 +442,7 @@
{
if (this.data == null)
this.data = copyDataMap(data);
- else
- if (this.data.size() == 1 && data.size() == 1 && this.data.keySet().iterator().next().equals(data.keySet().iterator().next()))
+ else if (this.data.size() == 1 && data.size() == 1 && this.data.keySet().iterator().next().equals(data.keySet().iterator().next()))
{
// replace key!
Entry<? extends K, ? extends V> e = data.entrySet().iterator().next();
Modified: core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,8 +21,8 @@
*/
package org.jboss.cache.buddyreplication;
-import org.jboss.cache.Fqn;
import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.tree.Fqn;
import org.jgroups.Address;
import java.util.ArrayList;
Modified: core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyGroup.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyGroup.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyGroup.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -22,7 +22,7 @@
package org.jboss.cache.buddyreplication;
import net.jcip.annotations.ThreadSafe;
-import org.jboss.cache.util.Immutables;
+import org.jboss.starobrno.util.Immutables;
import org.jgroups.Address;
import java.io.Serializable;
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-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,15 +23,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI_Legacy;
-import org.jboss.cache.DataContainer;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.RPCManager;
-import org.jboss.cache.Region;
-import org.jboss.cache.RegionEmptyException;
-import org.jboss.cache.RegionManager;
+import org.jboss.cache.*;
import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.VisitableCommand;
@@ -39,11 +31,6 @@
import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
import org.jboss.cache.commands.remote.ReplicateCommand;
-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.starobrno.util.ReflectionUtil;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.config.BuddyReplicationConfig;
import org.jboss.starobrno.config.BuddyReplicationConfig.BuddyLocatorConfig;
@@ -52,10 +39,16 @@
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.io.ExposedByteArrayOutputStream;
+import org.jboss.starobrno.lock.TimeoutException;
import org.jboss.starobrno.notifications.Notifier;
import org.jboss.starobrno.notifications.annotation.CacheListener;
import org.jboss.starobrno.notifications.annotation.ViewChanged;
import org.jboss.starobrno.notifications.event.ViewChangedEvent;
+import org.jboss.starobrno.statetransfer.StateTransferManager;
+import org.jboss.starobrno.tree.Fqn;
+import org.jboss.starobrno.util.ReflectionUtil;
+import org.jboss.starobrno.util.concurrent.ConcurrentHashSet;
import org.jboss.util.stream.MarshalledValueInputStream;
import org.jboss.util.stream.MarshalledValueOutputStream;
import org.jgroups.Address;
@@ -64,24 +57,8 @@
import org.jgroups.util.Util;
import java.io.ByteArrayInputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.Vector;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
+import java.util.*;
+import java.util.concurrent.*;
/**
* Class that manages buddy replication groups.
Modified: core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,30 +21,16 @@
*/
package org.jboss.cache.buddyreplication;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.AbstractVisitor;
import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.WriteCommand;
-import org.jboss.cache.commands.read.ExistsCommand;
-import org.jboss.cache.commands.read.GetChildrenNamesCommand;
-import org.jboss.cache.commands.read.GetDataMapCommand;
-import org.jboss.cache.commands.read.GetKeyValueCommand;
-import org.jboss.cache.commands.read.GetKeysCommand;
-import org.jboss.cache.commands.read.GetNodeCommand;
-import org.jboss.cache.commands.read.GravitateDataCommand;
+import org.jboss.cache.commands.read.*;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
-import org.jboss.cache.commands.write.ClearDataCommand;
-import org.jboss.cache.commands.write.EvictCommand;
-import org.jboss.cache.commands.write.InvalidateCommand;
-import org.jboss.cache.commands.write.MoveCommand;
-import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.commands.write.PutForExternalReadCommand;
-import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.commands.write.RemoveKeyCommand;
-import org.jboss.cache.commands.write.RemoveNodeCommand;
+import org.jboss.cache.commands.write.*;
+import org.jboss.starobrno.tree.Fqn;
import java.util.ArrayList;
import java.util.List;
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-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/GravitateResult.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,8 +21,8 @@
*/
package org.jboss.cache.buddyreplication;
-import org.jboss.cache.Fqn;
import org.jboss.starobrno.marshall.NodeData;
+import org.jboss.starobrno.tree.Fqn;
import java.util.List;
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/CommandsFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/CommandsFactory.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/CommandsFactory.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,34 +21,15 @@
*/
package org.jboss.cache.commands;
-import org.jboss.cache.Fqn;
import org.jboss.cache.buddyreplication.BuddyGroup;
-import org.jboss.cache.commands.read.ExistsCommand;
-import org.jboss.cache.commands.read.GetChildrenNamesCommand;
-import org.jboss.cache.commands.read.GetDataMapCommand;
-import org.jboss.cache.commands.read.GetKeyValueCommand;
-import org.jboss.cache.commands.read.GetKeysCommand;
-import org.jboss.cache.commands.read.GetNodeCommand;
-import org.jboss.cache.commands.read.GravitateDataCommand;
-import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
-import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
-import org.jboss.cache.commands.remote.ClusteredGetCommand;
-import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
-import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
-import org.jboss.cache.commands.remote.ReplicateCommand;
+import org.jboss.cache.commands.read.*;
+import org.jboss.cache.commands.remote.*;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
-import org.jboss.cache.commands.write.ClearDataCommand;
-import org.jboss.cache.commands.write.EvictCommand;
-import org.jboss.cache.commands.write.InvalidateCommand;
-import org.jboss.cache.commands.write.MoveCommand;
-import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.commands.write.PutForExternalReadCommand;
-import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.commands.write.RemoveKeyCommand;
-import org.jboss.cache.commands.write.RemoveNodeCommand;
+import org.jboss.cache.commands.write.*;
import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.starobrno.tree.Fqn;
import org.jgroups.Address;
import java.util.List;
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/CommandsFactoryImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/CommandsFactoryImpl.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/CommandsFactoryImpl.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,36 +23,16 @@
import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.DataContainer;
-import org.jboss.cache.Fqn;
import org.jboss.cache.RPCManager;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyGroup;
import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.cache.commands.read.ExistsCommand;
-import org.jboss.cache.commands.read.GetChildrenNamesCommand;
-import org.jboss.cache.commands.read.GetDataMapCommand;
-import org.jboss.cache.commands.read.GetKeyValueCommand;
-import org.jboss.cache.commands.read.GetKeysCommand;
-import org.jboss.cache.commands.read.GetNodeCommand;
-import org.jboss.cache.commands.read.GravitateDataCommand;
-import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
-import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
-import org.jboss.cache.commands.remote.ClusteredGetCommand;
-import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
-import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
-import org.jboss.cache.commands.remote.ReplicateCommand;
+import org.jboss.cache.commands.read.*;
+import org.jboss.cache.commands.remote.*;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
-import org.jboss.cache.commands.write.ClearDataCommand;
-import org.jboss.cache.commands.write.EvictCommand;
-import org.jboss.cache.commands.write.InvalidateCommand;
-import org.jboss.cache.commands.write.MoveCommand;
-import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.commands.write.PutForExternalReadCommand;
-import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.commands.write.RemoveKeyCommand;
-import org.jboss.cache.commands.write.RemoveNodeCommand;
+import org.jboss.cache.commands.write.*;
import org.jboss.cache.interceptors.InterceptorChain;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
@@ -60,6 +40,7 @@
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.notifications.Notifier;
+import org.jboss.starobrno.tree.Fqn;
import org.jgroups.Address;
import javax.transaction.TransactionManager;
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/DataCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/DataCommand.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/DataCommand.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.commands;
-import org.jboss.cache.Fqn;
+import org.jboss.starobrno.tree.Fqn;
/**
* Commands of this type manipulate data in the cache.
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/read/AbstractDataCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/read/AbstractDataCommand.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/read/AbstractDataCommand.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -22,8 +22,8 @@
package org.jboss.cache.commands.read;
import org.jboss.cache.DataContainer;
-import org.jboss.cache.Fqn;
import org.jboss.cache.commands.DataCommand;
+import org.jboss.starobrno.tree.Fqn;
/**
* An abstract class providing basic functionality of all {@link DataCommand}s.
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/read/ExistsCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/read/ExistsCommand.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/read/ExistsCommand.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,10 +21,10 @@
*/
package org.jboss.cache.commands.read;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
+import org.jboss.starobrno.tree.Fqn;
/**
* Checks whether a given node exists in current in-memory state of the cache.
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,11 +23,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
+import org.jboss.starobrno.tree.Fqn;
import java.util.Collection;
import java.util.HashSet;
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,11 +21,11 @@
*/
package org.jboss.cache.commands.read;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
-import org.jboss.cache.util.Immutables;
+import org.jboss.starobrno.tree.Fqn;
+import org.jboss.starobrno.util.Immutables;
/**
* Implements functionality defined by {@link org.jboss.cache.Cache_Legacy#getData(org.jboss.cache.Fqn)}
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -24,11 +24,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.DataContainer;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
import org.jboss.starobrno.notifications.Notifier;
+import org.jboss.starobrno.tree.Fqn;
/**
* Implements functionality defined by {@link org.jboss.cache.Cache_Legacy#get(String, Object)}
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,10 +21,10 @@
*/
package org.jboss.cache.commands.read;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
+import org.jboss.starobrno.tree.Fqn;
/**
* Implements functionality defined by {@link org.jboss.cache.Cache_Legacy#getKeys(org.jboss.cache.Fqn)}
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,10 +23,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
+import org.jboss.starobrno.tree.Fqn;
/**
* Implements functionality defined by {@link org.jboss.cache.Cache_Legacy#getNode(org.jboss.cache.Fqn)}
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-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,18 +23,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI_Legacy;
-import org.jboss.cache.DataContainer;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InternalNode;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.Node;
-import org.jboss.cache.NodeSPI;
+import org.jboss.cache.*;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.commands.Visitor;
import org.jboss.starobrno.marshall.NodeData;
+import org.jboss.starobrno.tree.Fqn;
import org.jgroups.Address;
import java.util.LinkedList;
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/remote/AssignToBuddyGroupCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/remote/AssignToBuddyGroupCommand.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/remote/AssignToBuddyGroupCommand.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,11 +21,11 @@
*/
package org.jboss.cache.commands.remote;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.buddyreplication.BuddyGroup;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.commands.ReplicableCommand;
+import org.jboss.starobrno.tree.Fqn;
import java.util.Arrays;
import java.util.Map;
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -24,7 +24,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.DataContainer;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
@@ -35,6 +34,7 @@
import org.jboss.cache.interceptors.InterceptorChain;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.starobrno.tree.Fqn;
import java.util.List;
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/AbstractVersionedDataCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/AbstractVersionedDataCommand.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/AbstractVersionedDataCommand.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -22,13 +22,13 @@
package org.jboss.cache.commands.write;
import org.jboss.cache.DataContainer;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.VersionedDataCommand;
import org.jboss.cache.commands.read.AbstractDataCommand;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.starobrno.notifications.Notifier;
+import org.jboss.starobrno.tree.Fqn;
/**
* Base version of {@link org.jboss.cache.commands.DataCommand} which handles common behaviour
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,11 +23,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.starobrno.tree.Fqn;
import java.util.Map;
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/EvictCommand.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/EvictCommand.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -24,13 +24,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.DataContainer;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.commands.read.AbstractDataCommand;
import org.jboss.starobrno.notifications.Notifier;
+import org.jboss.starobrno.tree.Fqn;
import java.util.Collection;
import java.util.Collections;
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -25,12 +25,12 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.DataContainer;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.commands.read.AbstractDataCommand;
import org.jboss.starobrno.notifications.Notifier;
+import org.jboss.starobrno.tree.Fqn;
/**
* Removes a node's content from memory - never removes the node.
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/MoveCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/MoveCommand.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/MoveCommand.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -24,7 +24,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.DataContainer;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
@@ -33,6 +32,7 @@
import org.jboss.cache.commands.read.AbstractDataCommand;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.starobrno.notifications.Notifier;
+import org.jboss.starobrno.tree.Fqn;
import java.util.Map;
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,12 +23,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeNotExistsException;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.starobrno.tree.Fqn;
import java.util.Map;
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutForExternalReadCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutForExternalReadCommand.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutForExternalReadCommand.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,10 +21,10 @@
*/
package org.jboss.cache.commands.write;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.starobrno.tree.Fqn;
/**
* Represents the {@link org.jboss.cache.Cache_Legacy#putForExternalRead(org.jboss.cache.Fqn, Object, Object)} method call.
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,12 +23,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeNotExistsException;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.starobrno.tree.Fqn;
import java.util.Collections;
import java.util.Map;
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,11 +23,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.starobrno.tree.Fqn;
import java.util.Collections;
import java.util.Map;
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,11 +23,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.starobrno.tree.Fqn;
import java.util.Map;
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,7 +21,6 @@
*/
package org.jboss.cache.interceptors;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.Modification;
@@ -31,27 +30,18 @@
import org.jboss.cache.commands.read.GetKeysCommand;
import org.jboss.cache.commands.read.GetNodeCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
-import org.jboss.cache.commands.write.ClearDataCommand;
-import org.jboss.cache.commands.write.MoveCommand;
-import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.commands.write.PutForExternalReadCommand;
-import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.commands.write.RemoveKeyCommand;
-import org.jboss.cache.commands.write.RemoveNodeCommand;
+import org.jboss.cache.commands.write.*;
import org.jboss.cache.jmx.annotations.ManagedAttribute;
import org.jboss.cache.jmx.annotations.ManagedOperation;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionContext;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.tree.Fqn;
import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/BuddyRegionAwareEvictionInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/BuddyRegionAwareEvictionInterceptor.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/BuddyRegionAwareEvictionInterceptor.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,11 +21,11 @@
*/
package org.jboss.cache.interceptors;
-import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.interceptors.EvictionInterceptor;
+import org.jboss.starobrno.tree.Fqn;
/**
* A subclass of EvictionInterceptor that is aware of and able to deal with buddy regions.
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -22,23 +22,12 @@
package org.jboss.cache.interceptors;
import org.jboss.cache.DataContainer;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.read.GetChildrenNamesCommand;
-import org.jboss.cache.commands.read.GetDataMapCommand;
-import org.jboss.cache.commands.read.GetKeyValueCommand;
-import org.jboss.cache.commands.read.GetKeysCommand;
-import org.jboss.cache.commands.read.GetNodeCommand;
+import org.jboss.cache.commands.read.*;
import org.jboss.cache.commands.tx.RollbackCommand;
-import org.jboss.cache.commands.write.ClearDataCommand;
-import org.jboss.cache.commands.write.MoveCommand;
-import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.commands.write.PutForExternalReadCommand;
-import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.commands.write.RemoveKeyCommand;
-import org.jboss.cache.commands.write.RemoveNodeCommand;
+import org.jboss.cache.commands.write.*;
import org.jboss.cache.interceptors.base.JmxStatsCommandInterceptor;
import org.jboss.cache.jmx.annotations.ManagedAttribute;
import org.jboss.cache.jmx.annotations.ManagedOperation;
@@ -50,12 +39,9 @@
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.Start;
import org.jboss.starobrno.notifications.Notifier;
+import org.jboss.starobrno.tree.Fqn;
-import java.util.HashMap;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
/**
* Loads nodes that don't exist at the time of the call into memory from the CacheLoader
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -22,7 +22,6 @@
package org.jboss.cache.interceptors;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.Modification;
import org.jboss.cache.NodeSPI;
@@ -32,13 +31,7 @@
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
-import org.jboss.cache.commands.write.ClearDataCommand;
-import org.jboss.cache.commands.write.MoveCommand;
-import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.commands.write.PutForExternalReadCommand;
-import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.commands.write.RemoveKeyCommand;
-import org.jboss.cache.commands.write.RemoveNodeCommand;
+import org.jboss.cache.commands.write.*;
import org.jboss.cache.interceptors.base.SkipCheckChainedInterceptor;
import org.jboss.cache.jmx.annotations.ManagedAttribute;
import org.jboss.cache.jmx.annotations.ManagedOperation;
@@ -49,15 +42,11 @@
import org.jboss.starobrno.config.CacheLoaderConfig;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.tree.Fqn;
import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor_Legacy.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor_Legacy.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor_Legacy.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,7 +21,6 @@
*/
package org.jboss.cache.interceptors;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.AbstractVisitor;
import org.jboss.cache.commands.CommandsFactory;
@@ -30,13 +29,7 @@
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
-import org.jboss.cache.commands.write.ClearDataCommand;
-import org.jboss.cache.commands.write.MoveCommand;
-import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.commands.write.PutForExternalReadCommand;
-import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.commands.write.RemoveKeyCommand;
-import org.jboss.cache.commands.write.RemoveNodeCommand;
+import org.jboss.cache.commands.write.*;
import org.jboss.cache.jmx.annotations.ManagedAttribute;
import org.jboss.cache.jmx.annotations.ManagedOperation;
import org.jboss.cache.transaction.GlobalTransaction;
@@ -45,15 +38,11 @@
import org.jboss.starobrno.config.Option;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.tree.Fqn;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,7 +21,6 @@
*/
package org.jboss.cache.interceptors;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.write.EvictCommand;
@@ -32,6 +31,7 @@
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.notifications.Notifier;
+import org.jboss.starobrno.tree.Fqn;
import java.util.HashMap;
import java.util.Map;
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-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,41 +23,17 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI_Legacy;
-import org.jboss.cache.CacheStatus;
-import org.jboss.cache.DataContainer;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.NodeNotExistsException;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.RPCManager;
-import org.jboss.cache.Region;
-import org.jboss.cache.RegionManager;
-import org.jboss.cache.Version;
+import org.jboss.cache.*;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.read.ExistsCommand;
-import org.jboss.cache.commands.read.GetChildrenNamesCommand;
-import org.jboss.cache.commands.read.GetDataMapCommand;
-import org.jboss.cache.commands.read.GetKeyValueCommand;
-import org.jboss.cache.commands.read.GetKeysCommand;
-import org.jboss.cache.commands.read.GetNodeCommand;
-import org.jboss.cache.commands.read.GravitateDataCommand;
-import org.jboss.cache.commands.write.EvictCommand;
-import org.jboss.cache.commands.write.MoveCommand;
-import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.commands.write.PutForExternalReadCommand;
-import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.commands.write.RemoveKeyCommand;
-import org.jboss.cache.commands.write.RemoveNodeCommand;
+import org.jboss.cache.commands.read.*;
+import org.jboss.cache.commands.write.*;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.marshall.Marshaller;
-import org.jboss.starobrno.statetransfer.StateTransferManager;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
-import org.jboss.cache.util.Immutables;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.batch.BatchContainer;
import org.jboss.starobrno.config.Configuration;
@@ -67,6 +43,9 @@
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.NonVolatile;
import org.jboss.starobrno.notifications.Notifier;
+import org.jboss.starobrno.statetransfer.StateTransferManager;
+import org.jboss.starobrno.tree.Fqn;
+import org.jboss.starobrno.util.Immutables;
import org.jgroups.Address;
import javax.transaction.Transaction;
Modified: core/branches/flat/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,11 +21,11 @@
*/
package org.jboss.cache.invocation;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.transaction.MVCCTransactionContext;
import org.jboss.cache.transaction.TransactionContext;
+import org.jboss.starobrno.tree.Fqn;
import java.util.Collections;
import java.util.HashMap;
Modified: core/branches/flat/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,18 +23,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI_Legacy;
-import org.jboss.cache.DataContainer;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InternalNode;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.Node;
-import org.jboss.cache.NodeNotValidException;
-import org.jboss.cache.NodeSPI;
+import org.jboss.cache.*;
import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.config.Option;
+import org.jboss.starobrno.tree.Fqn;
import java.util.Collections;
import java.util.HashSet;
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-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -24,18 +24,18 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI_Legacy;
-import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.marshall.Marshaller;
+import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.marshall.NodeData;
+import org.jboss.starobrno.marshall.NodeDataExceptionMarker;
import org.jboss.starobrno.marshall.NodeDataMarker;
-import org.jboss.starobrno.marshall.NodeDataExceptionMarker;
-import org.jboss.cache.util.Immutables;
-import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.tree.Fqn;
+import org.jboss.starobrno.util.Immutables;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractDelegatingCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractDelegatingCacheLoader.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractDelegatingCacheLoader.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -22,10 +22,10 @@
package org.jboss.cache.loader;
import org.jboss.cache.CacheSPI_Legacy;
-import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.RegionManager;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.tree.Fqn;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
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-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,31 +23,17 @@
import net.jcip.annotations.ThreadSafe;
import org.apache.commons.logging.Log;
-import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
-import org.jboss.starobrno.io.ByteBuffer;
import org.jboss.cache.lock.StripedLock;
-import org.jboss.starobrno.util.Util;
import org.jboss.starobrno.config.CacheLoaderConfig;
+import org.jboss.starobrno.io.ByteBuffer;
+import org.jboss.starobrno.tree.Fqn;
+import org.jboss.starobrno.util.Util;
import java.io.IOException;
import java.io.InputStream;
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.sql.Types;
-import java.util.AbstractMap;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
+import java.sql.*;
+import java.util.*;
/**
* Adjacency List Model is the model of persisting trees in which each children holds a reference to its parent.
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/AsyncCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/AsyncCacheLoader.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/AsyncCacheLoader.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,24 +23,18 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
-import org.jboss.cache.util.Immutables;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.tree.Fqn;
+import org.jboss.starobrno.util.Immutables;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
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-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoader.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,10 +23,10 @@
import net.jcip.annotations.ThreadSafe;
import org.jboss.cache.CacheSPI_Legacy;
-import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.RegionManager;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.tree.Fqn;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoaderAop.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoaderAop.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoaderAop.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.loader;
-import org.jboss.cache.Fqn;
+import org.jboss.starobrno.tree.Fqn;
/**
* Responsible for storing and retrieving objects to/from secondary storage.
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-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,28 +21,28 @@
*/
package org.jboss.cache.loader;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.StringTokenizer;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI_Legacy;
-import org.jboss.cache.Fqn;
import org.jboss.cache.RegionManager;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.config.CacheLoaderConfig;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.config.ConfigurationException;
-import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
-import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig;
import org.jboss.starobrno.factories.ComponentRegistry;
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.tree.Fqn;
import org.jboss.starobrno.util.ReflectionUtil;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.StringTokenizer;
+
/**
* Manages all cache loader functionality. This class is typically initialised with an XML DOM Element,
* represeting a cache loader configuration, or a {@link org.jboss.cache.config.CacheLoaderConfig} object.
@@ -225,7 +225,7 @@
private CacheLoader createCacheLoader(CacheLoaderConfig.IndividualCacheLoaderConfig cfg, CacheSPI_Legacy cache) throws Exception
{
// create loader
- CacheLoader tmpLoader = (CacheLoader)(cfg.getCacheLoader() == null ? createInstance(cfg.getClassName()) : cfg.getCacheLoader());
+ CacheLoader tmpLoader = (CacheLoader) (cfg.getCacheLoader() == null ? createInstance(cfg.getClassName()) : cfg.getCacheLoader());
if (tmpLoader != null)
{
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/ChainingCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/ChainingCacheLoader.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/ChainingCacheLoader.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,22 +21,17 @@
*/
package org.jboss.cache.loader;
-import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.RegionManager;
import org.jboss.starobrno.config.CacheLoaderConfig;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.starobrno.factories.ComponentRegistry;
import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.tree.Fqn;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
/**
* This decorator is used whenever more than one cache loader is configured. READ operations are directed to
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/ClusteredCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/ClusteredCacheLoader.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/ClusteredCacheLoader.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -24,12 +24,7 @@
import net.jcip.annotations.ThreadSafe;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheStatus;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Modification;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.RegionManager;
-import org.jboss.cache.ReplicationException;
+import org.jboss.cache.*;
import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.DataCommand;
import org.jboss.cache.commands.read.ExistsCommand;
@@ -40,18 +35,14 @@
import org.jboss.cache.lock.StripedLock;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.tree.Fqn;
import org.jgroups.Address;
import org.jgroups.blocks.GroupRequest;
import org.jgroups.blocks.RspFilter;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
/**
* A cache loader that consults other members in the cluster for values. Does
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/FileCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/FileCacheLoader.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/FileCacheLoader.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -24,24 +24,13 @@
import net.jcip.annotations.ThreadSafe;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
import org.jboss.cache.lock.StripedLock;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.tree.Fqn;
import org.jboss.util.stream.MarshalledValueInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.io.*;
+import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
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-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -24,18 +24,14 @@
import net.jcip.annotations.ThreadSafe;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.starobrno.marshall.NodeData;
import org.jboss.starobrno.config.CacheLoaderConfig;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.marshall.NodeData;
+import org.jboss.starobrno.tree.Fqn;
import java.io.InputStream;
import java.io.ObjectInputStream;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
+import java.sql.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderOld.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderOld.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderOld.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,8 +23,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.tree.Fqn;
import java.sql.Connection;
import java.sql.PreparedStatement;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/LocalDelegatingCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/LocalDelegatingCacheLoader.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/LocalDelegatingCacheLoader.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -22,10 +22,10 @@
package org.jboss.cache.loader;
import org.jboss.cache.CacheSPI_Legacy;
-import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.tree.Fqn;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/ReadOnlyDelegatingCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/ReadOnlyDelegatingCacheLoader.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/ReadOnlyDelegatingCacheLoader.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,8 +23,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
+import org.jboss.starobrno.tree.Fqn;
import java.io.ObjectInputStream;
import java.util.List;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/SingletonStoreCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/SingletonStoreCacheLoader.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/SingletonStoreCacheLoader.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -24,7 +24,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI_Legacy;
-import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.NodeSPI;
import org.jboss.starobrno.config.CacheLoaderConfig;
@@ -35,23 +34,13 @@
import org.jboss.starobrno.notifications.annotation.ViewChanged;
import org.jboss.starobrno.notifications.event.Event;
import org.jboss.starobrno.notifications.event.ViewChangedEvent;
+import org.jboss.starobrno.tree.Fqn;
import org.jgroups.Address;
import org.jgroups.View;
import java.io.ObjectInputStream;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Vector;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
+import java.util.*;
+import java.util.concurrent.*;
/**
* SingletonStoreCacheLoader is a delegating cache loader used for situations when only one node should interact with
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoader.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoader.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,17 +23,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.loader.tcp.TcpCacheOperations;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.tree.Fqn;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
+import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.Socket;
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-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -26,36 +26,21 @@
import com.sleepycat.bind.tuple.TupleBinding;
import com.sleepycat.bind.tuple.TupleInput;
import com.sleepycat.bind.tuple.TupleOutput;
-import com.sleepycat.je.Cursor;
-import com.sleepycat.je.Database;
-import com.sleepycat.je.DatabaseConfig;
-import com.sleepycat.je.DatabaseEntry;
-import com.sleepycat.je.DeadlockException;
-import com.sleepycat.je.Environment;
-import com.sleepycat.je.EnvironmentConfig;
-import com.sleepycat.je.JEVersion;
-import com.sleepycat.je.LockMode;
-import com.sleepycat.je.OperationStatus;
-import com.sleepycat.je.Transaction;
+import com.sleepycat.je.*;
import net.jcip.annotations.ThreadSafe;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI_Legacy;
-import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.loader.AbstractCacheLoader;
-import org.jboss.starobrno.util.ReflectionUtil;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.tree.Fqn;
+import org.jboss.starobrno.util.ReflectionUtil;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -30,22 +30,16 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI_Legacy;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.FqnComparator;
import org.jboss.cache.Modification;
import org.jboss.cache.loader.AbstractCacheLoader;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.tree.Fqn;
+import org.jboss.starobrno.tree.FqnComparator;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
+import java.util.*;
/**
* A persistent <code>CacheLoader</code> based on the JDBM project.
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/s3/S3CacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/s3/S3CacheLoader.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/s3/S3CacheLoader.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -22,26 +22,15 @@
package org.jboss.cache.loader.s3;
import net.jcip.annotations.ThreadSafe;
-import net.noderunner.amazon.s3.Bucket;
-import net.noderunner.amazon.s3.Connection;
-import net.noderunner.amazon.s3.Entry;
-import net.noderunner.amazon.s3.GetStreamResponse;
-import net.noderunner.amazon.s3.ListResponse;
-import net.noderunner.amazon.s3.Response;
-import net.noderunner.amazon.s3.S3Object;
+import net.noderunner.amazon.s3.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
import org.jboss.cache.loader.AbstractCacheLoader;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.tree.Fqn;
import java.io.BufferedInputStream;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
/**
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/tcp/TcpCacheServer.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/tcp/TcpCacheServer.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/tcp/TcpCacheServer.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,33 +23,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI_Legacy;
-import org.jboss.cache.Cache_Legacy;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Modification;
-import org.jboss.cache.Node;
-import org.jboss.cache.NodeSPI;
+import org.jboss.cache.*;
import org.jboss.cache.jmx.CacheJmxWrapperMBean;
import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.tree.Fqn;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.SocketException;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.io.*;
+import java.net.*;
+import java.util.*;
/**
* TCP-IP based CacheServer, setCache TcpDelegatingCacheLoader with host and port of this server
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-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/lock/IdentityLock.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,17 +23,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
import org.jboss.starobrno.lock.TimeoutException;
+import org.jboss.starobrno.tree.Fqn;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
+import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
Modified: core/branches/flat/src/main/java/org/jboss/cache/lock/LockManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/lock/LockManager.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/lock/LockManager.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,9 +21,9 @@
*/
package org.jboss.cache.lock;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
+import org.jboss.starobrno.tree.Fqn;
import java.util.Collection;
Modified: core/branches/flat/src/main/java/org/jboss/cache/lock/LockMap.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/lock/LockMap.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/lock/LockMap.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.lock;
-import org.jboss.cache.util.concurrent.ConcurrentHashSet;
+import org.jboss.starobrno.util.concurrent.ConcurrentHashSet;
import java.util.Collection;
Modified: core/branches/flat/src/main/java/org/jboss/cache/lock/LockUtil.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/lock/LockUtil.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/lock/LockUtil.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,7 +23,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.CommandsFactory;
@@ -31,6 +30,7 @@
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.starobrno.tree.Fqn;
import javax.transaction.Status;
import javax.transaction.Transaction;
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-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/lock/MVCCLockManager.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,29 +23,19 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI_Legacy;
-import org.jboss.cache.DataContainer;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InternalNode;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.Node;
-import org.jboss.cache.NodeSPI;
+import org.jboss.cache.*;
import org.jboss.cache.invocation.InvocationContextContainer;
import static org.jboss.cache.lock.LockType.READ;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.tree.Fqn;
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;
import javax.transaction.TransactionManager;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import java.util.concurrent.locks.Lock;
Modified: core/branches/flat/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -24,11 +24,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.DataContainer;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.tree.Fqn;
import java.util.ArrayList;
import java.util.Collection;
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-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/lock/NodeLock.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,8 +21,8 @@
*/
package org.jboss.cache.lock;
-import org.jboss.cache.Fqn;
import org.jboss.starobrno.lock.TimeoutException;
+import org.jboss.starobrno.tree.Fqn;
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-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,7 +23,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.CommandsFactory;
@@ -32,6 +31,7 @@
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.lock.TimeoutException;
+import org.jboss.starobrno.tree.Fqn;
import java.util.List;
Modified: core/branches/flat/src/main/java/org/jboss/cache/lock/StripedLock.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/lock/StripedLock.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/lock/StripedLock.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -22,7 +22,7 @@
package org.jboss.cache.lock;
import net.jcip.annotations.ThreadSafe;
-import org.jboss.cache.Fqn;
+import org.jboss.starobrno.tree.Fqn;
import java.util.List;
import java.util.concurrent.locks.ReentrantReadWriteLock;
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-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,14 +23,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
import org.jboss.cache.RegionManager;
-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;
import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.io.ByteBuffer;
import org.jboss.starobrno.transaction.GlobalTransaction;
+import org.jboss.starobrno.tree.Fqn;
import org.jgroups.util.Buffer;
import java.io.InputStream;
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-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,18 +21,18 @@
*/
package org.jboss.cache.marshall;
-import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.Region.Status;
import org.jboss.cache.buddyreplication.GravitateResult;
-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.*;
import org.jboss.starobrno.transaction.GlobalTransaction;
+import org.jboss.starobrno.tree.Fqn;
import org.jboss.starobrno.util.FastCopyHashMap;
+import org.jboss.starobrno.util.Immutables;
import org.jgroups.Address;
import org.jgroups.stack.IpAddress;
Modified: core/branches/flat/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,7 +21,6 @@
*/
package org.jboss.cache.marshall;
-import org.jboss.cache.util.concurrent.WithinThreadExecutor;
import org.jboss.starobrno.commands.ReplicableCommand;
import org.jboss.starobrno.commands.VisitableCommand;
import org.jboss.starobrno.commands.remote.AnnounceBuddyPoolNameCommand;
@@ -32,11 +31,8 @@
import org.jboss.starobrno.factories.ComponentRegistry;
import org.jboss.starobrno.interceptors.InterceptorChain;
import org.jboss.starobrno.invocation.InvocationContextContainer;
-import org.jgroups.Address;
-import org.jgroups.Channel;
-import org.jgroups.MembershipListener;
-import org.jgroups.Message;
-import org.jgroups.MessageListener;
+import org.jboss.starobrno.util.concurrent.WithinThreadExecutor;
+import org.jgroups.*;
import org.jgroups.blocks.RpcDispatcher;
import org.jgroups.blocks.RspFilter;
import org.jgroups.util.Buffer;
@@ -45,13 +41,7 @@
import java.io.NotSerializableException;
import java.util.Vector;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
/**
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-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/Marshaller.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,8 +21,8 @@
*/
package org.jboss.cache.marshall;
-import org.jboss.cache.Fqn;
import org.jboss.starobrno.io.ByteBuffer;
+import org.jboss.starobrno.tree.Fqn;
import org.jgroups.blocks.RpcDispatcher;
import java.io.InputStream;
Modified: core/branches/flat/src/main/java/org/jboss/cache/marshall/RegionalizedMethodCall.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/RegionalizedMethodCall.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/RegionalizedMethodCall.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,8 +21,8 @@
*/
package org.jboss.cache.marshall;
-import org.jboss.cache.Fqn;
import org.jboss.starobrno.commands.ReplicableCommand;
+import org.jboss.starobrno.tree.Fqn;
/**
* A regionalized MethodCall object, created when {@link Marshaller#regionalizedMethodCallFromByteBuffer(byte[])} or
Modified: core/branches/flat/src/main/java/org/jboss/cache/marshall/RegionalizedReturnValue.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/RegionalizedReturnValue.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/RegionalizedReturnValue.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.marshall;
-import org.jboss.cache.Fqn;
+import org.jboss.starobrno.tree.Fqn;
/**
* A return value that holds region information, so that the marshaller knows which region to use (and hence which
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-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,13 +23,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
+import org.jboss.starobrno.factories.ComponentRegistry;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
import org.jboss.starobrno.io.ByteBuffer;
import org.jboss.starobrno.io.ExposedByteArrayOutputStream;
+import org.jboss.starobrno.tree.Fqn;
import org.jboss.starobrno.util.Util;
-import org.jboss.starobrno.factories.ComponentRegistry;
-import org.jboss.starobrno.factories.annotations.Inject;
-import org.jboss.starobrno.factories.annotations.Start;
import org.jboss.util.stream.MarshalledValueInputStream;
import java.io.ByteArrayInputStream;
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-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessageListener.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,14 +23,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
-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;
import org.jboss.starobrno.factories.annotations.NonVolatile;
+import org.jboss.starobrno.io.ExposedByteArrayOutputStream;
+import org.jboss.starobrno.statetransfer.DefaultStateTransferManager;
+import org.jboss.starobrno.statetransfer.StateTransferManager;
+import org.jboss.starobrno.tree.Fqn;
import org.jboss.util.stream.MarshalledValueInputStream;
import org.jboss.util.stream.MarshalledValueOutputStream;
import org.jgroups.ExtendedMessageListener;
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-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferGenerator.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -24,7 +24,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI_Legacy;
-import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
import org.jboss.cache.Node;
import org.jboss.cache.Version;
@@ -32,6 +31,7 @@
import org.jboss.starobrno.marshall.NodeData;
import org.jboss.starobrno.marshall.NodeDataExceptionMarker;
import org.jboss.starobrno.statetransfer.DefaultStateTransferManager;
+import org.jboss.starobrno.tree.Fqn;
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-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,30 +23,22 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI_Legacy;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InternalNode;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.Node;
-import org.jboss.cache.NodeSPI;
+import org.jboss.cache.*;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
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;
+import org.jboss.starobrno.marshall.NodeData;
+import org.jboss.starobrno.marshall.NodeDataExceptionMarker;
+import org.jboss.starobrno.marshall.NodeDataMarker;
+import org.jboss.starobrno.tree.Fqn;
import java.io.IOException;
import java.io.ObjectInputStream;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
public class DefaultStateTransferIntegrator implements StateTransferIntegrator
{
Modified: core/branches/flat/src/main/java/org/jboss/cache/statetransfer/StateTransferIntegrator.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/statetransfer/StateTransferIntegrator.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/statetransfer/StateTransferIntegrator.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.statetransfer;
-import org.jboss.cache.Fqn;
+import org.jboss.starobrno.tree.Fqn;
import java.io.ObjectInputStream;
Modified: core/branches/flat/src/main/java/org/jboss/cache/transaction/AbstractTransactionContext.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/transaction/AbstractTransactionContext.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/transaction/AbstractTransactionContext.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -22,20 +22,16 @@
package org.jboss.cache.transaction;
-import org.jboss.cache.Fqn;
import org.jboss.cache.commands.WriteCommand;
import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
-import org.jboss.cache.util.Immutables;
import org.jboss.starobrno.config.Option;
+import org.jboss.starobrno.tree.Fqn;
+import org.jboss.starobrno.util.Immutables;
import javax.transaction.RollbackException;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
+import java.util.*;
/**
* An abstract transaction context
Modified: core/branches/flat/src/main/java/org/jboss/cache/transaction/MVCCTransactionContext.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/transaction/MVCCTransactionContext.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/transaction/MVCCTransactionContext.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,8 +21,8 @@
*/
package org.jboss.cache.transaction;
-import org.jboss.cache.Fqn;
import org.jboss.cache.NodeSPI;
+import org.jboss.starobrno.tree.Fqn;
import javax.transaction.RollbackException;
import javax.transaction.SystemException;
Modified: core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionContext.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionContext.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionContext.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,10 +21,10 @@
*/
package org.jboss.cache.transaction;
-import org.jboss.cache.Fqn;
import org.jboss.cache.commands.WriteCommand;
import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
import org.jboss.starobrno.config.Option;
+import org.jboss.starobrno.tree.Fqn;
import javax.transaction.Transaction;
import java.util.List;
Deleted: core/branches/flat/src/main/java/org/jboss/cache/util/BeanUtils.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/util/BeanUtils.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/util/BeanUtils.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -1,131 +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.lang.reflect.Method;
-import java.util.Locale;
-
-/**
- * Simple JavaBean manipulation helper methods
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @since 2.1.0
- */
-public class BeanUtils
-{
- /**
- * Retrieves a setter name based on a field name passed in
- *
- * @param fieldName field name to find setter for
- * @return name of setter method
- */
- public static String setterName(String fieldName)
- {
- StringBuilder sb = new StringBuilder("set");
- if (fieldName != null && fieldName.length() > 0)
- {
- sb.append(fieldName.substring(0, 1).toUpperCase(Locale.ENGLISH));
- if (fieldName.length() > 1)
- {
- sb.append(fieldName.substring(1));
- }
- }
- return sb.toString();
- }
-
- /**
- * Returns a getter for a given class
- *
- * @param componentClass class to find getter for
- * @return name of getter method
- */
- public static String getterName(Class componentClass)
- {
- if (componentClass == null) return null;
- StringBuilder sb = new StringBuilder("get");
- sb.append(componentClass.getSimpleName());
- return sb.toString();
- }
-
- /**
- * Returns a setter for a given class
- *
- * @param componentClass class to find setter for
- * @return name of getter method
- */
- public static String setterName(Class componentClass)
- {
- if (componentClass == null) return null;
- StringBuilder sb = new StringBuilder("set");
- sb.append(componentClass.getSimpleName());
- return sb.toString();
- }
-
-
- /**
- * Returns a Method object corresponding to a getter that retrieves an instance of componentClass from target.
- *
- * @param target class that the getter should exist on
- * @param componentClass component to get
- * @return Method object, or null of one does not exist
- */
- public static Method getterMethod(Class target, Class componentClass)
- {
- try
- {
- return target.getMethod(getterName(componentClass));
- }
- catch (NoSuchMethodException e)
- {
- //if (log.isTraceEnabled()) log.trace("Unable to find method " + getterName(componentClass) + " in class " + target);
- return null;
- }
- catch (NullPointerException e)
- {
- return null;
- }
- }
-
- /**
- * Returns a Method object corresponding to a setter that sets an instance of componentClass from target.
- *
- * @param target class that the setter should exist on
- * @param componentClass component to set
- * @return Method object, or null of one does not exist
- */
- public static Method setterMethod(Class target, Class componentClass)
- {
- try
- {
- return target.getMethod(setterName(componentClass), componentClass);
- }
- catch (NoSuchMethodException e)
- {
- //if (log.isTraceEnabled()) log.trace("Unable to find method " + setterName(componentClass) + " in class " + target);
- return null;
- }
- catch (NullPointerException e)
- {
- return null;
- }
- }
-}
Deleted: core/branches/flat/src/main/java/org/jboss/cache/util/BitEncodedIntegerSet.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/util/BitEncodedIntegerSet.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/util/BitEncodedIntegerSet.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -1,124 +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 net.jcip.annotations.NotThreadSafe;
-
-/**
- * A Set that encodes integers as bits in a long. Does not implement java.util.Set since autoboxing is unnecessarily
- * expensive for the ints stored, but follows very similar semantics to Set: no nulls, no duplicates, and order not guaranteed,
- * and adds one more: this can only store ints from 0 to 63, inclusive.
- * <p/>
- * Integers in this set are packed into a single long, setting bit values accordingly and hence the strict range on allowable
- * integers. The upshot is a guaranteed limit on how much memory is consumed, as well as very efficient operations on the set.
- * <p/>
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @since 2.1.0
- */
-@NotThreadSafe
-public class BitEncodedIntegerSet
-{
- private long encoded = 0;
-
- /**
- * Adds an integer to the set.
- *
- * @param i integer to add
- */
- public void add(int i)
- {
- encoded |= ((long) 1 << i);
- }
-
- /**
- * Removes an integer from the set
- *
- * @param i integer to remove
- */
- public void remove(int i)
- {
- encoded &= ~((long) 1 << i);
- }
-
- /**
- * Tests whether the set contains an integer
- *
- * @param i integer to check for
- * @return true if contained; false otherwise
- */
- public boolean contains(int i)
- {
- return (encoded & ((long) 1 << i)) != 0;
- }
-
- @Override
- public boolean equals(Object o)
- {
- if (o == this) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- BitEncodedIntegerSet that = (BitEncodedIntegerSet) o;
-
- return encoded == that.encoded;
- }
-
- @Override
- public int hashCode()
- {
- return (int) (encoded ^ (encoded >>> 32));
- }
-
- /**
- * Clears the set
- */
- public void clear()
- {
- encoded = 0;
- }
-
- /**
- * Tests if the set is empty
- *
- * @return true if empty
- */
- public boolean isEmpty()
- {
- return encoded == 0;
- }
-
- @Override
- public String toString()
- {
- return "BitEncodedSet (encoded as: " + Long.toBinaryString(encoded) + ")";
- }
-
- /**
- * Adds all elements of another BitEncodedIntegerSet to the current set.
- *
- * @param otherSet other set to add
- */
- public void addAll(BitEncodedIntegerSet otherSet)
- {
- encoded |= otherSet.encoded;
- }
-}
Modified: core/branches/flat/src/main/java/org/jboss/cache/util/Caches.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/util/Caches.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/util/Caches.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -22,17 +22,13 @@
package org.jboss.cache.util;
import org.jboss.cache.Cache_Legacy;
-import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.loader.CacheLoader;
+import org.jboss.starobrno.tree.Fqn;
+import org.jboss.starobrno.util.SimpleImmutableEntry;
-import java.util.AbstractMap;
-import java.util.AbstractSet;
-import java.util.ConcurrentModificationException;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
/**
* Adaptors for {@link org.jboss.cache.Cache_Legacy} classes, such as {@link Node}.
Deleted: core/branches/flat/src/main/java/org/jboss/cache/util/FileLookup.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/util/FileLookup.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/util/FileLookup.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -1,109 +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 org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-/**
- * Holds the logic of looking up a file, in the following sequence:
- * <ol>
- * <li> try to load it with the curent thread's context ClassLoader</li>
- * <li> if fails, the system ClassLoader</li>
- * <li> if fails, try to load it as a file from the disck </li>
- * </ol>
- *
- * @author Mircea.Markus(a)jboss.com
- * @since 3.0
- */
-public class FileLookup
-{
- private static final Log log = LogFactory.getLog(FileLookup.class);
-
- /**
- * Looks up the file, see : {@link FileLookup}.
- *
- * @param filename might be the name of the file (too look it up in the class path) or an url to a file.
- * @return an input stream to the file or null if nothing found through all lookup steps.
- */
- public InputStream lookupFile(String filename)
- {
- InputStream is = getAsInputStreamFromClassLoader(filename);
- if (is == null)
- {
- if (log.isDebugEnabled())
- log.debug("Unable to find configuration file " + filename + " in classpath; searching for this file on the filesystem instead.");
- try
- {
- is = new FileInputStream(filename);
- }
- catch (FileNotFoundException e)
- {
- return null;
- }
- }
- return is;
- }
-
- protected InputStream getAsInputStreamFromClassLoader(String filename)
- {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- InputStream is = cl == null ? null : cl.getResourceAsStream(filename);
- if (is == null)
- {
- // check system class loader
- is = getClass().getClassLoader().getResourceAsStream(filename);
- }
- return is;
- }
-
- public URL lookupFileLocation(String filename)
- {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- URL u = cl == null ? null : cl.getResource(filename);
- if (u == null)
- {
- // check system class loader
- u = getClass().getClassLoader().getResource(filename);
- }
- if (u == null)
- {
- File f = new File(filename);
- if (f.exists()) try
- {
- u = f.toURL();
- }
- catch (MalformedURLException e)
- {
- // what do we do here?
- }
- }
- return u;
- }
-}
Deleted: core/branches/flat/src/main/java/org/jboss/cache/util/ImmutableListCopy.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/util/ImmutableListCopy.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/util/ImmutableListCopy.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -1,477 +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 net.jcip.annotations.Immutable;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.lang.reflect.Array;
-import java.util.AbstractList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-
-/**
- * A lightweight, read-only copy of a List. Typically used in place of the common idiom:
- * <code>
- * return Collections.unmodifiableList(new ArrayList( myInternalList ));
- * </code>
- * <p/>
- * a it is far more efficient than making a defensive copy and then wrapping the defensive copy in a read-only wrapper.
- * <p/>
- * Also used whenever a read-only reference List is needed (such as in Fqns).
- * <p/>
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @since 3.0
- */
-@Immutable
-public class ImmutableListCopy<E> extends AbstractList<E> implements Externalizable, Immutables.Immutable
-{
- private static final long serialVersionUID = 10929568968966L;
- private E[] elements;
- private int size;
-
- /**
- * Constructs a new ImmutableListCopy.
- * Required by Serialization.
- */
- public ImmutableListCopy() {}
-
- /**
- * Only one copy constructor since the list is immutable.
- *
- * @param c collection to copy from
- */
- @SuppressWarnings("unchecked")
- public ImmutableListCopy(Collection<? extends E> c)
- {
- size = c.size();
- Object[] el = new Object[size]; // no room for growth;
- el = c.toArray(el);
- elements = (E[]) el;
- }
-
- /**
- * Assumes that the array passed in is "safe", i.e., is not referenced from elsewhere. Use with care!
- *
- * @param array to reference
- */
- public ImmutableListCopy(E[] array)
- {
- size = array.length;
- elements = array;
- }
-
- /**
- * Utility constructors to allow combining collections
- *
- * @param collection1 collection to copy from
- * @param collection2 collection to copy from
- */
- @SuppressWarnings("unchecked")
- public ImmutableListCopy(Collection<? extends E> collection1, Collection<? extends E> collection2)
- {
- size = collection1.size() + collection2.size();
- elements = (E[]) new Object[size]; // no room for growth;
- Object[] c1 = new Object[collection1.size()];
- Object[] c2 = new Object[collection2.size()];
- c1 = collection1.toArray(c1);
- c2 = collection2.toArray(c2);
- System.arraycopy(c1, 0, elements, 0, c1.length);
- System.arraycopy(c2, 0, elements, c1.length, c2.length);
- }
-
- @Override
- public final int size()
- {
- return size;
- }
-
- @Override
- public final boolean isEmpty()
- {
- return size == 0;
- }
-
- @Override
- public final boolean contains(Object o)
- {
- return indexOf(o) >= 0;
- }
-
- @Override
- public final Iterator<E> iterator()
- {
- return new ImmutableIterator();
- }
-
- @Override
- public final Object[] toArray()
- {
- Object[] result = new Object[size];
- System.arraycopy(elements, 0, result, 0, size);
- return result;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public final <T> T[] toArray(T[] a)
- {
- if (a.length < size)
- {
- a = (T[]) Array.newInstance(a.getClass().getComponentType(), size);
- }
- System.arraycopy(elements, 0, a, 0, size);
- if (a.length > size) a[size] = null;
- return a;
- }
-
- @Override
- public final boolean add(E o)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public final boolean remove(Object o)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public final boolean addAll(Collection<? extends E> c)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public final boolean addAll(int index, Collection<? extends E> c)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public final boolean removeAll(Collection<?> c)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public final boolean retainAll(Collection<?> c)
- {
- throw new UnsupportedOperationException();
- }
-
- public final E get(int index)
- {
- if (index >= size || index < 0) throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
- return elements[index];
- }
-
- @Override
- public final int indexOf(Object o)
- {
- if (o == null)
- {
- for (int i = 0; i < size; i++)
- {
- if (elements[i] == null) return i;
- }
- }
- else
- {
- for (int i = 0; i < size; i++)
- {
- if (o.equals(elements[i])) return i;
- }
- }
- return -1;
- }
-
- @Override
- public final int lastIndexOf(Object o)
- {
- if (o == null)
- {
- for (int i = size - 1; i >= 0; i--)
- {
- if (elements[i] == null) return i;
- }
- }
- else
- {
- for (int i = size - 1; i >= 0; i--)
- {
- if (o.equals(elements[i])) return i;
- }
- }
- return -1;
- }
-
- @Override
- public final ListIterator<E> listIterator()
- {
- return new ImmutableIterator();
- }
-
- @Override
- public final ListIterator<E> listIterator(int index)
- {
- return new ImmutableIterator(index);
- }
-
- @Override
- public final List<E> subList(int fromIndex, int toIndex)
- {
- return new ImmutableSubList<E>(fromIndex, toIndex);
- }
-
- /**
- * Format:
- * - entry array size (int)
- * - elements (Object)
- *
- * @param out stream to write to
- * @throws IOException
- */
- public void writeExternal(ObjectOutput out) throws IOException
- {
- out.writeInt(size);
- for (E e : elements) out.writeObject(e);
- }
-
- /**
- * See {@link #writeExternal(java.io.ObjectOutput)} for serialization format
- *
- * @param in stream
- * @throws IOException
- * @throws ClassNotFoundException
- */
- @SuppressWarnings("unchecked")
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- {
- size = in.readInt();
- elements = (E[]) new Object[size];
- for (int i = 0; i < size; i++) elements[i] = (E) in.readObject();
- }
-
- private class ImmutableIterator implements ListIterator<E>
- {
- int cursor = 0;
-
- ImmutableIterator(int index)
- {
- if (index < 0 || index > size()) throw new IndexOutOfBoundsException("Index: " + index);
- cursor = index;
- }
-
- ImmutableIterator()
- {
- }
-
- public boolean hasNext()
- {
- return cursor != size;
- }
-
- public E next()
- {
- try
- {
- return get(cursor++);
- }
- catch (IndexOutOfBoundsException e)
- {
- throw new NoSuchElementException();
- }
- }
-
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean hasPrevious()
- {
- return cursor != 0;
- }
-
- public E previous()
- {
- try
- {
- return get(--cursor);
- }
- catch (IndexOutOfBoundsException e)
- {
- throw new NoSuchElementException();
- }
- }
-
- public int nextIndex()
- {
- return cursor;
- }
-
- public int previousIndex()
- {
- return cursor - 1;
- }
-
- public void set(E o)
- {
- throw new UnsupportedOperationException();
- }
-
- public void add(E o)
- {
- throw new UnsupportedOperationException();
- }
- }
-
- private class ImmutableSubList<E> extends AbstractList<E>
- {
- private int offset;
- private int size;
-
- ImmutableSubList(int fromIndex, int toIndex)
- {
- if (fromIndex < 0 || toIndex > ImmutableListCopy.this.size || fromIndex > toIndex)
- throw new IllegalArgumentException("fromIndex(" + fromIndex + "), toIndex(" + toIndex + "), size (" + ImmutableListCopy.this.size + "), List=" + ImmutableListCopy.this.toString());
- offset = fromIndex;
- size = toIndex - fromIndex;
- }
-
- @SuppressWarnings("unchecked")
- public final E get(int index)
- {
- if (index < 0 || index >= size) throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
- return (E) ImmutableListCopy.this.get(index + offset);
- }
-
- public final int size()
- {
- return size;
- }
-
- @Override
- protected final void removeRange(int fromIndex, int toIndex)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public final boolean addAll(Collection<? extends E> c)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public final boolean addAll(int index, Collection<? extends E> c)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public final Iterator<E> iterator()
- {
- return listIterator();
- }
-
- @Override
- public final ListIterator<E> listIterator(final int index)
- {
- if (index < 0 || (index != 0 && index >= size))
- throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
-
- return new ListIterator<E>()
- {
- private ListIterator i = ImmutableListCopy.this.listIterator(index + offset);
-
- public boolean hasNext()
- {
- return nextIndex() < size;
- }
-
- @SuppressWarnings("unchecked")
- public E next()
- {
- if (hasNext())
- return (E) i.next();
- else
- throw new NoSuchElementException();
- }
-
- public boolean hasPrevious()
- {
- return previousIndex() >= 0;
- }
-
- @SuppressWarnings("unchecked")
- public E previous()
- {
- if (hasPrevious())
- return (E) i.previous();
- else
- throw new NoSuchElementException();
- }
-
- public int nextIndex()
- {
- return i.nextIndex() - offset;
- }
-
- public int previousIndex()
- {
- return i.previousIndex() - offset;
- }
-
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
-
- public void set(E o)
- {
- throw new UnsupportedOperationException();
- }
-
- public void add(E o)
- {
- throw new UnsupportedOperationException();
- }
- };
- }
-
- @Override
- public final List<E> subList(int fromIndex, int toIndex)
- {
- return new ImmutableSubList<E>(offset + fromIndex, offset + toIndex);
- }
- }
-}
Deleted: 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-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/util/Immutables.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -1,585 +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 org.jboss.starobrno.util.FastCopyHashMap;
-
-import java.io.Serializable;
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-/**
- * Factory for generating immutable type wrappers.
- *
- * @author Jason T. Greene
- */
-public class Immutables
-{
- /**
- * Whether or not this collection type is immutable
- *
- * @param o a Collection, Set, List, or Map
- * @return true if immutable, false if not
- */
- public static boolean isImmutable(Object o)
- {
- return o instanceof Immutable;
- }
-
- /**
- * Converts a Collection to an immutable List by copying it.
- *
- * @param source the collection to convert
- * @return a copied/converted immutable list
- */
- public static <T> List<T> immutableListConvert(Collection<? extends T> source)
- {
- return new ImmutableListCopy<T>(source);
- }
-
- /**
- * Creates an immutable copy of the list.
- *
- * @param list the list to copy
- * @return the immutable copy
- */
- public static <T> List<T> immutableListCopy(List<? extends T> list)
- {
- return new ImmutableListCopy<T>(list);
- }
-
- /**
- * Wraps an array with an immutable list. There is no copying involved.
- *
- * @param <T>
- * @param array the array to wrap
- * @return a list containing the array
- */
- public static <T> List<T> immutableListWrap(T... array)
- {
- return new ImmutableListCopy<T>(array);
- }
-
- /**
- * Creates a new immutable list containing the union (combined entries) of both lists.
- *
- * @param list1 contains the first elements of the new list
- * @param list2 contains the successor elements of the new list
- * @return a new immutable merged copy of list1 and list2
- */
- public static <T> List<T> immutableListMerge(List<? extends T> list1, List<? extends T> list2)
- {
- return new ImmutableListCopy<T>(list1, list2);
- }
-
- /**
- * Converts a Collections into an immutable Set by copying it.
- *
- * @param collection the collection to convert/copy
- * @return a new immutable set containing the elements in collection
- */
- public static <T> Set<T> immutableSetConvert(Collection<? extends T> collection)
- {
- return immutableSetWrap(new HashSet<T>(collection));
- }
-
- /**
- * Wraps a set with an immutable set. There is no copying involved.
- *
- * @param set the set to wrap
- * @return an immutable set wrapper that delegates to the original set
- */
- public static <T> Set<T> immutableSetWrap(Set<? extends T> set)
- {
- return new ImmutableSetWrapper<T>(set);
- }
-
- /**
- * Creates an immutable copy of the specified set.
- *
- * @param set the set to copy from
- * @return an immutable set copy
- */
- public static <T> Set<T> immutableSetCopy(Set<? extends T> set)
- {
- Set<? extends T> copy = attemptKnownSetCopy(set);
- if (copy == null)
- attemptClone(set);
- if (copy == null)
- // Set uses Collection copy-ctor
- copy = attemptCopyConstructor(set, Collection.class);
- if (copy == null)
- copy = new HashSet<T>(set);
-
- return new ImmutableSetWrapper<T>(copy);
- }
-
-
- /**
- * Wraps a map with an immutable map. There is no copying involved.
- *
- * @param map the map to wrap
- * @return an immutable map wrapper that delegates to the original map
- */
- public static <K, V> Map<K, V> immutableMapWrap(Map<? extends K, ? extends V> map)
- {
- return new ImmutableMapWrapper<K, V>(map);
- }
-
- /**
- * Creates an immutable copy of the specified map.
- *
- * @param map the map to copy from
- * @return an immutable map copy
- */
- public static <K, V> Map<K, V> immutableMapCopy(Map<? extends K, ? extends V> map)
- {
- Map<? extends K, ? extends V> copy = attemptKnownMapCopy(map);
-
- if (copy == null)
- attemptClone(map);
- if (copy == null)
- copy = attemptCopyConstructor(map, Map.class);
- if (copy == null)
- copy = new HashMap<K, V>(map);
-
- return new ImmutableMapWrapper<K, V>(copy);
- }
-
- /**
- * Creates a new immutable copy of the specified Collection.
- *
- * @param collection the collection to copy
- * @return an immutable copy
- */
- public static <T> Collection<T> immutableCollectionCopy(Collection<? extends T> collection)
- {
- Collection<? extends T> copy = attemptKnownSetCopy(collection);
- if (copy == null)
- copy = attemptClone(collection);
- if (copy == null)
- copy = attemptCopyConstructor(collection, Collection.class);
- if (copy == null)
- copy = new ArrayList<T>(collection);
-
- return new ImmutableCollectionWrapper<T>(copy);
- }
-
- @SuppressWarnings("unchecked")
- private static <T extends Map> T attemptKnownMapCopy(T map)
- {
- if (map instanceof FastCopyHashMap)
- return (T) ((FastCopyHashMap) map).clone();
- if (map instanceof HashMap)
- return (T) ((HashMap) map).clone();
- if (map instanceof LinkedHashMap)
- return (T) ((LinkedHashMap) map).clone();
- if (map instanceof TreeMap)
- return (T) ((TreeMap) map).clone();
-
- return null;
- }
-
- @SuppressWarnings("unchecked")
- private static <T extends Collection> T attemptKnownSetCopy(T set)
- {
- if (set instanceof HashSet)
- return (T) ((HashSet) set).clone();
- if (set instanceof LinkedHashSet)
- return (T) ((LinkedHashSet) set).clone();
- if (set instanceof TreeSet)
- return (T) ((TreeSet) set).clone();
-
- return null;
- }
-
- @SuppressWarnings("unchecked")
- private static <T> T attemptClone(T source)
- {
- if (source instanceof Cloneable)
- {
- try
- {
- return (T) source.getClass().getMethod("clone").invoke(source);
- }
- catch (Exception e)
- {
- }
- }
-
- return null;
- }
-
- @SuppressWarnings("unchecked")
- private static <T> T attemptCopyConstructor(T source, Class<? super T> clazz)
- {
- try
- {
- return (T) source.getClass().getConstructor(clazz).newInstance(source);
- }
- catch (Exception e)
- {
- }
-
- return null;
- }
-
-
- public interface Immutable
- {
- }
-
- /*
- * Immutable wrapper types.
- *
- * We have to re-implement Collections.unmodifiableXXX, since it is not
- * simple to detect them (the class names are JDK dependent).
- */
-
- private static class ImmutableIteratorWrapper<E> implements Iterator<E>
- {
- private Iterator<? extends E> iterator;
-
- public ImmutableIteratorWrapper(Iterator<? extends E> iterator)
- {
- this.iterator = iterator;
- }
-
- public boolean hasNext()
- {
- return iterator.hasNext();
- }
-
- public E next()
- {
- return iterator.next();
- }
-
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
- }
-
- private static class ImmutableCollectionWrapper<E> implements Collection<E>, Serializable, Immutable
- {
- private static final long serialVersionUID = 6777564328198393535L;
-
- Collection<? extends E> collection;
-
- public ImmutableCollectionWrapper(Collection<? extends E> collection)
- {
- this.collection = collection;
- }
-
- public boolean add(E o)
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean addAll(Collection<? extends E> c)
- {
- throw new UnsupportedOperationException();
- }
-
- public void clear()
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean contains(Object o)
- {
- return collection.contains(o);
- }
-
- public boolean containsAll(Collection<?> c)
- {
- return collection.containsAll(c);
- }
-
- public boolean equals(Object o)
- {
- return collection.equals(o);
- }
-
- public int hashCode()
- {
- return collection.hashCode();
- }
-
- public boolean isEmpty()
- {
- return collection.isEmpty();
- }
-
- public Iterator<E> iterator()
- {
- return new ImmutableIteratorWrapper<E>(collection.iterator());
- }
-
- public boolean remove(Object o)
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean removeAll(Collection<?> c)
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean retainAll(Collection<?> c)
- {
- throw new UnsupportedOperationException();
- }
-
- public int size()
- {
- return collection.size();
- }
-
- public Object[] toArray()
- {
- return collection.toArray();
- }
-
- public <T> T[] toArray(T[] a)
- {
- return collection.toArray(a);
- }
-
- public String toString()
- {
- return collection.toString();
- }
- }
-
-
- private static class ImmutableSetWrapper<E> extends ImmutableCollectionWrapper<E> implements Set<E>, Serializable, Immutable
- {
- private static final long serialVersionUID = 7991492805176142615L;
-
- public ImmutableSetWrapper(Set<? extends E> set)
- {
- super(set);
- }
- }
-
-
- static class ImmutableEntry<K, V> implements Map.Entry<K, V>
- {
- private K key;
- private V value;
- private int hash;
-
- ImmutableEntry(Map.Entry<? extends K, ? extends V> entry)
- {
- this.key = entry.getKey();
- this.value = entry.getValue();
- this.hash = entry.hashCode();
- }
-
- public K getKey()
- {
- return key;
- }
-
- public V getValue()
- {
- return value;
- }
-
- public V setValue(V value)
- {
- throw new UnsupportedOperationException();
- }
-
- private static boolean eq(Object o1, Object o2)
- {
- return o1 == o2 || (o1 != null && o1.equals(o2));
- }
-
- @SuppressWarnings("unchecked")
- public boolean equals(Object o)
- {
- if (!(o instanceof Map.Entry))
- return false;
-
- Map.Entry<K, V> entry = (Map.Entry<K, V>) o;
- return eq(entry.getKey(), key) && eq(entry.getValue(), value);
- }
-
- public int hashCode()
- {
- return hash;
- }
-
- public String toString()
- {
- return getKey() + "=" + getValue();
- }
- }
-
- private static class ImmutableEntrySetWrapper<K, V> extends ImmutableSetWrapper<Map.Entry<K, V>>
- {
- private static final long serialVersionUID = 6378667653889667692L;
-
- @SuppressWarnings("unchecked")
- public ImmutableEntrySetWrapper(Set<? extends Map.Entry<? extends K, ? extends V>> set)
- {
- super((Set<Entry<K, V>>) set);
- }
-
- public Object[] toArray()
- {
- Object[] array = new Object[collection.size()];
- int i = 0;
- for (Map.Entry<K, V> entry : this)
- array[i++] = entry;
- return array;
- }
-
- @SuppressWarnings("unchecked")
- public <T> T[] toArray(T[] array)
- {
- int size = collection.size();
- if (array.length < size)
- array = (T[]) Array.newInstance(array.getClass().getComponentType(), size);
-
- int i = 0;
- Object[] result = array;
- for (Map.Entry<K, V> entry : this)
- result[i++] = entry;
-
- return array;
- }
-
- public Iterator<Map.Entry<K, V>> iterator()
- {
- return new ImmutableIteratorWrapper<Entry<K, V>>(collection.iterator())
- {
- public Entry<K, V> next()
- {
- return new ImmutableEntry<K, V>(super.next());
- }
- };
- }
- }
-
- private static class ImmutableMapWrapper<K, V> implements Map<K, V>, Serializable, Immutable
- {
- private static final long serialVersionUID = 708144227046742221L;
-
- private Map<? extends K, ? extends V> map;
-
- public ImmutableMapWrapper(Map<? extends K, ? extends V> map)
- {
- this.map = map;
- }
-
- public void clear()
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean containsKey(Object key)
- {
- return map.containsKey(key);
- }
-
- public boolean containsValue(Object value)
- {
- return map.containsValue(value);
- }
-
- public Set<Entry<K, V>> entrySet()
- {
- return new ImmutableEntrySetWrapper<K, V>(map.entrySet());
- }
-
- public boolean equals(Object o)
- {
- return map.equals(o);
- }
-
- public V get(Object key)
- {
- return map.get(key);
- }
-
- public int hashCode()
- {
- return map.hashCode();
- }
-
- public boolean isEmpty()
- {
- return map.isEmpty();
- }
-
- public Set<K> keySet()
- {
- return new ImmutableSetWrapper<K>(map.keySet());
- }
-
- public V put(K key, V value)
- {
- throw new UnsupportedOperationException();
- }
-
- public void putAll(Map<? extends K, ? extends V> t)
- {
- throw new UnsupportedOperationException();
- }
-
- public V remove(Object key)
- {
- throw new UnsupportedOperationException();
- }
-
- public int size()
- {
- return map.size();
- }
-
- public Collection<V> values()
- {
- return new ImmutableCollectionWrapper<V>(map.values());
- }
-
- public String toString()
- {
- return map.toString();
- }
- }
-}
Deleted: core/branches/flat/src/main/java/org/jboss/cache/util/MinMapUtil.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/util/MinMapUtil.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/util/MinMapUtil.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -1,119 +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.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-/**
- * Minimizes Map memory usage by changing the map
- * instance based on the number of stored entries.
- *
- * @author Elias Ross
- */
-public class MinMapUtil
-{
-
- private static Class<?> singleton = Collections.singletonMap(null, null).getClass();
-
- private static Class<?> empty = Collections.emptyMap().getClass();
-
- private MinMapUtil()
- {
- }
-
- /**
- * Puts a mapping into a map, returns a map with the mapping.
- *
- * @param map destination
- */
- public static <K, V> Map<K, V> put(Map<K, V> map, K key, V value)
- {
- int size = map.size();
- if (size == 0)
- return Collections.singletonMap(key, value);
- if (size == 1)
- {
- HashMap<K, V> map2 = new HashMap<K, V>(map);
- map2.put(key, value);
- return map2;
- }
- else
- {
- map.put(key, value);
- return map;
- }
- }
-
- /**
- * Puts a number of entries into a map, returns a map.
- *
- * @param dest destination map
- * @param src source map
- */
- public static <K, V> Map<K, V> putAll(Map<K, V> dest, Map<K, V> src)
- {
- if (src == null)
- {
- return dest;
- }
- int srcSize = src.size();
- if (srcSize == 0)
- {
- return dest;
- }
- if (srcSize == 1)
- {
- Entry<K, V> next = src.entrySet().iterator().next();
- return Collections.singletonMap(next.getKey(), next.getValue());
- }
- Class<?> c = dest.getClass();
- if (c == empty || c == singleton)
- return new HashMap<K, V>(src);
- dest.putAll(src);
- return dest;
- }
-
- /**
- * Removes a mapping by key from a map, returns the map.
- */
- public static <K, V> Map<K, V> remove(Map<K, V> map, K key)
- {
- int size = map.size();
- if (size == 0)
- {
- return map;
- }
- if (size == 1)
- {
- if (map.containsKey(key))
- return Collections.emptyMap();
- else
- return map;
- }
- map.remove(key);
- return map;
- }
-
-}
Deleted: core/branches/flat/src/main/java/org/jboss/cache/util/SimpleImmutableEntry.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/util/SimpleImmutableEntry.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/util/SimpleImmutableEntry.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -1,88 +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.Serializable;
-import java.util.Map;
-import java.util.Map.Entry;
-
-/**
- * Where is Java 1.6?
- */
-class SimpleImmutableEntry<K, V> implements Map.Entry<K, V>, Serializable
-{
- private static final long serialVersionUID = -6092752114794052323L;
-
- private final K key;
-
- private final V value;
-
- public SimpleImmutableEntry(Entry<K, V> me)
- {
- key = me.getKey();
- value = me.getValue();
- }
-
- public SimpleImmutableEntry(K key, V value)
- {
- this.key = key;
- this.value = value;
- }
-
- public K getKey()
- {
- return key;
- }
-
- public V getValue()
- {
- return value;
- }
-
- public V setValue(V arg0)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean equals(Object o)
- {
- if (!(o instanceof Map.Entry))
- return false;
- Map.Entry e2 = (Map.Entry) o;
- return (getKey() == null ? e2.getKey() == null : getKey().equals(e2.getKey()))
- && (getValue() == null ? e2.getValue() == null : getValue().equals(e2.getValue()));
- }
-
- @Override
- public int hashCode()
- {
- return (getKey() == null ? 0 : getKey().hashCode()) ^
- (getValue() == null ? 0 : getValue().hashCode());
- }
-
- @Override
- public String toString()
- {
- return key + "=" + value;
- }
-}
\ No newline at end of file
Deleted: core/branches/flat/src/main/java/org/jboss/cache/util/ThreadGate.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/util/ThreadGate.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/cache/util/ThreadGate.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -1,119 +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.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.ReentrantLock;
-
-/**
- * A reclosable gate with timeout support.
- *
- * @author Jason T. Greene
- */
-public class ThreadGate
-{
- private final ReentrantLock lock = new ReentrantLock();
- private final Condition condition = lock.newCondition();
-
- private boolean open;
- private int sequence;
-
- /**
- * Open the gate.
- */
- public void open()
- {
- lock.lock();
- try
- {
- open = true;
- sequence++;
- condition.signalAll();
- }
- finally
- {
- lock.unlock();
- }
- }
-
- /**
- * Close the gate.
- */
- public void close()
- {
- lock.lock();
- try
- {
- open = false;
- }
- finally
- {
- lock.unlock();
- }
- }
-
- /**
- * Waits for the gate to open.
- *
- * @throws InterruptedException if this thread is interrupted
- */
- public void await() throws InterruptedException
- {
- lock.lock();
- try
- {
- int snapshot = sequence;
- while (!open && snapshot == sequence)
- condition.await();
- }
- finally
- {
- lock.unlock();
- }
- }
-
- /**
- * Waits for the gate to open or the specified time to elapse.
- *
- * @param time the maximum time in milliseconds to wait.
- * @return false if gate timeout occurred
- * @throws InterruptedException if this thread is interrupted
- */
- public boolean await(long time) throws InterruptedException
- {
- lock.lock();
- try
- {
- int snapshot = sequence;
- boolean success = true;
- while (!open && snapshot == sequence && success)
- success = condition.await(time, TimeUnit.MILLISECONDS);
-
- return success;
- }
- finally
- {
- lock.unlock();
- }
- }
-}
\ No newline at end of file
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/AssignToBuddyGroupCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/AssignToBuddyGroupCommand.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/AssignToBuddyGroupCommand.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,11 +21,11 @@
*/
package org.jboss.starobrno.commands.remote;
-import org.jboss.cache.Fqn;
import org.jboss.cache.buddyreplication.BuddyGroup;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.starobrno.commands.ReplicableCommand;
import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.tree.Fqn;
import java.util.Arrays;
import java.util.Map;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/DataGravitationCleanupCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/DataGravitationCleanupCommand.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/DataGravitationCleanupCommand.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,7 +23,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.commands.CommandsFactory;
@@ -33,6 +32,7 @@
import org.jboss.starobrno.interceptors.InterceptorChain;
import org.jboss.starobrno.transaction.GlobalTransaction;
import org.jboss.starobrno.transaction.TransactionTable;
+import org.jboss.starobrno.tree.Fqn;
/**
* Data gravitation cleanup handler. Primarily used by the {@link org.jboss.cache.interceptors.DataGravitatorInterceptor}.
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/InvalidateCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/InvalidateCommand.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/InvalidateCommand.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,14 +23,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.NodeSPI;
+import org.jboss.starobrno.CacheSPI;
+import org.jboss.starobrno.commands.Visitor;
import org.jboss.starobrno.commands.read.AbstractDataCommand;
-import org.jboss.starobrno.commands.Visitor;
-import org.jboss.starobrno.CacheSPI;
+import org.jboss.starobrno.container.DataContainer;
import org.jboss.starobrno.context.InvocationContext;
-import org.jboss.starobrno.container.DataContainer;
import org.jboss.starobrno.notifications.Notifier;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.Fqn;
+import org.jboss.starobrno.tree.Fqn;
/**
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionConfig.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionConfig.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,7 +21,6 @@
*/
package org.jboss.starobrno.config;
-import org.jboss.cache.Fqn;
import org.jboss.starobrno.eviction.DefaultEvictionAction;
import java.util.LinkedList;
@@ -273,14 +272,6 @@
*/
public EvictionCacheConfig getEvictionRegionConfig(String region)
{
- Fqn fqn = Fqn.fromString(region);
- for (EvictionCacheConfig evConfig : getEvictionCacheConfigs())
- {
-// if (evConfig.getCacheName().equals(fqn))
-// {
-// return evConfig;
-// }
-}
return null;
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/CacheConfigsXmlParser.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/CacheConfigsXmlParser.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/CacheConfigsXmlParser.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,9 +23,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.util.FileLookup;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.util.FileLookup;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/ConfigFilesConvertor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/ConfigFilesConvertor.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/ConfigFilesConvertor.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,7 +21,7 @@
*/
package org.jboss.starobrno.config.parsing;
-import org.jboss.cache.util.FileLookup;
+import org.jboss.starobrno.util.FileLookup;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
@@ -34,12 +34,7 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
+import java.io.*;
/**
* Class used for converting a config file from from 2.x version to 3.x verison.
@@ -52,7 +47,7 @@
/**
* Writes to the <b>os</b> the 3.x configuration file resulted by transforming the 2.x configuration file passed in
* as <b>is</b>. Transformation is performed according to the <b>xsltFile</b>. The xslt file is looked up using a
- * {@link org.jboss.cache.util.FileLookup}
+ * {@link org.jboss.starobrno.util.FileLookup}
*/
public void parse(InputStream is, OutputStream os, String xsltFile) throws Exception
{
@@ -72,7 +67,7 @@
/**
* Writes to the <b>os</b> the 3.x configuration file resulted by transforming the 2.x configuration file passed in
* as <b>inputFile</b>. Transformation is performed according to the <b>xsltFile</b>. Both <b>inputFile</b> and he xslt
- * file are looked up using a {@link org.jboss.cache.util.FileLookup}
+ * file are looked up using a {@link org.jboss.starobrno.util.FileLookup}
*/
public void parse(String inputFile, OutputStream os, String xsltFile) throws Exception
{
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigHelper.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigHelper.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigHelper.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,14 +23,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.util.BeanUtils;
import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.util.BeanUtils;
import org.jboss.util.StringPropertyReplacer;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
+import org.w3c.dom.*;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParser.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParser.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParser.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -22,17 +22,13 @@
package org.jboss.starobrno.config.parsing;
import org.jboss.cache.lock.IsolationLevel;
-import org.jboss.cache.util.FileLookup;
-import org.jboss.starobrno.config.BuddyReplicationConfig;
-import org.jboss.starobrno.config.CacheLoaderConfig;
-import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.*;
import org.jboss.starobrno.config.Configuration.CacheMode;
-import org.jboss.starobrno.config.ConfigurationException;
-import org.jboss.starobrno.config.CustomInterceptorConfig;
import org.jboss.starobrno.config.parsing.element.BuddyElementParser;
import org.jboss.starobrno.config.parsing.element.CustomInterceptorsElementParser;
import org.jboss.starobrno.config.parsing.element.EvictionElementParser;
import org.jboss.starobrno.config.parsing.element.LoadersElementParser;
+import org.jboss.starobrno.util.FileLookup;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.ErrorHandler;
@@ -95,9 +91,9 @@
/**
* Parses an XML file and returns a new configuration.
- * For looking up the file, {@link org.jboss.cache.util.FileLookup} is used.
+ * For looking up the file, {@link org.jboss.starobrno.util.FileLookup} is used.
*
- * @see org.jboss.cache.util.FileLookup
+ * @see org.jboss.starobrno.util.FileLookup
*/
public Configuration parseFile(String filename)
{
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContextImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContextImpl.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContextImpl.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,12 +23,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.util.Immutables;
import org.jboss.starobrno.config.Option;
import org.jboss.starobrno.container.MVCCEntry;
import org.jboss.starobrno.transaction.GlobalTransaction;
import org.jboss.starobrno.transaction.TransactionTable;
import org.jboss.starobrno.util.FastCopyHashMap;
+import org.jboss.starobrno.util.Immutables;
import javax.transaction.Transaction;
import java.util.Collections;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,12 +21,12 @@
*/
package org.jboss.starobrno.context;
-import org.jboss.cache.util.Immutables;
import org.jboss.starobrno.commands.VisitableCommand;
import org.jboss.starobrno.config.Option;
import org.jboss.starobrno.container.MVCCEntry;
import org.jboss.starobrno.transaction.GlobalTransaction;
import org.jboss.starobrno.util.FastCopyHashMap;
+import org.jboss.starobrno.util.Immutables;
import javax.transaction.RollbackException;
import javax.transaction.SystemException;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionCacheManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionCacheManager.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionCacheManager.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -1,10 +1,10 @@
package org.jboss.starobrno.eviction;
import org.jboss.starobrno.config.EvictionCacheConfig;
-import org.jboss.cache.Fqn;
/**
* There is one eviction manager per cache.
+ *
* @author Mircea.Markus(a)jboss.com
*/
public interface EvictionCacheManager<K>
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionEvent.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionEvent.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,8 +21,6 @@
*/
package org.jboss.starobrno.eviction;
-import org.jboss.cache.Fqn;
-
/**
* An eviction event records activity on nodes in the cache. These are recorded on a {@link org.jboss.cache.Region} for processing
* later by calls to {@link org.jboss.cache.Region#processEvictionQueues()}.
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/RemoveOnEvictActionPolicy.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/RemoveOnEvictActionPolicy.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/RemoveOnEvictActionPolicy.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,8 +23,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Cache_Legacy;
-import org.jboss.cache.Fqn;
import org.jboss.starobrno.Cache;
/**
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentRegistry.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentRegistry.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentRegistry.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -25,30 +25,19 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheStatus;
import org.jboss.cache.Version;
-import org.jboss.cache.util.BeanUtils;
-import org.jboss.starobrno.util.ReflectionUtil;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.CacheSPI;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.config.ConfigurationException;
import org.jboss.starobrno.config.RuntimeConfig;
-import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
-import org.jboss.starobrno.factories.annotations.Destroy;
-import org.jboss.starobrno.factories.annotations.Inject;
-import org.jboss.starobrno.factories.annotations.NonVolatile;
-import org.jboss.starobrno.factories.annotations.Start;
-import org.jboss.starobrno.factories.annotations.Stop;
+import org.jboss.starobrno.factories.annotations.*;
import org.jboss.starobrno.lifecycle.Lifecycle;
+import org.jboss.starobrno.util.BeanUtils;
+import org.jboss.starobrno.util.ReflectionUtil;
import javax.management.MBeanServerFactory;
import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
/**
* A registry where components which have been created are stored. Components are stored as singletons, registered under
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/factories/RuntimeConfigAwareFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/RuntimeConfigAwareFactory.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/RuntimeConfigAwareFactory.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,11 +21,11 @@
*/
package org.jboss.starobrno.factories;
-import org.jboss.cache.util.BeanUtils;
import org.jboss.starobrno.config.ConfigurationException;
import org.jboss.starobrno.config.RuntimeConfig;
import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
import org.jboss.starobrno.remoting.RPCManager;
+import org.jboss.starobrno.util.BeanUtils;
import java.lang.reflect.Method;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/TxInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/TxInterceptor.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/TxInterceptor.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,7 +21,6 @@
*/
package org.jboss.starobrno.interceptors;
-import org.jboss.cache.util.concurrent.ConcurrentHashSet;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.commands.CommandsFactory;
import org.jboss.starobrno.commands.ReplicableCommand;
@@ -44,6 +43,7 @@
import org.jboss.starobrno.remoting.ReplicationException;
import org.jboss.starobrno.transaction.GlobalTransaction;
import org.jboss.starobrno.transaction.TransactionTable;
+import org.jboss.starobrno.util.concurrent.ConcurrentHashSet;
import javax.transaction.*;
import java.util.*;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/loader/AsyncCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/loader/AsyncCacheLoader.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/loader/AsyncCacheLoader.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,28 +21,17 @@
*/
package org.jboss.starobrno.loader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.util.Immutables;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
/**
* The AsyncCacheLoader is a delegating cache loader that extends
* AbstractDelegatingCacheLoader overriding methods to that should not
@@ -101,7 +90,7 @@
*
* @author Manik Surtani (manik.surtani(a)jboss.com)
*/
-public class AsyncCacheLoader<K,V> extends AbstractDelegatingCacheLoader<K,V>
+public class AsyncCacheLoader<K, V> extends AbstractDelegatingCacheLoader<K, V>
{
private static final Log log = LogFactory.getLog(AsyncCacheLoader.class);
@@ -125,7 +114,7 @@
super(null);
}
- public AsyncCacheLoader(CacheLoader<K,V> cacheLoader)
+ public AsyncCacheLoader(CacheLoader<K, V> cacheLoader)
{
super(cacheLoader);
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/loader/CacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/loader/CacheLoader.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/loader/CacheLoader.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,19 +21,17 @@
*/
package org.jboss.starobrno.loader;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.List;
-import java.util.Map;
-
import net.jcip.annotations.ThreadSafe;
-
-import org.jboss.cache.Fqn;
import org.jboss.cache.loader.AbstractCacheLoader;
import org.jboss.starobrno.CacheSPI;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.starobrno.marshall.EntryData;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.List;
+import java.util.Map;
+
/**
* A {@link org.jboss.cache.loader.CacheLoader} implementation persists and load keys to and from
* secondary storage, such as a database or filesystem. Typically,
@@ -115,7 +113,7 @@
* node does not exist, all parent nodes from the root down are created
* automatically. Returns the old value.
*/
- V put(K key, V value) ;
+ V put(K key, V value);
/**
* Removes everything from this cache-loader
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/lock/StripedLock.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/lock/StripedLock.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/lock/StripedLock.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -22,7 +22,6 @@
package org.jboss.starobrno.lock;
import net.jcip.annotations.ThreadSafe;
-import org.jboss.cache.Fqn;
import java.util.List;
import java.util.concurrent.locks.ReentrantReadWriteLock;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/marshall/CommandAwareRpcDispatcher.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/marshall/CommandAwareRpcDispatcher.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/marshall/CommandAwareRpcDispatcher.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,8 +21,6 @@
*/
package org.jboss.starobrno.marshall;
-import org.jboss.cache.util.concurrent.BoundedExecutors;
-import org.jboss.cache.util.concurrent.WithinThreadExecutor;
import org.jboss.starobrno.commands.ReplicableCommand;
import org.jboss.starobrno.commands.VisitableCommand;
import org.jboss.starobrno.commands.remote.AnnounceBuddyPoolNameCommand;
@@ -33,11 +31,9 @@
import org.jboss.starobrno.factories.ComponentRegistry;
import org.jboss.starobrno.interceptors.InterceptorChain;
import org.jboss.starobrno.invocation.InvocationContextContainer;
-import org.jgroups.Address;
-import org.jgroups.Channel;
-import org.jgroups.MembershipListener;
-import org.jgroups.Message;
-import org.jgroups.MessageListener;
+import org.jboss.starobrno.util.concurrent.BoundedExecutors;
+import org.jboss.starobrno.util.concurrent.WithinThreadExecutor;
+import org.jgroups.*;
import org.jgroups.blocks.RpcDispatcher;
import org.jgroups.blocks.RspFilter;
import org.jgroups.util.Buffer;
@@ -46,12 +42,7 @@
import java.io.NotSerializableException;
import java.util.Vector;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
/**
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/marshall/NodeData.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/marshall/NodeData.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/marshall/NodeData.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,7 +21,7 @@
*/
package org.jboss.starobrno.marshall;
-import org.jboss.cache.Fqn;
+import org.jboss.starobrno.tree.Fqn;
import java.io.Externalizable;
import java.io.IOException;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/NotifierImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/NotifierImpl.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/NotifierImpl.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -24,21 +24,17 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.buddyreplication.BuddyGroup;
-import org.jboss.cache.util.concurrent.BoundedExecutors;
-import org.jboss.cache.util.concurrent.WithinThreadExecutor;
import org.jboss.starobrno.Cache;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.CacheSPI;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.context.InvocationContext;
-import org.jboss.starobrno.factories.annotations.Destroy;
-import org.jboss.starobrno.factories.annotations.Inject;
-import org.jboss.starobrno.factories.annotations.NonVolatile;
-import org.jboss.starobrno.factories.annotations.Start;
-import org.jboss.starobrno.factories.annotations.Stop;
+import org.jboss.starobrno.factories.annotations.*;
import org.jboss.starobrno.notifications.annotation.*;
import org.jboss.starobrno.notifications.event.*;
import static org.jboss.starobrno.notifications.event.Event.Type.*;
+import org.jboss.starobrno.util.concurrent.BoundedExecutors;
+import org.jboss.starobrno.util.concurrent.WithinThreadExecutor;
import org.jgroups.View;
import javax.transaction.Transaction;
@@ -46,12 +42,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadFactory;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/EventImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/EventImpl.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/EventImpl.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,9 +21,9 @@
*/
package org.jboss.starobrno.notifications.event;
-import org.jboss.cache.Fqn;
import org.jboss.cache.buddyreplication.BuddyGroup;
import org.jboss.starobrno.Cache;
+import org.jboss.starobrno.tree.Fqn;
import org.jgroups.View;
import javax.transaction.Transaction;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/remoting/ChannelMessageListener.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/remoting/ChannelMessageListener.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/remoting/ChannelMessageListener.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,14 +23,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
-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;
import org.jboss.starobrno.factories.annotations.NonVolatile;
+import org.jboss.starobrno.io.ExposedByteArrayOutputStream;
+import org.jboss.starobrno.statetransfer.DefaultStateTransferManager;
+import org.jboss.starobrno.statetransfer.StateTransferManager;
+import org.jboss.starobrno.tree.Fqn;
import org.jboss.util.stream.MarshalledValueInputStream;
import org.jboss.util.stream.MarshalledValueOutputStream;
import org.jgroups.ExtendedMessageListener;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManagerImpl.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManagerImpl.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,7 +23,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.util.concurrent.ReclosableLatch;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.CacheSPI;
import org.jboss.starobrno.commands.ReplicableCommand;
@@ -46,6 +45,7 @@
import org.jboss.starobrno.notifications.Notifier;
import org.jboss.starobrno.transaction.TransactionTable;
import org.jboss.starobrno.util.ReflectionUtil;
+import org.jboss.starobrno.util.concurrent.ReclosableLatch;
import org.jgroups.*;
import org.jgroups.blocks.GroupRequest;
import org.jgroups.blocks.RspFilter;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/statetransfer/DefaultStateTransferManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/statetransfer/DefaultStateTransferManager.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/statetransfer/DefaultStateTransferManager.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,20 +23,19 @@
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.statetransfer.StateTransferIntegrator;
-import org.jboss.cache.statetransfer.StateTransferGenerator;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.marshall.Marshaller;
-import org.jboss.starobrno.marshall.NodeData;
-import org.jboss.starobrno.marshall.NodeDataMarker;
+import org.jboss.cache.statetransfer.StateTransferGenerator;
+import org.jboss.cache.statetransfer.StateTransferIntegrator;
import org.jboss.starobrno.CacheSPI;
-import org.jboss.starobrno.statetransfer.StateTransferManager;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.marshall.NodeData;
+import org.jboss.starobrno.marshall.NodeDataMarker;
+import org.jboss.starobrno.tree.Fqn;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/statetransfer/StateTransferManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/statetransfer/StateTransferManager.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/statetransfer/StateTransferManager.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,7 +21,7 @@
*/
package org.jboss.starobrno.statetransfer;
-import org.jboss.cache.Fqn;
+import org.jboss.starobrno.tree.Fqn;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/tree/Fqn.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/tree/Fqn.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/tree/Fqn.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -23,7 +23,7 @@
import net.jcip.annotations.Immutable;
-import org.jboss.cache.util.Immutables;
+import org.jboss.starobrno.util.Immutables;
import java.io.Externalizable;
import java.io.IOException;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/util/Immutables.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/Immutables.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/Immutables.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -21,8 +21,6 @@
*/
package org.jboss.starobrno.util;
-import org.jboss.cache.util.ImmutableListCopy;
-
import java.io.Serializable;
import java.lang.reflect.Array;
import java.util.*;
Modified: core/branches/flat/src/test/java/org/jboss/starobrno/eviction/EvictionWatcher.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/eviction/EvictionWatcher.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/eviction/EvictionWatcher.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -1,16 +1,13 @@
package org.jboss.starobrno.eviction;
-import org.jboss.cache.Fqn;
import org.jboss.starobrno.Cache;
-import org.jboss.starobrno.notifications.annotation.CacheListener;
import org.jboss.starobrno.notifications.annotation.CacheEntryEvicted;
+import org.jboss.starobrno.notifications.annotation.CacheListener;
import org.jboss.starobrno.notifications.event.CacheEntryEvictedEvent;
+import org.jboss.starobrno.tree.Fqn;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
/**
* Watches and waits for eviction events
Modified: core/branches/flat/src/test/java/org/jboss/starobrno/eviction/FIFOPolicyTest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/eviction/FIFOPolicyTest.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/eviction/FIFOPolicyTest.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -1,26 +1,21 @@
package org.jboss.starobrno.eviction;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.Test;
-import static org.testng.AssertJUnit.fail;
-import static org.testng.AssertJUnit.assertNull;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertEquals;
-import org.jboss.cache.Fqn;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import org.jboss.starobrno.CacheSPI;
import org.jboss.starobrno.UnitTestCacheFactory;
-import org.jboss.starobrno.util.TestingUtil;
-import org.jboss.starobrno.eviction.algorithms.fifo.FIFOAlgorithmConfig;
-import org.jboss.starobrno.config.EvictionConfig;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.config.EvictionCacheConfig;
+import org.jboss.starobrno.config.EvictionConfig;
+import org.jboss.starobrno.eviction.algorithms.fifo.FIFOAlgorithmConfig;
+import org.jboss.starobrno.util.TestingUtil;
+import static org.testng.AssertJUnit.*;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
-import java.util.List;
import java.util.ArrayList;
-import java.util.concurrent.TimeUnit;
+import java.util.List;
/**
* @author Mircea.Markus(a)jboss.com
Modified: core/branches/flat/src/test/java/org/jboss/starobrno/notifications/NotifierTest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/notifications/NotifierTest.java 2008-12-10 16:16:42 UTC (rev 7276)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/notifications/NotifierTest.java 2008-12-10 16:43:27 UTC (rev 7277)
@@ -1,7 +1,6 @@
package org.jboss.starobrno.notifications;
import static org.easymock.EasyMock.*;
-import org.jboss.cache.Fqn;
import org.jboss.cache.buddyreplication.BuddyGroup;
import org.jboss.starobrno.CacheSPI;
import org.jboss.starobrno.config.Configuration;
@@ -9,6 +8,7 @@
import org.jboss.starobrno.context.InvocationContextImpl;
import org.jboss.starobrno.notifications.annotation.*;
import org.jboss.starobrno.notifications.event.*;
+import org.jboss.starobrno.tree.Fqn;
import org.jgroups.View;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -25,13 +25,16 @@
@Test(groups = "unit")
public class NotifierTest
{
-
+
private static final Fqn fqn = Fqn.fromString("/a/b/c");
- private class NotifierTestTL {
+
+ private class NotifierTestTL
+ {
private NotifierImpl notifier;
private InvocationContext ctx;
private AllEventsListener allEventsListener;
}
+
private ThreadLocal<NotifierTestTL> threadLocal = new ThreadLocal<NotifierTestTL>();
@BeforeMethod
@@ -65,7 +68,7 @@
NotifierImpl notifier = tl.notifier;
InvocationContext ctx = tl.ctx;
AllEventsListener allEventsListener = tl.allEventsListener;
-
+
assert allEventsListener.nodeCreatedEvent == null;
notifier.notifyCacheEntryCreated("K", true, ctx);
assert allEventsListener.nodeCreatedEvent != null;
16 years, 1 month
JBoss Cache SVN: r7276 - in core/branches/flat/src: main/java/org/jboss/starobrno/cluster and 10 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-12-10 11:16:42 -0500 (Wed, 10 Dec 2008)
New Revision: 7276
Added:
core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManager.java
core/branches/flat/src/test/java/org/jboss/starobrno/api/mvcc/PutForExternalReadTest.java
Removed:
core/branches/flat/src/main/java/org/jboss/starobrno/RPCManager.java
core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManager.java
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java
core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java
core/branches/flat/src/main/java/org/jboss/starobrno/CacheSPI.java
core/branches/flat/src/main/java/org/jboss/starobrno/cluster/ReplicationQueue.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/RuntimeConfig.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/EmptyConstructorFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/RuntimeConfigAwareFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InvocationContextInterceptor.java
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/TxInterceptor.java
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/BaseRpcInterceptor.java
core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManagerImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/transaction/TransactionTable.java
core/branches/flat/src/test/java/org/jboss/starobrno/util/TestingUtil.java
core/branches/flat/src/test/java/org/jboss/starobrno/util/internals/ReplicationListener.java
Log:
Fixed putForExternalread() and added unit tests
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java 2008-12-10 15:10:12 UTC (rev 7275)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java 2008-12-10 16:16:42 UTC (rev 7276)
@@ -40,7 +40,7 @@
/**
* Under special operating behavior, associates the value with the specified key.
* <ul>
- * <li> Only goes through if the key specified does not exist; no-op otherwise (similar to {@link java.util.concurrent.ConcurrentMap#replace(Object, Object)})</i>
+ * <li> Only goes through if the key specified does not exist; no-op otherwise (similar to {@link java.util.concurrent.ConcurrentMap#putIfAbsent(Object, Object)})</i>
* <li> Force asynchronous mode for replication to prevent any blocking.</li>
* <li> invalidation does not take place. </li>
* <li> 0ms lock timeout to prevent any blocking here either. If the lock is not acquired, this method is a no-op, and swallows the timeout exception.</li>
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java 2008-12-10 15:10:12 UTC (rev 7275)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java 2008-12-10 16:16:42 UTC (rev 7276)
@@ -49,6 +49,7 @@
import org.jboss.starobrno.lock.LockManager;
import org.jboss.starobrno.marshall.ExtendedMarshaller;
import org.jboss.starobrno.notifications.Notifier;
+import org.jboss.starobrno.remoting.RPCManager;
import org.jboss.starobrno.statetransfer.StateTransferManager;
import org.jboss.starobrno.transaction.GlobalTransaction;
import org.jboss.starobrno.transaction.TransactionTable;
@@ -224,7 +225,7 @@
ctx.getOptionOverrides().setFailSilently(true);
ctx.getOptionOverrides().setForceAsynchronous(true);
ctx.getOptionOverrides().setLockAcquisitionTimeout(0);
- replace(key, value);
+ putIfAbsent(key, value);
}
catch (Exception e)
{
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/CacheSPI.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/CacheSPI.java 2008-12-10 15:10:12 UTC (rev 7275)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/CacheSPI.java 2008-12-10 16:16:42 UTC (rev 7276)
@@ -36,6 +36,7 @@
import org.jboss.starobrno.lock.LockManager;
import org.jboss.starobrno.marshall.ExtendedMarshaller;
import org.jboss.starobrno.notifications.Notifier;
+import org.jboss.starobrno.remoting.RPCManager;
import org.jboss.starobrno.statetransfer.StateTransferManager;
import org.jboss.starobrno.transaction.GlobalTransaction;
import org.jboss.starobrno.transaction.TransactionTable;
Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/RPCManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/RPCManager.java 2008-12-10 15:10:12 UTC (rev 7275)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/RPCManager.java 2008-12-10 16:16:42 UTC (rev 7276)
@@ -1,135 +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.starobrno;
-
-import org.jboss.starobrno.commands.ReplicableCommand;
-import org.jgroups.Address;
-import org.jgroups.Channel;
-import org.jgroups.blocks.RspFilter;
-
-import java.util.List;
-import java.util.Vector;
-
-/**
- * Provides a mechanism for communicating with other caches in the cluster. For now this is based on JGroups as an underlying
- * transport, and in future more transport options may become available.
- * <p/>
- * Implementations have a simple lifecycle:
- * <ul>
- * <li>start() - starts the underlying channel based on configuration options injected, and connects the channel</li>
- * <li>disconnect() - disconnects the channel</li>
- * <li>stop() - stops the dispatcher and releases resources</li>
- * </ul>
- *
- * @author Manik Surtani
- * @since 2.1.0
- */
-public interface RPCManager
-{
- /**
- * Disconnects and closes the underlying JGroups channel.
- */
- void disconnect();
-
- /**
- * Stops the RPCDispatcher and frees resources. Closes and disconnects the underlying JGroups channel if this is
- * still open/connected.
- */
- void stop();
-
- /**
- * Starts the RPCManager by connecting the underlying JGroups channel (if configured for replication). Connecting
- * the channel may also involve state transfer (if configured) so the interceptor chain should be started and
- * available before this method is called.
- */
- void start();
-
- /**
- * Invokes an RPC call on other caches in the cluster.
- *
- * @param recipients a list of Addresses to invoke the call on. If this is null, the call is broadcast to the entire cluster.
- * @param cacheCommand the cache command to invoke
- * @param mode the group request mode to use. See {@link org.jgroups.blocks.GroupRequest}.
- * @param timeout a timeout after which to throw a replication exception.
- * @param responseFilter a response filter with which to filter out failed/unwanted/invalid responses.
- * @param useOutOfBandMessage if true, the message is put on JGroups' OOB queue. See JGroups docs for more info.
- * @return a list of responses from each member contacted.
- * @throws Exception in the event of problems.
- */
- List<Object> callRemoteMethods(Vector<Address> recipients, ReplicableCommand cacheCommand, int mode, long timeout, RspFilter responseFilter, boolean useOutOfBandMessage) throws Exception;
-
- /**
- * Invokes an RPC call on other caches in the cluster.
- *
- * @param recipients a list of Addresses to invoke the call on. If this is null, the call is broadcast to the entire cluster.
- * @param cacheCommand the cache command to invoke
- * @param mode the group request mode to use. See {@link org.jgroups.blocks.GroupRequest}.
- * @param timeout a timeout after which to throw a replication exception.
- * @param useOutOfBandMessage if true, the message is put on JGroups' OOB queue. See JGroups docs for more info.
- * @return a list of responses from each member contacted.
- * @throws Exception in the event of problems.
- */
- List<Object> callRemoteMethods(Vector<Address> recipients, ReplicableCommand cacheCommand, int mode, long timeout, boolean useOutOfBandMessage) throws Exception;
-
- /**
- * Invokes an RPC call on other caches in the cluster.
- *
- * @param recipients a list of Addresses to invoke the call on. If this is null, the call is broadcast to the entire cluster.
- * @param cacheCommand the cache command to invoke
- * @param synchronous if true, sets group request mode to {@link org.jgroups.blocks.GroupRequest#GET_ALL}, and if false sets it to {@link org.jgroups.blocks.GroupRequest#GET_NONE}.
- * @param timeout a timeout after which to throw a replication exception.
- * @param useOutOfBandMessage if true, the message is put on JGroups' OOB queue. See JGroups docs for more info.
- * @return a list of responses from each member contacted.
- * @throws Exception in the event of problems.
- */
- List<Object> callRemoteMethods(Vector<Address> recipients, ReplicableCommand cacheCommand, boolean synchronous, long timeout, boolean useOutOfBandMessage) throws Exception;
-
- /**
- * @return true if the current Channel is the coordinator of the cluster.
- */
- boolean isCoordinator();
-
- /**
- * @return the Address of the current coordinator.
- */
- Address getCoordinator();
-
- /**
- * Retrieves the local JGroups channel's address
- *
- * @return an Address
- */
- Address getLocalAddress();
-
- /**
- * Returns a defensively copied list of members in the current cluster view.
- */
- List<Address> getMembers();
-
-
- /**
- * Retrieves the Channel
- *
- * @return a channel
- */
- Channel getChannel();
-}
\ No newline at end of file
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/cluster/ReplicationQueue.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/cluster/ReplicationQueue.java 2008-12-10 15:10:12 UTC (rev 7275)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/cluster/ReplicationQueue.java 2008-12-10 16:16:42 UTC (rev 7276)
@@ -23,14 +23,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jboss.starobrno.commands.CommandsFactory;
+import org.jboss.starobrno.commands.ReplicableCommand;
+import org.jboss.starobrno.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 org.jboss.starobrno.commands.ReplicableCommand;
-import org.jboss.starobrno.commands.CommandsFactory;
-import org.jboss.starobrno.commands.remote.ReplicateCommand;
-import org.jboss.starobrno.RPCManager;
+import org.jboss.starobrno.remoting.RPCManager;
import java.util.ArrayList;
import java.util.LinkedList;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java 2008-12-10 15:10:12 UTC (rev 7275)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java 2008-12-10 16:16:42 UTC (rev 7276)
@@ -77,24 +77,28 @@
public Object perform(InvocationContext ctx) throws Throwable
{
- notifier.notifyCacheEntryModified(key, true, ctx);
+ Object o = null;
MVCCEntry e = ctx.lookupEntry(key);
- Object o;
- if (value instanceof Delta)
+ if (e.getValue() == null || !putIfAbsent)
{
- // magic
- Delta dv = (Delta) value;
- Object existing = e.getValue();
- DeltaAware toMergeWith = null;
- if (existing instanceof DeltaAware) toMergeWith = (DeltaAware) existing;
- e.setValue(dv.merge(toMergeWith));
- o = existing;
+ notifier.notifyCacheEntryModified(key, true, ctx);
+
+ if (value instanceof Delta)
+ {
+ // magic
+ Delta dv = (Delta) value;
+ Object existing = e.getValue();
+ DeltaAware toMergeWith = null;
+ if (existing instanceof DeltaAware) toMergeWith = (DeltaAware) existing;
+ e.setValue(dv.merge(toMergeWith));
+ o = existing;
+ }
+ else
+ {
+ o = e.setValue(value);
+ }
+ notifier.notifyCacheEntryModified(key, false, ctx);
}
- else
- {
- o = e.setValue(value);
- }
- notifier.notifyCacheEntryModified(key, false, ctx);
return o;
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/RuntimeConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/RuntimeConfig.java 2008-12-10 15:10:12 UTC (rev 7275)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/RuntimeConfig.java 2008-12-10 16:16:42 UTC (rev 7276)
@@ -21,8 +21,8 @@
*/
package org.jboss.starobrno.config;
-import org.jboss.cache.RPCManager;
import org.jboss.cache.buddyreplication.BuddyGroup;
+import org.jboss.starobrno.remoting.RPCManager;
import org.jboss.starobrno.util.Util;
import org.jgroups.Channel;
import org.jgroups.ChannelFactory;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/factories/EmptyConstructorFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/EmptyConstructorFactory.java 2008-12-10 15:10:12 UTC (rev 7275)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/EmptyConstructorFactory.java 2008-12-10 16:16:42 UTC (rev 7276)
@@ -26,7 +26,6 @@
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.invocation.CacheInvocationDelegate;
import org.jboss.cache.lock.LockStrategyFactory;
-import org.jboss.starobrno.RPCManager;
import org.jboss.starobrno.batch.BatchContainer;
import org.jboss.starobrno.commands.CommandsFactory;
import org.jboss.starobrno.config.ConfigurationException;
@@ -39,6 +38,7 @@
import org.jboss.starobrno.marshall.VersionAwareMarshaller;
import org.jboss.starobrno.notifications.Notifier;
import org.jboss.starobrno.remoting.ChannelMessageListener;
+import org.jboss.starobrno.remoting.RPCManager;
import org.jboss.starobrno.remoting.RPCManagerImpl;
import org.jboss.starobrno.transaction.TransactionTable;
@@ -67,10 +67,9 @@
{
componentImpl = VersionAwareMarshaller.class;
}
- else
- if (componentType.equals(RPCManager.class))
+ else if (componentType.equals(RPCManager.class))
{
- componentImpl = RPCManagerImpl.class;
+ componentImpl = RPCManagerImpl.class;
}
else
{
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/factories/RuntimeConfigAwareFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/RuntimeConfigAwareFactory.java 2008-12-10 15:10:12 UTC (rev 7275)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/RuntimeConfigAwareFactory.java 2008-12-10 16:16:42 UTC (rev 7276)
@@ -22,10 +22,10 @@
package org.jboss.starobrno.factories;
import org.jboss.cache.util.BeanUtils;
-import org.jboss.starobrno.RPCManager;
import org.jboss.starobrno.config.ConfigurationException;
import org.jboss.starobrno.config.RuntimeConfig;
import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
+import org.jboss.starobrno.remoting.RPCManager;
import java.lang.reflect.Method;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InvocationContextInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InvocationContextInterceptor.java 2008-12-10 15:10:12 UTC (rev 7275)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InvocationContextInterceptor.java 2008-12-10 16:16:42 UTC (rev 7276)
@@ -22,7 +22,6 @@
package org.jboss.starobrno.interceptors;
-import org.jboss.starobrno.RPCManager;
import org.jboss.starobrno.commands.VisitableCommand;
import org.jboss.starobrno.commands.tx.CommitCommand;
import org.jboss.starobrno.commands.tx.PrepareCommand;
@@ -32,6 +31,7 @@
import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.context.TransactionContext;
import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.remoting.RPCManager;
import org.jboss.starobrno.transaction.GlobalTransaction;
import org.jboss.starobrno.transaction.TransactionTable;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/TxInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/TxInterceptor.java 2008-12-10 15:10:12 UTC (rev 7275)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/TxInterceptor.java 2008-12-10 16:16:42 UTC (rev 7276)
@@ -23,7 +23,6 @@
import org.jboss.cache.util.concurrent.ConcurrentHashSet;
import org.jboss.starobrno.CacheException;
-import org.jboss.starobrno.RPCManager;
import org.jboss.starobrno.commands.CommandsFactory;
import org.jboss.starobrno.commands.ReplicableCommand;
import org.jboss.starobrno.commands.VisitableCommand;
@@ -41,6 +40,7 @@
import org.jboss.starobrno.jmx.annotations.ManagedOperation;
import org.jboss.starobrno.lock.LockManager;
import org.jboss.starobrno.notifications.Notifier;
+import org.jboss.starobrno.remoting.RPCManager;
import org.jboss.starobrno.remoting.ReplicationException;
import org.jboss.starobrno.transaction.GlobalTransaction;
import org.jboss.starobrno.transaction.TransactionTable;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/BaseRpcInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/BaseRpcInterceptor.java 2008-12-10 15:10:12 UTC (rev 7275)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/BaseRpcInterceptor.java 2008-12-10 16:16:42 UTC (rev 7276)
@@ -21,7 +21,6 @@
*/
package org.jboss.starobrno.interceptors.base;
-import org.jboss.starobrno.RPCManager;
import org.jboss.starobrno.cluster.ReplicationQueue;
import org.jboss.starobrno.commands.CommandsFactory;
import org.jboss.starobrno.commands.ReplicableCommand;
@@ -30,6 +29,7 @@
import org.jboss.starobrno.context.TransactionContext;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.remoting.RPCManager;
import org.jboss.starobrno.transaction.GlobalTransaction;
import org.jboss.starobrno.transaction.TransactionTable;
import org.jgroups.Address;
Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManager.java 2008-12-10 15:10:12 UTC (rev 7275)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManager.java 2008-12-10 16:16:42 UTC (rev 7276)
@@ -1,154 +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.starobrno.remoting;
-
-import org.jboss.cache.Fqn;
-import org.jboss.starobrno.commands.ReplicableCommand;
-import org.jgroups.Address;
-import org.jgroups.Channel;
-import org.jgroups.blocks.RspFilter;
-
-import java.util.List;
-import java.util.Vector;
-
-/**
- * Provides a mechanism for communicating with other caches in the cluster. For now this is based on JGroups as an underlying
- * transport, and in future more transport options may become available.
- * <p/>
- * Implementations have a simple lifecycle:
- * <ul>
- * <li>start() - starts the underlying channel based on configuration options injected, and connects the channel</li>
- * <li>disconnect() - disconnects the channel</li>
- * <li>stop() - stops the dispatcher and releases resources</li>
- * </ul>
- *
- * @author Manik Surtani
- * @since 2.1.0
- */
-public interface RPCManager
-{
- /**
- * Disconnects and closes the underlying JGroups channel.
- */
- void disconnect();
-
- /**
- * Stops the RPCDispatcher and frees resources. Closes and disconnects the underlying JGroups channel if this is
- * still open/connected.
- */
- void stop();
-
- /**
- * Starts the RPCManager by connecting the underlying JGroups channel (if configured for replication). Connecting
- * the channel may also involve state transfer (if configured) so the interceptor chain should be started and
- * available before this method is called.
- */
- void start();
-
- /**
- * Invokes an RPC call on other caches in the cluster.
- *
- * @param recipients a list of Addresses to invoke the call on. If this is null, the call is broadcast to the entire cluster.
- * @param cacheCommand the cache command to invoke
- * @param mode the group request mode to use. See {@link org.jgroups.blocks.GroupRequest}.
- * @param timeout a timeout after which to throw a replication exception.
- * @param responseFilter a response filter with which to filter out failed/unwanted/invalid responses.
- * @param useOutOfBandMessage if true, the message is put on JGroups' OOB queue. See JGroups docs for more info.
- * @return a list of responses from each member contacted.
- * @throws Exception in the event of problems.
- */
- List<Object> callRemoteMethods(Vector<Address> recipients, ReplicableCommand cacheCommand, int mode, long timeout, RspFilter responseFilter, boolean useOutOfBandMessage) throws Exception;
-
- /**
- * Invokes an RPC call on other caches in the cluster.
- *
- * @param recipients a list of Addresses to invoke the call on. If this is null, the call is broadcast to the entire cluster.
- * @param cacheCommand the cache command to invoke
- * @param mode the group request mode to use. See {@link org.jgroups.blocks.GroupRequest}.
- * @param timeout a timeout after which to throw a replication exception.
- * @param useOutOfBandMessage if true, the message is put on JGroups' OOB queue. See JGroups docs for more info.
- * @return a list of responses from each member contacted.
- * @throws Exception in the event of problems.
- */
- List<Object> callRemoteMethods(Vector<Address> recipients, ReplicableCommand cacheCommand, int mode, long timeout, boolean useOutOfBandMessage) throws Exception;
-
- /**
- * Invokes an RPC call on other caches in the cluster.
- *
- * @param recipients a list of Addresses to invoke the call on. If this is null, the call is broadcast to the entire cluster.
- * @param cacheCommand the cache command to invoke
- * @param synchronous if true, sets group request mode to {@link org.jgroups.blocks.GroupRequest#GET_ALL}, and if false sets it to {@link org.jgroups.blocks.GroupRequest#GET_NONE}.
- * @param timeout a timeout after which to throw a replication exception.
- * @param useOutOfBandMessage if true, the message is put on JGroups' OOB queue. See JGroups docs for more info.
- * @return a list of responses from each member contacted.
- * @throws Exception in the event of problems.
- */
- List<Object> callRemoteMethods(Vector<Address> recipients, ReplicableCommand cacheCommand, boolean synchronous, long timeout, boolean useOutOfBandMessage) throws Exception;
-
- /**
- * @return true if the current Channel is the coordinator of the cluster.
- */
- boolean isCoordinator();
-
- /**
- * @return the Address of the current coordinator.
- */
- Address getCoordinator();
-
- /**
- * Retrieves the local JGroups channel's address
- *
- * @return an Address
- */
- Address getLocalAddress();
-
- /**
- * Returns a defensively copied list of members in the current cluster view.
- */
- List<Address> getMembers();
-
- /**
- * Retrieves partial state from remote instances.
- *
- * @param sources sources to consider for a state transfer
- * @param sourceTarget Fqn on source to retrieve state for
- * @param integrationTarget integration point on local cache to apply state
- * @throws Exception in the event of problems
- */
- void fetchPartialState(List<Address> sources, Fqn sourceTarget, Fqn integrationTarget) throws Exception;
-
- /**
- * Retrieves partial state from remote instances.
- *
- * @param sources sources to consider for a state transfer
- * @param subtree Fqn subtree to retrieve. Will be integrated at the same point.
- * @throws Exception in the event of problems
- */
- void fetchPartialState(List<Address> sources, Fqn subtree) throws Exception;
-
- /**
- * Retrieves the Channel
- *
- * @return a channel
- */
- Channel getChannel();
-}
\ No newline at end of file
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManager.java (from rev 7261, core/branches/flat/src/main/java/org/jboss/starobrno/RPCManager.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManager.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManager.java 2008-12-10 16:16:42 UTC (rev 7276)
@@ -0,0 +1,135 @@
+/*
+ * 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.remoting;
+
+import org.jboss.starobrno.commands.ReplicableCommand;
+import org.jgroups.Address;
+import org.jgroups.Channel;
+import org.jgroups.blocks.RspFilter;
+
+import java.util.List;
+import java.util.Vector;
+
+/**
+ * Provides a mechanism for communicating with other caches in the cluster. For now this is based on JGroups as an underlying
+ * transport, and in future more transport options may become available.
+ * <p/>
+ * Implementations have a simple lifecycle:
+ * <ul>
+ * <li>start() - starts the underlying channel based on configuration options injected, and connects the channel</li>
+ * <li>disconnect() - disconnects the channel</li>
+ * <li>stop() - stops the dispatcher and releases resources</li>
+ * </ul>
+ *
+ * @author Manik Surtani
+ * @since 2.1.0
+ */
+public interface RPCManager
+{
+ /**
+ * Disconnects and closes the underlying JGroups channel.
+ */
+ void disconnect();
+
+ /**
+ * Stops the RPCDispatcher and frees resources. Closes and disconnects the underlying JGroups channel if this is
+ * still open/connected.
+ */
+ void stop();
+
+ /**
+ * Starts the RPCManager by connecting the underlying JGroups channel (if configured for replication). Connecting
+ * the channel may also involve state transfer (if configured) so the interceptor chain should be started and
+ * available before this method is called.
+ */
+ void start();
+
+ /**
+ * Invokes an RPC call on other caches in the cluster.
+ *
+ * @param recipients a list of Addresses to invoke the call on. If this is null, the call is broadcast to the entire cluster.
+ * @param cacheCommand the cache command to invoke
+ * @param mode the group request mode to use. See {@link org.jgroups.blocks.GroupRequest}.
+ * @param timeout a timeout after which to throw a replication exception.
+ * @param responseFilter a response filter with which to filter out failed/unwanted/invalid responses.
+ * @param useOutOfBandMessage if true, the message is put on JGroups' OOB queue. See JGroups docs for more info.
+ * @return a list of responses from each member contacted.
+ * @throws Exception in the event of problems.
+ */
+ List<Object> callRemoteMethods(Vector<Address> recipients, ReplicableCommand cacheCommand, int mode, long timeout, RspFilter responseFilter, boolean useOutOfBandMessage) throws Exception;
+
+ /**
+ * Invokes an RPC call on other caches in the cluster.
+ *
+ * @param recipients a list of Addresses to invoke the call on. If this is null, the call is broadcast to the entire cluster.
+ * @param cacheCommand the cache command to invoke
+ * @param mode the group request mode to use. See {@link org.jgroups.blocks.GroupRequest}.
+ * @param timeout a timeout after which to throw a replication exception.
+ * @param useOutOfBandMessage if true, the message is put on JGroups' OOB queue. See JGroups docs for more info.
+ * @return a list of responses from each member contacted.
+ * @throws Exception in the event of problems.
+ */
+ List<Object> callRemoteMethods(Vector<Address> recipients, ReplicableCommand cacheCommand, int mode, long timeout, boolean useOutOfBandMessage) throws Exception;
+
+ /**
+ * Invokes an RPC call on other caches in the cluster.
+ *
+ * @param recipients a list of Addresses to invoke the call on. If this is null, the call is broadcast to the entire cluster.
+ * @param cacheCommand the cache command to invoke
+ * @param synchronous if true, sets group request mode to {@link org.jgroups.blocks.GroupRequest#GET_ALL}, and if false sets it to {@link org.jgroups.blocks.GroupRequest#GET_NONE}.
+ * @param timeout a timeout after which to throw a replication exception.
+ * @param useOutOfBandMessage if true, the message is put on JGroups' OOB queue. See JGroups docs for more info.
+ * @return a list of responses from each member contacted.
+ * @throws Exception in the event of problems.
+ */
+ List<Object> callRemoteMethods(Vector<Address> recipients, ReplicableCommand cacheCommand, boolean synchronous, long timeout, boolean useOutOfBandMessage) throws Exception;
+
+ /**
+ * @return true if the current Channel is the coordinator of the cluster.
+ */
+ boolean isCoordinator();
+
+ /**
+ * @return the Address of the current coordinator.
+ */
+ Address getCoordinator();
+
+ /**
+ * Retrieves the local JGroups channel's address
+ *
+ * @return an Address
+ */
+ Address getLocalAddress();
+
+ /**
+ * Returns a defensively copied list of members in the current cluster view.
+ */
+ List<Address> getMembers();
+
+
+ /**
+ * Retrieves the Channel
+ *
+ * @return a channel
+ */
+ Channel getChannel();
+}
\ No newline at end of file
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManager.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManagerImpl.java 2008-12-10 15:10:12 UTC (rev 7275)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManagerImpl.java 2008-12-10 16:16:42 UTC (rev 7276)
@@ -23,13 +23,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.util.concurrent.ReclosableLatch;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.CacheSPI;
-import org.jboss.starobrno.RPCManager;
-import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.commands.ReplicableCommand;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.config.RuntimeConfig;
+import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.factories.ComponentRegistry;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.Start;
@@ -44,10 +44,8 @@
import org.jboss.starobrno.marshall.CommandAwareRpcDispatcher;
import org.jboss.starobrno.marshall.ExtendedMarshaller;
import org.jboss.starobrno.notifications.Notifier;
-import org.jboss.starobrno.remoting.ChannelMessageListener;
import org.jboss.starobrno.transaction.TransactionTable;
import org.jboss.starobrno.util.ReflectionUtil;
-import org.jboss.cache.util.concurrent.ReclosableLatch;
import org.jgroups.*;
import org.jgroups.blocks.GroupRequest;
import org.jgroups.blocks.RspFilter;
@@ -148,11 +146,11 @@
//otherwise just connect
try
- {
- channel.connect(configuration.getClusterName());
- }
- catch (ChannelException e)
{
+ channel.connect(configuration.getClusterName());
+ }
+ catch (ChannelException e)
+ {
throw new CacheException("Unable to connect to JGroups channel", e);
}
if (log.isInfoEnabled()) log.info("Cache local address is " + getLocalAddress());
@@ -206,7 +204,7 @@
channel.setOpt(Channel.AUTO_GETSTATE, false);
channel.setOpt(Channel.BLOCK, true);
rpcDispatcher = new CommandAwareRpcDispatcher(channel, messageListener, new MembershipListenerAdaptor(),
- invocationContextContainer, invocationContextContainer, interceptorChain, componentRegistry);
+ invocationContextContainer, invocationContextContainer, interceptorChain, componentRegistry);
checkAppropriateConfig();
rpcDispatcher.setRequestMarshaller(extendedMarshaller);
rpcDispatcher.setResponseMarshaller(extendedMarshaller);
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/transaction/TransactionTable.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/transaction/TransactionTable.java 2008-12-10 15:10:12 UTC (rev 7275)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/transaction/TransactionTable.java 2008-12-10 16:16:42 UTC (rev 7276)
@@ -24,12 +24,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.starobrno.CacheException;
-import org.jboss.starobrno.RPCManager;
import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.context.TransactionContext;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.NonVolatile;
import org.jboss.starobrno.factories.context.ContextFactory;
+import org.jboss.starobrno.remoting.RPCManager;
import org.jgroups.Address;
import javax.transaction.Status;
Added: core/branches/flat/src/test/java/org/jboss/starobrno/api/mvcc/PutForExternalReadTest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/api/mvcc/PutForExternalReadTest.java (rev 0)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/api/mvcc/PutForExternalReadTest.java 2008-12-10 16:16:42 UTC (rev 7276)
@@ -0,0 +1,343 @@
+package org.jboss.starobrno.api.mvcc;
+
+import org.easymock.EasyMock;
+import static org.easymock.EasyMock.*;
+import org.jboss.cache.CacheFactory;
+import org.jboss.starobrno.Cache;
+import org.jboss.starobrno.CacheSPI;
+import org.jboss.starobrno.UnitTestCacheFactory;
+import org.jboss.starobrno.commands.ReplicableCommand;
+import org.jboss.starobrno.commands.write.PutKeyValueCommand;
+import org.jboss.starobrno.commands.write.RemoveCommand;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.ComponentRegistry;
+import org.jboss.starobrno.remoting.RPCManager;
+import org.jboss.starobrno.transaction.TransactionTable;
+import org.jboss.starobrno.util.TestingUtil;
+import org.jboss.starobrno.util.internals.ReplicationListener;
+import org.jgroups.Address;
+import static org.testng.AssertJUnit.*;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import java.util.List;
+import java.util.Vector;
+
+@Test(groups = {"functional", "jgroups", "transaction"})
+public class PutForExternalReadTest
+{
+ protected final String key = "k", value = "v", value2 = "v2";
+
+ protected CacheSPI<String, String> cache1, cache2;
+
+ ReplicationListener replListener1;
+ ReplicationListener replListener2;
+
+ protected TransactionManager tm1, tm2;
+
+ protected boolean useTx;
+
+
+ @BeforeMethod(alwaysRun = true)
+ public void setUp()
+ {
+
+ CacheFactory<String, String> cf = new UnitTestCacheFactory<String, String>();
+ Configuration c = new Configuration();
+ c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ cache1 = (CacheSPI<String, String>) cf.createCache(c, false);
+ cache1.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ cache1.getConfiguration().setSerializationExecutorPoolSize(0);//this is very important for async tests!
+
+ cache1.start();
+ tm1 = cache1.getConfiguration().getRuntimeConfig().getTransactionManager();
+
+ cache2 = (CacheSPI<String, String>) cf.createCache(cache1.getConfiguration().clone());
+
+ tm2 = cache2.getConfiguration().getRuntimeConfig().getTransactionManager();
+ replListener1 = new ReplicationListener(cache1);
+ replListener2 = new ReplicationListener(cache2);
+
+ TestingUtil.blockUntilViewsReceived(10000, cache1, cache2);
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown()
+ {
+ TestingUtil.killCaches(cache1, cache2);
+ }
+
+ public void testNoOpWhenKeyPresent()
+ {
+ replListener2.expect(PutKeyValueCommand.class);
+ cache1.putForExternalRead(key, value);
+ replListener2.waitForReplicationToOccur();
+
+
+ assertEquals("PFER should have succeeded", value, cache1.get(key));
+ assertEquals("PFER should have replicated", value, cache2.get(key));
+
+ // reset
+ replListener2.expect(RemoveCommand.class);
+ cache1.remove(key);
+ replListener2.waitForReplicationToOccur();
+
+ assert cache1.isEmpty() : "Should have reset";
+ assert cache2.isEmpty() : "Should have reset";
+
+ replListener2.expect(PutKeyValueCommand.class);
+ cache1.put(key, value);
+ replListener2.waitForReplicationToOccur();
+
+ // now this pfer should be a no-op
+ cache1.putForExternalRead(key, value2);
+
+ assertEquals("PFER should have been a no-op", value, cache1.get(key));
+ assertEquals("PFER should have been a no-op", value, cache2.get(key));
+ }
+
+ private Vector<Address> anyAddresses()
+ {
+ anyObject();
+ return null;
+ }
+
+ public void testAsyncForce() throws Exception
+ {
+ RPCManager rpcManager = EasyMock.createNiceMock(RPCManager.class);
+ RPCManager originalRpcManager = cache1.getConfiguration().getRuntimeConfig().getRPCManager();
+ List<Address> memberList = originalRpcManager.getMembers();
+ expect(rpcManager.getMembers()).andReturn(memberList).anyTimes();
+ // inject a mock RPC manager so that we can test whether calls made are sync or async.
+ ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache1);
+ cr.registerComponent(rpcManager, RPCManager.class);
+ cr.rewire();
+
+ // specify what we expectWithTx called on the mock Rpc Manager. For params we don't care about, just use ANYTHING.
+ // setting the mock object to expectWithTx the "sync" param to be false.
+ expect(rpcManager.callRemoteMethods(anyAddresses(), (ReplicableCommand) anyObject(), eq(false), anyLong(), anyBoolean())).andReturn(null);
+
+ replay(rpcManager);
+
+ // now try a simple replication. Since the RPCManager is a mock object it will not actually replicate anything.
+ cache1.putForExternalRead(key, value);
+ verify(rpcManager);
+
+ // cleanup
+ TestingUtil.extractComponentRegistry(cache1).registerComponent(originalRpcManager, RPCManager.class);
+ cache1.remove(key);
+ }
+
+ public void testTxSuspension() throws Exception
+ {
+ // create parent node first
+ replListener2.expect(PutKeyValueCommand.class);
+ cache1.put(key + "0", value);
+ replListener2.waitForReplicationToOccur();
+
+ // start a tx and do some stuff.
+ replListener2.expect(PutKeyValueCommand.class);
+ tm1.begin();
+ cache1.get(key + "0");
+ cache1.putForExternalRead(key, value); // should have happened in a separate tx and have committed already.
+ Transaction t = tm1.suspend();
+
+ replListener2.waitForReplicationToOccur();
+ assertEquals("PFER should have completed", value, cache1.get(key));
+ assertEquals("PFER should have completed", value, cache2.get(key));
+
+ tm1.resume(t);
+ tm1.commit();
+
+ assertEquals("parent fqn tx should have completed", value, cache1.get(key + "0"));
+ assertEquals("parent fqn tx should have completed", value, cache2.get(key + "0"));
+ }
+
+ public void testExceptionSuppression() throws Exception
+ {
+ RPCManager barfingRpcManager = EasyMock.createNiceMock(RPCManager.class);
+ RPCManager originalRpcManager = cache1.getConfiguration().getRuntimeConfig().getRPCManager();
+ try
+ {
+ List<Address> memberList = originalRpcManager.getMembers();
+ expect(barfingRpcManager.getMembers()).andReturn(memberList).anyTimes();
+ expect(barfingRpcManager.getLocalAddress()).andReturn(originalRpcManager.getLocalAddress()).anyTimes();
+ expect(barfingRpcManager.callRemoteMethods(anyAddresses(), (ReplicableCommand) anyObject(), anyBoolean(), anyLong(), anyBoolean())).andThrow(new RuntimeException("Barf!")).anyTimes();
+ replay(barfingRpcManager);
+
+ TestingUtil.extractComponentRegistry(cache1).registerComponent(barfingRpcManager, RPCManager.class);
+ cache1.getConfiguration().getRuntimeConfig().setRPCManager(barfingRpcManager);
+ TestingUtil.extractComponentRegistry(cache1).rewire();
+
+ try
+ {
+ cache1.put(key, value);
+ fail("Should have barfed");
+ }
+ catch (RuntimeException re)
+ {
+ }
+
+ // clean up any indeterminate state left over
+ try
+ {
+ cache1.remove(key);
+ fail("Should have barfed");
+ }
+ catch (RuntimeException re)
+ {
+ }
+
+ assertNull("Should have cleaned up", cache1.get(key));
+
+ // should not barf
+ cache1.putForExternalRead(key, value);
+ }
+ finally
+ {
+ TestingUtil.extractComponentRegistry(cache1).registerComponent(originalRpcManager, RPCManager.class);
+ }
+ }
+
+ public void testBasicPropagation() throws Exception
+ {
+ assert !cache1.containsKey(key);
+ assert !cache2.containsKey(key);
+
+ replListener2.expect(PutKeyValueCommand.class);
+ cache1.putForExternalRead(key, value);
+ replListener2.waitForReplicationToOccur();
+
+ assertEquals("PFER updated cache1", value, cache1.get(key));
+ assertEquals("PFER propagated to cache2 as expected", value, cache2.get(key));
+
+ // replication to cache 1 should NOT happen.
+ cache2.putForExternalRead(key, value + "0");
+
+ assertEquals("PFER updated cache2", value, cache2.get(key));
+ assertEquals("Cache1 should be unaffected", value, cache1.get(key));
+ }
+
+ /**
+ * Tests that setting a cacheModeLocal=true Option prevents propagation
+ * of the putForExternalRead().
+ *
+ * @throws Exception
+ */
+ public void testSimpleCacheModeLocal() throws Exception
+ {
+ cacheModeLocalTest(false);
+ }
+
+ /**
+ * Tests that setting a cacheModeLocal=true Option prevents propagation
+ * of the putForExternalRead() when the call occurs inside a transaction.
+ *
+ * @throws Exception
+ */
+ public void testCacheModeLocalInTx() throws Exception
+ {
+ cacheModeLocalTest(true);
+ }
+
+ private TransactionTable getTransactionTable(Cache cache)
+ {
+ return TestingUtil.extractComponent(cache, TransactionTable.class);
+ }
+
+ /**
+ * Tests that suspended transactions do not leak. See JBCACHE-1246.
+ */
+ public void testMemLeakOnSuspendedTransactions() throws Exception
+ {
+ replListener2.expect(PutKeyValueCommand.class);
+ tm1.begin();
+ cache1.putForExternalRead(key, value);
+ tm1.commit();
+ replListener2.waitForReplicationToOccur();
+
+ TransactionTable tt1 = getTransactionTable(cache1);
+ TransactionTable tt2 = getTransactionTable(cache2);
+
+ assert tt1.getNumGlobalTransactions() == 0 : "Cache 1 should have no stale global TXs";
+ assert tt1.getNumLocalTransactions() == 0 : "Cache 1 should have no stale local TXs";
+ assert tt2.getNumGlobalTransactions() == 0 : "Cache 2 should have no stale global TXs";
+ assert tt2.getNumLocalTransactions() == 0 : "Cache 2 should have no stale local TXs";
+
+ System.out.println("PutForExternalReadTest.testMemLeakOnSuspendedTransactions");
+ //do not expectWithTx a PFER replication, as the node already exists so this is a no-op
+ replListener2.expectWithTx(PutKeyValueCommand.class);
+ tm1.begin();
+ cache1.putForExternalRead(key, value);
+ cache1.put(key, value);
+ tm1.commit();
+ replListener2.waitForReplicationToOccur();
+
+ assert tt1.getNumGlobalTransactions() == 0 : "Cache 1 should have no stale global TXs";
+ assert tt1.getNumLocalTransactions() == 0 : "Cache 1 should have no stale local TXs";
+ assert tt2.getNumGlobalTransactions() == 0 : "Cache 2 should have no stale global TXs";
+ assert tt2.getNumLocalTransactions() == 0 : "Cache 2 should have no stale local TXs";
+
+ replListener2.expectWithTx(PutKeyValueCommand.class);
+ tm1.begin();
+ cache1.put(key, value);
+ cache1.putForExternalRead(key, value);
+ tm1.commit();
+ replListener2.waitForReplicationToOccur();
+
+ assert tt1.getNumGlobalTransactions() == 0 : "Cache 1 should have no stale global TXs";
+ assert tt1.getNumLocalTransactions() == 0 : "Cache 1 should have no stale local TXs";
+ assert tt2.getNumGlobalTransactions() == 0 : "Cache 2 should have no stale global TXs";
+ assert tt2.getNumLocalTransactions() == 0 : "Cache 2 should have no stale local TXs";
+
+ //do not expectWithTx a PFER replication, as the node already exists so this is a no-op
+ replListener2.expectWithTx(PutKeyValueCommand.class, PutKeyValueCommand.class);
+ tm1.begin();
+ cache1.put(key, value);
+ cache1.putForExternalRead(key, value);
+ cache1.put(key, value);
+ tm1.commit();
+ replListener2.waitForReplicationToOccur();
+
+ assert tt1.getNumGlobalTransactions() == 0 : "Cache 1 should have no stale global TXs";
+ assert tt1.getNumLocalTransactions() == 0 : "Cache 1 should have no stale local TXs";
+ assert tt2.getNumGlobalTransactions() == 0 : "Cache 2 should have no stale global TXs";
+ assert tt2.getNumLocalTransactions() == 0 : "Cache 2 should have no stale local TXs";
+ }
+
+ /**
+ * Tests that setting a cacheModeLocal=true Option prevents propagation
+ * of the putForExternalRead().
+ *
+ * @throws Exception
+ */
+ private void cacheModeLocalTest(boolean transactional) throws Exception
+ {
+ RPCManager rpcManager = EasyMock.createMock(RPCManager.class);
+ RPCManager originalRpcManager = cache1.getConfiguration().getRuntimeConfig().getRPCManager();
+
+ // inject a mock RPC manager so that we can test whether calls made are sync or async.
+ cache1.getConfiguration().getRuntimeConfig().setRPCManager(rpcManager);
+
+ // specify that we expectWithTx nothing will be called on the mock Rpc Manager.
+ replay(rpcManager);
+
+ // now try a simple replication. Since the RPCManager is a mock object it will not actually replicate anything.
+ if (transactional)
+ tm1.begin();
+
+ cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
+ cache1.putForExternalRead(key, value);
+
+ if (transactional)
+ tm1.commit();
+
+ verify(rpcManager);
+ // cleanup
+ cache1.getConfiguration().getRuntimeConfig().setRPCManager(originalRpcManager);
+ cache1.remove(key);
+ }
+}
Modified: core/branches/flat/src/test/java/org/jboss/starobrno/util/TestingUtil.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/util/TestingUtil.java 2008-12-10 15:10:12 UTC (rev 7275)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/util/TestingUtil.java 2008-12-10 16:16:42 UTC (rev 7276)
@@ -426,7 +426,7 @@
public static void killTreeCaches(TreeCache... treeCaches)
{
- for (TreeCache tc: treeCaches)
+ for (TreeCache tc : treeCaches)
{
if (tc != null) killCaches(tc.getCache());
}
@@ -485,19 +485,25 @@
/**
* Clears transaction with the current thread in the given transaction manager.
+ *
* @param txManager a TransactionManager to be cleared
*/
- public static void killTransaction(TransactionManager txManager) {
- if (txManager != null) {
- try {
+ public static void killTransaction(TransactionManager txManager)
+ {
+ if (txManager != null)
+ {
+ try
+ {
txManager.rollback();
- } catch (Exception e) {
- // don't care
}
+ catch (Exception e)
+ {
+ // don't care
+ }
}
}
-
+
/**
* Clears any associated transactions with the current thread in the caches' transaction managers.
*/
@@ -674,4 +680,18 @@
{
dumpCacheContents(Arrays.asList(caches));
}
+
+ /**
+ * Extracts a component of a given type from the cache's internal component registry
+ *
+ * @param cache
+ * @param componentType
+ * @param <T>
+ * @return
+ */
+ public static <T> T extractComponent(Cache cache, Class<T> componentType)
+ {
+ ComponentRegistry cr = extractComponentRegistry(cache);
+ return cr.getComponent(componentType);
+ }
}
Modified: core/branches/flat/src/test/java/org/jboss/starobrno/util/internals/ReplicationListener.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/util/internals/ReplicationListener.java 2008-12-10 15:10:12 UTC (rev 7275)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/util/internals/ReplicationListener.java 2008-12-10 16:16:42 UTC (rev 7276)
@@ -1,16 +1,20 @@
package org.jboss.starobrno.util.internals;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.jboss.starobrno.Cache;
-import org.jboss.starobrno.RPCManager;
import org.jboss.starobrno.commands.ReplicableCommand;
import org.jboss.starobrno.commands.remote.ReplicateCommand;
+import org.jboss.starobrno.commands.tx.CommitCommand;
import org.jboss.starobrno.commands.tx.PrepareCommand;
+import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.factories.ComponentRegistry;
import org.jboss.starobrno.io.ByteBuffer;
import org.jboss.starobrno.marshall.CacheMarshallerStarobrno;
import org.jboss.starobrno.marshall.CommandAwareRpcDispatcher;
import org.jboss.starobrno.marshall.ExtendedMarshaller;
+import org.jboss.starobrno.remoting.RPCManager;
import org.jboss.starobrno.util.TestingUtil;
import org.jgroups.blocks.RpcDispatcher;
import org.jgroups.util.Buffer;
@@ -50,6 +54,8 @@
{
private CountDownLatch latch = new CountDownLatch(1);
private Set<Class<? extends ReplicableCommand>> expectedCommands;
+ Configuration configuration;
+ private static final Log log = LogFactory.getLog(ReplicationListener.class);
/**
* Builds a listener that will observe the given cache for recieving replication commands.
@@ -65,6 +71,7 @@
realDispatcher.setMarshaller(delegate);
realDispatcher.setRequestMarshaller(delegate);
realDispatcher.setResponseMarshaller(delegate);
+ configuration = cache.getConfiguration();
}
private class MarshallerDelegate implements RpcDispatcher.Marshaller2
@@ -130,7 +137,7 @@
}
finally
{
- System.out.println("Processed command: " + realOne);
+ log.trace("Processed command: " + realOne);
Iterator<Class<? extends ReplicableCommand>> it = expectedCommands.iterator();
while (it.hasNext())
{
@@ -138,7 +145,8 @@
if (realOne.containsCommandType(replicableCommandClass))
{
it.remove();
- } else if (realOne.getSingleModification() instanceof PrepareCommand) //explicit transaction
+ }
+ else if (realOne.getSingleModification() instanceof PrepareCommand) //explicit transaction
{
PrepareCommand prepareCommand = (PrepareCommand) realOne.getSingleModification();
if (prepareCommand.containsModificationType(replicableCommandClass))
@@ -198,7 +206,7 @@
public Object objectFromByteBuffer(byte[] buffer, int i, int i1) throws Exception
{
- Object result = realOne.objectFromByteBuffer(buffer, i , i1);
+ Object result = realOne.objectFromByteBuffer(buffer, i, i1);
if (result instanceof ReplicateCommand && expectedCommands != null)
{
ReplicateCommand replicateCommand = (ReplicateCommand) result;
@@ -209,14 +217,22 @@
}
/**
+ * Waits for 1 minute
+ */
+ public void waitForReplicationToOccur()
+ {
+ waitForReplicationToOccur(60000);
+ }
+
+ /**
* Blocks for the elements specified through {@link #expect(Class[])} invocations to be replicated in this cache.
* if replication does not occur in the give timeout then an exception is being thrown.
*/
public void waitForReplicationToOccur(long timeoutMillis)
{
- System.out.println("enter... ReplicationListener.waitForReplicationToOccur");
+ log.trace("enter... ReplicationListener.waitForReplicationToOccur");
waitForReplicationToOccur(timeoutMillis, TimeUnit.MILLISECONDS);
- System.out.println("exit... ReplicationListener.waitForReplicationToOccur");
+ log.trace("exit... ReplicationListener.waitForReplicationToOccur");
}
/**
@@ -266,4 +282,12 @@
{
expect();
}
+
+ public void expectWithTx(Class<? extends ReplicableCommand>... writeCommands)
+ {
+ expect(PrepareCommand.class);
+ //this is because for async replication we have an 1pc transaction
+ if (configuration.getCacheMode().isSynchronous()) expect(CommitCommand.class);
+ }
+
}
\ No newline at end of file
16 years, 1 month
JBoss Cache SVN: r7275 - in core/branches/flat/src: main/java/org/jboss/starobrno/commands/write and 3 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-12-10 10:10:12 -0500 (Wed, 10 Dec 2008)
New Revision: 7275
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java
core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/ReplaceCommand.java
core/branches/flat/src/test/java/org/jboss/starobrno/api/mvcc/read_committed/ReadCommittedLockTest.java
core/branches/flat/src/test/java/org/jboss/starobrno/profiling/ProfileTest.java
core/branches/flat/src/test/java/org/jboss/starobrno/profiling/TreeProfileTest.java
core/branches/flat/src/test/java/org/jboss/starobrno/profiling/testinternals/Generator.java
Log:
- Implemented putForExternalRead
- Fixed a bug in replace()
- Added better test for replace()
- Improved profiler tests
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java 2008-12-10 12:51:42 UTC (rev 7274)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java 2008-12-10 15:10:12 UTC (rev 7275)
@@ -37,6 +37,33 @@
*/
public interface Cache<K, V> extends ConcurrentMap<K, V>, Lifecycle
{
+ /**
+ * Under special operating behavior, associates the value with the specified key.
+ * <ul>
+ * <li> Only goes through if the key specified does not exist; no-op otherwise (similar to {@link java.util.concurrent.ConcurrentMap#replace(Object, Object)})</i>
+ * <li> Force asynchronous mode for replication to prevent any blocking.</li>
+ * <li> invalidation does not take place. </li>
+ * <li> 0ms lock timeout to prevent any blocking here either. If the lock is not acquired, this method is a no-op, and swallows the timeout exception.</li>
+ * <li> Ongoing transactions are suspended before this call, so failures here will not affect any ongoing transactions.</li>
+ * <li> Errors and exceptions are 'silent' - logged at a much lower level than normal, and this method does not throw exceptions</li>
+ * </ul>
+ * This method is for caching data that has an external representation in storage, where, concurrent modification and
+ * transactions are not a consideration, and failure to put the data in the cache should be treated as a 'suboptimal outcome'
+ * rather than a 'failing outcome'.
+ * <p/>
+ * An example of when this method is useful is when data is read from, for example, a legacy datastore, and is cached before
+ * returning the data to the caller. Subsequent calls would prefer to get the data from the cache and if the data doesn't exist
+ * in the cache, fetch again from the legacy datastore.
+ * <p/>
+ * See <a href="http://jira.jboss.com/jira/browse/JBCACHE-848">JBCACHE-848</a> for details around this feature.
+ * <p/>
+ *
+ * @param key key with which the specified value is to be associated.
+ * @param value value to be associated with the specified key.
+ * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link org.jboss.cache.CacheStatus#STARTED}.
+ */
+ void putForExternalRead(K key, V value);
+
void evict(K key);
Configuration getConfiguration();
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java 2008-12-10 12:51:42 UTC (rev 7274)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java 2008-12-10 15:10:12 UTC (rev 7275)
@@ -21,6 +21,8 @@
*/
package org.jboss.starobrno;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheStatus;
import org.jboss.cache.Version;
import org.jboss.cache.buddyreplication.BuddyManager;
@@ -79,6 +81,7 @@
private EvictionManager evictionManager;
private DataContainer dataContainer;
private LockManager lockManager;
+ private static final Log log = LogFactory.getLog(CacheDelegate.class);
@Inject
@@ -131,7 +134,7 @@
public V replace(K key, V value)
{
- ReplaceCommand command = commandsFactory.buildReplaceCommand(key, value, null);
+ ReplaceCommand command = commandsFactory.buildReplaceCommand(key, null, value);
return (V) invoker.invoke(buildCtx(), command);
}
@@ -206,6 +209,40 @@
throw new UnsupportedOperationException("Go away");
}
+ public void putForExternalRead(K key, V value)
+ {
+ InvocationContext ctx = invocationContextContainer.get();
+ Transaction ongoingTransaction = null;
+ try
+ {
+ if (transactionManager != null && (ongoingTransaction = transactionManager.getTransaction()) != null)
+ {
+ transactionManager.suspend();
+ }
+
+ // if the node exists then this should be a no-op.
+ ctx.getOptionOverrides().setFailSilently(true);
+ ctx.getOptionOverrides().setForceAsynchronous(true);
+ ctx.getOptionOverrides().setLockAcquisitionTimeout(0);
+ replace(key, value);
+ }
+ catch (Exception e)
+ {
+ if (log.isDebugEnabled()) log.debug("Caught exception while doing putForExternalRead()", e);
+ }
+ finally
+ {
+ try
+ {
+ if (ongoingTransaction != null) transactionManager.resume(ongoingTransaction);
+ }
+ catch (Exception e)
+ {
+ log.debug("Had problems trying to resume a transaction after putForExternalread()", e);
+ }
+ }
+ }
+
public void evict(K key)
{
EvictCommand command = commandsFactory.buildEvictCommand(key);
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java 2008-12-10 12:51:42 UTC (rev 7274)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java 2008-12-10 15:10:12 UTC (rev 7275)
@@ -79,7 +79,7 @@
{
notifier.notifyCacheEntryModified(key, true, ctx);
MVCCEntry e = ctx.lookupEntry(key);
- Object o = null;
+ Object o;
if (value instanceof Delta)
{
// magic
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/ReplaceCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/ReplaceCommand.java 2008-12-10 12:51:42 UTC (rev 7274)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/ReplaceCommand.java 2008-12-10 15:10:12 UTC (rev 7275)
@@ -57,7 +57,7 @@
{
MVCCEntry e = ctx.lookupEntry(key);
if (e == null || e.isNullEntry()) return false;
- if (oldValue.equals(e.getValue()))
+ if (oldValue == null || oldValue.equals(e.getValue()))
{
e.setValue(newValue);
return true;
Modified: core/branches/flat/src/test/java/org/jboss/starobrno/api/mvcc/read_committed/ReadCommittedLockTest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/api/mvcc/read_committed/ReadCommittedLockTest.java 2008-12-10 12:51:42 UTC (rev 7274)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/api/mvcc/read_committed/ReadCommittedLockTest.java 2008-12-10 15:10:12 UTC (rev 7275)
@@ -14,7 +14,7 @@
repeatableRead = false;
}
- public void testVisibilityOfCommittedData() throws Exception
+ public void testVisibilityOfCommittedDataPut() throws Exception
{
Cache c = threadLocal.get().cache;
c.put("k", "v");
@@ -42,4 +42,33 @@
assert "v2".equals(c.get("k")) : "Should read committed data";
threadLocal.get().tm.commit();
}
+
+ public void testVisibilityOfCommittedDataReplace() throws Exception
+ {
+ Cache c = threadLocal.get().cache;
+ c.put("k", "v");
+
+ assert "v".equals(c.get("k"));
+
+ // start a tx and read K
+ threadLocal.get().tm.begin();
+ assert "v".equals(c.get("k"));
+ assert "v".equals(c.get("k"));
+ Transaction reader = threadLocal.get().tm.suspend();
+
+ threadLocal.get().tm.begin();
+ c.replace("k", "v2");
+ Transaction writer = threadLocal.get().tm.suspend();
+
+ threadLocal.get().tm.resume(reader);
+ assert "v".equals(c.get("k")) : "Should not read uncommitted data";
+ reader = threadLocal.get().tm.suspend();
+
+ threadLocal.get().tm.resume(writer);
+ threadLocal.get().tm.commit();
+
+ threadLocal.get().tm.resume(reader);
+ assert "v2".equals(c.get("k")) : "Should read committed data";
+ threadLocal.get().tm.commit();
+ }
}
Modified: core/branches/flat/src/test/java/org/jboss/starobrno/profiling/ProfileTest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/profiling/ProfileTest.java 2008-12-10 12:51:42 UTC (rev 7274)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/profiling/ProfileTest.java 2008-12-10 15:10:12 UTC (rev 7275)
@@ -5,16 +5,14 @@
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.starobrno.Cache;
import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.profiling.testinternals.Generator;
+import org.jboss.starobrno.profiling.testinternals.TaskRunner;
import org.jboss.starobrno.util.TestingUtil;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.Random;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
/**
@@ -44,7 +42,6 @@
protected static final boolean USE_SLEEP = false; // throttle generation a bit
private List<Object> keys = new ArrayList<Object>(MAX_OVERALL_KEYS);
- private Random r = new Random();
Log log = LogFactory.getLog(ProfileTest.class);
@@ -54,7 +51,7 @@
Cache c = (Cache) cache;
c.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
c.getConfiguration().setConcurrencyLevel(2000);
- c.getConfiguration().setIsolationLevel(IsolationLevel.READ_COMMITTED);
+ c.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
runCompleteTest();
}
@@ -80,8 +77,13 @@
keys.clear();
for (int i = 0; i < MAX_OVERALL_KEYS; i++)
{
- Object key = createRandomKey(r);
- while (keys.contains(key)) key = createRandomKey(r);
+ Object key;
+ do
+ {
+ key = Generator.createRandomKey();
+ }
+ while (keys.contains(key));
+
if (i % 10 == 0)
{
log.warn("Generated " + i + " keys");
@@ -93,12 +95,7 @@
log.warn("Finished init() phase. " + printDuration(duration));
}
- private Object createRandomKey(Random r)
- {
- return Integer.toHexString(r.nextInt(Integer.MAX_VALUE));
- }
-
protected void startup()
{
long startTime = System.currentTimeMillis();
@@ -111,7 +108,7 @@
private void warmup() throws InterruptedException
{
long startTime = System.currentTimeMillis();
- ExecutorService exec = Executors.newFixedThreadPool(NUM_THREADS);
+ TaskRunner exec = new TaskRunner(NUM_THREADS);
log.warn("Starting warmup");
// creates all the Fqns since this can be expensive and we don't really want to measure this (for now)
for (final Object key : keys)
@@ -133,7 +130,7 @@
{
public void run()
{
- Object key = keys.get(r.nextInt(MAX_OVERALL_KEYS));
+ Object key = Generator.getRandomElement(keys);
cache.get(key);
cache.put(key, "Value");
cache.remove(key);
@@ -141,8 +138,7 @@
});
}
- exec.shutdown();
- exec.awaitTermination(360, TimeUnit.SECONDS);
+ exec.stop();
long duration = System.currentTimeMillis() - startTime;
log.warn("Finished warmup. " + printDuration(duration));
@@ -154,7 +150,7 @@
private void doTest() throws Exception
{
- ExecutorService exec = Executors.newFixedThreadPool(NUM_THREADS);
+ TaskRunner exec = new TaskRunner(NUM_THREADS);
log.warn("Starting test");
int i;
long print = NUM_OPERATIONS / 10;
@@ -187,11 +183,7 @@
}
log.warn("Finished generating runnables; awaiting executor completion");
// wait for executors to complete!
- exec.shutdown();
- while (!exec.awaitTermination(((long) i), TimeUnit.SECONDS))
- {
- Thread.sleep(1);
- }
+ exec.stop();
// wait up to 1 sec for each call?
long elapsedTimeNanos = System.nanoTime() - stElapsed;
@@ -229,12 +221,12 @@
public void run()
{
- Object key = keys.get(r.nextInt(MAX_OVERALL_KEYS));
+ Object key = Generator.getRandomElement(keys);
long d = 0, st = 0;
switch (mode)
{
case PUT:
- Object value = getRandomString();
+ Object value = Generator.getRandomString();
st = System.nanoTime();
cache.put(key, value);
d = System.nanoTime() - st;
@@ -284,18 +276,6 @@
}
}
- private String getRandomString()
- {
- StringBuilder sb = new StringBuilder();
- int len = r.nextInt(10);
-
- for (int i = 0; i < len; i++)
- {
- sb.append((char) (63 + r.nextInt(26)));
- }
- return sb.toString();
- }
-
protected String printDuration(long duration)
{
if (duration > 2000)
Modified: core/branches/flat/src/test/java/org/jboss/starobrno/profiling/TreeProfileTest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/profiling/TreeProfileTest.java 2008-12-10 12:51:42 UTC (rev 7274)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/profiling/TreeProfileTest.java 2008-12-10 15:10:12 UTC (rev 7275)
@@ -60,7 +60,7 @@
cfg.setConcurrencyLevel(2000);
cfg.setLockAcquisitionTimeout(120000);
cfg.setLockParentForChildInsertRemove(true);
- cfg.setIsolationLevel(IsolationLevel.READ_COMMITTED);
+ cfg.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
Cache c = new UnitTestCacheFactory().createCache(cfg);
cache = new TreeCacheImpl(c);
}
Modified: core/branches/flat/src/test/java/org/jboss/starobrno/profiling/testinternals/Generator.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/profiling/testinternals/Generator.java 2008-12-10 12:51:42 UTC (rev 7274)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/profiling/testinternals/Generator.java 2008-12-10 15:10:12 UTC (rev 7275)
@@ -33,4 +33,9 @@
for (int i = 0; i < depth; i++) fqnElements.add(Integer.toHexString(r.nextInt(Integer.MAX_VALUE)));
return Fqn.fromList(fqnElements, true);
}
+
+ public static Object createRandomKey()
+ {
+ return Integer.toHexString(r.nextInt(Integer.MAX_VALUE));
+ }
}
16 years, 1 month
JBoss Cache SVN: r7274 - in core/branches/flat/src: main/java/org/jboss/starobrno/interceptors and 2 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-12-10 07:51:42 -0500 (Wed, 10 Dec 2008)
New Revision: 7274
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/context/EntryLookup.java
core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContextImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/LockingInterceptor.java
core/branches/flat/src/test/java/org/jboss/starobrno/api/mvcc/read_committed/ReadCommittedLockTest.java
core/branches/flat/src/test/java/org/jboss/starobrno/profiling/TreeProfileTest.java
Log:
Perf improvements + added tests
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/context/EntryLookup.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/context/EntryLookup.java 2008-12-10 11:04:37 UTC (rev 7273)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/context/EntryLookup.java 2008-12-10 12:51:42 UTC (rev 7274)
@@ -41,5 +41,7 @@
void putLookedUpEntries(Map<Object, MVCCEntry> lookedUpEntries);
+ void removeLookedUpEntry(Object key);
+
void clearLookedUpEntries();
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContextImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContextImpl.java 2008-12-10 11:04:37 UTC (rev 7273)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContextImpl.java 2008-12-10 12:51:42 UTC (rev 7274)
@@ -28,9 +28,13 @@
import org.jboss.starobrno.container.MVCCEntry;
import org.jboss.starobrno.transaction.GlobalTransaction;
import org.jboss.starobrno.transaction.TransactionTable;
+import org.jboss.starobrno.util.FastCopyHashMap;
import javax.transaction.Transaction;
-import java.util.*;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
/**
* // TODO: MANIK: Document this
@@ -59,15 +63,15 @@
* once we drop support for opt/pess locks we can genericise this to contain Fqns. - Manik Surtani, June 2008
*/
protected LinkedHashSet<Object> invocationLocks;
- private HashMap<Object, MVCCEntry> lookedUpEntries = null;
+ private FastCopyHashMap<Object, MVCCEntry> lookedUpEntries = null;
/**
* Retrieves a node from the registry of looked up nodes in the current scope.
* <p/>
- * If a transaction is in progress, implementations should delegate to {@link org.jboss.cache.transaction.MVCCTransactionContext#lookUpNode(Fqn)}
+ * If a transaction is in progress, implementations should delegate to {@link org.jboss.starobrno.context.TransactionContext#lookupEntry(Object)}
* <p/>
*
- * @param fqn fqn to look up
+ * @param k key to look up
* @return a node, or null if it cannot be found.
*/
public MVCCEntry lookupEntry(Object k)
@@ -82,10 +86,22 @@
}
}
+ public void removeLookedUpEntry(Object key)
+ {
+ if (transactionContext != null)
+ {
+ transactionContext.removeLookedUpEntry(key);
+ }
+ else
+ {
+ if (lookedUpEntries != null) lookedUpEntries.remove(key);
+ }
+ }
+
/**
* Puts an entry in the registry of looked up nodes in the current scope.
* <p/>
- * If a transaction is in progress, implementations should delegate to {@link org.jboss.cache.transaction.MVCCTransactionContext#putLookedUpNode(Fqn, NodeSPI)}
+ * If a transaction is in progress, implementations should delegate to {@link TransactionContext#putLookedUpEntry(Object, org.jboss.starobrno.container.MVCCEntry)}
* <p/>
*
* @param key
@@ -96,7 +112,7 @@
transactionContext.putLookedUpEntry(key, e);
else
{
- if (lookedUpEntries == null) lookedUpEntries = new HashMap<Object, MVCCEntry>(4);
+ if (lookedUpEntries == null) lookedUpEntries = new FastCopyHashMap<Object, MVCCEntry>(4);
lookedUpEntries.put(key, e);
}
}
@@ -108,7 +124,7 @@
else
{
if (this.lookedUpEntries == null)
- this.lookedUpEntries = new HashMap<Object, MVCCEntry>();
+ this.lookedUpEntries = new FastCopyHashMap<Object, MVCCEntry>();
this.lookedUpEntries.putAll(lookedUpEntries);
}
@@ -142,7 +158,7 @@
{
InvocationContextImpl copy = new InvocationContextImpl();
doCopy(copy);
- if (lookedUpEntries != null) copy.lookedUpEntries = (HashMap<Object, MVCCEntry>) lookedUpEntries.clone();
+ if (lookedUpEntries != null) copy.lookedUpEntries = (FastCopyHashMap<Object, MVCCEntry>) lookedUpEntries.clone();
return copy;
}
@@ -314,9 +330,6 @@
* Note that if a transaction is in scope, implementations should record this lock on the {@link org.jboss.cache.transaction.TransactionContext}.
* Using this method should always ensure that the appropriate scope is used.
* <p/>
- * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses {@link Fqn}s as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for
- * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link Fqn}.
*
* @param lock lock to add
*/
@@ -342,9 +355,6 @@
* Note that if a transaction is in scope, implementations should remove this lock from the {@link org.jboss.cache.transaction.TransactionContext}.
* Using this method should always ensure that the lock is removed from the appropriate scope.
* <p/>
- * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses {@link Fqn}s as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for
- * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link Fqn}.
*
* @param lock lock to remove
*/
@@ -369,9 +379,6 @@
* Note that if a transaction is in scope, implementations should clear locks from the {@link org.jboss.cache.transaction.TransactionContext}.
* Using this method should always ensure locks are cleared in the appropriate scope.
* <p/>
- * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses {@link Fqn}s as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for
- * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link Fqn}.
*/
public void clearKeysLocked()
{
@@ -408,7 +415,7 @@
}
/**
- * @return true if options exist to suppress locking - false otherwise. Note that this is only used by the {@link org.jboss.cache.interceptors.PessimisticLockInterceptor}.
+ * @return true if options exist to suppress locking - false otherwise.
*/
public boolean isLockingSuppressed()
{
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java 2008-12-10 11:04:37 UTC (rev 7273)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java 2008-12-10 12:51:42 UTC (rev 7274)
@@ -26,6 +26,7 @@
import org.jboss.starobrno.config.Option;
import org.jboss.starobrno.container.MVCCEntry;
import org.jboss.starobrno.transaction.GlobalTransaction;
+import org.jboss.starobrno.util.FastCopyHashMap;
import javax.transaction.RollbackException;
import javax.transaction.SystemException;
@@ -77,7 +78,7 @@
*/
private List<Object> removedNodes = null;
- private final Map<Object, MVCCEntry> lookedUpEntries = new HashMap<Object, MVCCEntry>(8);
+ private final FastCopyHashMap<Object, MVCCEntry> lookedUpEntries = new FastCopyHashMap<Object, MVCCEntry>(8);
private GlobalTransaction gtx;
public TransactionContextImpl(Transaction tx) throws SystemException, RollbackException
@@ -100,6 +101,11 @@
return lookedUpEntries.get(key);
}
+ public void removeLookedUpEntry(Object key)
+ {
+ lookedUpEntries.remove(key);
+ }
+
/**
* Puts an entry in the registry of looked up nodes in the current scope.
* <p/>
@@ -107,7 +113,7 @@
* would delegate to this method if a transaction is in scope.
* <p/>
*
- * @param key
+ * @param key key to put
*/
public void putLookedUpEntry(Object key, MVCCEntry entry)
{
@@ -290,7 +296,7 @@
public String toString()
{
StringBuilder sb = new StringBuilder();
- sb.append("TransactionContext (" + System.identityHashCode(this) + ") nmodificationList: ").append(modificationList);
+ sb.append("TransactionContext (").append(System.identityHashCode(this)).append(") nmodificationList: ").append(modificationList);
return sb.toString();
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/LockingInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/LockingInterceptor.java 2008-12-10 11:04:37 UTC (rev 7273)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/LockingInterceptor.java 2008-12-10 12:51:42 UTC (rev 7274)
@@ -22,6 +22,7 @@
package org.jboss.starobrno.interceptors;
import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.starobrno.commands.TransactionBoundaryCommand;
import org.jboss.starobrno.commands.VisitableCommand;
import org.jboss.starobrno.commands.read.GetKeyValueCommand;
import org.jboss.starobrno.commands.read.GravitateDataCommand;
@@ -39,10 +40,10 @@
import org.jboss.starobrno.interceptors.base.PrePostProcessingCommandInterceptor;
import org.jboss.starobrno.lock.LockManager;
-import java.util.HashSet;
+import java.util.HashMap;
import java.util.List;
import java.util.ListIterator;
-import java.util.Set;
+import java.util.Map;
/**
* Interceptor to implement <a href="http://wiki.jboss.org/wiki/JBossCacheMVCC">MVCC</a> functionality.
@@ -213,23 +214,18 @@
}
else
{
- if (useReadCommitted)
+ if (useReadCommitted && !(command instanceof TransactionBoundaryCommand))
{
- if (trace) log.trace("Wiping unnecessary entries from context");
- // wipe all unchanged entries from context, to force subsequent reads to go to the container,
- // hence providing R_C semantics.
- Set<Object> keysToRemove = new HashSet<Object>();
- for (MVCCEntry e : ctx.getLookedUpEntries().values())
+ Map<Object, MVCCEntry> original = ctx.getLookedUpEntries();
+ if (!original.isEmpty())
{
- if (!e.isChanged()) keysToRemove.add(e.getKey());
+ Map<Object, MVCCEntry> defensiveCopy = new HashMap<Object, MVCCEntry>(original);
+ for (Map.Entry<Object, MVCCEntry> e : defensiveCopy.entrySet())
+ {
+ if (!e.getValue().isChanged()) ctx.removeLookedUpEntry(e.getKey());
+ }
}
- for (Object k : keysToRemove) ctx.removeKeyLocked(k);
}
- else
- {
- if (trace) log.trace("Nothing to do since there is a transaction in scope.");
- }
-
}
}
Modified: core/branches/flat/src/test/java/org/jboss/starobrno/api/mvcc/read_committed/ReadCommittedLockTest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/api/mvcc/read_committed/ReadCommittedLockTest.java 2008-12-10 11:04:37 UTC (rev 7273)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/api/mvcc/read_committed/ReadCommittedLockTest.java 2008-12-10 12:51:42 UTC (rev 7274)
@@ -1,8 +1,11 @@
package org.jboss.starobrno.api.mvcc.read_committed;
+import org.jboss.starobrno.Cache;
import org.jboss.starobrno.api.mvcc.LockTestBase;
import org.testng.annotations.Test;
+import javax.transaction.Transaction;
+
@Test(groups = {"functional", "mvcc"})
public class ReadCommittedLockTest extends LockTestBase
{
@@ -10,4 +13,33 @@
{
repeatableRead = false;
}
+
+ public void testVisibilityOfCommittedData() throws Exception
+ {
+ Cache c = threadLocal.get().cache;
+ c.put("k", "v");
+
+ assert "v".equals(c.get("k"));
+
+ // start a tx and read K
+ threadLocal.get().tm.begin();
+ assert "v".equals(c.get("k"));
+ assert "v".equals(c.get("k"));
+ Transaction reader = threadLocal.get().tm.suspend();
+
+ threadLocal.get().tm.begin();
+ c.put("k", "v2");
+ Transaction writer = threadLocal.get().tm.suspend();
+
+ threadLocal.get().tm.resume(reader);
+ assert "v".equals(c.get("k")) : "Should not read uncommitted data";
+ reader = threadLocal.get().tm.suspend();
+
+ threadLocal.get().tm.resume(writer);
+ threadLocal.get().tm.commit();
+
+ threadLocal.get().tm.resume(reader);
+ assert "v2".equals(c.get("k")) : "Should read committed data";
+ threadLocal.get().tm.commit();
+ }
}
Modified: core/branches/flat/src/test/java/org/jboss/starobrno/profiling/TreeProfileTest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/profiling/TreeProfileTest.java 2008-12-10 11:04:37 UTC (rev 7273)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/profiling/TreeProfileTest.java 2008-12-10 12:51:42 UTC (rev 7274)
@@ -42,10 +42,10 @@
Test configuration options
*/
protected static final long NUM_OPERATIONS = 1000000; // DURATION is replaced with a fixed number of operations instead.
- protected static final int NUM_THREADS = 50;
+ protected static final int NUM_THREADS = 25;
protected static final int MAX_RANDOM_SLEEP_MILLIS = 1;
- protected static final int MAX_OVERALL_FQNS = 2000;
- protected static final int TREE_DEPTH = 2;
+ protected static final int MAX_DEPTH = 3;
+ protected static final int MAX_OVERALL_NODES = 2000;
protected static final int WARMUP_LOOPS = 20000;
protected static final boolean USE_SLEEP = false; // throttle generation a bit
@@ -60,7 +60,7 @@
cfg.setConcurrencyLevel(2000);
cfg.setLockAcquisitionTimeout(120000);
cfg.setLockParentForChildInsertRemove(true);
- cfg.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ cfg.setIsolationLevel(IsolationLevel.READ_COMMITTED);
Cache c = new UnitTestCacheFactory().createCache(cfg);
cache = new TreeCacheImpl(c);
}
@@ -72,7 +72,7 @@
cache = null;
}
- private List<Fqn> fqns = new ArrayList<Fqn>(MAX_OVERALL_FQNS);
+ private List<Fqn> fqns = new ArrayList<Fqn>(MAX_OVERALL_NODES);
Log log = LogFactory.getLog(TreeProfileTest.class);
@@ -102,12 +102,12 @@
long startTime = System.currentTimeMillis();
log.warn("Starting init() phase");
fqns.clear();
- for (int i = 0; i < MAX_OVERALL_FQNS; i++)
+ for (int i = 0; i < MAX_OVERALL_NODES; i++)
{
Fqn fqn;
do
{
- fqn = Generator.createRandomFqn(TREE_DEPTH);
+ fqn = Generator.createRandomFqn(MAX_DEPTH);
}
while (fqns.contains(fqn));
16 years, 1 month
JBoss Cache SVN: r7273 - benchmarks/benchmark-fwk/trunk.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-12-10 06:04:37 -0500 (Wed, 10 Dec 2008)
New Revision: 7273
Modified:
benchmarks/benchmark-fwk/trunk/build.xml
Log:
Fixed typo
Modified: benchmarks/benchmark-fwk/trunk/build.xml
===================================================================
--- benchmarks/benchmark-fwk/trunk/build.xml 2008-12-09 18:17:00 UTC (rev 7272)
+++ benchmarks/benchmark-fwk/trunk/build.xml 2008-12-10 11:04:37 UTC (rev 7273)
@@ -86,7 +86,7 @@
</javac>
</target>
- <target name="compile.module.ehcache159" depends="fwk"
+ <target name="compile.module.ehcache150" depends="fwk"
description="Compile module ehcache-1.5.0; production classes">
<mkdir dir="./classes/production/ehcache-1.5.0"/>
<javac destdir="./classes/production/ehcache-1.5.0" debug="${compiler.debug}"
@@ -252,7 +252,7 @@
</target>
<target name="all"
- depends="clean, fwk, compile.module.jbosscache140, compile.module.jbosscache200, compile.module.pojocache220, compile.module.jbosscache210, compile.module.jbosscache220, compile.module.terracotta250, compile.module.ehcache159, compile.module.whirlycache101, compile.module.jbosscache300, compile.module.coherence331, compile.module.starobrno"
+ depends="clean, fwk, compile.module.jbosscache140, compile.module.jbosscache200, compile.module.pojocache220, compile.module.jbosscache210, compile.module.jbosscache220, compile.module.terracotta250, compile.module.ehcache150, compile.module.whirlycache101, compile.module.jbosscache300, compile.module.coherence331, compile.module.starobrno"
description="build all"/>
<target name="checkClusterAddresses" depends="fwk"
16 years, 1 month
JBoss Cache SVN: r7272 - in core/branches/flat/src/test/java/org/jboss/starobrno/profiling: testinternals and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-12-09 13:17:00 -0500 (Tue, 09 Dec 2008)
New Revision: 7272
Added:
core/branches/flat/src/test/java/org/jboss/starobrno/profiling/testinternals/
core/branches/flat/src/test/java/org/jboss/starobrno/profiling/testinternals/Generator.java
core/branches/flat/src/test/java/org/jboss/starobrno/profiling/testinternals/TaskRunner.java
Modified:
core/branches/flat/src/test/java/org/jboss/starobrno/profiling/TreeProfileTest.java
Log:
Improved test harness
Modified: core/branches/flat/src/test/java/org/jboss/starobrno/profiling/TreeProfileTest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/profiling/TreeProfileTest.java 2008-12-09 18:06:59 UTC (rev 7271)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/profiling/TreeProfileTest.java 2008-12-09 18:17:00 UTC (rev 7272)
@@ -7,6 +7,8 @@
import org.jboss.starobrno.Cache;
import org.jboss.starobrno.UnitTestCacheFactory;
import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.profiling.testinternals.Generator;
+import org.jboss.starobrno.profiling.testinternals.TaskRunner;
import org.jboss.starobrno.tree.Fqn;
import org.jboss.starobrno.tree.TreeCache;
import org.jboss.starobrno.tree.TreeCacheImpl;
@@ -18,10 +20,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.Random;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
/**
@@ -75,7 +73,6 @@
}
private List<Fqn> fqns = new ArrayList<Fqn>(MAX_OVERALL_FQNS);
- private Random r = new Random();
Log log = LogFactory.getLog(TreeProfileTest.class);
@@ -107,12 +104,14 @@
fqns.clear();
for (int i = 0; i < MAX_OVERALL_FQNS; i++)
{
- Fqn fqn = createRandomFqn(r);
- while (fqns.contains(fqn)) fqn = createRandomFqn(r);
- if (i % 100 == 0)
+ Fqn fqn;
+ do
{
- log.warn("Generated " + i + " fqns");
+ fqn = Generator.createRandomFqn(TREE_DEPTH);
}
+ while (fqns.contains(fqn));
+
+ if (i % 100 == 0) log.warn("Generated " + i + " fqns");
fqns.add(fqn);
}
System.gc();
@@ -120,14 +119,6 @@
log.warn("Finished init() phase. " + printDuration(duration));
}
- private Fqn createRandomFqn(Random r)
- {
- List<String> fqnElements = new ArrayList<String>(TREE_DEPTH);
- for (int i = 0; i < TREE_DEPTH; i++) fqnElements.add(Integer.toHexString(r.nextInt(Integer.MAX_VALUE)));
- return Fqn.fromList(fqnElements, true);
- }
-
-
protected void startup()
{
long startTime = System.currentTimeMillis();
@@ -140,12 +131,12 @@
private void warmup() throws InterruptedException
{
long startTime = System.currentTimeMillis();
- ExecutorService exec = Executors.newFixedThreadPool(NUM_THREADS);
+ TaskRunner runner = new TaskRunner(NUM_THREADS);
log.warn("Starting warmup");
// creates all the Fqns since this can be expensive and we don't really want to measure this (for now)
for (final Fqn fqn : fqns)
{
- exec.execute(new Runnable()
+ runner.execute(new Runnable()
{
public void run()
{
@@ -165,13 +156,13 @@
// loop through WARMUP_LOOPS gets and puts for JVM optimisation
for (int i = 0; i < WARMUP_LOOPS; i++)
{
- exec.execute(new Runnable()
+ runner.execute(new Runnable()
{
public void run()
{
try
{
- Fqn fqn = fqns.get(r.nextInt(MAX_OVERALL_FQNS));
+ Fqn fqn = Generator.getRandomElement(fqns);
DummyTransactionManager.getInstance().begin();
cache.get(fqn, "key");
DummyTransactionManager.getInstance().commit();
@@ -190,8 +181,7 @@
});
}
- exec.shutdown();
- exec.awaitTermination(360, TimeUnit.SECONDS);
+ runner.stop();
long duration = System.currentTimeMillis() - startTime;
log.warn("Finished warmup. " + printDuration(duration));
@@ -203,7 +193,8 @@
private void doTest() throws Exception
{
- ExecutorService exec = Executors.newFixedThreadPool(NUM_THREADS);
+ TaskRunner runner = new TaskRunner(NUM_THREADS);
+
log.warn("Starting test");
int i;
long print = NUM_OPERATIONS / 10;
@@ -230,17 +221,13 @@
}
if (i % print == 0)
log.warn("processing iteration " + i);
- exec.execute(r);
+ runner.execute(r);
// if (USE_SLEEP) TestingUtil.sleepRandom(MAX_RANDOM_SLEEP_MILLIS);
if (USE_SLEEP) TestingUtil.sleepThread(MAX_RANDOM_SLEEP_MILLIS);
}
log.warn("Finished generating runnables; awaiting executor completion");
// wait for executors to complete!
- exec.shutdown();
- while (!exec.awaitTermination(((long) i), TimeUnit.SECONDS))
- {
- Thread.sleep(1);
- }
+ runner.stop();
// wait up to 1 sec for each call?
long elapsedTimeNanos = System.nanoTime() - stElapsed;
@@ -278,32 +265,27 @@
public void run()
{
- Fqn fqn = fqns.get(r.nextInt(MAX_OVERALL_FQNS));
+ Fqn fqn = Generator.getRandomElement(fqns);
long d = 0, st = 0;
try
{
switch (mode)
{
case PUT:
- Object value = getRandomString();
+ Object value = Generator.getRandomString();
+
st = System.nanoTime();
- DummyTransactionManager.getInstance().begin();
cache.put(fqn, "key", value);
- DummyTransactionManager.getInstance().commit();
d = System.nanoTime() - st;
break;
case GET:
st = System.nanoTime();
- DummyTransactionManager.getInstance().begin();
cache.get(fqn, "key");
- DummyTransactionManager.getInstance().commit();
d = System.nanoTime() - st;
break;
case REMOVE:
st = System.nanoTime();
- DummyTransactionManager.getInstance().begin();
cache.remove(fqn, "key");
- DummyTransactionManager.getInstance().commit();
d = System.nanoTime() - st;
break;
}
@@ -346,18 +328,6 @@
}
}
- private String getRandomString()
- {
- StringBuilder sb = new StringBuilder();
- int len = r.nextInt(10);
-
- for (int i = 0; i < len; i++)
- {
- sb.append((char) (63 + r.nextInt(26)));
- }
- return sb.toString();
- }
-
protected String printDuration(long duration)
{
if (duration > 2000)
Added: core/branches/flat/src/test/java/org/jboss/starobrno/profiling/testinternals/Generator.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/profiling/testinternals/Generator.java (rev 0)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/profiling/testinternals/Generator.java 2008-12-09 18:17:00 UTC (rev 7272)
@@ -0,0 +1,36 @@
+package org.jboss.starobrno.profiling.testinternals;
+
+import org.jboss.starobrno.tree.Fqn;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+public class Generator
+{
+ private static final Random r = new Random();
+
+ public static String getRandomString()
+ {
+ StringBuilder sb = new StringBuilder();
+ int len = r.nextInt(10);
+
+ for (int i = 0; i < len; i++)
+ {
+ sb.append((char) (63 + r.nextInt(26)));
+ }
+ return sb.toString();
+ }
+
+ public static <T> T getRandomElement(List<T> list)
+ {
+ return list.get(r.nextInt(list.size()));
+ }
+
+ public static Fqn createRandomFqn(int depth)
+ {
+ List<String> fqnElements = new ArrayList<String>(depth);
+ for (int i = 0; i < depth; i++) fqnElements.add(Integer.toHexString(r.nextInt(Integer.MAX_VALUE)));
+ return Fqn.fromList(fqnElements, true);
+ }
+}
Added: core/branches/flat/src/test/java/org/jboss/starobrno/profiling/testinternals/TaskRunner.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/profiling/testinternals/TaskRunner.java (rev 0)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/profiling/testinternals/TaskRunner.java 2008-12-09 18:17:00 UTC (rev 7272)
@@ -0,0 +1,30 @@
+package org.jboss.starobrno.profiling.testinternals;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Essentially a delegate to an ExecutorService, but a special one that is only used by perf tests so it can be ignored
+ * when profiling.
+ */
+public class TaskRunner
+{
+ ExecutorService exec;
+
+ public TaskRunner(int numThreads)
+ {
+ this.exec = Executors.newFixedThreadPool(numThreads);
+ }
+
+ public void execute(Runnable r)
+ {
+ exec.execute(r);
+ }
+
+ public void stop() throws InterruptedException
+ {
+ exec.shutdown();
+ while (!exec.awaitTermination(30, TimeUnit.SECONDS)) Thread.sleep(30);
+ }
+}
16 years, 1 month
JBoss Cache SVN: r7271 - in core/branches/flat/src/main/java/org/jboss: starobrno/atomic and 5 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-12-09 13:06:59 -0500 (Tue, 09 Dec 2008)
New Revision: 7271
Modified:
core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionTable.java
core/branches/flat/src/main/java/org/jboss/starobrno/atomic/AtomicHashMap.java
core/branches/flat/src/main/java/org/jboss/starobrno/atomic/AtomicHashMapProxy.java
core/branches/flat/src/main/java/org/jboss/starobrno/batch/AutoBatchSupport.java
core/branches/flat/src/main/java/org/jboss/starobrno/batch/BatchContainer.java
core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java
core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/BaseTransactionalContextInterceptor.java
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InvocationContextInterceptor.java
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/TxInterceptor.java
core/branches/flat/src/main/java/org/jboss/starobrno/transaction/TransactionTable.java
core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeCacheImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeStructureSupport.java
Log:
better batch handling
Modified: core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionTable.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionTable.java 2008-12-09 18:03:13 UTC (rev 7270)
+++ core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionTable.java 2008-12-09 18:06:59 UTC (rev 7271)
@@ -226,7 +226,7 @@
StringBuilder sb = new StringBuilder();
sb.append("LocalTransactions: ").append(tx2gtxMap.size()).append("\n");
sb.append("GlobalTransactions: ").append(gtx2ContextMap.size()).append("\n");
- sb.append("tx2gtxMap:\n");
+ sb.append("txMapping:\n");
for (Map.Entry<Transaction, GlobalTransaction> entry : tx2gtxMap.entrySet())
{
sb.append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/atomic/AtomicHashMap.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/atomic/AtomicHashMap.java 2008-12-09 18:03:13 UTC (rev 7270)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/atomic/AtomicHashMap.java 2008-12-09 18:06:59 UTC (rev 7271)
@@ -38,7 +38,7 @@
* @param <V>
*/
@NotThreadSafe
-public class AtomicHashMap<K, V> implements AtomicMap<K, V>, DeltaAware
+public class AtomicHashMap<K, V> implements AtomicMap<K, V>, DeltaAware, Cloneable
{
FastCopyHashMap<K, V> delegate;
AtomicHashMapDelta delta = null;
@@ -162,10 +162,18 @@
public AtomicHashMap copyForWrite()
{
- AtomicHashMap clone = new AtomicHashMap();
- clone.delegate = (FastCopyHashMap) delegate.clone();
- clone.proxy = proxy;
- return clone;
+ try
+ {
+ AtomicHashMap clone = (AtomicHashMap) super.clone();
+ clone.delegate = (FastCopyHashMap) delegate.clone();
+ clone.proxy = proxy;
+ return clone;
+ }
+ catch (CloneNotSupportedException e)
+ {
+ // should never happen!!
+ throw new RuntimeException(e);
+ }
}
@Override
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/atomic/AtomicHashMapProxy.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/atomic/AtomicHashMapProxy.java 2008-12-09 18:03:13 UTC (rev 7270)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/atomic/AtomicHashMapProxy.java 2008-12-09 18:06:59 UTC (rev 7271)
@@ -43,7 +43,6 @@
{
this.cache = cache;
this.deltaMapKey = deltaMapKey;
- assertBatchingSupported(cache.getConfiguration());
this.batchContainer = ((CacheSPI) cache).getBatchContainer();
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/batch/AutoBatchSupport.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/batch/AutoBatchSupport.java 2008-12-09 18:03:13 UTC (rev 7270)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/batch/AutoBatchSupport.java 2008-12-09 18:06:59 UTC (rev 7271)
@@ -33,14 +33,6 @@
@NotThreadSafe
public abstract class AutoBatchSupport
{
- ThreadLocal<BatchDetails> batchDetails = new ThreadLocal<BatchDetails>()
- {
- @Override
- protected BatchDetails initialValue()
- {
- return new BatchDetails();
- }
- };
protected BatchContainer batchContainer;
protected void assertBatchingSupported(Configuration c)
@@ -51,26 +43,11 @@
protected void startAtomic()
{
- BatchDetails bd = batchDetails.get();
- if (!bd.startedBatch) bd.startedBatch = batchContainer.startBatch(true);
- bd.invocationCount++;
+ batchContainer.startBatch(true);
}
protected void endAtomic()
{
- BatchDetails bd = batchDetails.get();
- bd.invocationCount--;
- if (bd.startedBatch && bd.invocationCount == 0)
- {
- batchContainer.endBatch(true, true);
- bd.startedBatch = false;
- }
+ batchContainer.endBatch(true, true);
}
-
- private static class BatchDetails
- {
- boolean startedBatch;
- // this count is to deal with reentrancy from within the same class
- int invocationCount;
- }
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/batch/BatchContainer.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/batch/BatchContainer.java 2008-12-09 18:03:13 UTC (rev 7270)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/batch/BatchContainer.java 2008-12-09 18:06:59 UTC (rev 7271)
@@ -37,13 +37,12 @@
public class BatchContainer
{
TransactionManager transactionManager;
- private ThreadLocal<Transaction> batchTransactionContainer = new ThreadLocal<Transaction>();
- private ThreadLocal<Boolean> suspendTxAfterInvocation = new ThreadLocal<Boolean>()
+ private ThreadLocal<BatchDetails> batchDetails = new ThreadLocal<BatchDetails>()
{
@Override
- protected Boolean initialValue()
+ protected BatchDetails initialValue()
{
- return false;
+ return new BatchDetails();
}
};
@@ -66,17 +65,21 @@
public boolean startBatch(boolean autoBatch) throws CacheException
{
+ BatchDetails bd = batchDetails.get();
try
{
- if (transactionManager.getTransaction() == null && batchTransactionContainer.get() == null)
+ bd.invocationCount++;
+ if (transactionManager.getTransaction() == null && bd.tx == null)
{
transactionManager.begin();
- suspendTxAfterInvocation.set(!autoBatch);
+ bd.suspendTxAfterInvocation = !autoBatch;
+ // do not suspend if this is from an AutoBatch!
if (autoBatch)
- batchTransactionContainer.set(transactionManager.getTransaction());
+ bd.tx = transactionManager.getTransaction();
else
- batchTransactionContainer.set(transactionManager.suspend()); // do not suspend if this is from an AutoBatch!
+ bd.tx = transactionManager.suspend();
+
return true;
}
return false;
@@ -85,6 +88,10 @@
{
throw new CacheException("Unable to start batch", e);
}
+ finally
+ {
+ batchDetails.set(bd);
+ }
}
public void endBatch(boolean success)
@@ -94,46 +101,61 @@
public void endBatch(boolean autoBatch, boolean success)
{
- Transaction tx = batchTransactionContainer.get();
- if (tx == null) return;
- Transaction existingTx = null;
- try
+ BatchDetails bd = batchDetails.get();
+ if (bd.tx == null) return;
+ if (autoBatch) bd.invocationCount--;
+ if (!autoBatch || bd.invocationCount == 0)
{
- existingTx = transactionManager.getTransaction();
+ Transaction existingTx = null;
+ try
+ {
+ existingTx = transactionManager.getTransaction();
- if ((existingTx == null && !autoBatch) || !tx.equals(existingTx))
- transactionManager.resume(tx);
+ if ((existingTx == null && !autoBatch) || !bd.tx.equals(existingTx))
+ transactionManager.resume(bd.tx);
- if (success)
- tx.commit();
- else
- tx.rollback();
- }
- catch (Exception e)
- {
- throw new CacheException("Unable to end batch", e);
- }
- finally
- {
- batchTransactionContainer.remove();
- try
- {
- if (!autoBatch && existingTx != null) transactionManager.resume(existingTx);
+ if (success)
+ bd.tx.commit();
+ else
+ bd.tx.rollback();
}
catch (Exception e)
{
- throw new CacheException("Failed resuming existing transaction " + existingTx, e);
+ throw new CacheException("Unable to end batch", e);
}
+ finally
+ {
+ batchDetails.remove();
+ try
+ {
+ if (!autoBatch && existingTx != null) transactionManager.resume(existingTx);
+ }
+ catch (Exception e)
+ {
+ throw new CacheException("Failed resuming existing transaction " + existingTx, e);
+ }
+ }
}
+ else
+ {
+ batchDetails.set(bd);
+ }
}
public Transaction getBatchTransaction()
{
- return batchTransactionContainer.get();
+ return batchDetails.get().tx;
}
public boolean isSuspendTxAfterInvocation()
{
- return suspendTxAfterInvocation.get();
+ return batchDetails.get().suspendTxAfterInvocation;
}
+
+ private static class BatchDetails
+ {
+ int invocationCount;
+ boolean suspendTxAfterInvocation;
+ Transaction tx;
+ }
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java 2008-12-09 18:03:13 UTC (rev 7270)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java 2008-12-09 18:06:59 UTC (rev 7271)
@@ -23,6 +23,7 @@
import org.jboss.starobrno.commands.VisitableCommand;
import org.jboss.starobrno.config.Option;
+import org.jboss.starobrno.transaction.GlobalTransaction;
import javax.transaction.Transaction;
import java.util.List;
@@ -89,6 +90,8 @@
*/
void setTransaction(Transaction tx);
+ void setGlobalTransaction(GlobalTransaction gtx);
+
/**
* Returns a local transaction associated with this context.
*
@@ -266,4 +269,6 @@
* Cleans up internal state, freeing up references.
*/
void reset();
+
+ GlobalTransaction getGobalTransaction();
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java 2008-12-09 18:03:13 UTC (rev 7270)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java 2008-12-09 18:06:59 UTC (rev 7271)
@@ -25,6 +25,7 @@
import org.jboss.starobrno.commands.VisitableCommand;
import org.jboss.starobrno.config.Option;
import org.jboss.starobrno.container.MVCCEntry;
+import org.jboss.starobrno.transaction.GlobalTransaction;
import javax.transaction.RollbackException;
import javax.transaction.SystemException;
@@ -77,6 +78,7 @@
private List<Object> removedNodes = null;
private final Map<Object, MVCCEntry> lookedUpEntries = new HashMap<Object, MVCCEntry>(8);
+ private GlobalTransaction gtx;
public TransactionContextImpl(Transaction tx) throws SystemException, RollbackException
{
@@ -149,6 +151,11 @@
lookedUpEntries.clear();
}
+ public GlobalTransaction getGobalTransaction()
+ {
+ return gtx;
+ }
+
public void putLookedUpEntries(Map<Object, MVCCEntry> entries)
{
lookedUpEntries.putAll(entries);
@@ -199,6 +206,11 @@
ltx = tx;
}
+ public void setGlobalTransaction(GlobalTransaction gtx)
+ {
+ this.gtx = gtx;
+ }
+
public Transaction getTransaction()
{
return ltx;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/BaseTransactionalContextInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/BaseTransactionalContextInterceptor.java 2008-12-09 18:03:13 UTC (rev 7270)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/BaseTransactionalContextInterceptor.java 2008-12-09 18:06:59 UTC (rev 7271)
@@ -21,7 +21,6 @@
*/
package org.jboss.starobrno.interceptors;
-import org.jboss.starobrno.config.Option;
import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.context.TransactionContext;
import org.jboss.starobrno.factories.annotations.Inject;
@@ -51,19 +50,6 @@
this.txTable = txTable;
}
- protected void copyInvocationScopeOptionsToTxScope(InvocationContext ctx)
- {
- // notify the transaction tCtx that this override is in place.
- TransactionContext tCtx = txTable.get(ctx.getGlobalTransaction());
- if (tCtx != null)
- {
- Option txScopeOption = new Option();
- txScopeOption.setCacheModeLocal(ctx.getOptionOverrides() != null && ctx.getOptionOverrides().isCacheModeLocal());
- txScopeOption.setSkipCacheStatusCheck(ctx.getOptionOverrides() != null && ctx.getOptionOverrides().isSkipCacheStatusCheck());
- tCtx.setOption(txScopeOption);
- }
- }
-
protected void setTransactionalContext(Transaction tx, GlobalTransaction gtx, TransactionContext tCtx, InvocationContext ctx)
{
if (trace)
@@ -77,7 +63,7 @@
{
if (gtx != null)
{
- ctx.setTransactionContext(txTable.get(gtx));
+ ctx.setTransactionContext(txTable.getTransactionContext(gtx));
}
else if (tx == null)
{
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InvocationContextInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InvocationContextInterceptor.java 2008-12-09 18:03:13 UTC (rev 7270)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InvocationContextInterceptor.java 2008-12-09 18:06:59 UTC (rev 7271)
@@ -22,21 +22,18 @@
package org.jboss.starobrno.interceptors;
+import org.jboss.starobrno.RPCManager;
import org.jboss.starobrno.commands.VisitableCommand;
import org.jboss.starobrno.commands.tx.CommitCommand;
import org.jboss.starobrno.commands.tx.PrepareCommand;
import org.jboss.starobrno.commands.tx.RollbackCommand;
-import org.jboss.starobrno.commands.write.ClearCommand;
-import org.jboss.starobrno.commands.write.PutKeyValueCommand;
-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.write.*;
import org.jboss.starobrno.config.Option;
import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.context.TransactionContext;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.transaction.GlobalTransaction;
import org.jboss.starobrno.transaction.TransactionTable;
-import org.jboss.starobrno.RPCManager;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
@@ -237,4 +234,17 @@
{
return gtx != null && (gtx.getAddress() != null) && (!gtx.getAddress().equals(rpcManager.getLocalAddress()));
}
+
+ private void copyInvocationScopeOptionsToTxScope(InvocationContext ctx)
+ {
+ // notify the transaction tCtx that this override is in place.
+ TransactionContext tCtx = ctx.getTransactionContext();
+ if (tCtx != null)
+ {
+ Option txScopeOption = new Option();
+ txScopeOption.setCacheModeLocal(ctx.getOptionOverrides() != null && ctx.getOptionOverrides().isCacheModeLocal());
+ txScopeOption.setSkipCacheStatusCheck(ctx.getOptionOverrides() != null && ctx.getOptionOverrides().isSkipCacheStatusCheck());
+ tCtx.setOption(txScopeOption);
+ }
+ }
}
\ No newline at end of file
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/TxInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/TxInterceptor.java 2008-12-09 18:03:13 UTC (rev 7270)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/TxInterceptor.java 2008-12-09 18:06:59 UTC (rev 7271)
@@ -162,7 +162,7 @@
// remove from local lists.
transactions.remove(ltx);
// this tx has completed. Clean up in the tx table.
- txTable.remove(gtx, ltx);
+ txTable.cleanup(gtx);
}
if (log.isDebugEnabled()) log.debug("Finished remote rollback method for " + gtx);
}
@@ -189,7 +189,7 @@
if (ltx == null)
{
log.warn("No local transaction for this remotely originating rollback. Possibly rolling back before a prepare call was broadcast?");
- txTable.remove(gtx);
+ txTable.cleanup(gtx);
return null;
}
// disconnect if we have a current tx associated
@@ -221,7 +221,7 @@
transactions.remove(ltx);
// this tx has completed. Clean up in the tx table.
- txTable.remove(gtx, ltx);
+ txTable.cleanup(gtx);
}
if (log.isDebugEnabled()) log.debug("Finished remote commit/rollback method for " + gtx);
}
@@ -278,7 +278,7 @@
// in the invocation context
Transaction ltx = txTable.getLocalTransaction(gtx);
Transaction currentTx = txManager.getTransaction();
-
+ TransactionContext transactionContext;
Object retval = null;
boolean success = false;
try
@@ -288,8 +288,10 @@
if (currentTx != null) txManager.suspend();
// create a new local transaction
ltx = createLocalTx();
+ if (log.isDebugEnabled()) log.debug("creating new tx transactionContext");
+ transactionContext = contextFactory.createTransactionContext(ltx);
// associate this with a global tx
- txTable.put(ltx, gtx);
+ txTable.associateTransaction(ltx, gtx, transactionContext);
if (trace) log.trace("Created new tx for gtx " + gtx);
if (log.isDebugEnabled())
@@ -308,26 +310,28 @@
txManager.suspend();
txManager.resume(ltx);
}
+
+ // Asssociate the local TX with the global TX. Create new
+ // transactionContext for TX in txTable, the modifications
+ // below will need this transactionContext to add their modifications
+ // under the GlobalTx key
+ transactionContext = txTable.getTransactionContext(gtx);
+ if (transactionContext == null)
+ {
+ // create a new transaction transactionContext
+ if (log.isDebugEnabled()) log.debug("creating new tx transactionContext");
+ transactionContext = contextFactory.createTransactionContext(ltx);
+ txTable.associateTransaction(ltx, gtx, transactionContext);
+ }
}
if (trace) log.trace("Resuming existing tx " + ltx + ", global tx=" + gtx);
// at this point we have a non-null ltx
+// setTransactionalContext(ltx, gtx, transactionContext, ctx);
+ ctx.setTransactionContext(transactionContext);
+ ctx.setTransaction(ltx);
+ ctx.setGlobalTransaction(gtx);
- // Asssociate the local TX with the global TX. Create new
- // transactionContext for TX in txTable, the modifications
- // below will need this transactionContext to add their modifications
- // under the GlobalTx key
- TransactionContext transactionContext = txTable.get(gtx);
- if (transactionContext == null)
- {
- // create a new transaction transactionContext
- if (log.isDebugEnabled()) log.debug("creating new tx transactionContext");
- transactionContext = contextFactory.createTransactionContext(ltx);
- txTable.put(gtx, transactionContext);
- }
-
- setTransactionalContext(ltx, gtx, transactionContext, ctx);
-
// register a sync handler for this tx.
registerHandler(ltx, new RemoteSynchronizationHandler(gtx, ltx, transactionContext), ctx);
@@ -630,7 +634,7 @@
if (ctx.getGlobalTransaction() == null)
{
ctx.setGlobalTransaction(gtx);
- transactionContext = txTable.get(gtx);
+ transactionContext = txTable.getTransactionContext(gtx);
ctx.setTransactionContext(transactionContext);
}
else
@@ -803,8 +807,7 @@
finally
{
// clean up the tx table
- txTable.remove(gtx);
- txTable.remove(tx);
+ txTable.cleanup(gtx);
setTransactionalContext(null, null, null, ctx);
cleanupInternalState();
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/transaction/TransactionTable.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/transaction/TransactionTable.java 2008-12-09 18:03:13 UTC (rev 7270)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/transaction/TransactionTable.java 2008-12-09 18:06:59 UTC (rev 7271)
@@ -53,19 +53,15 @@
private static final boolean trace = log.isTraceEnabled();
/**
- * Mapping between local (javax.transaction.Transaction)
- * and GlobalTransactions.
- * New: a local TX can have a number of GTXs
+ * Mapping between local (javax.transaction.Transaction) and a TransactionContext
*/
- protected final Map<Transaction, GlobalTransaction> tx2gtxMap = new ConcurrentHashMap<Transaction, GlobalTransaction>();
+ protected final Map<Transaction, TransactionContext> txMapping = new ConcurrentHashMap<Transaction, TransactionContext>();
/**
- * Mappings between GlobalTransactions and modifications.
+ * Mappong between GlobalTransaction and a TransactionContext
*/
- protected final Map<GlobalTransaction, TransactionContext> gtx2ContextMap = new ConcurrentHashMap<GlobalTransaction, TransactionContext>();
+ protected final Map<GlobalTransaction, TransactionContext> gtxMapping = new ConcurrentHashMap<GlobalTransaction, TransactionContext>();
- protected final Map<GlobalTransaction, Transaction> gtx2TxMap = new ConcurrentHashMap<GlobalTransaction, Transaction>();
-
private TransactionManager transactionManager = null;
private RPCManager rpcManager;
@@ -85,7 +81,7 @@
*/
public int getNumLocalTransactions()
{
- return tx2gtxMap.size();
+ return txMapping.size();
}
/**
@@ -93,7 +89,7 @@
*/
public int getNumGlobalTransactions()
{
- return gtx2ContextMap.size();
+ return txMapping.size();
}
/**
@@ -102,26 +98,12 @@
*/
public GlobalTransaction get(Transaction tx)
{
- if (tx == null)
- return null;
- return tx2gtxMap.get(tx);
+ if (tx == null) return null;
+ TransactionContext ctx = txMapping.get(tx);
+ return ctx == null ? null : ctx.getGobalTransaction();
}
/**
- * Returns the local transaction associated with a GlobalTransaction.
- *
- * @param gtx The GlobalTransaction
- * @return Transaction. The local transaction associated with a given
- * GlobalTransaction). This will be null if no local transaction is
- * associated with a given GTX
- */
- public Transaction getLocalTransaction(GlobalTransaction gtx)
- {
- if (gtx == null) return null;
- return gtx2TxMap.get(gtx);
- }
-
- /**
* If assers exists is true and the coresponding local transaction is null an IllegalStateExcetpion is being thrown.
*/
public Transaction getLocalTransaction(GlobalTransaction gtx, boolean assertExists)
@@ -143,77 +125,36 @@
}
/**
- * Associates the global transaction with the local transaction.
+ * Associates 3 elements of a transaction - a local Transaction, a GlobalTransaction and a TransactionContext -
+ * with each other.
+ *
+ * @param tx transaction to associate
+ * @param gtx global transaction to associate
+ * @param ctx transaction context to associate
*/
- public void put(Transaction tx, GlobalTransaction gtx)
+ public void associateTransaction(Transaction tx, GlobalTransaction gtx, TransactionContext ctx)
{
- if (tx == null)
- {
- log.error("key (Transaction) is null");
- return;
- }
- tx2gtxMap.put(tx, gtx);
- gtx2TxMap.put(gtx, tx);
- }
+ if (ctx.getTransaction() == null) ctx.setTransaction(tx);
+ if (ctx.getGobalTransaction() == null) ctx.setGlobalTransaction(gtx);
- /**
- * Returns the local transaction entry for the global transaction.
- * Returns null if tx is null or it was not found.
- */
- public TransactionContext get(GlobalTransaction gtx)
- {
- return gtx != null ? gtx2ContextMap.get(gtx) : null;
+ txMapping.put(tx, ctx);
+ gtxMapping.put(gtx, ctx);
}
- /**
- * Associates the global transaction with a transaction context.
- */
- public void put(GlobalTransaction tx, TransactionContext transactionContext)
+ public Transaction getLocalTransaction(GlobalTransaction gtx)
{
- if (tx == null)
- {
- log.error("key (GlobalTransaction) is null");
- return;
- }
- gtx2ContextMap.put(tx, transactionContext);
+ TransactionContext ctx = gtxMapping.get(gtx);
+ return ctx == null ? null : ctx.getTransaction();
}
/**
- * Removes a global transation, returns the old transaction entry.
- */
- public TransactionContext remove(GlobalTransaction tx)
- {
- if (tx == null) return null;
- gtx2TxMap.remove(tx);
- return gtx2ContextMap.remove(tx);
- }
-
- /**
- * Removes a local transation, returns the global transaction entry.
- */
- public GlobalTransaction remove(Transaction tx)
- {
- if (tx == null)
- return null;
- return tx2gtxMap.remove(tx);
- }
-
- public void remove(GlobalTransaction gtx, Transaction tx)
- {
- gtx2TxMap.remove(gtx);
- gtx2ContextMap.remove(gtx);
- tx2gtxMap.remove(tx);
- }
-
- /**
* Returns summary debug information.
*/
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
- sb.append(tx2gtxMap.size()).append(" mappings, ");
- sb.append(gtx2ContextMap.size()).append(" transactions");
+ sb.append(txMapping.size()).append(" transactions");
return sb.toString();
}
@@ -225,18 +166,12 @@
if (!printDetails)
return toString();
StringBuilder sb = new StringBuilder();
- sb.append("LocalTransactions: ").append(tx2gtxMap.size()).append("\n");
- sb.append("GlobalTransactions: ").append(gtx2ContextMap.size()).append("\n");
- sb.append("tx2gtxMap:\n");
- for (Map.Entry<Transaction, GlobalTransaction> entry : tx2gtxMap.entrySet())
+ sb.append("Transactions: ").append(txMapping.size()).append("\n");
+ sb.append("mappings:\n");
+ for (Map.Entry<Transaction, TransactionContext> entry : txMapping.entrySet())
{
sb.append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
}
- sb.append("gtx2EntryMap:\n");
- for (Map.Entry<GlobalTransaction, TransactionContext> transactionContextEntry : gtx2ContextMap.entrySet())
- {
- sb.append(transactionContextEntry.getKey()).append(": ").append(transactionContextEntry.getValue()).append("\n");
- }
return sb.toString();
}
@@ -406,7 +341,6 @@
Address addr = rpcManager.getLocalAddress();
gtx = GlobalTransaction.create(addr);
if (trace) log.trace("Creating new GlobalTransaction " + gtx);
- put(tx, gtx);
TransactionContext transactionContext;
try
{
@@ -416,8 +350,7 @@
{
throw new CacheException("Unable to create a transaction entry!", e);
}
-
- put(gtx, transactionContext);
+ associateTransaction(tx, gtx, transactionContext);
if (trace)
{
log.trace("created new GTX: " + gtx + ", local TX=" + tx);
@@ -425,4 +358,15 @@
}
return gtx;
}
+
+ public TransactionContext getTransactionContext(GlobalTransaction gtx)
+ {
+ return gtxMapping.get(gtx);
+ }
+
+ public void cleanup(GlobalTransaction gtx)
+ {
+ TransactionContext ctx = gtxMapping.remove(gtx);
+ if (ctx != null) txMapping.remove(ctx.getTransaction());
+ }
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeCacheImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeCacheImpl.java 2008-12-09 18:03:13 UTC (rev 7270)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeCacheImpl.java 2008-12-09 18:06:59 UTC (rev 7271)
@@ -49,6 +49,7 @@
public TreeCacheImpl(Cache<K, V> cache)
{
super(cache);
+ assertBatchingSupported(cache.getConfiguration());
createRoot();
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeStructureSupport.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeStructureSupport.java 2008-12-09 18:03:13 UTC (rev 7270)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeStructureSupport.java 2008-12-09 18:06:59 UTC (rev 7271)
@@ -34,7 +34,6 @@
public TreeStructureSupport(Cache cache)
{
this.cache = (AtomicMapCache) cache;
- assertBatchingSupported(cache.getConfiguration());
batchContainer = ((CacheSPI) cache).getBatchContainer();
}
16 years, 1 month
JBoss Cache SVN: r7270 - core/trunk/src/main/java/org/jboss/cache/interceptors.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-12-09 13:03:13 -0500 (Tue, 09 Dec 2008)
New Revision: 7270
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java
Log:
JBCACHE-1450 - putForExternalRead() doesn't use a 0 lock acquisition timeout with MVCC
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java 2008-12-09 15:04:25 UTC (rev 7269)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java 2008-12-09 18:03:13 UTC (rev 7270)
@@ -81,7 +81,10 @@
@Override
protected boolean doBeforeCall(InvocationContext ctx, VisitableCommand command)
{
- if (ctx.getOptionOverrides().isSuppressLocking() && log.isWarnEnabled()) log.warn("Lock suppression not supported with MVCC!");
+ if (ctx.getOptionOverrides().isSuppressLocking() && log.isWarnEnabled())
+ {
+ log.warn("Lock suppression not supported with MVCC!");
+ }
return true;
}
@@ -102,6 +105,7 @@
@Override
public Object handlePutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
{
+ ctx.getOptionOverrides().setLockAcquisitionTimeout(0);
helper.wrapNodeForWriting(ctx, command.getFqn(), true, true, false, false, false); // get the node and stick it in the context.
return invokeNextInterceptor(ctx, command);
}
@@ -150,7 +154,9 @@
fqnsToEvict = new LinkedList<Fqn>();
// lock recursively.
for (InternalNode child : children.values())
+ {
fqnsToEvict.addAll(helper.wrapNodesRecursivelyForRemoval(ctx, child.getFqn()));
+ }
}
else
{
@@ -177,7 +183,9 @@
if (!children.isEmpty())
{
for (InternalNode child : children.values())
+ {
helper.wrapNodeForWriting(ctx, child.getFqn(), true, false, false, true, true);
+ }
}
}
else
16 years, 1 month