Applying patch ACCUMULO-1380
git-svn-id: https://svn.apache.org/repos/asf/accumulo/branches/1.4@1481697 13f79535-47bb-0310-9956-ffa450edef68 Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/f04bdfef Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/f04bdfef Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/f04bdfef Branch: refs/heads/master Commit: f04bdfef070fa7c7febe24a0f07a490bc21e8e4a Parents: 0e463d4 Author: Corey J. Nolet <[email protected]> Authored: Mon May 13 04:27:23 2013 +0000 Committer: Corey J. Nolet <[email protected]> Committed: Mon May 13 04:27:23 2013 +0000 ---------------------------------------------------------------------- docs/mockAccumulo.html | 80 -------------------- docs/src/user_manual/accumulo_user_manual.tex | 1 + .../chapters/development_clients.tex | 1 + 3 files changed, 2 insertions(+), 80 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/f04bdfef/docs/mockAccumulo.html ---------------------------------------------------------------------- diff --git a/docs/mockAccumulo.html b/docs/mockAccumulo.html deleted file mode 100644 index 54c6449..0000000 --- a/docs/mockAccumulo.html +++ /dev/null @@ -1,80 +0,0 @@ -<!-- - 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. ---> -<html> -<head> -<title>Accumulo Mock</title> -<link rel='stylesheet' type='text/css' href='documentation.css' media='screen'/> -</head> -<body> - -<h1>Apache Accumulo Documentation : Mock Accumulo</h1> - -<p>Normally, accumulo consists of lots of moving parts. Even a stand-alone version of accumulo requires hadoop, -zookeeper, the accumulo master, a tablet server, etc. If you want to write a unit test that uses accumulo, you need a lot of -infrastructure in place before your test can run. To help developers with their tests, we have created a fake version of -Accumulo called MockAccumulo. The normal interaction with the client API looks something like this: -</p> - -<pre> - Instance instance = new ZooKeeperInstance(...); - Connector conn = instance.getConnector(user, passwd); - BatchScanner scanner = conn.createBatchScaner(...); - // configure scanner - // ... - for (Entry<Key, Value> entry : scanner) { - // process entry - } -</pre> - -<p>MockAccumulo supports the same client API. Just replace the ZooKeeperInstance with MockInstance:</p> - -<pre> - Instance instance = new MockInstance(); - // as above -</pre> - -<p>In fact, you can use the <tt>--fake</tt> option to the accumulo shell and interact with MockAccumulo:</p> - -<pre> -$ ./bin/accumulo shell --fake -u root -p nonsense - -Shell - Apache Accumulo Interactive Shell -- -- version: 1.3.2-SNAPSHOT -- instance name: mock-instance -- instance id: mock-instance-id -- -- type 'help' for a list of available commands -- -root@mock-instance> createtable test -root@mock-instance test> insert row1 cf cq value -root@mock-instance test> insert row2 cf cq value2 -root@mock-instance test> insert row3 cf cq value3 -root@mock-instance test> scan -row1 cf:cq [] value -row2 cf:cq [] value2 -row3 cf:cq [] value3 -root@mock-instance test> scan -b row2 -e row2 -row2 cf:cq [] value2 -root@mock-instance test> -</pre> - -<p>MockAccumulo presently does not enforce users, logins, permissions, etc. It <b>does</b> support Iterators and Aggregators. -Note that MockAccumulo holds all data in memory, and will not retain any data or settings between runs.</p> - -</body> -</html> http://git-wip-us.apache.org/repos/asf/accumulo/blob/f04bdfef/docs/src/user_manual/accumulo_user_manual.tex ---------------------------------------------------------------------- diff --git a/docs/src/user_manual/accumulo_user_manual.tex b/docs/src/user_manual/accumulo_user_manual.tex index e20ce1d..9c95348 100644 --- a/docs/src/user_manual/accumulo_user_manual.tex +++ b/docs/src/user_manual/accumulo_user_manual.tex @@ -43,6 +43,7 @@ Version 1.4} \include{chapters/design} \include{chapters/shell} \include{chapters/clients} +\include{chapters/development_clients} \include{chapters/table_configuration} \include{chapters/table_design} \include{chapters/high_speed_ingest} http://git-wip-us.apache.org/repos/asf/accumulo/blob/f04bdfef/docs/src/user_manual/chapters/development_clients.tex ---------------------------------------------------------------------- diff --git a/docs/src/user_manual/chapters/development_clients.tex b/docs/src/user_manual/chapters/development_clients.tex new file mode 100644 index 0000000..3edb88d --- /dev/null +++ b/docs/src/user_manual/chapters/development_clients.tex @@ -0,0 +1 @@ + % 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. \chapter{Development Clients} Normally, Accumulo consists of lots of moving parts. Even a stand-alone version of Accumulo requires Hadoop, Zookeeper, the Accumulo master, a tablet server, etc. If you want to writ e a unit test that uses Accumulo, you need a lot of infrastructure in place before your test can run. \section{Mock Accumulo} Mock Accumulo supplies mock implementations for much of the client API. It presently does not enforce users, logins, permissions, etc. It does support Iterators and Combiners. Note that MockAccumulo holds all data in memory, and will not retain any data or settings between runs. While normal interaction with the Accumulo client looks like this: \small \begin{verbatim} Instance instance = new ZooKeeperInstance(...); Connector conn = instance.getConnector(user, passwd); \end{verbatim} \normalsize To interact with the MockAccumulo, just replace the ZooKeeperInstance with MockInstance: \small \begin{verbatim} Instance instance = new MockInstance(); \end{verbatim} \normalsize In fact, you can use the "--fake" option to the Accumulo shell and interact with MockAccumulo: \small \begin{verbatim} $ ./bin/accumulo shell --fake -u root -p nonsense Shell - Apach e Accumulo Interactive Shell - - version: 1.4.4 - instance name: mock-instance - instance id: mock-instance-id - - type 'help' for a list of available commands - root@mock-instance> createtable test root@mock-instance test> insert row1 cf cq value root@mock-instance test> insert row2 cf cq value2 root@mock-instance test> insert row3 cf cq value3 root@mock-instance test> scan row1 cf:cq [] value row2 cf:cq [] value2 row3 cf:cq [] value3 root@mock-instance test> scan -b row2 -e row2 row2 cf:cq [] value2 root@mock-instance test> \end{verbatim} \normalsize When testing Map Reduce jobs, you can also set the Mock Accumulo on the AccumuloInputFormat and AccumuloOutputFormat classes: \small \begin{verbatim} // ... set up job configuration AccumuloInputFormat.setMockInstance(job, "mockInstance"); AccumuloOutputFormat.setMockInstance(job, "mockInstance"); \end{verbatim} \normalsize \section{Mini Accumulo Cluster} While the Mock Accumulo provides a lightweight implementation of the client API for unit testing, it is often necessary to write more realistic end-to-end integration tests that take advantage of the entire ecosystem. The Mini Accumulo Cluster makes this possible by configuring and starting Zookeeper, initializing Accumulo, and starting the Master as well as some Tablet Servers. It runs against the local filesystem instead of having to start up HDFS. To start it up, you will need to supply an empty directory and a root password as arguments: \small \begin{verbatim} File tempDirectory = // JUnit and Guava supply mechanisms for creating temp directories MiniAccumuloCluster accumulo = new MiniAccumuloCluster(tempDirectory, "password"); accumulo.start(); \end{verbatim} \normalsize Once we have our mini cluster running, we will want to interact with the Accumulo client API: \small \begin{verbatim} Instance instance = new ZooKeeperInstance(accumulo.getInstanceName(), accumulo.getZooKeepers()); Connector conn = instance.getConnector("root", "passwo rd"); \end{verbatim} \normalsize Upon completion of our development code, we will want to shutdown our MiniAccumuloCluster: \small \begin{verbatim} accumulo.stop() // delete your temporary folder \end{verbatim} \normalsize \ No newline at end of file
