JBoss Cache SVN: r5346 - in core/trunk/src: test/java/org/jboss/cache/marshall and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-02-12 14:41:54 -0500 (Tue, 12 Feb 2008)
New Revision: 5346
Modified:
core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java
Log:
fixed broken tests
Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2008-02-12 18:38:52 UTC (rev 5345)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2008-02-12 19:41:54 UTC (rev 5346)
@@ -411,12 +411,7 @@
throw new IllegalArgumentException("cache mode " + configuration.getCacheMode() + " is invalid");
}
- // these 2 components need to be started manually since they can only be started after ALL other components have started.
- // i.e., rpcManager's start() method may do state transfers. State transfers will rely on the interceptor chain being started.
- // the interceptor chain cannot start until the rpcManager is started. And similarly, the buddyManager relies on the
- // rpcManager being started.
- if (rpcManager != null) rpcManager.start();
- if (buddyManager != null) buddyManager.init();
+ startManualComponents();
//now attempt to preload the cache from the loader - Manik
if (cacheLoaderManager != null)
@@ -439,6 +434,16 @@
cacheStatus = CacheStatus.STARTED;
}
+ private void startManualComponents()
+ {
+ // these 2 components need to be started manually since they can only be started after ALL other components have started.
+ // i.e., rpcManager's start() method may do state transfers. State transfers will rely on the interceptor chain being started.
+ // the interceptor chain cannot start until the rpcManager is started. And similarly, the buddyManager relies on the
+ // rpcManager being started.
+ if (rpcManager != null) rpcManager.start();
+ if (buddyManager != null) buddyManager.init();
+ }
+
private void addShutdownHook()
{
ArrayList al = MBeanServerFactory.findMBeanServer(null);
@@ -2329,6 +2334,9 @@
componentRegistry.registerComponent(i, Interceptor.class);
interceptors.add(++position, i);
setInterceptorChain(factory.correctInterceptorChaining(interceptors));
+ componentRegistry.start();
+ // make sure I start the last 2 "manually startable" components
+ startManualComponents();
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-02-12 18:38:52 UTC (rev 5345)
+++ core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-02-12 19:41:54 UTC (rev 5346)
@@ -200,7 +200,6 @@
{
log.info("Stopping the RpcDispatcher");
disp.stop();
- disp = null;
}
if (members != null)
{
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java 2008-02-12 18:38:52 UTC (rev 5345)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java 2008-02-12 19:41:54 UTC (rev 5346)
@@ -44,12 +44,15 @@
@BeforeMethod
- public void setUp()
+ public void setUp() throws CloneNotSupportedException
{
cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_SYNC, false), false);
- cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_SYNC, false), false);
+ if (cache1.getConfiguration().getBuddyReplicationConfig() != null)
+ cache1.getConfiguration().setBuddyReplicationConfig(null);
cache1.getConfiguration().setUseLazyDeserialization(true);
- cache2.getConfiguration().setUseLazyDeserialization(true);
+
+ cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(cache1.getConfiguration().clone(), false);
+
cache1.start();
cache2.start();
@@ -321,17 +324,21 @@
public Object invoke(InvocationContext ctx) throws Throwable
{
- invocationCount++;
- MethodCall mc = ctx.getMethodCall();
- for (Object arg : mc.getArgs())
+ if (MethodDeclarations.isPutMethod(ctx.getMethodCall().getMethodId()))
{
- if (arg instanceof MarshalledValue) assertOnlyOneRepresentationExists((MarshalledValue) arg);
- }
+ invocationCount++;
+ MethodCall mc = ctx.getMethodCall();
+ for (Object arg : mc.getArgs())
+ {
+ if (arg instanceof MarshalledValue) assertOnlyOneRepresentationExists((MarshalledValue) arg);
+ }
- Object retval = nextInterceptor(ctx);
+ Object retval = nextInterceptor(ctx);
- if (retval instanceof MarshalledValue) assertOnlyOneRepresentationExists((MarshalledValue) retval);
- return retval;
+ if (retval instanceof MarshalledValue) assertOnlyOneRepresentationExists((MarshalledValue) retval);
+ return retval;
+ }
+ else return nextInterceptor(ctx);
}
}
16 years, 10 months
JBoss Cache SVN: r5345 - in jbosscache-lucene/trunk: src and 12 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-02-12 13:38:52 -0500 (Tue, 12 Feb 2008)
New Revision: 5345
Added:
jbosscache-lucene/trunk/TODO.txt
jbosscache-lucene/trunk/pom.xml
jbosscache-lucene/trunk/src/
jbosscache-lucene/trunk/src/main/
jbosscache-lucene/trunk/src/main/java/
jbosscache-lucene/trunk/src/main/java/org/
jbosscache-lucene/trunk/src/main/java/org/jboss/
jbosscache-lucene/trunk/src/main/java/org/jboss/cache/
jbosscache-lucene/trunk/src/main/java/org/jboss/cache/lucene/
jbosscache-lucene/trunk/src/main/java/org/jboss/cache/lucene/ByteArrayIO.java
jbosscache-lucene/trunk/src/main/java/org/jboss/cache/lucene/File.java
jbosscache-lucene/trunk/src/main/java/org/jboss/cache/lucene/JBCDirectory.java
jbosscache-lucene/trunk/src/test/
jbosscache-lucene/trunk/src/test/java/
jbosscache-lucene/trunk/src/test/java/org/
jbosscache-lucene/trunk/src/test/java/org/jboss/
jbosscache-lucene/trunk/src/test/java/org/jboss/cache/
jbosscache-lucene/trunk/src/test/java/org/jboss/cache/lucene/
jbosscache-lucene/trunk/src/test/java/org/jboss/cache/lucene/ByteArrayIOTest.java
Log:
Added: jbosscache-lucene/trunk/TODO.txt
===================================================================
--- jbosscache-lucene/trunk/TODO.txt (rev 0)
+++ jbosscache-lucene/trunk/TODO.txt 2008-02-12 18:38:52 UTC (rev 5345)
@@ -0,0 +1,5 @@
+1. Figure out how to instantiate, pass in a cache instance
+2. Provide a subtree root in the cache, a starting point
+3. Retrieve cache from srcs such as JNDI and JMX
+4. Test
+5. Document
Added: jbosscache-lucene/trunk/pom.xml
===================================================================
--- jbosscache-lucene/trunk/pom.xml (rev 0)
+++ jbosscache-lucene/trunk/pom.xml 2008-02-12 18:38:52 UTC (rev 5345)
@@ -0,0 +1,80 @@
+<?xml version="1.0"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.jboss.cache</groupId>
+ <artifactId>jbosscache-common-parent</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ </parent>
+ <groupId>org.jboss.cache</groupId>
+ <artifactId>jbosscache-lucene-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <name>JBoss Cache Lucene integration plugin</name>
+ <description>JBoss Cache Lucene integration plugin</description>
+ <packaging>jar</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.cache</groupId>
+ <artifactId>jbosscache-core</artifactId>
+ <version>2.1.0.CR3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-core</artifactId>
+ <version>2.2.0</version>
+ </dependency>
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>2.3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.transaction</groupId>
+ <artifactId>jboss-jta</artifactId>
+ <version>4.2.3.SP5</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2-beta-1</version>
+ <executions>
+ <execution>
+ <id>assemble</id>
+ <phase>install</phase>
+ <goals>
+ <goal>attached</goal>
+ </goals>
+ <configuration>
+ <descriptors>
+ <descriptor>assembly.xml</descriptor>
+ </descriptors>
+ <finalName>${artifactId}-${version}</finalName>
+ <outputDirectory>target/distribution</outputDirectory>
+ <workDirectory>target/assembly/work</workDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <!-- basic JBoss repository so that the common parent POM in jbosscache-support can be found -->
+ <repositories>
+ <repository>
+ <id>repository.jboss.org</id>
+ <url>http://repository.jboss.org/maven2</url>
+ </repository>
+ <repository>
+ <id>snapshots.jboss.org</id>
+ <url>http://snapshots.jboss.org/maven2</url>
+ </repository>
+ </repositories>
+
+</project>
Added: jbosscache-lucene/trunk/src/main/java/org/jboss/cache/lucene/ByteArrayIO.java
===================================================================
--- jbosscache-lucene/trunk/src/main/java/org/jboss/cache/lucene/ByteArrayIO.java (rev 0)
+++ jbosscache-lucene/trunk/src/main/java/org/jboss/cache/lucene/ByteArrayIO.java 2008-02-12 18:38:52 UTC (rev 5345)
@@ -0,0 +1,191 @@
+package org.jboss.cache.lucene;
+
+import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.store.IndexOutput;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+public class ByteArrayIO
+{
+ static int getChunkNumber(long positionToRead)
+ {
+ if (positionToRead < 0) return 0;
+ return (int) (positionToRead >>> JBCDirectory.CHUNK_SIZE_BITS);
+ }
+
+ static int getChunkPointer(long pointer)
+ {
+ return (int) (JBCDirectory.CHUNK_MASK & pointer);
+ }
+
+ static byte[] getChunkData(int chunkNumber, Map<Integer, Node> chunks, Node fileNode)
+ {
+ Node chunk = chunks.get(chunkNumber);
+ if (chunk == null)
+ {
+ chunk = fileNode.getChild(chunkNumber);
+ chunks.put(chunkNumber, chunk);
+ }
+
+ return (byte[]) chunk.get("buf");
+ }
+
+ public static class ByteArrayIndexInput extends IndexInput
+ {
+ private Node fileNode;
+ private long pointer;
+ private File metadata;
+ private Map<Integer, Node> chunks = new HashMap<Integer, Node>();
+
+ /**
+ * @param node node containing chunks as children
+ * @param file containing metadata
+ */
+ public ByteArrayIndexInput(Node fileNode, File metadata)
+ {
+ this.fileNode = fileNode;
+ this.metadata = metadata;
+ }
+
+ public byte readByte() throws IOException
+ {
+ if (pointer + 1 > metadata.getSize()) throw new IOException(metadata.getName() + ": Reading past end of file");
+ return getChunkData(getChunkNumber(pointer), chunks, fileNode)[getChunkPointer(pointer++)];
+ }
+
+ public void readBytes(byte[] bytes, int offset, int length) throws IOException
+ {
+ if (pointer + length > metadata.getSize())
+ throw new IOException(metadata.getName() + ": Reading past end of file");
+
+ int toRead = length;
+ int bytesReadSoFar = 0;
+ boolean first = true;
+ while (toRead > 0)
+ {
+ byte[] chunkData = getChunkData(getChunkNumber(pointer), chunks, fileNode);
+ int startingPoint = first ? getChunkPointer(pointer) : 0;
+ if (first) first = false;
+ int bytesToRead = Math.min(toRead, chunkData.length - startingPoint);
+ System.arraycopy(chunkData, startingPoint, bytes, offset + bytesReadSoFar, bytesToRead);
+ toRead = toRead - bytesToRead;
+ bytesReadSoFar += bytesToRead;
+ pointer += bytesToRead;
+ }
+ }
+
+ public void close() throws IOException
+ {
+ // do nothing, except reset the pointer and release resources.
+ chunks.clear();
+ pointer = 0;
+ }
+
+ public long getFilePointer()
+ {
+ return pointer;
+ }
+
+ public void seek(long l) throws IOException
+ {
+ pointer = (int) l;
+ }
+
+ public long length()
+ {
+ return metadata.getSize();
+ }
+ }
+
+ public static class ByteArrayIndexOutput extends IndexOutput
+ {
+ private Node fileNode;
+ private File metadata;
+ private long pointer;
+ private Map<Integer, Node> chunks = new HashMap<Integer, Node>();
+ private byte[] buffer = new byte[JBCDirectory.CHUNK_SIZE];
+ private int bufferpointer;
+
+ public ByteArrayIndexOutput(Node fileNode, File metadata)
+ {
+ this.fileNode = fileNode;
+ this.metadata = metadata;
+ }
+
+ void newChunk() throws IOException
+ {
+ flush();
+ bufferpointer = 0;
+ buffer = new byte[JBCDirectory.CHUNK_SIZE];
+ }
+
+ public void writeByte(byte b) throws IOException
+ {
+ if (bufferpointer == buffer.length)
+ {
+ newChunk();
+ }
+ buffer[bufferpointer++] = b;
+ pointer++;
+ metadata.setSize(metadata.getSize() + 1);
+ }
+
+ public void writeBytes(byte[] bytes, int offset, int length) throws IOException
+ {
+
+ int bytesWritten = 0;
+
+ while (bytesWritten < length)
+ {
+ int spaceInBuffer = buffer.length - bufferpointer;
+ int bytesToWrite = Math.min(spaceInBuffer, length - bytesWritten);
+ System.arraycopy(bytes, offset + bytesWritten, buffer, bufferpointer, bytesToWrite);
+ bytesWritten += bytesToWrite;
+ if (bytesWritten < length) newChunk();
+ }
+ metadata.setSize(metadata.getSize() + length);
+ pointer += length;
+ }
+
+ public void flush() throws IOException
+ {
+ int chunkNumber = getChunkNumber(pointer);
+ fileNode.addChild(new Fqn(chunkNumber)).put("buf", buffer);
+ }
+
+ public void close() throws IOException
+ {
+ flush();
+ bufferpointer = 0;
+ buffer = new byte[JBCDirectory.CHUNK_SIZE];
+ pointer = 0;
+ }
+
+ public long getFilePointer()
+ {
+ return pointer;
+ }
+
+ public void seek(long l) throws IOException
+ {
+ if (l > metadata.getSize()) throw new IOException(metadata.getName() + ": seeking past end of file!");
+ // first flush
+ flush();
+ pointer = l;
+ int cn = getChunkNumber(pointer);
+ buffer = getChunkData(cn, chunks, fileNode);
+ bufferpointer = getChunkPointer(pointer);
+ metadata.setSize(pointer);
+ }
+
+ public long length() throws IOException
+ {
+ return metadata.getSize();
+ }
+ }
+
+}
Added: jbosscache-lucene/trunk/src/main/java/org/jboss/cache/lucene/File.java
===================================================================
--- jbosscache-lucene/trunk/src/main/java/org/jboss/cache/lucene/File.java (rev 0)
+++ jbosscache-lucene/trunk/src/main/java/org/jboss/cache/lucene/File.java 2008-02-12 18:38:52 UTC (rev 5345)
@@ -0,0 +1,72 @@
+package org.jboss.cache.lucene;
+
+import java.io.Serializable;
+
+/**
+ * Metadata for a file.
+ */
+public class File implements Serializable
+{
+ private long lastModified;
+ private String name;
+ private int numChunks;
+ private long size;
+
+ public File(String name)
+ {
+ this.name = name;
+ touch();
+ }
+
+ public File(long lastModified, String name, int numChunks)
+ {
+ this.lastModified = lastModified;
+ this.name = name;
+ this.numChunks = numChunks;
+ }
+
+ public long getLastModified()
+ {
+ return lastModified;
+ }
+
+ public void setLastModified(long lastModified)
+ {
+ this.lastModified = lastModified;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public int getNumChunks()
+ {
+ return numChunks;
+ }
+
+ public void setNumChunks(int numChunks)
+ {
+ this.numChunks = numChunks;
+ }
+
+ public long getSize()
+ {
+ return size;
+ }
+
+ public void setSize(long size)
+ {
+ this.size = size;
+ }
+
+ public void touch()
+ {
+ setLastModified(System.currentTimeMillis());
+ }
+}
Added: jbosscache-lucene/trunk/src/main/java/org/jboss/cache/lucene/JBCDirectory.java
===================================================================
--- jbosscache-lucene/trunk/src/main/java/org/jboss/cache/lucene/JBCDirectory.java (rev 0)
+++ jbosscache-lucene/trunk/src/main/java/org/jboss/cache/lucene/JBCDirectory.java 2008-02-12 18:38:52 UTC (rev 5345)
@@ -0,0 +1,139 @@
+package org.jboss.cache.lucene;
+
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.store.IndexOutput;
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+
+import java.io.IOException;
+import java.util.Set;
+
+/**
+ * Structure is that each Directory maps to a Node in JBoss Cache.
+ * <p/>
+ * Each node will contain some attributes, as metadata:
+ * <p/>
+ * <ul>
+ * <li>
+ * {@link Constants#TYPE}, which could have values of {@link Constants#DIRECTORY}, or {@link Constants#FILECHUNK}.
+ * </li>
+ * <li>
+ * {@link org.jboss.cache.lucene.Constants#CONTENTS} - payload of the node. This only applies to FILECHUNK type nodes,
+ * and this is a byte array.
+ * </li>
+ * </ul>
+ * <p/>
+ * Also, in the case of DIRECTORY type nodes, additional attributes will exist. These attributes are keyed on a String,
+ * denoting a file name, and point to a {@link File} object as value, containing metadata for each file, in the directory
+ * <p/>
+ * Some configuration parameters include <tt>-Dorg.jboss.cache.lucene.blocksize</tt>, which defaults to <tt>"16k"</tt>.
+ * Other supported values for this setting include "4k", "8k", "16k", "32k", "64k" and "128k".
+ * This denotes the size, in bytes, of file chunks and the tradeoff between size and performance that applies to file
+ * system block sizes applies here.
+ */
+public class JBCDirectory extends Directory
+{
+ static String CHUNK_SIZE_STR = System.getProperty("org.jboss.cache.lucene.blocksize", "16k");
+ static int CHUNK_SIZE = 1024 * Integer.parseInt(CHUNK_SIZE_STR.toUpperCase().replace("K", ""));
+ static int CHUNK_SIZE_BITS = (int) (Math.log(CHUNK_SIZE) / Math.log(2));
+ static int CHUNK_MASK = CHUNK_SIZE - 1;
+
+ private Cache<Object, Object> cache;
+ private Node<Object, Object> node;
+
+ public JBCDirectory(Node node, Cache cache)
+ {
+ this.node = node;
+ this.cache = cache;
+ }
+
+ public JBCDirectory(Node node)
+ {
+ this.node = node;
+ }
+
+ public String[] list() throws IOException
+ {
+ Set childrenNames = node.getKeys();
+ return (String[]) childrenNames.toArray(new String[]{});
+ }
+
+ public boolean fileExists(String name) throws IOException
+ {
+ return node.get(name) != null;
+ }
+
+ public long fileModified(String name) throws IOException
+ {
+ return getFile(name).getLastModified();
+ }
+
+ public void touchFile(String name) throws IOException
+ {
+ getFile(name).touch();
+ }
+
+ public void deleteFile(String name) throws IOException
+ {
+ removeFile(name);
+ }
+
+ public void renameFile(String from, String to) throws IOException
+ {
+ File file = getFile(from);
+ if (file != null)
+ {
+ Node newFile = node.addChild(new Fqn(to));
+ Node oldFile = node.getChild(from);
+
+ for (Object o : oldFile.getChildrenNames()) // chunks
+ {
+ cache.move(new Fqn(oldFile.getFqn(), o), newFile.getFqn());
+ }
+ cache.removeNode(oldFile.getFqn());
+ }
+ file.setName(to);
+ file.touch();
+ node.remove(from); // remove old metadata
+ node.put(to, file); // new metadata
+ }
+
+ public long fileLength(String name) throws IOException
+ {
+ return getFile(name).getSize();
+ }
+
+ public IndexOutput createOutput(String name) throws IOException
+ {
+ if (!fileExists(name))
+ {
+ // create it
+ File file = new File(name);
+ node.addChild(new Fqn(name));
+ node.put(name, file);
+ }
+ return new ByteArrayIO.ByteArrayIndexOutput(node.getChild(name), getFile(name));
+ }
+
+ public IndexInput openInput(String name) throws IOException
+ {
+ return new ByteArrayIO.ByteArrayIndexInput(node.getChild(name), getFile(name));
+ }
+
+ public void close() throws IOException
+ {
+ }
+
+ protected File getFile(String name)
+ {
+ return (File) node.get(name);
+ }
+
+ protected void removeFile(String name)
+ {
+ File file = (File) node.remove(name);
+ if (file != null) node.removeChild(file.getName());
+ }
+}
Added: jbosscache-lucene/trunk/src/test/java/org/jboss/cache/lucene/ByteArrayIOTest.java
===================================================================
--- jbosscache-lucene/trunk/src/test/java/org/jboss/cache/lucene/ByteArrayIOTest.java (rev 0)
+++ jbosscache-lucene/trunk/src/test/java/org/jboss/cache/lucene/ByteArrayIOTest.java 2008-02-12 18:38:52 UTC (rev 5345)
@@ -0,0 +1,221 @@
+package org.jboss.cache.lucene;
+
+import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.store.IndexOutput;
+import org.jboss.cache.Cache;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+import org.testng.annotations.Test;
+
+import java.io.ByteArrayOutputStream;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+@Test
+public class ByteArrayIOTest
+{
+ public void testChunkNumbering()
+ {
+ assert ByteArrayIO.getChunkNumber(-1) == 0;
+ assert ByteArrayIO.getChunkNumber(0) == 0;
+ assert ByteArrayIO.getChunkNumber(1) == 0;
+ assert ByteArrayIO.getChunkNumber(JBCDirectory.CHUNK_SIZE - 1) == 0;
+ assert ByteArrayIO.getChunkNumber(JBCDirectory.CHUNK_SIZE) == 1;
+ assert ByteArrayIO.getChunkNumber(JBCDirectory.CHUNK_SIZE + 1) == 1;
+ }
+
+ public void testChunkPointer()
+ {
+ assert ByteArrayIO.getChunkPointer(0) == 0;
+ assert ByteArrayIO.getChunkPointer(1) == 1;
+ assert ByteArrayIO.getChunkPointer(JBCDirectory.CHUNK_SIZE - 1) == JBCDirectory.CHUNK_SIZE - 1;
+ assert ByteArrayIO.getChunkPointer(JBCDirectory.CHUNK_SIZE) == 0;
+ assert ByteArrayIO.getChunkPointer(JBCDirectory.CHUNK_SIZE + 1) == 1;
+ assert ByteArrayIO.getChunkPointer(2 * JBCDirectory.CHUNK_SIZE) == 0;
+ assert ByteArrayIO.getChunkPointer(2 * JBCDirectory.CHUNK_SIZE + 9) == 9;
+ }
+
+ // now some REAL tests
+
+ public void readChunks() throws Exception
+ {
+ JBCDirectory.CHUNK_SIZE = 64;
+ JBCDirectory.CHUNK_SIZE_BITS = 6;
+ JBCDirectory.CHUNK_MASK = 63;
+
+ Cache cache = new DefaultCacheFactory().createCache();
+ File file1 = new File(0L, "Hello.txt", 1);
+ cache.put("/Dir", file1.getName(), file1);
+
+ File file2 = new File(0L, "World.txt", 1);
+ cache.put("/Dir", file2.getName(), file2);
+
+ // byte array for Hello.txt
+ String helloText = "Hello world. This is some text.";
+ cache.put(new Fqn("Dir", "Hello.txt", new Integer(0)), "buf", helloText.getBytes());
+
+ // byte array for World.txt - shouldbe in at least 2 chunks.
+ String worldText = "This String should contain more than sixty four characters but less than one hundred and twenty eight.";
+
+ byte[] buf = new byte[JBCDirectory.CHUNK_SIZE];
+ System.arraycopy(worldText.getBytes(), 0, buf, 0, JBCDirectory.CHUNK_SIZE);
+ cache.put(new Fqn("Dir", "World.txt", new Integer(0)), "buf", buf);
+ String part1 = new String(buf);
+ buf = new byte[JBCDirectory.CHUNK_SIZE];
+ System.arraycopy(worldText.getBytes(), JBCDirectory.CHUNK_SIZE, buf, 0, worldText.length() - JBCDirectory.CHUNK_SIZE);
+ cache.put(new Fqn("Dir", "World.txt", new Integer(1)), "buf", buf);
+ String part2 = new String(buf);
+ // make sure the generated bytes do add up!
+ assert worldText.equals(part1 + part2.trim());
+
+ file1.setSize(helloText.length());
+ file2.setSize(worldText.length());
+
+ // now we're set up. Nice.
+
+ JBCDirectory dir = new JBCDirectory(cache.getNode("/Dir"), cache);
+
+
+ Set s = new HashSet();
+ s.add("Hello.txt");
+ s.add("World.txt");
+ Set other = new HashSet(Arrays.asList(dir.list()));
+
+ // ok, file listing works.
+ assert other.equals(s);
+
+ IndexInput ii = dir.openInput("Hello.txt");
+
+ assert ii.length() == helloText.length();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ for (int i = 0; i < ii.length(); i++) baos.write(ii.readByte());
+
+ assert new String(baos.toByteArray()).equals(helloText);
+
+ ii = dir.openInput("World.txt");
+
+ assert ii.length() == worldText.length();
+
+ baos = new ByteArrayOutputStream();
+
+ for (int i = 0; i < ii.length(); i++) baos.write(ii.readByte());
+
+ assert new String(baos.toByteArray()).equals(worldText);
+
+ // now with buffered reading
+
+ ii = dir.openInput("Hello.txt");
+
+ assert ii.length() == helloText.length();
+
+ baos = new ByteArrayOutputStream();
+
+ long toRead = ii.length();
+ while (toRead > 0)
+ {
+ buf = new byte[19]; // suitably arbitrary
+ int bytesRead = (int) Math.min(toRead, 19);
+ ii.readBytes(buf, 0, bytesRead);
+ toRead = toRead - bytesRead;
+ baos.write(buf, 0, bytesRead);
+ }
+
+ assert new String(baos.toByteArray()).equals(helloText);
+
+ ii = dir.openInput("World.txt");
+
+ assert ii.length() == worldText.length();
+
+ baos = new ByteArrayOutputStream();
+
+ toRead = ii.length();
+ while (toRead > 0)
+ {
+ buf = new byte[19]; // suitably arbitrary
+ int bytesRead = (int) Math.min(toRead, 19);
+ ii.readBytes(buf, 0, bytesRead);
+ toRead = toRead - bytesRead;
+ baos.write(buf, 0, bytesRead);
+ }
+
+ assert new String(baos.toByteArray()).equals(worldText);
+
+ dir.removeFile("Hello.txt");
+ assert !cache.getRoot().getChild("Dir").hasChild("Hello.txt");
+
+ dir.renameFile("World.txt", "HelloWorld.txt");
+ assert !cache.getRoot().getChild("Dir").hasChild("World.txt");
+ assert cache.getRoot().getChild("Dir").hasChild("HelloWorld.txt");
+
+ // test that contents survive a move
+ ii = dir.openInput("HelloWorld.txt");
+
+ assert ii.length() == worldText.length();
+
+ baos = new ByteArrayOutputStream();
+
+ toRead = ii.length();
+ while (toRead > 0)
+ {
+ buf = new byte[19]; // suitably arbitrary
+ int bytesRead = (int) Math.min(toRead, 19);
+ ii.readBytes(buf, 0, bytesRead);
+ toRead = toRead - bytesRead;
+ baos.write(buf, 0, bytesRead);
+ }
+
+ assert new String(baos.toByteArray()).equals(worldText);
+
+ }
+
+ public void writeChunks() throws Exception
+ {
+ JBCDirectory.CHUNK_SIZE = 64;
+ JBCDirectory.CHUNK_SIZE_BITS = 6;
+ JBCDirectory.CHUNK_MASK = 63;
+
+ Cache cache = new DefaultCacheFactory().createCache();
+ Node d = cache.getRoot().addChild(Fqn.fromString("/Dir"));
+
+ JBCDirectory dir = new JBCDirectory(d, cache);
+
+ IndexOutput io = dir.createOutput("MyNewFile.txt");
+
+ io.writeByte((byte) 66);
+ io.writeByte((byte) 69);
+
+ io.close();
+
+ assert d.hasChild("MyNewFile.txt");
+ Node f = d.getChild("MyNewFile.txt");
+ assert f.hasChild(new Integer(0));
+
+ // test contents by reading:
+ byte[] buf = new byte[9];
+ IndexInput ii = dir.openInput("MyNewFile.txt");
+ ii.readBytes(buf, 0, (int) ii.length());
+
+ assert new String(new byte[]{66, 69}).equals(new String(buf).trim());
+
+ String testText = "This is some rubbish again that will span more than one chunk - one hopes. Who knows, maybe even three or four chunks.";
+ io.seek(0);
+ io.writeBytes(testText.getBytes(), 0, testText.length());
+ io.close();
+ // now compare.
+ assert d.hasChild("MyNewFile.txt");
+ f = d.getChild("MyNewFile.txt");
+ assert f.hasChild(new Integer(0));
+ assert f.hasChild(new Integer(1));
+
+ Node c0 = f.getChild(new Integer(0));
+ Node c1 = f.getChild(new Integer(1));
+
+ assert testText.equals(new String((byte[]) c0.get("buf")) + new String((byte[]) c1.get("buf")).trim());
+
+ }
+
+}
16 years, 10 months
JBoss Cache SVN: r5344 - jbosscache-lucene.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-02-12 13:28:00 -0500 (Tue, 12 Feb 2008)
New Revision: 5344
Added:
jbosscache-lucene/trunk/
Log:
16 years, 10 months
JBoss Cache SVN: r5343 - /.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-02-12 13:27:51 -0500 (Tue, 12 Feb 2008)
New Revision: 5343
Added:
jbosscache-lucene/
Log:
16 years, 10 months
JBoss Cache SVN: r5342 - in core/trunk/src/main/java/org/jboss/cache/marshall: io and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-02-11 17:00:17 -0500 (Mon, 11 Feb 2008)
New Revision: 5342
Modified:
core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java
core/trunk/src/main/java/org/jboss/cache/marshall/io/ReusableObjectInputStream.java
core/trunk/src/main/java/org/jboss/cache/marshall/io/ReusableObjectOutputStream.java
Log:
make sure we add object stream headers so streams from reusable streams are compatible with JDK object streams
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java 2008-02-11 13:54:22 UTC (rev 5341)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java 2008-02-11 22:00:17 UTC (rev 5342)
@@ -13,7 +13,6 @@
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.marshall.io.ObjectStreamPool;
-import org.jboss.cache.marshall.io.ReusableObjectInputStream;
import org.jboss.cache.marshall.io.ReusableObjectOutputStream;
import org.jboss.cache.util.Util;
import org.jboss.util.stream.MarshalledValueInputStream;
@@ -23,8 +22,6 @@
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.io.PushbackInputStream;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
@@ -240,15 +237,17 @@
// we don't have a reusable implementation for non-byte-backed streams as yet.
short versionId;
Marshaller marshaller;
- PushbackInputStream pis = new PushbackInputStream(is);
- byte[] first4bytes = new byte[4];
- pis.read(first4bytes);
- boolean needToWriteHeader = !Arrays.equals(first4bytes, ReusableObjectInputStream.INIT_BYTES);
- // first push back the bytes read
- pis.unread(first4bytes);
- if (needToWriteHeader) pis.unread(ReusableObjectInputStream.INIT_BYTES);
- ObjectInputStream in = new MarshalledValueInputStream(pis);
+// PushbackInputStream pis = new PushbackInputStream(is);
+// byte[] first4bytes = new byte[4];
+// pis.read(first4bytes);
+// boolean needToWriteHeader = !Arrays.equals(first4bytes, ReusableObjectInputStream.INIT_BYTES);
+// // first push back the bytes read
+// pis.unread(first4bytes);
+// if (needToWriteHeader) pis.unread(ReusableObjectInputStream.INIT_BYTES);
+//
+// ObjectInputStream in = new MarshalledValueInputStream(pis);
+ ObjectInputStream in = new MarshalledValueInputStream(is);
try
{
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/io/ReusableObjectInputStream.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/io/ReusableObjectInputStream.java 2008-02-11 13:54:22 UTC (rev 5341)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/io/ReusableObjectInputStream.java 2008-02-11 22:00:17 UTC (rev 5342)
@@ -1,5 +1,6 @@
package org.jboss.cache.marshall.io;
+import org.jboss.cache.CacheException;
import org.jboss.util.stream.MarshalledValueInputStream;
import java.io.ByteArrayInputStream;
@@ -86,9 +87,10 @@
*/
public void init(byte[] b)
{
+ if (b.length < 4) throw new CacheException("No header bytes!");
buf = b;
count = buf.length;
- pos = 0;
+ pos = 4;
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/io/ReusableObjectOutputStream.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/io/ReusableObjectOutputStream.java 2008-02-11 13:54:22 UTC (rev 5341)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/io/ReusableObjectOutputStream.java 2008-02-11 22:00:17 UTC (rev 5342)
@@ -96,7 +96,9 @@
public void init()
{
if (buf == null) buf = new byte[defaultBufferSize];
- count = 0;
+ // write the header bytes
+ System.arraycopy(ReusableObjectInputStream.INIT_BYTES, 0, buf, 0, 4);
+ count = 4;
}
}
}
16 years, 10 months
Build failed in Hudson: jboss-cache-core-jdk1.6 » JBoss Cache - Core Edition #188
by jboss-qa-internal@redhat.com
See https://hudson.jboss.org/hudson/job/jboss-cache-core-jdk1.6/org.jboss.cac...
Changes:
[galder.zamarreno(a)jboss.com] Added svn ignores for: .classpath, .project, eclipse-output and .settings
------------------------------------------
[...truncated 76327 lines...]
cache1 (after rollback):
cache2 (after rollback):
-------------------------------------------------------
GMS: address is 127.0.0.1:49318
-------------------------------------------------------
-------------------------------------------------------
GMS: address is 127.0.0.1:49319
-------------------------------------------------------
TransactionTable for cache1 after cache1.put():
LocalTransactions: 1
GlobalTransactions: 1
tx_map:
org.jboss.cache.transaction.DummyTransaction@13a3d36: GlobalTransaction:<127.0.0.1:49318>:27
txs:
GlobalTransaction:<127.0.0.1:49318>:27: TransactionEntry
modification_list: [MethodName: _put; MethodIdInteger: 3; Args: ( arg[0] = GlobalTransaction:<127.0.0.1:49318>:27 ...)]
undo_list: [MethodName: _remove; MethodIdInteger: 5; Args: ( arg[0] = GlobalTransaction:<127.0.0.1:49318>:27 ...), MethodName: _remove; MethodIdInteger: 5; Args: ( arg[0] = GlobalTransaction:<127.0.0.1:49318>:27 ...), MethodName: _remove; MethodIdInteger: 5; Args: ( arg[0] = GlobalTransaction:<127.0.0.1:49318>:27 ...), MethodName: _remove; MethodIdInteger: 6; Args: ( arg[0] = GlobalTransaction:<127.0.0.1:49318>:27 ...)]
locks: [read owners=[GlobalTransaction:<127.0.0.1:49318>:27], write owner=GlobalTransaction:<127.0.0.1:49318>:27, write owner=GlobalTransaction:<127.0.0.1:49318>:27, write owner=GlobalTransaction:<127.0.0.1:49318>:27]
TransactionTable for cache2 after cache2.put():
LocalTransactions: 1
GlobalTransactions: 1
tx_map:
org.jboss.cache.transaction.DummyTransaction@13a3d36: GlobalTransaction:<127.0.0.1:49319>:28
txs:
GlobalTransaction:<127.0.0.1:49319>:28: TransactionEntry
modification_list: [MethodName: _put; MethodIdInteger: 3; Args: ( arg[0] = GlobalTransaction:<127.0.0.1:49319>:28 ...)]
undo_list: [MethodName: _remove; MethodIdInteger: 5; Args: ( arg[0] = GlobalTransaction:<127.0.0.1:49319>:28 ...), MethodName: _remove; MethodIdInteger: 5; Args: ( arg[0] = GlobalTransaction:<127.0.0.1:49319>:28 ...), MethodName: _remove; MethodIdInteger: 5; Args: ( arg[0] = GlobalTransaction:<127.0.0.1:49319>:28 ...), MethodName: _remove; MethodIdInteger: 6; Args: ( arg[0] = GlobalTransaction:<127.0.0.1:49319>:28 ...)]
locks: [read owners=[GlobalTransaction:<127.0.0.1:49319>:28], write owner=GlobalTransaction:<127.0.0.1:49319>:28, write owner=GlobalTransaction:<127.0.0.1:49319>:28, write owner=GlobalTransaction:<127.0.0.1:49319>:28]
cache1 before commit:
/one (write owner=GlobalTransaction:<127.0.0.1:49318>:27)
/two (write owner=GlobalTransaction:<127.0.0.1:49318>:27)
/three (write owner=GlobalTransaction:<127.0.0.1:49318>:27)
cache2 before commit:
/one (write owner=GlobalTransaction:<127.0.0.1:49319>:28)
/two (write owner=GlobalTransaction:<127.0.0.1:49319>:28)
/three (write owner=GlobalTransaction:<127.0.0.1:49319>:28)
Transaction was rolled back, this is correct
cache1 after commit:
cache2 after commit:
-------------------------------------------------------
GMS: address is 127.0.0.1:49320
-------------------------------------------------------
-------------------------------------------------------
GMS: address is 127.0.0.1:49321
-------------------------------------------------------
[Thread2] ** LOCK INFO cache1:
/bela (write owner=GlobalTransaction:<127.0.0.1:49320>:29)
/ban (write owner=GlobalTransaction:<127.0.0.1:49320>:29)
[Thread2] ** LOCK INFO cache2:
[Thread2] ** LOCK INFO cache1:
/bela (read owners=[GlobalTransaction:<127.0.0.1:49320>:30])
/ban (write owner=GlobalTransaction:<127.0.0.1:49320>:30)
[Thread2] ** LOCK INFO cache2:
/bela
/ban
[Thread1] ** LOCK INFO cache1:
/bela (read owners=[GlobalTransaction:<127.0.0.1:49320>:30])
/ban (write owner=GlobalTransaction:<127.0.0.1:49320>:30)
[Thread1] ** LOCK INFO cache2:
/bela
/ban
[Thread2] ** LOCK INFO cache1:
/bela
/ban
[Thread2] ** LOCK INFO cache2:
/bela
/ban
Tests run: 17, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 140.459 sec
Running org.jboss.cache.notifications.NotificationThreadTest (of functional)
-------------------------------------------------------
GMS: address is 127.0.0.1:49289
-------------------------------------------------------
-------------------------------------------------------
GMS: address is 127.0.0.1:49290
-------------------------------------------------------
-------------------------------------------------------
GMS: address is 127.0.0.1:49291
-------------------------------------------------------
-------------------------------------------------------
GMS: address is 127.0.0.1:49292
-------------------------------------------------------
-------------------------------------------------------
GMS: address is 127.0.0.1:49293
-------------------------------------------------------
-------------------------------------------------------
GMS: address is 127.0.0.1:49294
-------------------------------------------------------
-------------------------------------------------------
GMS: address is 127.0.0.1:49295
-------------------------------------------------------
-------------------------------------------------------
GMS: address is 127.0.0.1:49296
-------------------------------------------------------
-------------------------------------------------------
GMS: address is 127.0.0.1:49297
-------------------------------------------------------
-------------------------------------------------------
GMS: address is 127.0.0.1:49298
-------------------------------------------------------
-------------------------------------------------------
GMS: address is 127.0.0.1:49299
-------------------------------------------------------
-------------------------------------------------------
GMS: address is 127.0.0.1:49300
-------------------------------------------------------
-------------------------------------------------------
GMS: address is 127.0.0.1:49301
-------------------------------------------------------
-------------------------------------------------------
GMS: address is 127.0.0.1:49302
-------------------------------------------------------
-------------------------------------------------------
GMS: address is 127.0.0.1:49303
-------------------------------------------------------
-------------------------------------------------------
GMS: address is 127.0.0.1:49304
-------------------------------------------------------
Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 46.592 sec
Results :
Failed tests:
Tests run: 2661, Failures: 227, Errors: 0, Skipped: 0
[ERROR] There are test failures.
[HUDSON] Recording test results
[INFO] Preparing surefire-report:report-only
[INFO] [enforcer:enforce {execution: enforce-java}]
[INFO] Preparing findbugs:findbugs
[INFO] [enforcer:enforce {execution: enforce-java}]
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [site:site]
[INFO] Unable to load parent project from a relative path: Could not find the model file '/home/hudson/hudson_workspace/workspace/jboss-cache-core-jdk1.6/./../pom.xml'.
[INFO] Parent project loaded from repository.
Downloading: http://snapshots.jboss.org/maven2/org/jboss/cache/jbosscache-common-paren...
Downloading: http://snapshots.jboss.org/maven2/org/jboss/cache/jbosscache-common-paren...
[INFO] Parent project loaded from repository.
Downloading: http://snapshots.jboss.org/maven2/org/jboss/cache/jbosscache-support/1.1-...
Downloading: http://snapshots.jboss.org/maven2/org/jboss/cache/jbosscache-support/1.1-...
[INFO] artifact org.apache.maven.skins:maven-default-skin: checking for updates from repository.jboss.org
[INFO] artifact org.apache.maven.skins:maven-default-skin: checking for updates from snapshots.jboss.org
[INFO] Skipped "Maven Surefire Report" report, file "surefire-report.html" already exists for the English version.
[INFO] Generating "Source Xref" report.
[WARNING] Unable to locate Javadoc to link to - DISABLED
[INFO] Generating "Test Source Xref" report.
[INFO] Generating "CPD Report" report.
[INFO] Generating "PMD Report" report.
[INFO] Generating "Maven Surefire Report" report.
[INFO] Generating "FindBugs Report" report.
[HUDSON] Archiving /home/hudson/hudson_workspace/workspace/jboss-cache-core-jdk1.6/./pom.xml
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] org/apache/maven/plugin/logging/Log
[INFO] ------------------------------------------------------------------------
[INFO] Trace
java.lang.NoClassDefFoundError: org/apache/maven/plugin/logging/Log
at org.codehaus.mojo.findbugs.FindBugsMojo.debugSourceDirectory(FindBugsMojo.java:698)
at org.codehaus.mojo.findbugs.FindBugsMojo.executeReport(FindBugsMojo.java:718)
at org.apache.maven.reporting.AbstractMavenReport.generate(AbstractMavenReport.java:101)
at org.apache.maven.plugins.site.ReportDocumentRenderer.renderDocument(ReportDocumentRenderer.java:139)
at org.apache.maven.doxia.siterenderer.DefaultSiteRenderer.renderModule(DefaultSiteRenderer.java:269)
at org.apache.maven.doxia.siterenderer.DefaultSiteRenderer.render(DefaultSiteRenderer.java:101)
at org.apache.maven.plugins.site.SiteMojo.renderLocale(SiteMojo.java:129)
at org.apache.maven.plugins.site.SiteMojo.execute(SiteMojo.java:96)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:443)
at hudson.maven.agent.PluginManagerInterceptor.executeMojo(PluginManagerInterceptor.java:135)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:480)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:459)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:278)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
at org.apache.maven.lifecycle.LifecycleExecutorInterceptor.execute(LifecycleExecutorInterceptor.java:42)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:334)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:125)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:272)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at hudson.maven.agent.Main.launch(Main.java:97)
at hudson.maven.MavenBuilder.call(MavenBuilder.java:129)
at hudson.maven.MavenBuilder.call(MavenBuilder.java:52)
at hudson.remoting.UserRequest.perform(UserRequest.java:69)
at hudson.remoting.UserRequest.perform(UserRequest.java:23)
at hudson.remoting.Request$2.run(Request.java:200)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 107 minutes 9 seconds
[INFO] Finished at: Mon Feb 11 13:53:12 EST 2008
[INFO] Final Memory: 37M/114M
[INFO] ------------------------------------------------------------------------
Waiting for Hudson to finish collecting data
Sending e-mails to: dpospisi(a)redhat.com galder.zamarreno(a)jboss.com
Build was marked for publishing on https://hudson.jboss.org/hudson/
finished: FAILURE
16 years, 10 months
JBoss Cache SVN: r5341 - core/trunk.
by jbosscache-commits@lists.jboss.org
Author: galder.zamarreno(a)jboss.com
Date: 2008-02-11 08:54:22 -0500 (Mon, 11 Feb 2008)
New Revision: 5341
Modified:
core/trunk/
Log:
Added svn ignores for: .classpath, .project, eclipse-output and .settings
Property changes on: core/trunk
___________________________________________________________________
Name: svn:ignore
- output
build.log
junit*
0000*
je.lck
*.iml
*.ipr
*.iws
bin
jbossdb
dist
derby.log
target
build
+ output
build.log
junit*
0000*
je.lck
*.iml
*.ipr
*.iws
bin
jbossdb
dist
derby.log
target
build
.classpath
.project
.settings
eclipse-output
16 years, 10 months
JBoss Cache SVN: r5340 - core/trunk/src/test/java/org/jboss/cache/api.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-02-08 13:48:35 -0500 (Fri, 08 Feb 2008)
New Revision: 5340
Modified:
core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java
Log:
Rolled back immutable/defensively copied map performance enhancement
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java 2008-02-08 18:47:21 UTC (rev 5339)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java 2008-02-08 18:48:35 UTC (rev 5340)
@@ -178,6 +178,31 @@
tm.commit();
}
+ public void testImmutabilityOfData()
+ {
+ rootNode.put("key", "value");
+ Map<Object, Object> m = rootNode.getData();
+ try
+ {
+ m.put("x", "y");
+ fail("Map should be immutable!!");
+ }
+ catch (Exception e)
+ {
+ // expected
+ }
+
+ try
+ {
+ rootNode.getKeys().add(new Object());
+ fail("Key set should be immutable");
+ }
+ catch (Exception e)
+ {
+ // expected
+ }
+ }
+
public void testImmutabilityOfChildren()
{
rootNode.addChild(A);
16 years, 10 months
JBoss Cache SVN: r5339 - in core/trunk/src: test/java/org/jboss/cache/api and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-02-08 13:47:21 -0500 (Fri, 08 Feb 2008)
New Revision: 5339
Modified:
core/trunk/src/main/java/org/jboss/cache/NodeSPI.java
core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
core/trunk/src/test/java/org/jboss/cache/api/NodeSPITest.java
Log:
Rolled back immutable/defensively copied map performance enhancement
Modified: core/trunk/src/main/java/org/jboss/cache/NodeSPI.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/NodeSPI.java 2008-02-08 18:45:18 UTC (rev 5338)
+++ core/trunk/src/main/java/org/jboss/cache/NodeSPI.java 2008-02-08 18:47:21 UTC (rev 5339)
@@ -40,11 +40,6 @@
* It is important to node that the direct <b>read</b> methods, such as getDataDirect(), return unmodifiable collections.
* In addition to being unmodifiable, they are also defensively copied from the underlying data map to ensure view consistency.
* <p/>
- * <b>Note:</b> the above paragraph was true for JBoss Cache 2.0.0, but for 2.1.0, this has changed to now offer direct view of
- * the data structures, since the defensive copying was seriously affecting scalability. Please use the *Direct() methods
- * with care - even though you may be able to directly manipulate the data structures returned, the cache isn't designed
- * for you to do so. Use with care.
- * <p/>
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
* @see Node
Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-02-08 18:45:18 UTC (rev 5338)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-02-08 18:47:21 UTC (rev 5339)
@@ -223,8 +223,7 @@
public Map getDataDirect()
{
if (data == null) return Collections.emptyMap();
- //return Collections.unmodifiableMap(data);
- return data; // wrapping in an unmodifiable map is too expensive!
+ return Collections.unmodifiableMap(data);
}
public Object put(Object key, Object value)
@@ -487,8 +486,7 @@
public Set<Object> getChildrenNamesDirect()
{
- //return children == null ? Collections.emptySet() : new HashSet<Object>(children.keySet());
- return children == null ? Collections.emptySet() : children.keySet();
+ return children == null ? Collections.emptySet() : new HashSet<Object>(children.keySet());
}
public Set<Object> getKeysDirect()
@@ -497,8 +495,7 @@
{
return Collections.emptySet();
}
-// return Collections.unmodifiableSet(new HashSet<Object>(data.keySet()));
- return data.keySet();
+ return Collections.unmodifiableSet(new HashSet<Object>(data.keySet()));
}
public boolean removeChildDirect(Object childName)
@@ -637,8 +634,7 @@
NodeSPI spi = (NodeSPI) n;
if (!spi.isDeleted()) exclDeleted.add(spi);
}
-// return Collections.unmodifiableSet(exclDeleted);
- return exclDeleted;
+ return Collections.unmodifiableSet(exclDeleted);
}
public boolean hasChildrenDirect()
@@ -652,8 +648,7 @@
{
if (children != null && !children.isEmpty())
{
-// return Collections.unmodifiableSet(new HashSet(children.values()));
- return new HashSet(children.values());
+ return Collections.unmodifiableSet(new HashSet(children.values()));
}
else
{
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeSPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeSPITest.java 2008-02-08 18:45:18 UTC (rev 5338)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeSPITest.java 2008-02-08 18:47:21 UTC (rev 5339)
@@ -83,26 +83,26 @@
Map dataDirect = root.getDataDirect();
Set keysDirect = root.getKeysDirect();
-// try
-// {
-// dataDirect.remove("k");
-// fail("getDataDirect() should return an unmodifiable collection object");
-// }
-// catch (UnsupportedOperationException uoe)
-// {
-// // good; should be immutable
-// }
-//
-// try
-// {
-// keysDirect.clear();
-// fail("getKeysDirect() should return an unmodifiable collection object");
-// }
-// catch (UnsupportedOperationException uoe)
-// {
-// // good; should be immutable
-// }
+ try
+ {
+ dataDirect.remove("k");
+ fail("getDataDirect() should return an unmodifiable collection object");
+ }
+ catch (UnsupportedOperationException uoe)
+ {
+ // good; should be immutable
+ }
+ try
+ {
+ keysDirect.clear();
+ fail("getKeysDirect() should return an unmodifiable collection object");
+ }
+ catch (UnsupportedOperationException uoe)
+ {
+ // good; should be immutable
+ }
+
// now test defensive copy
root.put("k2", "v2");
@@ -111,7 +111,7 @@
assertTrue("getKeysDirect() should have made a defensive copy of the data collection object", !keysDirect.contains("k2"));
}
- public void testChildrenDefensiveCopy()
+ public void testChildrenImmutabilityAndDefensiveCopy()
{
// put some stuff in the root node
String childName = "childName";
@@ -119,7 +119,17 @@
root.addChild(new Fqn<String>(childName));
Set childrenDirect = root.getChildrenDirect();
- // test defensive copy
+ try
+ {
+ childrenDirect.clear();
+ fail("getChildrenDirect() should return an unmodifiable collection object");
+ }
+ catch (UnsupportedOperationException uoe)
+ {
+ // good; should be immutable
+ }
+
+ // now test defensive copy
root.addChild(new Fqn<String>(newChild));
assertTrue("root.addChild() should have succeeded", root.getChildrenNamesDirect().contains(newChild));
16 years, 10 months
JBoss Cache SVN: r5338 - core/trunk/src/main/java/org/jboss/cache/marshall/io.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-02-08 13:45:18 -0500 (Fri, 08 Feb 2008)
New Revision: 5338
Modified:
core/trunk/src/main/java/org/jboss/cache/marshall/io/ReusableObjectInputStream.java
Log:
push back header if it doesn't exist in the stream
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/io/ReusableObjectInputStream.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/io/ReusableObjectInputStream.java 2008-02-08 18:24:39 UTC (rev 5337)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/io/ReusableObjectInputStream.java 2008-02-08 18:45:18 UTC (rev 5338)
@@ -17,6 +17,11 @@
*/
public class ReusableObjectInputStream extends MarshalledValueInputStream
{
+ public final static byte[] INIT_BYTES = {(byte) ((STREAM_MAGIC >>> 8) & 0xFF),
+ (byte) ((STREAM_MAGIC) & 0xFF),
+ (byte) ((STREAM_VERSION >>> 8)),
+ (byte) ((STREAM_VERSION) & 0xFF),
+ TC_BLOCKDATA, 0};
ResettableByteArrayInputStream bytes;
public ReusableObjectInputStream() throws IOException, SecurityException
@@ -58,12 +63,6 @@
*/
static class ResettableByteArrayInputStream extends ByteArrayInputStream
{
- private final static byte[] INIT_BYTES = {(byte) ((STREAM_MAGIC >>> 8) & 0xFF),
- (byte) ((STREAM_MAGIC) & 0xFF),
- (byte) ((STREAM_VERSION >>> 8)),
- (byte) ((STREAM_VERSION) & 0xFF),
- TC_BLOCKDATA, 0};
-
/**
* Creates a new instance with a null byte buffer. Use {@link #init(byte[])} to set the byte buffer to use.
*/
16 years, 10 months