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 54563D515 for ; Tue, 21 May 2013 18:55:31 +0000 (UTC) Received: (qmail 35269 invoked by uid 500); 21 May 2013 18:55:31 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 35196 invoked by uid 500); 21 May 2013 18:55:30 -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 35174 invoked by uid 99); 21 May 2013 18:55:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 May 2013 18:55:30 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED 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; Tue, 21 May 2013 18:55:28 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id DE74E23889EB; Tue, 21 May 2013 18:55:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1484903 - /accumulo/branches/1.5/docs/src/main/latex/accumulo_user_manual/chapters/clients.tex Date: Tue, 21 May 2013 18:55:08 -0000 To: commits@accumulo.apache.org From: cjnolet@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130521185508.DE74E23889EB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: cjnolet Date: Tue May 21 18:55:08 2013 New Revision: 1484903 URL: http://svn.apache.org/r1484903 Log: ACCUMULO-1414 Adding proxy to user manual Modified: accumulo/branches/1.5/docs/src/main/latex/accumulo_user_manual/chapters/clients.tex Modified: accumulo/branches/1.5/docs/src/main/latex/accumulo_user_manual/chapters/clients.tex URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/docs/src/main/latex/accumulo_user_manual/chapters/clients.tex?rev=1484903&r1=1484902&r2=1484903&view=diff ============================================================================== --- accumulo/branches/1.5/docs/src/main/latex/accumulo_user_manual/chapters/clients.tex (original) +++ accumulo/branches/1.5/docs/src/main/latex/accumulo_user_manual/chapters/clients.tex Tue May 21 18:55:08 2013 @@ -37,7 +37,7 @@ configured Accumulo system to see what i \small \begin{verbatim} -$ACCUMULO_HOME/bin/accumulo classpath +$ACCUMULO_HOME/bin/accumulo classpath \end{verbatim} \normalsize @@ -168,7 +168,7 @@ crash a tablet server. By default rows a can easily supply their own buffer if they wish to buffer to disk when rows are large. -For an example, look at the following\\ +For an example, look at the following\\ \texttt{examples/simple/src/main/java/org/apache/accumulo/examples/simple/isolation/InterferenceTest.java} \subsection{BatchScanner} @@ -193,7 +193,6 @@ BatchScanner bscan = bscan.setRanges(ranges); bscan.fetchFamily("attributes"); - for(Entry entry : scan) System.out.println(entry.getValue()); \end{verbatim} @@ -202,3 +201,132 @@ for(Entry entry : scan) An example of the BatchScanner can be found at\\ accumulo/docs/examples/README.batch +\section{Proxy} + +The proxy API allows the interaction with Accumulo with languages other than Java. +A proxy server is provided in the codebase and a client can further be generated. + +\subsection{Prequisites} + +The proxy server can live on any node in which the basic client API would work. That +means it must be able to communicate with the Master, ZooKeepers, NameNode, and the +Data nodes. A proxy client only needs the ability to communicate with the proxy server. + + +\subsection{Configuration} + +The configuration options for the proxy server live inside of a properties file. At +the very least, you need to supply the following properties: + +\small +\begin{verbatim} +protocolFactory=org.apache.thrift.protocol.TCompactProtocol$Factory +tokenClass=org.apache.accumulo.core.client.security.tokens.PasswordToken +port=42424 +instance=test +zookeepers=localhost:2181 +\end{verbatim} +\normalsize + +You can find a sample configuration file in your distribution: + +\small +\begin{verbatim} +$ACCUMULO_HOME/proxy/proxy.properties. +\end{verbatim} +\normalsize + +This sample configuration file further demonstrates an abilty to back the proxy server +by MockAccumulo or the MiniAccumuloCluster. + +\subsection{Running the Proxy Server} + +After the properties file holding the configuration is created, the proxy server +can be started using the following command in the Accumulo distribution (assuming +you your properties file is named config.properties): + +\small +\begin{verbatim} +$ACCUMULO_HOME/bin/accumulo proxy -p config.properties +\end{verbatim} +\normalsize + +\subsection{Creating a Proxy Client} + +Aside from installing the Thrift compiler, you will also need the language-specific library +for Thrift installed to generate client code in that language. Typically, your operating +system's package manager will be able to automatically install these for you in an expected +location such as /usr/lib/python/site-packages/thrift. + +You can find the thrift file for generating the client: + +\small +\begin{verbatim} +$ACCUMULO_HOME/proxy/proxy.thrift. +\end{verbatim} +\normalsize + +After a client is generated, the port specified in the configuration properties above will be +used to connect to the server. + +\subsection{Using a Proxy Client} + +The following examples have been written in Java and the method signatures may be +slightly different depending on the language specified when generating client with +the Thrift compiler. After initiating a connection to the Proxy (see Apache Thrift's +documentation for examples of connecting to a Thrift service), the methods on the +proxy client will be available. The first thing to do is log in: + +\small +\begin{verbatim} +Map password = new HashMap(); +password.put("password", "secret"); +ByteBuffer token = client.login("root", password); +\end{verbatim} +\normalsize + +Once logged in, the token returned will be used for most subsequent calls to the client. +Let's create a table, add some data, scan the table, and delete it. + + +First, create a table. + +\small +\begin{verbatim} +client.createTable(token, "myTable", true, TimeType.MILLIS); +\end{verbatim} +\normalsize + + +Next, add some data: + +\small +\begin{verbatim} +// first, create a writer on the server +String writer = client.createWriter(token, "myTable", new WriterOptions()); + +// build column updates +Map cells> cellsToUpdate = //... + +// send updates to the server +client.updateAndFlush(writer, "myTable", cellsToUpdate); + +client.closeWriter(writer); +\end{verbatim} +\normalsize + + +Scan for the data and batch the return of the results on the server: + +\small +\begin{verbatim} +String scanner = client.createScanner(token, "myTable", new ScanOptions()); +ScanResult results = client.nextK(scanner, 100); + +for(KeyValue keyValue : results.getResultsIterator()) { + // do something with results +} + +client.closeScanner(scanner); +\end{verbatim} +\normalsize \ No newline at end of file