JBoss Cache SVN: r7376 - core/trunk/src/test/resources.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-05 12:18:58 -0500 (Mon, 05 Jan 2009)
New Revision: 7376
Modified:
core/trunk/src/test/resources/log4j.xml
Log:
Better log levels
Modified: core/trunk/src/test/resources/log4j.xml
===================================================================
--- core/trunk/src/test/resources/log4j.xml 2009-01-05 17:15:07 UTC (rev 7375)
+++ core/trunk/src/test/resources/log4j.xml 2009-01-05 17:18:58 UTC (rev 7376)
@@ -7,73 +7,74 @@
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
- <!-- A time/date based rolling appender -->
- <appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
- <param name="File" value="../jbosscache.log"/>
- <param name="Append" value="false"/>
+ <!-- A time/date based rolling appender -->
+ <appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
+ <param name="File" value="../jbosscache.log"/>
+ <param name="Append" value="false"/>
- <!-- Rollover at midnight each day -->
- <param name="DatePattern" value="'.'yyyy-MM-dd"/>
+ <!-- Rollover at midnight each day -->
+ <param name="DatePattern" value="'.'yyyy-MM-dd"/>
- <!-- Rollover at the top of each hour
- <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
- -->
- <param name="Threshold" value="INFO"/>
+ <!-- Rollover at the top of each hour
+ <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
+ -->
+ <param name="Threshold" value="INFO"/>
- <layout class="org.apache.log4j.PatternLayout">
- <!-- The default pattern: Date Priority [Category] Message\n -->
- <param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n"/>
- <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
- <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
- -->
- </layout>
- </appender>
+ <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
+ <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+ -->
+ </layout>
+ </appender>
- <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
- <param name="Threshold" value="TRACE"/>
- <param name="Target" value="System.out"/>
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Threshold" value="TRACE"/>
+ <param name="Target" value="System.out"/>
- <layout class="org.apache.log4j.PatternLayout">
- <!-- The default pattern: Date Priority [Category] Message\n -->
- <param name="ConversionPattern" value="%d %-5p [%c{1}] (%t) %m%n"/>
- </layout>
- </appender>
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d %-5p [%c{1}] (%t) %m%n"/>
+ </layout>
+ </appender>
- <!-- ================ -->
- <!-- Limit categories -->
- <!-- ================ -->
+ <!-- ================ -->
+ <!-- Limit categories -->
+ <!-- ================ -->
- <category name="org.jboss.cache">
- <priority value="WARN"/>
- </category>
+ <category name="org.jboss.cache">
+ <priority value="WARN"/>
+ </category>
- <!-- these two are in separate sections since they
- make a lot of noise in DEBUG or TRACE -->
- <category name="org.jboss.cache.factories">
- <priority value="WARN"/>
- </category>
+ <!-- these two are in separate sections since they
+make a lot of noise in DEBUG or TRACE -->
+ <category name="org.jboss.cache.factories">
+ <priority value="WARN"/>
+ </category>
- <category name="org.jboss.cache.jmx">
- <priority value="WARN"/>
- </category>
+ <category name="org.jboss.cache.jmx">
+ <priority value="WARN"/>
+ </category>
- <category name="org.jboss.tm">
- <priority value="WARN"/>
- </category>
+ <category name="org.jboss.tm">
+ <priority value="WARN"/>
+ </category>
- <category name="org.jgroups">
- <priority value="WARN"/>
- </category>
+ <category name="org.jgroups">
+ <priority value="WARN"/>
+ </category>
- <!-- ======================= -->
- <!-- Setup the Root category -->
- <!-- ======================= -->
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
- <root>
- <!--<appender-ref ref="CONSOLE"/>-->
- <appender-ref ref="FILE"/>
- </root>
+ <root>
+ <priority value="WARN"/>
+ <appender-ref ref="FILE"/>
+ <!--<appender-ref ref="CONSOLE"/>-->
+ </root>
</log4j:configuration>
15 years, 11 months
JBoss Cache SVN: r7375 - in core/trunk/src/main/java/org/jboss/cache: transaction and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-05 12:15:07 -0500 (Mon, 05 Jan 2009)
New Revision: 7375
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java
core/trunk/src/main/java/org/jboss/cache/transaction/GenericTransactionManagerLookup.java
Log:
logging noise
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java 2009-01-05 16:44:21 UTC (rev 7374)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java 2009-01-05 17:15:07 UTC (rev 7375)
@@ -70,7 +70,7 @@
NodeSPI targetNode = peekVersioned(ctx);
if (targetNode == null)
{
- log.warn("node " + fqn + " not found");
+ if (log.isInfoEnabled()) log.info("node " + fqn + " not found");
return null;
}
@@ -95,9 +95,13 @@
public Object[] getParameters()
{
if (isVersioned())
+ {
return new Object[]{globalTransaction, fqn, true, dataVersion};
+ }
else
+ {
return new Object[]{globalTransaction, fqn, true};
+ }
}
@Override
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/GenericTransactionManagerLookup.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/GenericTransactionManagerLookup.java 2009-01-05 16:44:21 UTC (rev 7374)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/GenericTransactionManagerLookup.java 2009-01-05 17:15:07 UTC (rev 7375)
@@ -104,14 +104,18 @@
public TransactionManager getTransactionManager()
{
if (!lookupDone)
+ {
doLookups();
+ }
if (tm != null)
+ {
return tm;
+ }
if (lookupFailed)
{
//fall back to a dummy from JBossCache
tm = DummyTransactionManager.getInstance();
- log.warn("Falling back to DummyTransactionManager from JBossCache");
+ log.warn("Falling back to JBoss Cache's internal DummyTransactionManager");
}
return tm;
}
@@ -122,7 +126,9 @@
private static void doLookups()
{
if (lookupFailed)
+ {
return;
+ }
InitialContext ctx;
try
{
@@ -141,7 +147,9 @@
try
{
if (log.isDebugEnabled())
+ {
log.debug("Trying to lookup TransactionManager for " + knownJNDIManager[1]);
+ }
jndiObject = ctx.lookup(knownJNDIManager[0]);
}
catch (NamingException e)
15 years, 11 months
JBoss Cache SVN: r7374 - core/trunk/src/test/java/org/jboss/cache/util.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-05 11:44:21 -0500 (Mon, 05 Jan 2009)
New Revision: 7374
Added:
core/trunk/src/test/java/org/jboss/cache/util/FastCopyHashMapTest.java
Removed:
core/trunk/src/test/java/org/jboss/cache/util/FastCopyHashMapSerialTest.java
Log:
Test FCHM
Deleted: core/trunk/src/test/java/org/jboss/cache/util/FastCopyHashMapSerialTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/FastCopyHashMapSerialTest.java 2009-01-05 16:05:58 UTC (rev 7373)
+++ core/trunk/src/test/java/org/jboss/cache/util/FastCopyHashMapSerialTest.java 2009-01-05 16:44:21 UTC (rev 7374)
@@ -1,34 +0,0 @@
-package org.jboss.cache.util;
-
-import org.testng.annotations.Test;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.Map;
-
-@Test(groups = "functional")
-public class FastCopyHashMapSerialTest
-{
- public void testSerialization() throws Exception
- {
- Map map = new FastCopyHashMap();
- map.put("k1", "v1");
- map.put("k2", "v2");
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(map);
- oos.close();
- baos.close();
-
- ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
- Map map2 = (Map) ois.readObject();
- ois.close();
-
- assert map2 instanceof FastCopyHashMap;
- assert map2.size() == map.size();
- for (Object key : map.keySet()) assert map2.containsKey(key);
- }
-}
Copied: core/trunk/src/test/java/org/jboss/cache/util/FastCopyHashMapTest.java (from rev 7373, core/trunk/src/test/java/org/jboss/cache/util/FastCopyHashMapSerialTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/FastCopyHashMapTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/util/FastCopyHashMapTest.java 2009-01-05 16:44:21 UTC (rev 7374)
@@ -0,0 +1,58 @@
+package org.jboss.cache.util;
+
+import org.testng.annotations.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Map;
+
+@Test(groups = "unit")
+public class FastCopyHashMapTest
+{
+ public void testSerialization() throws Exception
+ {
+ Map map = new FastCopyHashMap();
+ map.put("k1", "v1");
+ map.put("k2", "v2");
+
+ Map map2 = serializeAndDeserialize(map);
+
+ assert map2 instanceof FastCopyHashMap;
+ assert map2.size() == map.size();
+ for (Object key : map.keySet()) assert map2.containsKey(key);
+ }
+
+ public void testNonexistentKey() throws Exception
+ {
+ Map map = new FastCopyHashMap();
+ map.put("k1", "v1");
+ map.put("k2", "v2");
+
+ assert map.get("dont exist") == null;
+ }
+
+ public void testNonexistentKeyDeserialized() throws Exception
+ {
+ Map map = new FastCopyHashMap();
+ map.put("k1", "v1");
+ map.put("k2", "v2");
+ Map map2 = serializeAndDeserialize(map);
+ assert map2.get("dont exist") == null;
+ }
+
+ private <T> T serializeAndDeserialize(T object) throws Exception
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(object);
+ oos.close();
+ baos.close();
+
+ ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
+ Object retval = ois.readObject();
+ ois.close();
+ return (T) retval;
+ }
+}
15 years, 11 months
JBoss Cache SVN: r7373 - core/trunk/src/main/java/org/jboss/cache/util.
by jbosscache-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2009-01-05 11:05:58 -0500 (Mon, 05 Jan 2009)
New Revision: 7373
Modified:
core/trunk/src/main/java/org/jboss/cache/util/FastCopyHashMap.java
Log:
Fix serialization bug
Fix SimpleEntry.hashCode()
Modified: core/trunk/src/main/java/org/jboss/cache/util/FastCopyHashMap.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/FastCopyHashMap.java 2009-01-05 15:52:48 UTC (rev 7372)
+++ core/trunk/src/main/java/org/jboss/cache/util/FastCopyHashMap.java 2009-01-05 16:05:58 UTC (rev 7373)
@@ -68,12 +68,12 @@
/**
* The open-addressed table
*/
- private Entry<K, V>[] table;
+ private transient Entry<K, V>[] table;
/**
* The current number of key-value pairs
*/
- private int size;
+ private transient int size;
/**
* The next resize
@@ -98,19 +98,13 @@
public FastCopyHashMap(int initialCapacity, float loadFactor)
{
if (initialCapacity < 0)
- {
throw new IllegalArgumentException("Can not have a negative size table!");
- }
if (initialCapacity > MAXIMUM_CAPACITY)
- {
initialCapacity = MAXIMUM_CAPACITY;
- }
if (!(loadFactor > 0F && loadFactor <= 1F))
- {
throw new IllegalArgumentException("Load factor must be greater than 0 and less than or equal to 1");
- }
this.loadFactor = loadFactor;
init(initialCapacity, loadFactor);
@@ -213,14 +207,10 @@
{
Entry<K, V> e = table[index];
if (e == null)
- {
return null;
- }
if (e.hash == hash && eq(key, e.key))
- {
return e.value;
- }
index = nextIndex(index, length);
}
@@ -238,14 +228,10 @@
{
Entry<K, V> e = table[index];
if (e == null)
- {
return false;
- }
if (e.hash == hash && eq(key, e.key))
- {
return true;
- }
index = nextIndex(index, length);
}
@@ -254,12 +240,8 @@
public boolean containsValue(Object value)
{
for (Entry<K, V> e : table)
- {
if (e != null && eq(value, e.value))
- {
return true;
- }
- }
return false;
}
@@ -279,9 +261,7 @@
{
Entry<K, V> e = table[index];
if (e == null)
- {
break;
- }
if (e.hash == hash && eq(key, e.key))
{
@@ -291,17 +271,13 @@
index = nextIndex(index, length);
if (index == start)
- {
throw new IllegalStateException("Table is full!");
- }
}
modCount++;
table[index] = new Entry<K, V>(key, hash, value);
if (++size >= threshold)
- {
resize(length);
- }
return null;
}
@@ -314,9 +290,7 @@
// Can't get any bigger
if (newLength > MAXIMUM_CAPACITY || newLength <= from)
- {
return;
- }
Entry<K, V>[] newTable = new Entry[newLength];
Entry<K, V>[] old = table;
@@ -324,15 +298,11 @@
for (Entry<K, V> e : old)
{
if (e == null)
- {
continue;
- }
int index = index(e.hash, newLength);
while (newTable[index] != null)
- {
index = nextIndex(index, newLength);
- }
newTable[index] = e;
}
@@ -345,16 +315,12 @@
{
int size = map.size();
if (size == 0)
- {
return;
- }
if (size > threshold)
{
if (size > MAXIMUM_CAPACITY)
- {
size = MAXIMUM_CAPACITY;
- }
int length = table.length;
for (; length < size; length <<= 1) ;
@@ -363,9 +329,7 @@
}
for (Map.Entry<? extends K, ? extends V> e : map.entrySet())
- {
put(e.getKey(), e.getValue());
- }
}
public V remove(Object key)
@@ -381,9 +345,7 @@
{
Entry<K, V> e = table[index];
if (e == null)
- {
return null;
- }
if (e.hash == hash && eq(key, e.key))
{
@@ -396,9 +358,7 @@
index = nextIndex(index, length);
if (index == start)
- {
return null;
- }
}
@@ -414,9 +374,7 @@
{
Entry<K, V> e = table[current];
if (e == null)
- {
return;
- }
// A Doug Lea variant of Knuth's Section 6.4 Algorithm R.
// This provides a non-recursive method of relocating
@@ -439,9 +397,7 @@
modCount++;
Entry<K, V>[] table = this.table;
for (int i = 0; i < table.length; i++)
- {
table[i] = null;
- }
size = 0;
}
@@ -480,9 +436,7 @@
total++;
int target = index(e.hash, table.length);
if (i == target)
- {
optimal++;
- }
else
{
int skew = Math.abs(i - target);
@@ -503,9 +457,7 @@
public Set<Map.Entry<K, V>> entrySet()
{
if (entrySet == null)
- {
entrySet = new EntrySet();
- }
return entrySet;
}
@@ -513,9 +465,7 @@
public Set<K> keySet()
{
if (keySet == null)
- {
keySet = new KeySet();
- }
return keySet;
}
@@ -523,9 +473,7 @@
public Collection<V> values()
{
if (values == null)
- {
values = new Values();
- }
return values;
}
@@ -545,6 +493,8 @@
V value = (V) s.readObject();
putForCreate(key, value);
}
+
+ this.size = size;
}
@SuppressWarnings("unchecked")
@@ -607,9 +557,7 @@
public boolean hasNext()
{
if (hasNext == true)
- {
return true;
- }
Entry<K, V> table[] = this.table;
for (int i = next; i < table.length; i++)
@@ -628,14 +576,10 @@
protected Entry<K, V> nextEntry()
{
if (modCount != expectedCount)
- {
throw new ConcurrentModificationException();
- }
if (!hasNext && !hasNext())
- {
throw new NoSuchElementException();
- }
current = next++;
hasNext = false;
@@ -647,17 +591,13 @@
public void remove()
{
if (modCount != expectedCount)
- {
throw new ConcurrentModificationException();
- }
int current = this.current;
int delete = current;
if (current == -1)
- {
throw new IllegalStateException();
- }
// Invalidate current (prevents multiple remove)
this.current = -1;
@@ -686,9 +626,7 @@
i = nextIndex(i, length);
Entry<K, V> e = table[i];
if (e == null)
- {
break;
- }
int prefer = index(e.hash, length);
if ((i < prefer && (prefer <= delete || delete <= i))
@@ -746,9 +684,7 @@
public V setValue(V value)
{
if (table != FastCopyHashMap.this.table)
- {
FastCopyHashMap.this.put(getKey(), value);
- }
return super.setValue(value);
}
@@ -820,9 +756,7 @@
public boolean contains(Object o)
{
if (!(o instanceof Map.Entry))
- {
return false;
- }
Map.Entry<?, ?> entry = (Map.Entry<?, ?>) o;
Object value = get(entry.getKey());
@@ -882,22 +816,18 @@
public boolean equals(Object o)
{
if (this == o)
- {
return true;
- }
if (!(o instanceof Map.Entry))
- {
return false;
- }
Map.Entry<?, ?> e = (Map.Entry<?, ?>) o;
return eq(key, e.getKey()) && eq(value, e.getValue());
}
public int hashCode()
{
- return hash(maskNull(key)) ^
- (value == null ? 0 : hash(value));
+ return (key == null ? 0 : hash(key)) ^
+ (value == null ? 0 : hash(value));
}
public String toString()
15 years, 11 months
JBoss Cache SVN: r7372 - core/trunk/src/main/java/org/jboss/cache/util.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-05 10:52:48 -0500 (Mon, 05 Jan 2009)
New Revision: 7372
Modified:
core/trunk/src/main/java/org/jboss/cache/util/FastCopyHashMap.java
Log:
Test FCHM
Modified: core/trunk/src/main/java/org/jboss/cache/util/FastCopyHashMap.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/FastCopyHashMap.java 2009-01-05 15:51:37 UTC (rev 7371)
+++ core/trunk/src/main/java/org/jboss/cache/util/FastCopyHashMap.java 2009-01-05 15:52:48 UTC (rev 7372)
@@ -68,12 +68,12 @@
/**
* The open-addressed table
*/
- private transient Entry<K, V>[] table;
+ private Entry<K, V>[] table;
/**
* The current number of key-value pairs
*/
- private transient int size;
+ private int size;
/**
* The next resize
@@ -98,13 +98,19 @@
public FastCopyHashMap(int initialCapacity, float loadFactor)
{
if (initialCapacity < 0)
+ {
throw new IllegalArgumentException("Can not have a negative size table!");
+ }
if (initialCapacity > MAXIMUM_CAPACITY)
+ {
initialCapacity = MAXIMUM_CAPACITY;
+ }
if (!(loadFactor > 0F && loadFactor <= 1F))
+ {
throw new IllegalArgumentException("Load factor must be greater than 0 and less than or equal to 1");
+ }
this.loadFactor = loadFactor;
init(initialCapacity, loadFactor);
@@ -207,10 +213,14 @@
{
Entry<K, V> e = table[index];
if (e == null)
+ {
return null;
+ }
if (e.hash == hash && eq(key, e.key))
+ {
return e.value;
+ }
index = nextIndex(index, length);
}
@@ -228,10 +238,14 @@
{
Entry<K, V> e = table[index];
if (e == null)
+ {
return false;
+ }
if (e.hash == hash && eq(key, e.key))
+ {
return true;
+ }
index = nextIndex(index, length);
}
@@ -240,8 +254,12 @@
public boolean containsValue(Object value)
{
for (Entry<K, V> e : table)
+ {
if (e != null && eq(value, e.value))
+ {
return true;
+ }
+ }
return false;
}
@@ -261,7 +279,9 @@
{
Entry<K, V> e = table[index];
if (e == null)
+ {
break;
+ }
if (e.hash == hash && eq(key, e.key))
{
@@ -271,13 +291,17 @@
index = nextIndex(index, length);
if (index == start)
+ {
throw new IllegalStateException("Table is full!");
+ }
}
modCount++;
table[index] = new Entry<K, V>(key, hash, value);
if (++size >= threshold)
+ {
resize(length);
+ }
return null;
}
@@ -290,7 +314,9 @@
// Can't get any bigger
if (newLength > MAXIMUM_CAPACITY || newLength <= from)
+ {
return;
+ }
Entry<K, V>[] newTable = new Entry[newLength];
Entry<K, V>[] old = table;
@@ -298,11 +324,15 @@
for (Entry<K, V> e : old)
{
if (e == null)
+ {
continue;
+ }
int index = index(e.hash, newLength);
while (newTable[index] != null)
+ {
index = nextIndex(index, newLength);
+ }
newTable[index] = e;
}
@@ -315,12 +345,16 @@
{
int size = map.size();
if (size == 0)
+ {
return;
+ }
if (size > threshold)
{
if (size > MAXIMUM_CAPACITY)
+ {
size = MAXIMUM_CAPACITY;
+ }
int length = table.length;
for (; length < size; length <<= 1) ;
@@ -329,7 +363,9 @@
}
for (Map.Entry<? extends K, ? extends V> e : map.entrySet())
+ {
put(e.getKey(), e.getValue());
+ }
}
public V remove(Object key)
@@ -345,7 +381,9 @@
{
Entry<K, V> e = table[index];
if (e == null)
+ {
return null;
+ }
if (e.hash == hash && eq(key, e.key))
{
@@ -358,7 +396,9 @@
index = nextIndex(index, length);
if (index == start)
+ {
return null;
+ }
}
@@ -374,7 +414,9 @@
{
Entry<K, V> e = table[current];
if (e == null)
+ {
return;
+ }
// A Doug Lea variant of Knuth's Section 6.4 Algorithm R.
// This provides a non-recursive method of relocating
@@ -397,7 +439,9 @@
modCount++;
Entry<K, V>[] table = this.table;
for (int i = 0; i < table.length; i++)
+ {
table[i] = null;
+ }
size = 0;
}
@@ -436,7 +480,9 @@
total++;
int target = index(e.hash, table.length);
if (i == target)
+ {
optimal++;
+ }
else
{
int skew = Math.abs(i - target);
@@ -457,7 +503,9 @@
public Set<Map.Entry<K, V>> entrySet()
{
if (entrySet == null)
+ {
entrySet = new EntrySet();
+ }
return entrySet;
}
@@ -465,7 +513,9 @@
public Set<K> keySet()
{
if (keySet == null)
+ {
keySet = new KeySet();
+ }
return keySet;
}
@@ -473,7 +523,9 @@
public Collection<V> values()
{
if (values == null)
+ {
values = new Values();
+ }
return values;
}
@@ -555,7 +607,9 @@
public boolean hasNext()
{
if (hasNext == true)
+ {
return true;
+ }
Entry<K, V> table[] = this.table;
for (int i = next; i < table.length; i++)
@@ -574,10 +628,14 @@
protected Entry<K, V> nextEntry()
{
if (modCount != expectedCount)
+ {
throw new ConcurrentModificationException();
+ }
if (!hasNext && !hasNext())
+ {
throw new NoSuchElementException();
+ }
current = next++;
hasNext = false;
@@ -589,13 +647,17 @@
public void remove()
{
if (modCount != expectedCount)
+ {
throw new ConcurrentModificationException();
+ }
int current = this.current;
int delete = current;
if (current == -1)
+ {
throw new IllegalStateException();
+ }
// Invalidate current (prevents multiple remove)
this.current = -1;
@@ -624,7 +686,9 @@
i = nextIndex(i, length);
Entry<K, V> e = table[i];
if (e == null)
+ {
break;
+ }
int prefer = index(e.hash, length);
if ((i < prefer && (prefer <= delete || delete <= i))
@@ -682,7 +746,9 @@
public V setValue(V value)
{
if (table != FastCopyHashMap.this.table)
+ {
FastCopyHashMap.this.put(getKey(), value);
+ }
return super.setValue(value);
}
@@ -754,7 +820,9 @@
public boolean contains(Object o)
{
if (!(o instanceof Map.Entry))
+ {
return false;
+ }
Map.Entry<?, ?> entry = (Map.Entry<?, ?>) o;
Object value = get(entry.getKey());
@@ -814,17 +882,21 @@
public boolean equals(Object o)
{
if (this == o)
+ {
return true;
+ }
if (!(o instanceof Map.Entry))
+ {
return false;
+ }
Map.Entry<?, ?> e = (Map.Entry<?, ?>) o;
return eq(key, e.getKey()) && eq(value, e.getValue());
}
public int hashCode()
{
- return hash(key) ^
+ return hash(maskNull(key)) ^
(value == null ? 0 : hash(value));
}
15 years, 11 months
JBoss Cache SVN: r7371 - core/trunk/src/test/java/org/jboss/cache/util.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-05 10:51:37 -0500 (Mon, 05 Jan 2009)
New Revision: 7371
Added:
core/trunk/src/test/java/org/jboss/cache/util/FastCopyHashMapSerialTest.java
Log:
Test FCHM
Added: core/trunk/src/test/java/org/jboss/cache/util/FastCopyHashMapSerialTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/FastCopyHashMapSerialTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/util/FastCopyHashMapSerialTest.java 2009-01-05 15:51:37 UTC (rev 7371)
@@ -0,0 +1,34 @@
+package org.jboss.cache.util;
+
+import org.testng.annotations.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Map;
+
+@Test(groups = "functional")
+public class FastCopyHashMapSerialTest
+{
+ public void testSerialization() throws Exception
+ {
+ Map map = new FastCopyHashMap();
+ map.put("k1", "v1");
+ map.put("k2", "v2");
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(map);
+ oos.close();
+ baos.close();
+
+ ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
+ Map map2 = (Map) ois.readObject();
+ ois.close();
+
+ assert map2 instanceof FastCopyHashMap;
+ assert map2.size() == map.size();
+ for (Object key : map.keySet()) assert map2.containsKey(key);
+ }
+}
15 years, 11 months
JBoss Cache SVN: r7370 - in core/branches/1.4.X: src/org/jboss/cache and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-05 09:29:43 -0500 (Mon, 05 Jan 2009)
New Revision: 7370
Modified:
core/branches/1.4.X/build.xml
core/branches/1.4.X/src/org/jboss/cache/Version.java
Log:
Updated versions
Modified: core/branches/1.4.X/build.xml
===================================================================
--- core/branches/1.4.X/build.xml 2009-01-05 14:28:20 UTC (rev 7369)
+++ core/branches/1.4.X/build.xml 2009-01-05 14:29:43 UTC (rev 7370)
@@ -6,7 +6,7 @@
<property name="module.name" value="JBossCache"/>
<!--We now requires version to have no white space since Ant+JBossAop will sometime choke. -->
- <property name="module.version" value="1.4.1.SP8"/>
+ <property name="module.version" value="1.4.1-SNAPSHOT"/>
<property name="implementation.url" value="http://www.jboss.com/products/jbosscache"/>
<property file="build.properties"/>
<property name="root.dir" value="${basedir}"/>
Modified: core/branches/1.4.X/src/org/jboss/cache/Version.java
===================================================================
--- core/branches/1.4.X/src/org/jboss/cache/Version.java 2009-01-05 14:28:20 UTC (rev 7369)
+++ core/branches/1.4.X/src/org/jboss/cache/Version.java 2009-01-05 14:29:43 UTC (rev 7370)
@@ -10,9 +10,9 @@
*/
public class Version
{
- public static final String version = "1.4.1.SP8";
+ public static final String version = "1.4.1-SNAPSHOT";
public static final String codename = "Cayenne";
- public static byte[] version_id = {'0', '1', '4', '1', 'S', 'P', '8'};
+ public static byte[] version_id = {'0', '1', '4', '1'};
public static final String cvs = "$Id$";
private static final int MAJOR_SHIFT = 11;
15 years, 11 months
JBoss Cache SVN: r7369 - core/branches/1.4.X/docs.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-05 09:28:20 -0500 (Mon, 05 Jan 2009)
New Revision: 7369
Modified:
core/branches/1.4.X/docs/Changelog.txt
Log:
Updated changelog
Modified: core/branches/1.4.X/docs/Changelog.txt
===================================================================
--- core/branches/1.4.X/docs/Changelog.txt 2009-01-05 14:27:20 UTC (rev 7368)
+++ core/branches/1.4.X/docs/Changelog.txt 2009-01-05 14:28:20 UTC (rev 7369)
@@ -1,5 +1,39 @@
$Id$
+Release 1.4.1.SP11 (January 5, 2009)
+====================================
+Patch release on 1.4.1.GA
+
+** Bug
+ * [ JBCACHE-1452 ] JDBCCacheLoader Doesn't Work With Sybase
+ * [ JBCACHE-1453 ] JDBCExtCacheLoader Doesn't Handle Persistent State Transfer Correctly
+
+Release 1.4.1.SP10 (October 6, 2008)
+====================================
+Patch release on 1.4.1.GA
+
+** Feature Request
+ * [ JBCACHE-1230 ] toString() should not print entire contents of a node if it exceeds a certain size
+
+** Bug
+ * [ JBCACHE-1241 ] Buddy replication, add data to a node and delete root will cause a exception to be thrown
+ * [ JBCACHE-1244 ] Buddy Manager to create _BUDDY_BACKUP_ region on initialisation before accepting any state or membership requests from buddies
+ * [ JBCACHE-1316 ] recycleQueue.put() could block forever halting evictions and eventually any replications
+ * [ JBCACHE-1357 ] Root nodes of marshalled regions won't be loaded correclty from cache loaders
+ * [ JBCACHE-1370 ] Objects retrieved using getObject() in a transaction that rollsback are unusable
+ * [ JBCACHE-1393 ] putFailFast javadoc on timeout is misleading
+ * [ JBCACHE-1406 ] issue with removing an node in tx
+ * [ JBCACHE-1412 ] Marshaller uses equals() to test object equality instead of identity when performing reference counting
+
+Release 1.4.1.SP9 (April 4, 2008)
+=================================
+Patch release on 1.4.1.GA
+
+** Bug
+ * [ JBCACHE-1246 ] TransactionTable leaks memory when used with FAIL_SILENTLY option
+ * [ JBCACHE-1255 ] setUseInterceptorMbeans not available in TreeCacheMBean interface, causing problems when deployed in JBoss AS
+ * [ JBCACHE-1292 ] endless loop on concurrent remove
+
Release 1.4.1.SP8 (December 12, 2007)
=====================================
Patch release on 1.4.1.GA
15 years, 11 months
JBoss Cache SVN: r7368 - core/tags/1.4.1.SP11/docs.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-05 09:27:20 -0500 (Mon, 05 Jan 2009)
New Revision: 7368
Modified:
core/tags/1.4.1.SP11/docs/Changelog.txt
Log:
Updated changelog
Modified: core/tags/1.4.1.SP11/docs/Changelog.txt
===================================================================
--- core/tags/1.4.1.SP11/docs/Changelog.txt 2009-01-05 14:10:17 UTC (rev 7367)
+++ core/tags/1.4.1.SP11/docs/Changelog.txt 2009-01-05 14:27:20 UTC (rev 7368)
@@ -1,5 +1,39 @@
$Id$
+Release 1.4.1.SP11 (January 5, 2009)
+====================================
+Patch release on 1.4.1.GA
+
+** Bug
+ * [ JBCACHE-1452 ] JDBCCacheLoader Doesn't Work With Sybase
+ * [ JBCACHE-1453 ] JDBCExtCacheLoader Doesn't Handle Persistent State Transfer Correctly
+
+Release 1.4.1.SP10 (October 6, 2008)
+====================================
+Patch release on 1.4.1.GA
+
+** Feature Request
+ * [ JBCACHE-1230 ] toString() should not print entire contents of a node if it exceeds a certain size
+
+** Bug
+ * [ JBCACHE-1241 ] Buddy replication, add data to a node and delete root will cause a exception to be thrown
+ * [ JBCACHE-1244 ] Buddy Manager to create _BUDDY_BACKUP_ region on initialisation before accepting any state or membership requests from buddies
+ * [ JBCACHE-1316 ] recycleQueue.put() could block forever halting evictions and eventually any replications
+ * [ JBCACHE-1357 ] Root nodes of marshalled regions won't be loaded correclty from cache loaders
+ * [ JBCACHE-1370 ] Objects retrieved using getObject() in a transaction that rollsback are unusable
+ * [ JBCACHE-1393 ] putFailFast javadoc on timeout is misleading
+ * [ JBCACHE-1406 ] issue with removing an node in tx
+ * [ JBCACHE-1412 ] Marshaller uses equals() to test object equality instead of identity when performing reference counting
+
+Release 1.4.1.SP9 (April 4, 2008)
+=================================
+Patch release on 1.4.1.GA
+
+** Bug
+ * [ JBCACHE-1246 ] TransactionTable leaks memory when used with FAIL_SILENTLY option
+ * [ JBCACHE-1255 ] setUseInterceptorMbeans not available in TreeCacheMBean interface, causing problems when deployed in JBoss AS
+ * [ JBCACHE-1292 ] endless loop on concurrent remove
+
Release 1.4.1.SP8 (December 12, 2007)
=====================================
Patch release on 1.4.1.GA
15 years, 11 months
JBoss Cache SVN: r7367 - core/trunk/src/test/java/org/jboss/cache/notifications.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-05 09:10:17 -0500 (Mon, 05 Jan 2009)
New Revision: 7367
Added:
core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerRemovalTest.java
Log:
Added test
Added: core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerRemovalTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerRemovalTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerRemovalTest.java 2009-01-05 14:10:17 UTC (rev 7367)
@@ -0,0 +1,64 @@
+package org.jboss.cache.notifications;
+
+import org.jboss.cache.Cache;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.notifications.annotation.CacheListener;
+import org.jboss.cache.notifications.annotation.NodeVisited;
+import org.jboss.cache.notifications.event.Event;
+import org.testng.annotations.Test;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * @author Manik Surtani
+ */
+@Test(groups = "functional")
+public class CacheListenerRemovalTest
+{
+ public void testListenerRemoval()
+ {
+ Cache cache = new DefaultCacheFactory().createCache();
+ AtomicInteger i = new AtomicInteger(0);
+ try
+ {
+ assert 0 == cache.getCacheListeners().size();
+ Listener l = new Listener(i);
+ cache.addCacheListener(l);
+ assert 1 == cache.getCacheListeners().size();
+ assert cache.getCacheListeners().iterator().next() == l;
+ assert 0 == i.get();
+ cache.get(Fqn.ROOT, "x");
+ assert 1 == i.get();
+
+ // remove the listener
+ cache.removeCacheListener(l);
+ assert 0 == cache.getCacheListeners().size();
+ i.set(0);
+ assert 0 == i.get();
+ cache.get(Fqn.ROOT, "x");
+ assert 0 == i.get();
+ }
+ finally
+ {
+ cache.stop();
+ }
+ }
+
+ @CacheListener
+ public static class Listener
+ {
+ AtomicInteger i;
+
+ private Listener(AtomicInteger i)
+ {
+ this.i = i;
+ }
+
+ @NodeVisited
+ public void listen(Event e)
+ {
+ if (e.isPre()) i.incrementAndGet();
+ }
+ }
+}
15 years, 11 months