You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by mr...@apache.org on 2009/04/08 14:47:32 UTC

svn commit: r763222 - in /jackrabbit/sandbox/jackrabbit-spi2hadoop: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/jackrabbit/ src/main/java/org/apache/jackrabbit/spi/ src/main/java/org/apache/jac...

Author: mreutegg
Date: Wed Apr  8 12:47:31 2009
New Revision: 763222

URL: http://svn.apache.org/viewvc?rev=763222&view=rev
Log:
SPI implementation on top of Hadoop HDFS

Added:
    jackrabbit/sandbox/jackrabbit-spi2hadoop/   (with props)
    jackrabbit/sandbox/jackrabbit-spi2hadoop/README.txt   (with props)
    jackrabbit/sandbox/jackrabbit-spi2hadoop/pom.xml   (with props)
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/AbstractNodeInfo.java   (with props)
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/FileInfo.java   (with props)
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/FolderInfo.java   (with props)
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/HadoopRepositoryService.java   (with props)
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/ResourceInfo.java   (with props)
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/resources/
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/resources/org/
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/resources/org/apache/
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/resources/org/apache/jackrabbit/
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/resources/org/apache/jackrabbit/spi/
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/resources/org/apache/jackrabbit/spi/hadoop/
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/resources/org/apache/jackrabbit/spi/hadoop/descriptor.properties   (with props)
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/resources/org/apache/jackrabbit/spi/hadoop/files-and-folders.cnd
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/test/
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/test/java/
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/test/java/org/
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/test/java/org/apache/
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/test/java/org/apache/jackrabbit/
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/test/java/org/apache/jackrabbit/spi/
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/test/java/org/apache/jackrabbit/spi/hadoop/
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/test/java/org/apache/jackrabbit/spi/hadoop/HadoopRepositoryConfig.java   (with props)
    jackrabbit/sandbox/jackrabbit-spi2hadoop/src/test/java/org/apache/jackrabbit/spi/hadoop/Main.java   (with props)

Propchange: jackrabbit/sandbox/jackrabbit-spi2hadoop/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Apr  8 12:47:31 2009
@@ -0,0 +1,4 @@
+*.iml
+*.ipr
+*.iws
+target

Added: jackrabbit/sandbox/jackrabbit-spi2hadoop/README.txt
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-spi2hadoop/README.txt?rev=763222&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-spi2hadoop/README.txt (added)
+++ jackrabbit/sandbox/jackrabbit-spi2hadoop/README.txt Wed Apr  8 12:47:31 2009
@@ -0,0 +1,10 @@
+This module provides an SPI implementation on top of Hadoop HDFS.
+The files and folders are exposed as nt:file/nt:resource and
+nt:folder.
+
+Limitation: nt:resource nodes are not referenceable!
+
+Building this module requires JAVA 6 and you need to manually
+deploy the dependency hadoop-core-0.19.0.jar.
+Simply run 'mvn install' and you will get instructions on how
+this can be done.

Propchange: jackrabbit/sandbox/jackrabbit-spi2hadoop/README.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/sandbox/jackrabbit-spi2hadoop/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-spi2hadoop/pom.xml?rev=763222&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-spi2hadoop/pom.xml (added)
+++ jackrabbit/sandbox/jackrabbit-spi2hadoop/pom.xml Wed Apr  8 12:47:31 2009
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+  -->
+
+<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">
+    <modelVersion>4.0.0</modelVersion>
+
+    <!-- ====================================================================== -->
+    <!-- P R O J E C T  D E S C R I P T I O N                                   -->
+    <!-- ====================================================================== -->
+    <groupId>org.apache.jackrabbit</groupId>
+    <artifactId>jackrabbit-spi2hadoop</artifactId>
+    <version>1.6-SNAPSHOT</version>
+    <name>Jackrabbit SPI to Hadoop</name>
+    <description>Jackrabbit SPI implementation on Hadoop HDFS</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>javax.jcr</groupId>
+            <artifactId>jcr</artifactId>
+            <version>1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-spi</artifactId>
+            <version>1.6-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-spi-commons</artifactId>
+            <version>1.6-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>1.5.3</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>jcl-over-slf4j</artifactId>
+            <version>1.5.3</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.hadoop</groupId>
+            <artifactId>hadoop-core</artifactId>
+            <version>0.19.0</version>
+        </dependency>
+        <!-- test -->
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-jcr2spi</artifactId>
+            <version>1.6-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <target>1.6</target>
+                    <source>1.6</source>
+                </configuration>
+            </plugin>
+            <plugin>
+                <artifactId>maven-idea-plugin</artifactId>
+                <version>2.0</version>
+                <configuration>
+                    <downloadSources>true</downloadSources>
+                    <jdkLevel>1.6</jdkLevel>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

Propchange: jackrabbit/sandbox/jackrabbit-spi2hadoop/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/AbstractNodeInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/AbstractNodeInfo.java?rev=763222&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/AbstractNodeInfo.java (added)
+++ jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/AbstractNodeInfo.java Wed Apr  8 12:47:31 2009
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.hadoop;
+
+import java.util.Iterator;
+import java.util.Collections;
+import java.util.Map;
+import java.util.HashMap;
+
+import org.apache.jackrabbit.spi.commons.NodeInfoImpl;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.PropertyInfo;
+import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.hadoop.fs.FileStatus;
+
+/**
+ * <code>AbstractNodeInfo</code>...
+ */
+public class AbstractNodeInfo extends NodeInfoImpl {
+
+    protected static final Iterator EMPTY = Collections.EMPTY_LIST.iterator();
+
+    protected final Map<PropertyId, PropertyInfo> propertyInfos = new HashMap<PropertyId, PropertyInfo>();
+
+    protected final FileStatus status;
+
+    protected final IdFactory idFactory;
+
+    protected final PathFactory pathFactory;
+
+    protected final QValueFactory valueFactory;
+
+    public AbstractNodeInfo(NodeId id, Name primaryTypeName,
+                            Iterator childInfos, IdFactory idFactory,
+                            PathFactory pathFactory, QValueFactory valueFactory,
+                            FileStatus status) {
+        super(id.getPath(), id, 1, primaryTypeName, new Name[0],
+                EMPTY, EMPTY, childInfos);
+        this.status = status;
+        this.idFactory = idFactory;
+        this.pathFactory = pathFactory;
+        this.valueFactory = valueFactory;
+    }
+
+    public Iterator getPropertyIds() {
+        return propertyInfos.keySet().iterator();
+    }
+
+    public PropertyInfo getPropertyInfo(PropertyId id) {
+        return propertyInfos.get(id);
+    }
+}

Propchange: jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/AbstractNodeInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/FileInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/FileInfo.java?rev=763222&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/FileInfo.java (added)
+++ jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/FileInfo.java Wed Apr  8 12:47:31 2009
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.hadoop;
+
+import java.util.Collections;
+import java.util.Calendar;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.PropertyType;
+
+import org.apache.jackrabbit.spi.commons.ChildInfoImpl;
+import org.apache.jackrabbit.spi.commons.PropertyInfoImpl;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.ChildInfo;
+import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+
+/**
+ * <code>FileInfo</code>...
+ */
+public class FileInfo extends AbstractNodeInfo {
+
+    private static final ChildInfo JCR_CONTENT = new ChildInfoImpl(NameConstants.JCR_CONTENT, null, 1);
+
+
+    public FileInfo(NodeId id, FileStatus status, IdFactory idFactory,
+                    PathFactory pathFactory, QValueFactory valueFactory)
+            throws RepositoryException {
+        super(id, NameConstants.NT_FILE, Collections.singleton(JCR_CONTENT).iterator(),
+                idFactory, pathFactory, valueFactory, status);
+        // jcr:primaryType
+        PropertyId propId = idFactory.createPropertyId(getId(), NameConstants.JCR_PRIMARYTYPE);
+        QValue value = valueFactory.create(getNodetype());
+        propertyInfos.put(propId, new PropertyInfoImpl(propId.getPath(), propId, PropertyType.NAME, false, new QValue[]{value}));
+        // jcr:created
+        propId = idFactory.createPropertyId(getId(), NameConstants.JCR_CREATED);
+        Calendar cal = Calendar.getInstance();
+        cal.setTimeInMillis(0);
+        value = valueFactory.create(cal);
+        propertyInfos.put(propId, new PropertyInfoImpl(propId.getPath(), propId, PropertyType.DATE, false, new QValue[]{value}));
+    }
+
+    public ResourceInfo getResourceInfo(FileSystem fs)
+            throws RepositoryException {
+        NodeId id = idFactory.createNodeId(getId(), pathFactory.create(NameConstants.JCR_CONTENT));
+        return new ResourceInfo(id, status, fs, idFactory, pathFactory, valueFactory);
+    }
+}

Propchange: jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/FileInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/FolderInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/FolderInfo.java?rev=763222&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/FolderInfo.java (added)
+++ jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/FolderInfo.java Wed Apr  8 12:47:31 2009
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.hadoop;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Calendar;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.apache.jackrabbit.spi.commons.ChildInfoImpl;
+import org.apache.jackrabbit.spi.commons.PropertyInfoImpl;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.spi.ChildInfo;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.hadoop.fs.FileStatus;
+
+/**
+ * <code>FolderInfo</code>...
+ */
+public class FolderInfo extends AbstractNodeInfo {
+
+    public FolderInfo(NodeId id, IdFactory idFactory, PathFactory pathFactory,
+                      QValueFactory valueFactory, FileStatus status,
+                      Name[] childNames) throws RepositoryException {
+        super(id, NameConstants.NT_FOLDER, getChildInfos(childNames),
+                idFactory, pathFactory, valueFactory, status);
+        // jcr:primaryType
+        PropertyId propId = idFactory.createPropertyId(getId(), NameConstants.JCR_PRIMARYTYPE);
+        QValue value = valueFactory.create(getNodetype());
+        propertyInfos.put(propId, new PropertyInfoImpl(propId.getPath(), propId, PropertyType.NAME, false, new QValue[]{value}));
+        // jcr:created
+        propId = idFactory.createPropertyId(getId(), NameConstants.JCR_CREATED);
+        Calendar cal = Calendar.getInstance();
+        cal.setTimeInMillis(0);
+        value = valueFactory.create(cal);
+        propertyInfos.put(propId, new PropertyInfoImpl(propId.getPath(), propId, PropertyType.DATE, false, new QValue[]{value}));
+    }
+
+    private static Iterator getChildInfos(Name[] childNames) {
+        List<ChildInfo> infos = new ArrayList<ChildInfo>();
+        for (Name n : childNames) {
+            infos.add(new ChildInfoImpl(n, null, 1));
+        }
+        return infos.iterator();
+    }
+}

Propchange: jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/FolderInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/HadoopRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/HadoopRepositoryService.java?rev=763222&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/HadoopRepositoryService.java (added)
+++ jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/HadoopRepositoryService.java Wed Apr  8 12:47:31 2009
@@ -0,0 +1,180 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.hadoop;
+
+import java.util.Map;
+import java.util.Iterator;
+import java.util.HashMap;
+import java.util.Properties;
+import java.util.Collections;
+import java.util.List;
+import java.util.ArrayList;
+import java.io.Reader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.io.FileNotFoundException;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Credentials;
+import javax.jcr.LoginException;
+import javax.jcr.ItemNotFoundException;
+
+import org.apache.jackrabbit.spi.commons.AbstractReadableRepositoryService;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.apache.jackrabbit.spi.commons.nodetype.compact.ParseException;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.SessionInfo;
+import org.apache.jackrabbit.spi.NodeInfo;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.PropertyInfo;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.conf.Configuration;
+
+/**
+ * <code>HadoopRepositoryService</code>...
+ */
+public class HadoopRepositoryService extends AbstractReadableRepositoryService {
+
+    private static final Map DESCRIPTORS;
+
+    static {
+        InputStream in = HadoopRepositoryService.class.getResourceAsStream("descriptor.properties");
+        try {
+            Properties props = new Properties();
+            props.load(in);
+            DESCRIPTORS = Collections.unmodifiableMap(props);
+        } catch (IOException e) {
+            throw (InternalError) new InternalError().initCause(e);
+        } finally {
+            try {
+                in.close();
+            } catch (IOException e) {
+                throw (InternalError) new InternalError().initCause(e);
+            }
+        }
+    }
+
+    private final FileSystem fs;
+
+    /**
+     * The hadoop file system configuration.
+     */
+    private final Configuration config = new Configuration();
+
+    private final NamePathResolver resolver;
+
+    public HadoopRepositoryService(String fs_default_name)
+            throws RepositoryException, ParseException {
+        super(DESCRIPTORS, new HashMap(), createCNDReader(),
+                Collections.singletonList("default"));
+        try {
+            config.set("fs.default.name", fs_default_name);
+            this.fs = FileSystem.get(config);
+        } catch (IOException e) {
+            throw new RepositoryException(e);
+        }
+        namespaces.setMapping("", "");
+        this.resolver = new DefaultNamePathResolver(namespaces);
+    }
+
+    protected static Reader createCNDReader() {
+        try {
+            return new InputStreamReader(
+                    HadoopRepositoryService.class.getResourceAsStream(
+                            "files-and-folders.cnd"), "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            // UTF-8 is always supported
+            throw new InternalError();
+        }
+    }
+
+    protected QNodeDefinition createRootNodeDefinition()
+            throws RepositoryException {
+        QNodeTypeDefinition ntDef = (QNodeTypeDefinition) nodeTypeDefs.get(NameConstants.NT_FOLDER);
+        return ntDef.getChildNodeDefs()[0];
+    }
+
+    protected void checkCredentials(Credentials credentials, String workspaceName)
+            throws LoginException {
+        // accept all credentials
+    }
+
+    public NodeInfo getNodeInfo(SessionInfo sessionInfo, NodeId nodeId) throws
+            ItemNotFoundException, RepositoryException {
+        boolean isResource;
+        if (nodeId.getPath().getNameElement().getName().equals(NameConstants.JCR_CONTENT)) {
+            isResource = true;
+            nodeId = getIdFactory().createNodeId((String) null, nodeId.getPath().getAncestor(1));
+        } else {
+            isResource = false;
+        }
+        Path p = new Path(resolver.getJCRPath(nodeId.getPath()));
+        try {
+            FileStatus status = fs.getFileStatus(p);
+            if (status.isDir()) {
+                // folder
+                List<Name> childNames = new ArrayList<Name>();
+                for (FileStatus s : fs.listStatus(p)) {
+                    childNames.add(resolver.getQName(s.getPath().getName()));
+                }
+                return new FolderInfo(nodeId, getIdFactory(), getPathFactory(),
+                        getQValueFactory(), status,
+                        childNames.toArray(new Name[childNames.size()]));
+            } else {
+                // file or resource
+                FileInfo info = new FileInfo(nodeId, status, getIdFactory(),
+                        getPathFactory(), getQValueFactory());
+                if (isResource) {
+                    return info.getResourceInfo(fs);
+                } else {
+                    return info;
+                }
+            }
+        } catch (FileNotFoundException e) {
+            throw new ItemNotFoundException(e);
+        } catch (IOException e) {
+            throw new RepositoryException(e);
+        }
+    }
+
+    public Iterator getChildInfos(SessionInfo sessionInfo, NodeId parentId)
+            throws ItemNotFoundException, RepositoryException {
+        return getNodeInfo(sessionInfo, parentId).getChildInfos();
+    }
+
+    public PropertyInfo getPropertyInfo(SessionInfo sessionInfo, PropertyId propertyId)
+            throws ItemNotFoundException, RepositoryException {
+        return ((AbstractNodeInfo) getNodeInfo(sessionInfo, propertyId.getParentId())).getPropertyInfo(propertyId);
+    }
+
+    public void dispose() {
+        try {
+            fs.close();
+        } catch (IOException e) {
+            // TODO: log
+        }
+    }
+}

Propchange: jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/HadoopRepositoryService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/ResourceInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/ResourceInfo.java?rev=763222&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/ResourceInfo.java (added)
+++ jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/ResourceInfo.java Wed Apr  8 12:47:31 2009
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.hadoop;
+
+import java.util.Calendar;
+import java.net.URLConnection;
+import java.io.InputStream;
+import java.io.IOException;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.PropertyType;
+
+import org.apache.jackrabbit.spi.commons.PropertyInfoImpl;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+
+/**
+ * <code>ResourceInfo</code>...
+ */
+public class ResourceInfo extends AbstractNodeInfo {
+
+    private final FileSystem fs;
+
+    public ResourceInfo(NodeId id, FileStatus status, FileSystem fs,
+                        IdFactory idFactory, PathFactory pathFactory,
+                        QValueFactory valueFactory) throws RepositoryException {
+        super(id, NameConstants.NT_RESOURCE, EMPTY, idFactory,
+                pathFactory, valueFactory, status);
+        this.fs = fs;
+        // jcr:primaryType
+        PropertyId propId = idFactory.createPropertyId(getId(), NameConstants.JCR_PRIMARYTYPE);
+        QValue value = valueFactory.create(getNodetype());
+        propertyInfos.put(propId, new PropertyInfoImpl(propId.getPath(), propId, PropertyType.NAME, false, new QValue[]{value}));
+        // jcr:lastModified
+        propId = idFactory.createPropertyId(getId(), NameConstants.JCR_LASTMODIFIED);
+        Calendar cal = Calendar.getInstance();
+        cal.setTimeInMillis(status.getModificationTime());
+        value = valueFactory.create(cal);
+        propertyInfos.put(propId, new PropertyInfoImpl(propId.getPath(), propId, PropertyType.DATE, false, new QValue[]{value}));
+        // jcr:mimeType
+        propId = idFactory.createPropertyId(getId(), NameConstants.JCR_MIMETYPE);
+        String mimeType = URLConnection.guessContentTypeFromName(status.getPath().getName());
+        if (mimeType == null) {
+            mimeType = "application/octet-stream";
+        }
+        value = valueFactory.create(mimeType, PropertyType.STRING);
+        propertyInfos.put(propId, new PropertyInfoImpl(propId.getPath(), propId, PropertyType.STRING, false, new QValue[]{value}));
+        // jcr:data
+        propId = idFactory.createPropertyId(getId(), NameConstants.JCR_DATA);
+        propertyInfos.put(propId, new PropertyInfoImpl(propId.getPath(), propId, PropertyType.BINARY, false, new QValue[]{new BinaryQValue()}));
+    }
+
+    private class BinaryQValue implements QValue {
+
+        public int getType() {
+            return PropertyType.BINARY;
+        }
+
+        public long getLength() throws RepositoryException {
+            return status.getLen();
+        }
+
+        public String getString() throws RepositoryException {
+            throw new UnsupportedOperationException();
+        }
+
+        public InputStream getStream() throws RepositoryException {
+            try {
+                return fs.open(status.getPath());
+            } catch (IOException e) {
+                throw new RepositoryException(e);
+            }
+        }
+
+        public Calendar getCalendar() throws RepositoryException {
+            throw new UnsupportedOperationException();
+        }
+
+        public double getDouble() throws RepositoryException {
+            throw new UnsupportedOperationException();
+        }
+
+        public long getLong() throws RepositoryException {
+            throw new UnsupportedOperationException();
+        }
+
+        public boolean getBoolean() throws RepositoryException {
+            throw new UnsupportedOperationException();
+        }
+
+        public Name getName() throws RepositoryException {
+            throw new UnsupportedOperationException();
+        }
+
+        public Path getPath() throws RepositoryException {
+            throw new UnsupportedOperationException();
+        }
+
+        public void discard() {
+        }
+    }
+}

Propchange: jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/java/org/apache/jackrabbit/spi/hadoop/ResourceInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/resources/org/apache/jackrabbit/spi/hadoop/descriptor.properties
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/resources/org/apache/jackrabbit/spi/hadoop/descriptor.properties?rev=763222&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/resources/org/apache/jackrabbit/spi/hadoop/descriptor.properties (added)
+++ jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/resources/org/apache/jackrabbit/spi/hadoop/descriptor.properties Wed Apr  8 12:47:31 2009
@@ -0,0 +1,38 @@
+#
+#  Licensed to the Apache Software Foundation (ASF) under one or more
+#  contributor license agreements.  See the NOTICE file distributed with
+#  this work for additional information regarding copyright ownership.
+#  The ASF licenses this file to You under the Apache License, Version 2.0
+#  (the "License"); you may not use this file except in compliance with
+#  the License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+################################################################################
+# Repository Version and Implementation Information
+
+jcr.specification.version = 1.0
+jcr.specification.name = Content Repository API for Java(TM) Technology Specification
+jcr.repository.vendor = Apache Software Foundation
+jcr.repository.vendor.url = http://jackrabbit.apache.org/
+jcr.repository.name = JCR2HDFS
+jcr.repository.version = ${pom.version}
+
+################################################################################
+# Repository features and support information
+
+level.1.supported = false
+level.2.supported = false
+option.transactions.supported = false
+option.versioning.supported = false
+option.observation.supported = false
+option.locking.supported = false
+option.query.sql.supported = false
+query.xpath.pos.index = false
+query.xpath.doc.order = false

Propchange: jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/resources/org/apache/jackrabbit/spi/hadoop/descriptor.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/resources/org/apache/jackrabbit/spi/hadoop/files-and-folders.cnd
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/resources/org/apache/jackrabbit/spi/hadoop/files-and-folders.cnd?rev=763222&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/resources/org/apache/jackrabbit/spi/hadoop/files-and-folders.cnd (added)
+++ jackrabbit/sandbox/jackrabbit-spi2hadoop/src/main/resources/org/apache/jackrabbit/spi/hadoop/files-and-folders.cnd Wed Apr  8 12:47:31 2009
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+<jcr='http://www.jcp.org/jcr/1.0'>
+<nt='http://www.jcp.org/jcr/nt/1.0'>
+<mix='http://www.jcp.org/jcr/mix/1.0'>
+
+//------------------------------------------------------------------------------
+// B A S E  T Y P E S
+//------------------------------------------------------------------------------
+
+[nt:base]
+  - jcr:primaryType (name) mandatory autocreated protected compute
+  - jcr:mixinTypes (name) protected multiple compute
+
+[nt:hierarchyNode]
+  - jcr:created (date) autocreated protected initialize
+
+[nt:folder] > nt:hierarchyNode
+  + * (nt:hierarchyNode) version
+
+[nt:file] > nt:hierarchyNode
+  + jcr:content (nt:base) primary mandatory
+
+[nt:resource] > mix:referenceable
+  - jcr:encoding (string)
+  - jcr:mimeType (string) mandatory
+  - jcr:data (binary) primary mandatory
+  - jcr:lastModified (date) mandatory ignore

Added: jackrabbit/sandbox/jackrabbit-spi2hadoop/src/test/java/org/apache/jackrabbit/spi/hadoop/HadoopRepositoryConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-spi2hadoop/src/test/java/org/apache/jackrabbit/spi/hadoop/HadoopRepositoryConfig.java?rev=763222&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-spi2hadoop/src/test/java/org/apache/jackrabbit/spi/hadoop/HadoopRepositoryConfig.java (added)
+++ jackrabbit/sandbox/jackrabbit-spi2hadoop/src/test/java/org/apache/jackrabbit/spi/hadoop/HadoopRepositoryConfig.java Wed Apr  8 12:47:31 2009
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.hadoop;
+
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
+import org.apache.jackrabbit.jcr2spi.config.CacheBehaviour;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi.hadoop.HadoopRepositoryService;
+import org.apache.jackrabbit.spi.commons.nodetype.compact.ParseException;
+
+/**
+ * <code>HadoopRepositoryConfig</code>...
+ */
+public class HadoopRepositoryConfig implements RepositoryConfig {
+
+    private final HadoopRepositoryService service;
+
+    public HadoopRepositoryConfig(String url)
+            throws RepositoryException, ParseException {
+        this.service = new HadoopRepositoryService(url);
+    }
+
+    public RepositoryService getRepositoryService() throws RepositoryException {
+        return service;
+    }
+
+    public CacheBehaviour getCacheBehaviour() {
+        return CacheBehaviour.INVALIDATE;
+    }
+
+    public int getItemCacheSize() {
+        return 1000;
+    }
+
+    public int getPollTimeout() {
+        return 5000;
+    }
+}

Propchange: jackrabbit/sandbox/jackrabbit-spi2hadoop/src/test/java/org/apache/jackrabbit/spi/hadoop/HadoopRepositoryConfig.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/sandbox/jackrabbit-spi2hadoop/src/test/java/org/apache/jackrabbit/spi/hadoop/Main.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-spi2hadoop/src/test/java/org/apache/jackrabbit/spi/hadoop/Main.java?rev=763222&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-spi2hadoop/src/test/java/org/apache/jackrabbit/spi/hadoop/Main.java (added)
+++ jackrabbit/sandbox/jackrabbit-spi2hadoop/src/test/java/org/apache/jackrabbit/spi/hadoop/Main.java Wed Apr  8 12:47:31 2009
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.hadoop;
+
+import javax.jcr.Repository;
+import javax.jcr.SimpleCredentials;
+import javax.jcr.Session;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.util.TraversingItemVisitor;
+
+import org.apache.jackrabbit.jcr2spi.RepositoryImpl;
+import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
+
+/**
+ * <code>Main</code>...
+ */
+public class Main {
+
+    public static void main(String[] args) throws Exception {
+        RepositoryConfig config = new HadoopRepositoryConfig("hdfs://localhost:9000");
+        HadoopRepositoryService service = (HadoopRepositoryService) config.getRepositoryService();
+        Repository repo;
+        try {
+            repo = RepositoryImpl.create(config);
+
+            Session s = repo.login(new SimpleCredentials("user", "pass".toCharArray()), "default");
+            try {
+                s.getRootNode().accept(new TraversingItemVisitor() {
+                    protected void entering(Property property, int level)
+                    throws RepositoryException {
+                    }
+
+                    protected void entering(Node node, int level) throws RepositoryException {
+                        System.out.println(node.getPath());
+                    }
+
+                    protected void leaving(Property property, int level)
+                    throws RepositoryException {
+                    }
+
+                    protected void leaving(Node node, int level) throws RepositoryException {
+                    }
+                });
+            } finally {
+                s.logout();
+            }
+        } finally {
+            service.dispose();
+        }
+    }
+}

Propchange: jackrabbit/sandbox/jackrabbit-spi2hadoop/src/test/java/org/apache/jackrabbit/spi/hadoop/Main.java
------------------------------------------------------------------------------
    svn:eol-style = native