[jboss-cvs] JBossAS SVN: r104216 - in projects/demos/microcontainer/trunk: gfs and 10 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Apr 24 16:15:55 EDT 2010
Author: alesj
Date: 2010-04-24 16:15:54 -0400 (Sat, 24 Apr 2010)
New Revision: 104216
Added:
projects/demos/microcontainer/trunk/gfs/
projects/demos/microcontainer/trunk/gfs/bond.iso
projects/demos/microcontainer/trunk/gfs/pom.xml
projects/demos/microcontainer/trunk/gfs/src/
projects/demos/microcontainer/trunk/gfs/src/main/
projects/demos/microcontainer/trunk/gfs/src/main/java/
projects/demos/microcontainer/trunk/gfs/src/main/java/org/
projects/demos/microcontainer/trunk/gfs/src/main/java/org/jboss/
projects/demos/microcontainer/trunk/gfs/src/main/java/org/jboss/demos/
projects/demos/microcontainer/trunk/gfs/src/main/java/org/jboss/demos/gfs/
projects/demos/microcontainer/trunk/gfs/src/main/java/org/jboss/demos/gfs/Test.java
projects/demos/microcontainer/trunk/gfs/src/main/resources/
projects/demos/microcontainer/trunk/gfs/src/main/resources/META-INF/
projects/demos/microcontainer/trunk/gfs/src/main/resources/META-INF/gfs-beans.xml
projects/demos/microcontainer/trunk/gfs/src/main/resources/META-INF/jboss-infinispan.xml
Modified:
projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/gfs/MountGFStoVFS.java
projects/demos/microcontainer/trunk/pom.xml
Log:
Test GFS.
Added: projects/demos/microcontainer/trunk/gfs/bond.iso
===================================================================
--- projects/demos/microcontainer/trunk/gfs/bond.iso (rev 0)
+++ projects/demos/microcontainer/trunk/gfs/bond.iso 2010-04-24 20:15:54 UTC (rev 104216)
@@ -0,0 +1 @@
+My name is Bond, James Bond.
Added: projects/demos/microcontainer/trunk/gfs/pom.xml
===================================================================
--- projects/demos/microcontainer/trunk/gfs/pom.xml (rev 0)
+++ projects/demos/microcontainer/trunk/gfs/pom.xml 2010-04-24 20:15:54 UTC (rev 104216)
@@ -0,0 +1,31 @@
+<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/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.demos</groupId>
+ <artifactId>jboss-demos</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.demos</groupId>
+ <artifactId>jboss-demos-gfs</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss MC Demos GFS</name>
+ <url>http://www.jboss.org/jbossmc</url>
+ <description>JBoss MC Demos</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.demos</groupId>
+ <artifactId>jboss-demos-bootstrap</artifactId>
+ </dependency>
+ <!-- Compile (global dependencies) -->
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.infinispan</groupId>
+ <artifactId>infinispan-core</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
Added: projects/demos/microcontainer/trunk/gfs/src/main/java/org/jboss/demos/gfs/Test.java
===================================================================
--- projects/demos/microcontainer/trunk/gfs/src/main/java/org/jboss/demos/gfs/Test.java (rev 0)
+++ projects/demos/microcontainer/trunk/gfs/src/main/java/org/jboss/demos/gfs/Test.java 2010-04-24 20:15:54 UTC (rev 104216)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.demos.gfs;
+
+import java.io.*;
+
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VirtualFile;
+
+import org.infinispan.io.GridFilesystem;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class Test
+{
+ private GridFilesystem gfs;
+
+ public Test(GridFilesystem gfs)
+ {
+ if (gfs == null)
+ throw new IllegalArgumentException("Null GFS");
+ this.gfs = gfs;
+ }
+
+ public void create() throws Exception
+ {
+ File file = new File("/Users/alesj/projects/demos/mc/gfs/bond.iso");
+ if (file.exists() == false)
+ throw new IllegalArgumentException("File doesn't exist: " + file);
+
+ File movies = gfs.getFile("movies");
+ if (movies.mkdir() == false)
+ throw new IllegalArgumentException("Failed to create movies dir.");
+
+ InputStream in = new FileInputStream(file);
+ OutputStream out = gfs.getOutput("movies/bond.iso");
+ byte[] buffer = new byte[20000];
+ int len;
+ while ((len = in.read(buffer, 0, buffer.length)) != -1)
+ {
+ out.write(buffer, 0, len);
+ }
+ in.close();
+ out.close();
+ }
+
+ public void start() throws Exception
+ {
+ VirtualFile grid = VFS.getChild("GFS-" + gfs.hashCode());
+ VirtualFile file = grid.getChild("movies/bond.iso");
+ InputStream is = file.openStream();
+ try
+ {
+ int ch;
+ while((ch = is.read()) != -1)
+ System.out.print((char)ch);
+ }
+ finally
+ {
+ is.close();
+ }
+ }
+
+ public void stop() throws Exception
+ {
+ VirtualFile grid = VFS.getChild("GRID-" + gfs.hashCode());
+ VirtualFile file = grid.getChild("movies/bond.iso");
+ file.delete();
+ }
+
+ public void destroy() throws Exception
+ {
+ VirtualFile grid = VFS.getChild("GRID-" + gfs.hashCode());
+ VirtualFile file = grid.getChild("movies/bond.iso");
+ if (file.exists())
+ throw new IllegalArgumentException("Didn't delete grid file: " + file);
+
+ gfs.remove("movies", true);
+ }
+}
Added: projects/demos/microcontainer/trunk/gfs/src/main/resources/META-INF/gfs-beans.xml
===================================================================
--- projects/demos/microcontainer/trunk/gfs/src/main/resources/META-INF/gfs-beans.xml (rev 0)
+++ projects/demos/microcontainer/trunk/gfs/src/main/resources/META-INF/gfs-beans.xml 2010-04-24 20:15:54 UTC (rev 104216)
@@ -0,0 +1,9 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Test" class="org.jboss.demos.gfs.Test">
+ <constructor>
+ <parameter><inject/></parameter>
+ </constructor>
+ </bean>
+
+</deployment>
Added: projects/demos/microcontainer/trunk/gfs/src/main/resources/META-INF/jboss-infinispan.xml
===================================================================
--- projects/demos/microcontainer/trunk/gfs/src/main/resources/META-INF/jboss-infinispan.xml (rev 0)
+++ projects/demos/microcontainer/trunk/gfs/src/main/resources/META-INF/jboss-infinispan.xml 2010-04-24 20:15:54 UTC (rev 104216)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<infinispan
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:infinispan:config:4.0 http://www.infinispan.org/schemas/infinispan-config-4.0.xsd"
+ xmlns="urn:infinispan:config:4.0">
+ <global>
+ <transport clusterName="WebDavGridFS" />
+ </global>
+
+ <default>
+ <locking concurrencyLevel="1000" lockAcquisitionTimeout="60000" />
+ <lazyDeserialization enabled="true" />
+ </default>
+
+ <namedCache name="data">
+ <clustering mode="d">
+ <sync replTimeout="60000" />
+ <l1 enabled="false" />
+ </clustering>
+ </namedCache>
+
+ <namedCache name="metadata">
+ <clustering mode="r">
+ <sync replTimeout="60000" />
+ <stateRetrieval fetchInMemoryState="true" />
+ </clustering>
+ </namedCache>
+</infinispan>
Modified: projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/gfs/MountGFStoVFS.java
===================================================================
--- projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/gfs/MountGFStoVFS.java 2010-04-24 19:34:37 UTC (rev 104215)
+++ projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/gfs/MountGFStoVFS.java 2010-04-24 20:15:54 UTC (rev 104216)
@@ -39,9 +39,6 @@
*/
public class MountGFStoVFS
{
- /** The temp counter - temp workaround */
- private AtomicInteger counter = new AtomicInteger();
-
// closeable handle for file system
private Map<GridFilesystem, Closeable> handles = new HashMap<GridFilesystem, Closeable>();
@@ -53,7 +50,7 @@
*/
public void mount(GridFilesystem gfs) throws Exception
{
- VirtualFile grid = VFS.getChild("GFS-" + counter.incrementAndGet()); // TODO gfs should have some qualifier
+ VirtualFile grid = VFS.getChild("GFS-" + gfs.hashCode()); // TODO gfs should have some qualifier
Closeable closeable = VFS.mount(grid, new GridFileSystem(gfs));
handles.put(gfs, closeable);
}
Modified: projects/demos/microcontainer/trunk/pom.xml
===================================================================
--- projects/demos/microcontainer/trunk/pom.xml 2010-04-24 19:34:37 UTC (rev 104215)
+++ projects/demos/microcontainer/trunk/pom.xml 2010-04-24 20:15:54 UTC (rev 104216)
@@ -35,6 +35,7 @@
<module>policy</module>
<module>threads</module>
<module>infinispan</module>
+ <module>gfs</module>
<!-- <module>osgi</module> -->
<module>build</module>
</modules>
More information about the jboss-cvs-commits
mailing list