Return-Path: X-Original-To: apmail-accumulo-commits-archive@www.apache.org Delivered-To: apmail-accumulo-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2BD4DF358 for ; Mon, 13 May 2013 05:14:20 +0000 (UTC) Received: (qmail 69349 invoked by uid 500); 13 May 2013 05:14:20 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 69305 invoked by uid 500); 13 May 2013 05:14:18 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 69282 invoked by uid 99); 13 May 2013 05:14:18 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 May 2013 05:14:18 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_FRT_STOCK2 X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 May 2013 05:14:15 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id E350E23888E3; Mon, 13 May 2013 05:13:53 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1481699 - in /accumulo/branches/1.5/docs: mockAccumulo.html src/main/latex/accumulo_user_manual/accumulo_user_manual.tex src/main/latex/accumulo_user_manual/chapters/development_clients.tex Date: Mon, 13 May 2013 05:13:53 -0000 To: commits@accumulo.apache.org From: cjnolet@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130513051353.E350E23888E3@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: cjnolet Date: Mon May 13 05:13:53 2013 New Revision: 1481699 URL: http://svn.apache.org/r1481699 Log: Applying patch ACCUMULO-1380 Added: accumulo/branches/1.5/docs/src/main/latex/accumulo_user_manual/chapters/development_clients.tex Removed: accumulo/branches/1.5/docs/mockAccumulo.html Modified: accumulo/branches/1.5/docs/src/main/latex/accumulo_user_manual/accumulo_user_manual.tex Modified: accumulo/branches/1.5/docs/src/main/latex/accumulo_user_manual/accumulo_user_manual.tex URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/docs/src/main/latex/accumulo_user_manual/accumulo_user_manual.tex?rev=1481699&r1=1481698&r2=1481699&view=diff ============================================================================== --- accumulo/branches/1.5/docs/src/main/latex/accumulo_user_manual/accumulo_user_manual.tex (original) +++ accumulo/branches/1.5/docs/src/main/latex/accumulo_user_manual/accumulo_user_manual.tex Mon May 13 05:13:53 2013 @@ -43,6 +43,7 @@ Version 1.5} \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} Added: accumulo/branches/1.5/docs/src/main/latex/accumulo_user_manual/chapters/development_clients.tex URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/docs/src/main/latex/accumulo_user_manual/chapters/development_clients.tex?rev=1481699&view=auto ============================================================================== --- accumulo/branches/1.5/docs/src/main/latex/accumulo_user_manual/chapters/development_clients.tex (added) +++ accumulo/branches/1.5/docs/src/main/latex/accumulo_user_manual/chapters/development_clients.tex Mon May 13 05:13:53 2013 @@ -0,0 +1,123 @@ + +% 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 write 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 - Apache Accumulo Interactive Shell +- +- version: 1.5 +- 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", "password"); +\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