accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject svn commit: r1481697 - in /accumulo/branches/1.4/docs: mockAccumulo.html src/user_manual/accumulo_user_manual.tex src/user_manual/chapters/development_clients.tex
Date Mon, 13 May 2013 04:27:24 GMT
Author: cjnolet
Date: Mon May 13 04:27:23 2013
New Revision: 1481697

Applying patch ACCUMULO-1380


Modified: accumulo/branches/1.4/docs/src/user_manual/accumulo_user_manual.tex
--- accumulo/branches/1.4/docs/src/user_manual/accumulo_user_manual.tex (original)
+++ accumulo/branches/1.4/docs/src/user_manual/accumulo_user_manual.tex Mon May 13 04:27:23
@@ -43,6 +43,7 @@ Version 1.4}

Added: accumulo/branches/1.4/docs/src/user_manual/chapters/development_clients.tex
--- accumulo/branches/1.4/docs/src/user_manual/chapters/development_clients.tex (added)
+++ accumulo/branches/1.4/docs/src/user_manual/chapters/development_clients.tex Mon May 13
04:27:23 2013
@@ -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
% Unless required by applicable law or agreed to in writing, software
% distributed under the License is distributed on an "AS IS" BASIS,
% 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:

Instance instance = new ZooKeeperInstance(...);
Connector conn = instance.getConnector(user, passwd);

To interact with the MockAccumulo, just replace the ZooKeeperInstance with MockInstance:

Instance instance = new MockInstance();

In fact, you can use the "--fake" option to the Accumulo shell and interact with

$ ./bin/accumulo shell --fake -u root -p nonsense

Shell - Apache 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>

When testing Map Reduce jobs, you can also set the Mock Accumulo on the AccumuloInputFormat
and AccumuloOutputFormat classes:

// ... set up job configuration
AccumuloInputFormat.setMockInstance(job, "mockInstance");
AccumuloOutputFormat.setMockInstance(job, "mockInstance");

\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:

File tempDirectory = // JUnit and Guava supply mechanisms for creating temp directories
MiniAccumuloCluster accumulo = new MiniAccumuloCluster(tempDirectory, "password");

Once we have our mini cluster running, we will want to interact with the Accumulo client API:

Instance instance = new ZooKeeperInstance(accumulo.getInstanceName(), accumulo.getZooKeepers());
Connector conn = instance.getConnector("root", "password");

Upon completion of our development code, we will want to shutdown our MiniAccumuloCluster:

// delete your temporary folder
\ No newline at end of file

View raw message