james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject svn commit: r1154497 - in /james/server/trunk/hbase: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/james/ src/main/java/org/apache/james/domainlist/ src/main/java/org/apache/james/domainlist/hbas...
Date Sat, 06 Aug 2011 12:08:55 GMT
Author: eric
Date: Sat Aug  6 12:08:54 2011
New Revision: 1154497

URL: http://svn.apache.org/viewvc?rev=1154497&view=rev
Log:
Bulk initial commit for HBase user and domain persistence - Missing: javadoc, rrt wilcard, rrt recursive and rrt alias (JAMES-1273)

Added:
    james/server/trunk/hbase/
    james/server/trunk/hbase/pom.xml
    james/server/trunk/hbase/src/
    james/server/trunk/hbase/src/main/
    james/server/trunk/hbase/src/main/java/
    james/server/trunk/hbase/src/main/java/org/
    james/server/trunk/hbase/src/main/java/org/apache/
    james/server/trunk/hbase/src/main/java/org/apache/james/
    james/server/trunk/hbase/src/main/java/org/apache/james/domainlist/
    james/server/trunk/hbase/src/main/java/org/apache/james/domainlist/hbase/
    james/server/trunk/hbase/src/main/java/org/apache/james/domainlist/hbase/HBaseDomainList.java
    james/server/trunk/hbase/src/main/java/org/apache/james/domainlist/hbase/def/
    james/server/trunk/hbase/src/main/java/org/apache/james/domainlist/hbase/def/HDomainList.java
    james/server/trunk/hbase/src/main/java/org/apache/james/rrt/
    james/server/trunk/hbase/src/main/java/org/apache/james/rrt/hbase/
    james/server/trunk/hbase/src/main/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTable.java
    james/server/trunk/hbase/src/main/java/org/apache/james/rrt/hbase/def/
    james/server/trunk/hbase/src/main/java/org/apache/james/rrt/hbase/def/HRecipientRewriteTable.java
    james/server/trunk/hbase/src/main/java/org/apache/james/system/
    james/server/trunk/hbase/src/main/java/org/apache/james/system/hbase/
    james/server/trunk/hbase/src/main/java/org/apache/james/system/hbase/TablePool.java
    james/server/trunk/hbase/src/main/java/org/apache/james/user/
    james/server/trunk/hbase/src/main/java/org/apache/james/user/hbase/
    james/server/trunk/hbase/src/main/java/org/apache/james/user/hbase/HBaseUsersRepository.java
    james/server/trunk/hbase/src/main/java/org/apache/james/user/hbase/def/
    james/server/trunk/hbase/src/main/java/org/apache/james/user/hbase/def/HUsersRepository.java
    james/server/trunk/hbase/src/main/resources/
    james/server/trunk/hbase/src/test/
    james/server/trunk/hbase/src/test/java/
    james/server/trunk/hbase/src/test/java/org/
    james/server/trunk/hbase/src/test/java/org/apache/
    james/server/trunk/hbase/src/test/java/org/apache/james/
    james/server/trunk/hbase/src/test/java/org/apache/james/JamesServerHBaseIntegrationTest.java
    james/server/trunk/hbase/src/test/java/org/apache/james/domainlist/
    james/server/trunk/hbase/src/test/java/org/apache/james/domainlist/hbase/
    james/server/trunk/hbase/src/test/java/org/apache/james/domainlist/hbase/HBaseDomainListTest.java
    james/server/trunk/hbase/src/test/java/org/apache/james/rrt/
    james/server/trunk/hbase/src/test/java/org/apache/james/rrt/hbase/
    james/server/trunk/hbase/src/test/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTableTest.java
    james/server/trunk/hbase/src/test/java/org/apache/james/system/
    james/server/trunk/hbase/src/test/java/org/apache/james/system/hbase/
    james/server/trunk/hbase/src/test/java/org/apache/james/system/hbase/TablePoolTest.java
    james/server/trunk/hbase/src/test/java/org/apache/james/user/
    james/server/trunk/hbase/src/test/java/org/apache/james/user/hbase/
    james/server/trunk/hbase/src/test/java/org/apache/james/user/hbase/HBaseUsersRepositoryTest.java
    james/server/trunk/hbase/src/test/resources/
    james/server/trunk/hbase/src/test/resources/log4j.properties

Added: james/server/trunk/hbase/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/hbase/pom.xml?rev=1154497&view=auto
==============================================================================
--- james/server/trunk/hbase/pom.xml (added)
+++ james/server/trunk/hbase/pom.xml Sat Aug  6 12:08:54 2011
@@ -0,0 +1,175 @@
+<?xml version="1.0" encoding="ISO-8859-15"?>
+<!--
+  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">
+  <parent>
+    <artifactId>james-server</artifactId>
+    <groupId>org.apache.james</groupId>
+    <version>3.0-beta4-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.james</groupId>
+  <artifactId>james-server-hbase</artifactId>
+  <name>Apache James Server HBase Data Persistence</name>
+  
+  <properties>
+    <hbase.version>0.90.3</hbase.version>
+    <hadoop.version>0.20-append-r1057313</hadoop.version>
+    <junit.version>4.8.2</junit.version>
+  </properties>
+  
+<!-- 
+  TODO Move some definitions to server parent.
+-->
+
+  <repositories>
+    <repository>
+      <id>hadoop-non-releases</id>
+      <name>Hadoop non-releases</name>
+      <url>http://people.apache.org/~rawson/repo/</url>
+      <snapshots>
+        <enabled>false</enabled>
+      </snapshots>
+      <releases>
+        <enabled>true</enabled>
+      </releases>
+    </repository>
+  </repositories>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+<!--
+Inherit configuration from parent pom.
+-->
+        <executions>
+          <execution>
+            <goals>
+              <goal>jar</goal>
+<!--
+Allow tests to be used by other modules.
+Parent pom build failure prevents inheritance.
+-->
+              <goal>test-jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <forkMode>pertest</forkMode>
+          <argLine>-Xms256m -Xmx512m</argLine>
+          <testFailureIgnore>false</testFailureIgnore>
+          <skip>false</skip>
+          <includes>
+            <include>**/*IntegrationTest.java</include>
+          </includes>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>james-server-lifecycle-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>james-server-dnsservice-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>james-server-data-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>james-server-data-library</artifactId>
+    </dependency>
+     <dependency>
+      <groupId>commons-configuration</groupId>
+      <artifactId>commons-configuration</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>commons-codec</groupId>
+      <artifactId>commons-codec</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hbase</groupId>
+      <artifactId>hbase</artifactId>
+      <version>${hbase.version}</version>
+     </dependency>
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+    </dependency>
+
+    <!-- Test dependencies -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+      <version>${junit.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>james-server-data-library</artifactId>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.derby</groupId>
+      <artifactId>derby</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>james-server-dnsservice-api</artifactId>
+      <scope>test</scope>
+      <type>test-jar</type>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hbase</groupId>
+      <artifactId>hbase</artifactId>
+      <scope>test</scope>
+      <type>test-jar</type>
+      <version>${hbase.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hadoop</groupId>
+      <artifactId>hadoop-test</artifactId>
+      <scope>test</scope>
+      <version>${hadoop.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+  </dependencies>
+</project>

Added: james/server/trunk/hbase/src/main/java/org/apache/james/domainlist/hbase/HBaseDomainList.java
URL: http://svn.apache.org/viewvc/james/server/trunk/hbase/src/main/java/org/apache/james/domainlist/hbase/HBaseDomainList.java?rev=1154497&view=auto
==============================================================================
--- james/server/trunk/hbase/src/main/java/org/apache/james/domainlist/hbase/HBaseDomainList.java (added)
+++ james/server/trunk/hbase/src/main/java/org/apache/james/domainlist/hbase/HBaseDomainList.java Sat Aug  6 12:08:54 2011
@@ -0,0 +1,147 @@
+/****************************************************************
+ * 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.james.domainlist.hbase;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hadoop.hbase.client.Delete;
+import org.apache.hadoop.hbase.client.Get;
+import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.ResultScanner;
+import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.james.domainlist.api.DomainListException;
+import org.apache.james.domainlist.hbase.def.HDomainList;
+import org.apache.james.domainlist.lib.AbstractDomainList;
+import org.apache.james.system.hbase.TablePool;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class HBaseDomainList extends AbstractDomainList {
+
+    private static Logger log = LoggerFactory.getLogger(HBaseDomainList.class.getName());
+
+    @Override
+    public boolean containsDomain(String domain) throws DomainListException {
+        HTable table = null;
+        try {
+            table = TablePool.getInstance().getDomainlistTable();
+            Get get = new Get(Bytes.toBytes(domain));
+            Result result = table.get(get);
+            if (! result.isEmpty()) {
+                return true;
+            }
+        } catch (IOException e) {
+            log.error("Error while counting domains from HBase", e);
+            throw new DomainListException("Error while counting domains from HBase", e);
+        } finally {
+            if (table != null) {
+                try {
+                    TablePool.getInstance().putTable(table);
+                } catch (IOException e) {
+                    // Do nothing, we can't get access to the HBaseSchema.
+                }
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public void addDomain(String domain) throws DomainListException {
+        HTable table = null;
+        try {
+            table = TablePool.getInstance().getDomainlistTable();
+            Put put = new Put(Bytes.toBytes(domain));
+            put.add(HDomainList.COLUMN_FAMILY_NAME, HDomainList.COLUMN.DOMAIN, null);
+            table.put(put);
+            table.flushCommits();
+        } catch (IOException e) {
+            log.error("Error while adding domain in HBase", e);
+            throw new DomainListException("Error while adding domain in HBase", e);
+        } finally {
+            if (table != null) {
+                try {
+                    TablePool.getInstance().putTable(table);
+                } catch (IOException e) {
+                    // Do nothing, we can't get access to the HBaseSchema.
+                }
+            }
+        }
+    }
+
+    @Override
+    public void removeDomain(String domain) throws DomainListException {
+        HTable table = null;
+        try {
+            table = TablePool.getInstance().getDomainlistTable();
+            Delete delete = new Delete(Bytes.toBytes(domain));
+            table.delete(delete);
+            table.flushCommits();
+        } catch (IOException e) {
+            log.error("Error while deleting user from HBase", e);
+            throw new DomainListException("Error while deleting domain from HBase", e);
+        } finally {
+            if (table != null) {
+                try {
+                    TablePool.getInstance().putTable(table);
+                } catch (IOException e) {
+                    // Do nothing, we can't get access to the HBaseSchema.
+                }
+            }
+        }
+    }
+
+    @Override
+    protected List<String> getDomainListInternal() throws DomainListException {
+        List<String> list = new ArrayList<String>();
+        HTable table = null;
+        ResultScanner resultScanner = null;
+        try {
+            table = TablePool.getInstance().getDomainlistTable();
+            Scan scan = new Scan();
+            scan.addFamily(HDomainList.COLUMN_FAMILY_NAME);
+            scan.setCaching(table.getScannerCaching() * 2);
+            resultScanner = table.getScanner(scan);
+            Result result = null;
+            while ((result = resultScanner.next()) != null) {
+                list.add(Bytes.toString(result.getRow()));
+            }
+        } catch (IOException e) {
+            log.error("Error while counting domains from HBase", e);
+            throw new DomainListException("Error while counting domains from HBase", e);
+        } finally {
+            if (resultScanner != null) {
+                resultScanner.close();
+            }
+            if (table != null) {
+                try {
+                    TablePool.getInstance().putTable(table);
+                } catch (IOException e) {
+                    // Do nothing, we can't get access to the HBaseSchema.
+                }
+            }
+        }
+        return list;
+    }
+
+}

Added: james/server/trunk/hbase/src/main/java/org/apache/james/domainlist/hbase/def/HDomainList.java
URL: http://svn.apache.org/viewvc/james/server/trunk/hbase/src/main/java/org/apache/james/domainlist/hbase/def/HDomainList.java?rev=1154497&view=auto
==============================================================================
--- james/server/trunk/hbase/src/main/java/org/apache/james/domainlist/hbase/def/HDomainList.java (added)
+++ james/server/trunk/hbase/src/main/java/org/apache/james/domainlist/hbase/def/HDomainList.java Sat Aug  6 12:08:54 2011
@@ -0,0 +1,32 @@
+/****************************************************************
+ * 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.james.domainlist.hbase.def;
+
+import org.apache.hadoop.hbase.util.Bytes;
+
+public interface HDomainList {
+
+    byte[] TABLE_NAME = Bytes.toBytes("JAMES_DOMAINLIST");
+    byte[] COLUMN_FAMILY_NAME = Bytes.toBytes("JAMES_DOMAINLIST");
+    
+    public interface COLUMN {
+        byte [] DOMAIN = Bytes.toBytes("dom");
+    }
+
+}

Added: james/server/trunk/hbase/src/main/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTable.java
URL: http://svn.apache.org/viewvc/james/server/trunk/hbase/src/main/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTable.java?rev=1154497&view=auto
==============================================================================
--- james/server/trunk/hbase/src/main/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTable.java (added)
+++ james/server/trunk/hbase/src/main/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTable.java Sat Aug  6 12:08:54 2011
@@ -0,0 +1,220 @@
+/****************************************************************
+ * 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.james.rrt.hbase;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.client.Delete;
+import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.ResultScanner;
+import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.filter.BinaryComparator;
+import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
+import org.apache.hadoop.hbase.filter.Filter;
+import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.james.rrt.api.RecipientRewriteTableException;
+import org.apache.james.rrt.hbase.def.HRecipientRewriteTable;
+import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
+import org.apache.james.system.hbase.TablePool;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class HBaseRecipientRewriteTable extends AbstractRecipientRewriteTable {
+
+    private static Logger log = LoggerFactory.getLogger(HBaseRecipientRewriteTable.class.getName());
+    
+    @Override
+    protected void addMappingInternal(String user, String domain, String mapping) throws RecipientRewriteTableException {
+        HTable table = null;
+        try {
+            table = TablePool.getInstance().getRecipientRewriteTable();
+            Put put = new Put(Bytes.toBytes(mapping));
+            put.add(HRecipientRewriteTable.COLUMN_FAMILY_NAME, Bytes.toBytes(user), Bytes.toBytes(domain));
+            table.put(put);
+            table.flushCommits();
+        } catch (IOException e) {
+            log.error("Error while adding mapping in HBase", e);
+            throw new RecipientRewriteTableException("Error while adding mapping in HBase", e);
+        } finally {
+            if (table != null) {
+                try {
+                    TablePool.getInstance().putTable(table);
+                } catch (IOException e) {
+                    // Do nothing, we can't get access to the HBaseSchema.
+                }
+            }
+        }
+    }
+
+    @Override
+    protected void removeMappingInternal(String user, String domain, String mapping) throws RecipientRewriteTableException {
+        HTable table = null;
+        try {
+            table = TablePool.getInstance().getRecipientRewriteTable();
+            Delete delete = new Delete(Bytes.toBytes(mapping));
+            delete.deleteColumn(HRecipientRewriteTable.COLUMN_FAMILY_NAME, Bytes.toBytes(user));
+            table.delete(delete);
+            table.flushCommits();
+        } catch (IOException e) {
+            log.error("Error while removing mapping from HBase", e);
+            throw new RecipientRewriteTableException("Error while removing mapping from HBase", e);
+        } finally {
+            if (table != null) {
+                try {
+                    TablePool.getInstance().putTable(table);
+                } catch (IOException e) {
+                    // Do nothing, we can't get access to the HBaseSchema.
+                }
+            }
+        }
+    }
+
+    @Override
+    protected Collection<String> getUserDomainMappingsInternal(String user, String domain) throws RecipientRewriteTableException {
+        HTable table = null;
+        List<String> list = new ArrayList<String>();
+        ResultScanner resultScanner = null;
+        try {
+            table = TablePool.getInstance().getRecipientRewriteTable();
+            Scan scan = new Scan();
+            scan.addFamily(HRecipientRewriteTable.COLUMN_FAMILY_NAME);
+            scan.setCaching(table.getScannerCaching() * 2);
+            Filter filter = new SingleColumnValueFilter(HRecipientRewriteTable.COLUMN_FAMILY_NAME, Bytes.toBytes(user), CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes(user)));
+            scan.setFilter(filter);
+            resultScanner = table.getScanner(scan);
+            Result result = null;
+            while ((result = resultScanner.next()) != null) {
+                list.add(Bytes.toString(result.getRow()));
+            }
+        } catch (IOException e) {
+            log.error("Error while getting user domain mapping in HBase", e);
+            throw new RecipientRewriteTableException("Error while getting user domain mapping in HBase", e);
+        } finally {
+            if (resultScanner != null) {
+                resultScanner.close();
+            }
+            if (table != null) {
+                try {
+                    TablePool.getInstance().putTable(table);
+                } catch (IOException e) {
+                    // Do nothing, we can't get access to the HBaseSchema.
+                }
+            }
+        }
+        return list;
+    }
+
+    @Override
+    protected Map<String, Collection<String>> getAllMappingsInternal() throws RecipientRewriteTableException {
+        HTable table = null;
+        ResultScanner resultScanner = null;
+        Map<String, Collection<String>> map = null;
+        try {
+            table = TablePool.getInstance().getRecipientRewriteTable();
+            Scan scan = new Scan();
+            scan.addFamily(HRecipientRewriteTable.COLUMN_FAMILY_NAME);
+            scan.setCaching(table.getScannerCaching() * 2);
+            resultScanner = table.getScanner(scan);
+            Result result = null;
+            while ((result = resultScanner.next()) != null) {
+                List<KeyValue> keyValues = result.list();
+                if (keyValues != null) {
+                    for (KeyValue keyValue: keyValues) {
+                        byte[] user = keyValue.getQualifier();
+                        byte[] domain = keyValue.getValue();
+                        String email = Bytes.toString(user) + '@' + Bytes.toString(domain);
+                        if (map == null) {
+                            map = new HashMap<String, Collection<String>>();
+                        }
+                        Collection<String> list = map.get(email);
+                        if (list == null) {
+                            list = new ArrayList<String>();
+                        }
+                        list.add(Bytes.toString(keyValue.getRow()));
+                        map.put(email, list);
+                    }
+                }
+            }
+        } catch (IOException e) {
+            log.error("Error while getting all mapping from HBase", e);
+            throw new RecipientRewriteTableException("Error while getting all mappings from HBase", e);
+        } finally {
+            if (resultScanner != null) {
+                resultScanner.close();
+            }
+            if (table != null) {
+                try {
+                    TablePool.getInstance().putTable(table);
+                } catch (IOException e) {
+                    // Do nothing, we can't get access to the HBaseSchema.
+                }
+            }
+        }
+        return map;
+    }
+
+    @Override
+    protected String mapAddressInternal(String user, String domain) throws RecipientRewriteTableException {
+        HTable table = null;
+        ResultScanner resultScanner = null;
+        StringBuffer mappingBuffer = new StringBuffer();
+        try {
+            table = TablePool.getInstance().getRecipientRewriteTable();
+            Scan scan = new Scan();
+            scan.addFamily(HRecipientRewriteTable.COLUMN_FAMILY_NAME);
+            scan.setCaching(table.getScannerCaching() * 2);
+            Filter filter = new SingleColumnValueFilter(HRecipientRewriteTable.COLUMN_FAMILY_NAME, Bytes.toBytes(user), CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes(domain)));
+            scan.setFilter(filter);
+            resultScanner = table.getScanner(scan);
+            Result result = null;
+            while ((result = resultScanner.next()) != null) {
+                mappingBuffer.append(Bytes.toString(result.getRow()) + ";");
+            }
+        } catch (IOException e) {
+            log.error("Error while mapping address in HBase", e);
+            throw new RecipientRewriteTableException("Error while mapping address in HBase", e);
+        } finally {
+            if (resultScanner != null) {
+                resultScanner.close();
+            }
+            if (table != null) {
+                try {
+                    TablePool.getInstance().putTable(table);
+                } catch (IOException e) {
+                    // Do nothing, we can't get access to the HBaseSchema.
+                }
+            }
+        }
+        if (mappingBuffer.length() == 0) {
+            return null;
+        }
+        String mapping = mappingBuffer.toString();
+        return mapping.substring(0, mapping.length() - 1);
+    }
+    
+}

Added: james/server/trunk/hbase/src/main/java/org/apache/james/rrt/hbase/def/HRecipientRewriteTable.java
URL: http://svn.apache.org/viewvc/james/server/trunk/hbase/src/main/java/org/apache/james/rrt/hbase/def/HRecipientRewriteTable.java?rev=1154497&view=auto
==============================================================================
--- james/server/trunk/hbase/src/main/java/org/apache/james/rrt/hbase/def/HRecipientRewriteTable.java (added)
+++ james/server/trunk/hbase/src/main/java/org/apache/james/rrt/hbase/def/HRecipientRewriteTable.java Sat Aug  6 12:08:54 2011
@@ -0,0 +1,28 @@
+/****************************************************************
+ * 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.james.rrt.hbase.def;
+
+import org.apache.hadoop.hbase.util.Bytes;
+
+public interface HRecipientRewriteTable {
+
+    byte[] TABLE_NAME = Bytes.toBytes("JAMES_RRT");
+    byte[] COLUMN_FAMILY_NAME = Bytes.toBytes("JAMES_RRT");
+
+}

Added: james/server/trunk/hbase/src/main/java/org/apache/james/system/hbase/TablePool.java
URL: http://svn.apache.org/viewvc/james/server/trunk/hbase/src/main/java/org/apache/james/system/hbase/TablePool.java?rev=1154497&view=auto
==============================================================================
--- james/server/trunk/hbase/src/main/java/org/apache/james/system/hbase/TablePool.java (added)
+++ james/server/trunk/hbase/src/main/java/org/apache/james/system/hbase/TablePool.java Sat Aug  6 12:08:54 2011
@@ -0,0 +1,87 @@
+/****************************************************************
+ * 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.james.system.hbase;
+
+import java.io.IOException;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.client.HBaseAdmin;
+import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.HTablePool;
+import org.apache.james.domainlist.hbase.def.HDomainList;
+import org.apache.james.rrt.hbase.def.HRecipientRewriteTable;
+import org.apache.james.user.hbase.def.HUsersRepository;
+
+public class TablePool {    
+    
+    private static Configuration configuration;
+    private static TablePool hbaseSchema;
+    private static HTablePool htablePool;
+    
+    public static TablePool getInstance() throws IOException {
+        return getInstance(HBaseConfiguration.create());
+    }
+
+    public static TablePool getInstance(Configuration configuration) throws IOException {
+        if (hbaseSchema == null) {
+            TablePool.configuration = configuration;
+            TablePool.hbaseSchema = new TablePool();
+            TablePool.htablePool = new HTablePool(configuration, 100);
+            ensureTable(HDomainList.TABLE_NAME, HDomainList.COLUMN_FAMILY_NAME);
+            ensureTable(HRecipientRewriteTable.TABLE_NAME, HRecipientRewriteTable.COLUMN_FAMILY_NAME);
+            ensureTable(HUsersRepository.TABLE_NAME, HUsersRepository.COLUMN_FAMILY_NAME);
+        }
+        return hbaseSchema;
+    }
+    
+    public HTable getDomainlistTable() {
+        return (HTable) htablePool.getTable(HDomainList.TABLE_NAME);
+    }
+
+    public HTable getRecipientRewriteTable() {
+        return (HTable) htablePool.getTable(HRecipientRewriteTable.TABLE_NAME);
+    }
+
+    public HTable getUsersRepositoryTable() {
+        return (HTable) htablePool.getTable(HUsersRepository.TABLE_NAME);
+    }
+
+    // With later HBase versions, we won't have to put back the table in the pool.
+    // See https://issues.apache.org/jira/browse/HBASE-4054
+    public void putTable(HTable table) {
+        if (table != null) {
+            htablePool.putTable(table);
+        }
+    }
+    
+    private static void ensureTable(byte[] tableName, byte[] columnFamilyName) throws IOException {
+        HBaseAdmin hbaseAdmin = new HBaseAdmin(configuration);
+        if (! hbaseAdmin.tableExists(tableName)) {
+          HTableDescriptor desc = new HTableDescriptor(tableName);
+          HColumnDescriptor hColumnDescriptor = new HColumnDescriptor(columnFamilyName);
+          hColumnDescriptor.setMaxVersions(1);
+          desc.addFamily(hColumnDescriptor);
+          hbaseAdmin.createTable(desc);
+        }
+    }
+
+}

Added: james/server/trunk/hbase/src/main/java/org/apache/james/user/hbase/HBaseUsersRepository.java
URL: http://svn.apache.org/viewvc/james/server/trunk/hbase/src/main/java/org/apache/james/user/hbase/HBaseUsersRepository.java?rev=1154497&view=auto
==============================================================================
--- james/server/trunk/hbase/src/main/java/org/apache/james/user/hbase/HBaseUsersRepository.java (added)
+++ james/server/trunk/hbase/src/main/java/org/apache/james/user/hbase/HBaseUsersRepository.java Sat Aug  6 12:08:54 2011
@@ -0,0 +1,243 @@
+/****************************************************************
+ * 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.james.user.hbase;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.client.Delete;
+import org.apache.hadoop.hbase.client.Get;
+import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.ResultScanner;
+import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.james.system.hbase.TablePool;
+import org.apache.james.user.api.UsersRepositoryException;
+import org.apache.james.user.api.model.User;
+import org.apache.james.user.hbase.def.HUsersRepository;
+import org.apache.james.user.lib.AbstractUsersRepository;
+import org.apache.james.user.lib.model.DefaultUser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class HBaseUsersRepository extends AbstractUsersRepository {
+    
+    private static Logger log = LoggerFactory.getLogger(HBaseUsersRepository.class.getName());
+
+    private String algo;
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.james.user.lib.AbstractUsersRepository#doConfigure(org.apache.commons.configuration.HierarchicalConfiguration)
+     */
+    public void doConfigure(HierarchicalConfiguration config) throws ConfigurationException {
+        algo = config.getString("algorithm", "MD5");
+        super.doConfigure(config);
+    }
+
+    @Override
+    public User getUserByName(String name) throws UsersRepositoryException {
+        KeyValue keyValue = getKeyValue(name);
+        User user = null;
+        if (keyValue != null) {
+            user = new DefaultUser(Bytes.toString(keyValue.getRow()), Bytes.toString(keyValue.getValue()), algo);
+        }
+        return user;
+    }
+
+    @Override
+    public void updateUser(User user) throws UsersRepositoryException {
+        if (user == null) {
+            throw new UsersRepositoryException("Please provide a non null user");
+        }
+        if (! (user instanceof DefaultUser)) {
+            throw new UsersRepositoryException("Please provide a user instanceof DefaultUser");
+        }
+        User existingUser = getUserByName(user.getUserName());
+        if (existingUser == null) {
+            throw new UsersRepositoryException("Please provide an existing user to update");
+        }
+        putUser((DefaultUser) user);
+    }
+
+    @Override
+    public void removeUser(String name) throws UsersRepositoryException {
+        HTable table = null;
+        try {
+            table = TablePool.getInstance().getUsersRepositoryTable();
+            Delete delete = new Delete(Bytes.toBytes(name));
+            table.delete(delete);
+            table.flushCommits();
+        } catch (IOException e) {
+            log.error("Error while deleting user from HBase", e);
+            throw new UsersRepositoryException("Error while deleting user from HBase", e);
+        } finally {
+            if (table != null) {
+                try {
+                    TablePool.getInstance().putTable(table);
+                } catch (IOException e) {
+                    // Do nothing, we can't get access to the HBaseSchema.
+                }
+            }
+        }
+    }
+
+    @Override
+    public boolean contains(String name) throws UsersRepositoryException {
+        KeyValue keyValue = getKeyValue(name);
+        return (keyValue != null);
+    }
+
+    @Override
+    public boolean test(String name, String password) throws UsersRepositoryException {
+        KeyValue keyValue = getKeyValue(name);
+        if (keyValue != null) {
+            DefaultUser user = new DefaultUser(name, algo);
+            user.setPassword(password);
+            return Bytes.toString(keyValue.getValue()).equals(user.getHashedPassword());
+        }
+        return false;
+    }
+
+    @Override
+    public int countUsers() throws UsersRepositoryException {
+        HTable table = null;
+        ResultScanner resultScanner = null;
+        try {
+            table = TablePool.getInstance().getUsersRepositoryTable();
+            Scan scan = new Scan();
+            scan.addFamily(HUsersRepository.COLUMN_FAMILY_NAME);
+            scan.setCaching(table.getScannerCaching() * 2);
+            resultScanner = table.getScanner(scan);
+            int resultCount = 0;
+            Result result = null;
+            while ((result = resultScanner.next()) != null) {
+                resultCount++;
+            }
+            return resultCount;
+        } catch (IOException e) {
+            log.error("Error while counting users from HBase", e);
+            throw new UsersRepositoryException("Error while counting users from HBase", e);
+        } finally {
+            if (resultScanner != null) {
+                resultScanner.close();
+            }
+            if (table != null) {
+                try {
+                    TablePool.getInstance().putTable(table);
+                } catch (IOException e) {
+                    // Do nothing, we can't get access to the HBaseSchema.
+                }
+            }
+        }
+    }
+
+    @Override
+    public Iterator<String> list() throws UsersRepositoryException {
+        List<String> list = new ArrayList<String>();
+        HTable table = null;
+        ResultScanner resultScanner = null;
+        try {
+            table = TablePool.getInstance().getUsersRepositoryTable();
+            Scan scan = new Scan();
+            scan.addFamily(HUsersRepository.COLUMN_FAMILY_NAME);
+            scan.setCaching(table.getScannerCaching() * 2);
+            resultScanner = table.getScanner(scan);
+            Result result = null;
+            while ((result = resultScanner.next()) != null) {
+                list.add(Bytes.toString(result.getRow()));
+            }
+        } catch (IOException e) {
+            log.error("Error while scanning users from HBase", e);
+            throw new UsersRepositoryException("Error while scanning users from HBase", e);
+        } finally {
+            if (resultScanner != null) {
+                resultScanner.close();
+            }
+            if (table != null) {
+                try {
+                    TablePool.getInstance().putTable(table);
+                } catch (IOException e) {
+                    // Do nothing, we can't get access to the HBaseSchema.
+                }
+            }
+        }
+        return list.iterator();
+    }
+
+    @Override
+    protected void doAddUser(String username, String password) throws UsersRepositoryException {
+        DefaultUser user = new DefaultUser(username, algo);
+        user.setPassword(password);
+        putUser(user);
+    }
+    
+    private KeyValue getKeyValue(String username) throws UsersRepositoryException {
+        HTable table = null;
+        try {
+            table = TablePool.getInstance().getUsersRepositoryTable();
+            Get get = new Get(Bytes.toBytes(username));
+            Result result = table.get(get);
+            KeyValue keyValue = result.getColumnLatest(HUsersRepository.COLUMN_FAMILY_NAME, HUsersRepository.COLUMN.PWD);
+            return keyValue;
+        } catch (IOException e) {
+            log.error("Error while counting users from HBase", e);
+            throw new UsersRepositoryException("Error while counting users from HBase", e);
+        } finally {
+            if (table != null) {
+                try {
+                    TablePool.getInstance().putTable(table);
+                } catch (IOException e) {
+                    // Do nothing, we can't get access to the HBaseSchema.
+                }
+            }
+        }
+    }
+    
+    private void putUser(DefaultUser user) throws UsersRepositoryException {
+        HTable table = null;
+        try {
+            table = TablePool.getInstance().getUsersRepositoryTable();
+            Put put = new Put(Bytes.toBytes(user.getUserName()));
+            put.add(HUsersRepository.COLUMN_FAMILY_NAME, HUsersRepository.COLUMN.PWD, Bytes.toBytes(user.getHashedPassword()));
+            table.put(put);
+            table.flushCommits();
+        } catch (IOException e) {
+            log.error("Error while adding user in HBase", e);
+            throw new UsersRepositoryException("Error while adding user in HBase", e);
+        } finally {
+            if (table != null) {
+                try {
+                    TablePool.getInstance().putTable(table);
+                } catch (IOException e) {
+                    // Do nothing, we can't get access to the HBaseSchema.
+                }
+            }
+        }
+    }
+
+}

Added: james/server/trunk/hbase/src/main/java/org/apache/james/user/hbase/def/HUsersRepository.java
URL: http://svn.apache.org/viewvc/james/server/trunk/hbase/src/main/java/org/apache/james/user/hbase/def/HUsersRepository.java?rev=1154497&view=auto
==============================================================================
--- james/server/trunk/hbase/src/main/java/org/apache/james/user/hbase/def/HUsersRepository.java (added)
+++ james/server/trunk/hbase/src/main/java/org/apache/james/user/hbase/def/HUsersRepository.java Sat Aug  6 12:08:54 2011
@@ -0,0 +1,32 @@
+/****************************************************************
+ * 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.james.user.hbase.def;
+
+import org.apache.hadoop.hbase.util.Bytes;
+
+public interface HUsersRepository {
+
+    byte[] TABLE_NAME = Bytes.toBytes("JAMES_USERS");
+    byte[] COLUMN_FAMILY_NAME = Bytes.toBytes("JAMES_USERS");
+    
+    public interface COLUMN {
+        byte [] PWD = Bytes.toBytes("pwd");
+    }
+
+}

Added: james/server/trunk/hbase/src/test/java/org/apache/james/JamesServerHBaseIntegrationTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/hbase/src/test/java/org/apache/james/JamesServerHBaseIntegrationTest.java?rev=1154497&view=auto
==============================================================================
--- james/server/trunk/hbase/src/test/java/org/apache/james/JamesServerHBaseIntegrationTest.java (added)
+++ james/server/trunk/hbase/src/test/java/org/apache/james/JamesServerHBaseIntegrationTest.java Sat Aug  6 12:08:54 2011
@@ -0,0 +1,76 @@
+/****************************************************************
+ * 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.james;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.MiniHBaseCluster;
+import org.apache.james.domainlist.hbase.HBaseDomainListTest;
+import org.apache.james.rrt.hbase.HBaseRecipientRewriteTableTest;
+import org.apache.james.system.hbase.TablePool;
+import org.apache.james.system.hbase.TablePoolTest;
+import org.apache.james.user.hbase.HBaseUsersRepositoryTest;
+import org.apache.log4j.Logger;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({
+    TablePoolTest.class,
+    HBaseDomainListTest.class,
+    HBaseRecipientRewriteTableTest.class,
+    HBaseUsersRepositoryTest.class
+  })
+public class JamesServerHBaseIntegrationTest {
+
+    private static Logger logger = Logger.getLogger(JamesServerHBaseIntegrationTest.class);
+    
+    private static MiniHBaseCluster hbaseCluster;
+    
+    @BeforeClass
+    public static void setup() throws Exception {
+        HBaseTestingUtility htu = new HBaseTestingUtility();
+        htu.getConfiguration().setBoolean("dfs.support.append", true);
+        try {
+            hbaseCluster = htu.startMiniCluster();
+        } 
+        catch (Exception e) {
+            logger.error("Exception when starting HBase Mini Cluster", e);
+        }
+        TablePool.getInstance(getConfiguration());
+    }
+    
+    @AfterClass
+    public static void tearDown() throws Exception {
+       if (hbaseCluster != null) {
+           hbaseCluster.shutdown();
+       }
+    }
+    
+    public static Configuration getConfiguration() {
+        if (hbaseCluster == null) {
+            throw new IllegalStateException("Please instanciate HBaseTestingUtility before invoking this method");
+        }
+        return hbaseCluster.getConfiguration();
+    }
+
+}

Added: james/server/trunk/hbase/src/test/java/org/apache/james/domainlist/hbase/HBaseDomainListTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/hbase/src/test/java/org/apache/james/domainlist/hbase/HBaseDomainListTest.java?rev=1154497&view=auto
==============================================================================
--- james/server/trunk/hbase/src/test/java/org/apache/james/domainlist/hbase/HBaseDomainListTest.java (added)
+++ james/server/trunk/hbase/src/test/java/org/apache/james/domainlist/hbase/HBaseDomainListTest.java Sat Aug  6 12:08:54 2011
@@ -0,0 +1,37 @@
+/****************************************************************
+ * 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.james.domainlist.hbase;
+
+import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.lib.AbstractDomainListTest;
+import org.slf4j.LoggerFactory;
+
+public class HBaseDomainListTest extends AbstractDomainListTest {
+
+    @Override
+    protected DomainList createDomainList() {
+        HBaseDomainList domainList = new HBaseDomainList();
+        domainList.setLog(LoggerFactory.getLogger("MockLog"));
+        domainList.setDNSService(getDNSServer("localhost"));
+        domainList.setAutoDetect(false);
+        domainList.setAutoDetectIP(false);
+        return domainList;
+    }
+
+}

Added: james/server/trunk/hbase/src/test/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTableTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/hbase/src/test/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTableTest.java?rev=1154497&view=auto
==============================================================================
--- james/server/trunk/hbase/src/test/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTableTest.java (added)
+++ james/server/trunk/hbase/src/test/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTableTest.java Sat Aug  6 12:08:54 2011
@@ -0,0 +1,83 @@
+/****************************************************************
+ * 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.james.rrt.hbase;
+
+import org.apache.commons.configuration.DefaultConfigurationBuilder;
+import org.apache.james.rrt.api.RecipientRewriteTableException;
+import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
+import org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest;
+import org.slf4j.LoggerFactory;
+
+public class HBaseRecipientRewriteTableTest extends AbstractRecipientRewriteTableTest {
+
+    @Override
+    protected AbstractRecipientRewriteTable getRecipientRewriteTable() throws Exception {
+        HBaseRecipientRewriteTable rrt = new HBaseRecipientRewriteTable();
+        rrt.setLog(LoggerFactory.getLogger("MockLog"));
+        rrt.configure(new DefaultConfigurationBuilder());
+        return rrt;
+    }
+
+    /**
+     * @see org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest#addMapping(java.lang.String,
+     *      java.lang.String, java.lang.String, int)
+     */
+    protected boolean addMapping(String user, String domain, String mapping, int type) throws RecipientRewriteTableException {
+        try {
+            if (type == ERROR_TYPE) {
+                virtualUserTable.addErrorMapping(user, domain, mapping);
+            } else if (type == REGEX_TYPE) {
+                virtualUserTable.addRegexMapping(user, domain, mapping);
+            } else if (type == ADDRESS_TYPE) {
+                virtualUserTable.addAddressMapping(user, domain, mapping);
+            } else if (type == ALIASDOMAIN_TYPE) {
+                virtualUserTable.addAliasDomainMapping(domain, mapping);
+            } else {
+                return false;
+            }
+            return true;
+        } catch (RecipientRewriteTableException e) {
+            return false;
+        }
+    }
+
+    /**
+     * @see org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest#removeMapping(java.lang.String,
+     *      java.lang.String, java.lang.String, int)
+     */
+    protected boolean removeMapping(String user, String domain, String mapping, int type) throws RecipientRewriteTableException {
+        try {
+            if (type == ERROR_TYPE) {
+                virtualUserTable.removeErrorMapping(user, domain, mapping);
+            } else if (type == REGEX_TYPE) {
+                virtualUserTable.removeRegexMapping(user, domain, mapping);
+            } else if (type == ADDRESS_TYPE) {
+                virtualUserTable.removeAddressMapping(user, domain, mapping);
+            } else if (type == ALIASDOMAIN_TYPE) {
+                virtualUserTable.removeAliasDomainMapping(domain, mapping);
+            } else {
+                return false;
+            }
+            return true;
+        } catch (RecipientRewriteTableException e) {
+            return false;
+        }
+    }
+
+}

Added: james/server/trunk/hbase/src/test/java/org/apache/james/system/hbase/TablePoolTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/hbase/src/test/java/org/apache/james/system/hbase/TablePoolTest.java?rev=1154497&view=auto
==============================================================================
--- james/server/trunk/hbase/src/test/java/org/apache/james/system/hbase/TablePoolTest.java (added)
+++ james/server/trunk/hbase/src/test/java/org/apache/james/system/hbase/TablePoolTest.java Sat Aug  6 12:08:54 2011
@@ -0,0 +1,49 @@
+/****************************************************************
+ * 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.james.system.hbase;
+
+import java.io.IOException;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+public class TablePoolTest {
+    
+    @Test
+    public void testGetInstance() throws IOException {
+        Assert.assertNotNull(TablePool.getInstance());
+    }
+    
+    @Test
+    public void testGetDomainlistTable() throws IOException {
+        Assert.assertNotNull(TablePool.getInstance().getDomainlistTable());
+    }
+
+    @Test
+    public void testGetRecipientRewriteTable() throws IOException {
+        Assert.assertNotNull(TablePool.getInstance().getRecipientRewriteTable());
+    }
+
+    @Test
+    public void testGetUsersRepositoryTable() throws IOException {
+        Assert.assertNotNull(TablePool.getInstance().getUsersRepositoryTable());
+    }
+
+}

Added: james/server/trunk/hbase/src/test/java/org/apache/james/user/hbase/HBaseUsersRepositoryTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/hbase/src/test/java/org/apache/james/user/hbase/HBaseUsersRepositoryTest.java?rev=1154497&view=auto
==============================================================================
--- james/server/trunk/hbase/src/test/java/org/apache/james/user/hbase/HBaseUsersRepositoryTest.java (added)
+++ james/server/trunk/hbase/src/test/java/org/apache/james/user/hbase/HBaseUsersRepositoryTest.java Sat Aug  6 12:08:54 2011
@@ -0,0 +1,61 @@
+/****************************************************************
+ * 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.james.user.hbase;
+
+import java.util.Iterator;
+
+import org.apache.commons.configuration.DefaultConfigurationBuilder;
+import org.apache.james.user.api.UsersRepository;
+import org.apache.james.user.api.UsersRepositoryException;
+import org.apache.james.user.lib.AbstractUsersRepositoryTest;
+import org.junit.After;
+import org.junit.Before;
+import org.slf4j.LoggerFactory;
+
+public class HBaseUsersRepositoryTest extends AbstractUsersRepositoryTest {
+
+    @Override
+    @Before
+    protected void setUp() throws Exception {
+        super.setUp();
+        deleteAll();
+    }
+
+    @Override
+    @After
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    private void deleteAll() throws UsersRepositoryException, Exception {
+        Iterator<String> it = getUsersRepository().list();
+        while (it.hasNext()) {
+            getUsersRepository().removeUser(it.next());
+        }
+    }
+    
+    @Override
+    protected UsersRepository getUsersRepository() throws Exception {
+        HBaseUsersRepository userRepository = new HBaseUsersRepository();
+        userRepository.setLog(LoggerFactory.getLogger("MockLog"));
+        userRepository.configure(new DefaultConfigurationBuilder());
+        return userRepository;
+    }
+
+}

Added: james/server/trunk/hbase/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/james/server/trunk/hbase/src/test/resources/log4j.properties?rev=1154497&view=auto
==============================================================================
--- james/server/trunk/hbase/src/test/resources/log4j.properties (added)
+++ james/server/trunk/hbase/src/test/resources/log4j.properties Sat Aug  6 12:08:54 2011
@@ -0,0 +1,6 @@
+log4j.rootLogger=WARN, A1
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+
+# Print the date in ISO 8601 format
+log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message