From notifications-return-42685-archive-asf-public=cust-asf.ponee.io@accumulo.apache.org Mon Mar 26 17:02:36 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 425FD180649 for ; Mon, 26 Mar 2018 17:02:36 +0200 (CEST) Received: (qmail 57823 invoked by uid 500); 26 Mar 2018 15:02:35 -0000 Mailing-List: contact notifications-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jira@apache.org Delivered-To: mailing list notifications@accumulo.apache.org Received: (qmail 57772 invoked by uid 99); 26 Mar 2018 15:02:35 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Mar 2018 15:02:35 +0000 From: GitBox To: notifications@accumulo.apache.org Subject: [GitHub] keith-turner commented on a change in pull request #11: Fixes #10 - Update helloworld example to new Connector builder Message-ID: <152207655462.15574.16799862014843955835.gitbox@gitbox.apache.org> Date: Mon, 26 Mar 2018 15:02:34 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit keith-turner commented on a change in pull request #11: Fixes #10 - Update helloworld example to new Connector builder URL: https://github.com/apache/accumulo-examples/pull/11#discussion_r177121826 ########## File path: src/main/java/org/apache/accumulo/examples/helloworld/InsertWithBatchWriter.java ########## @@ -20,46 +20,42 @@ import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.BatchWriter; import org.apache.accumulo.core.client.Connector; -import org.apache.accumulo.core.client.MultiTableBatchWriter; -import org.apache.accumulo.core.client.MutationsRejectedException; import org.apache.accumulo.core.client.TableExistsException; import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.core.data.Mutation; import org.apache.accumulo.core.data.Value; -import org.apache.accumulo.examples.cli.BatchWriterOpts; -import org.apache.accumulo.examples.cli.ClientOnRequiredTable; import org.apache.hadoop.io.Text; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Inserts 10K rows (50K entries) into accumulo with each row having 5 entries. */ public class InsertWithBatchWriter { - public static void main(String[] args) throws AccumuloException, AccumuloSecurityException, MutationsRejectedException, TableExistsException, + private static final Logger log = LoggerFactory.getLogger(InsertWithBatchWriter.class); + + public static void main(String[] args) throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException { - ClientOnRequiredTable opts = new ClientOnRequiredTable(); - BatchWriterOpts bwOpts = new BatchWriterOpts(); - opts.parseArgs(InsertWithBatchWriter.class.getName(), args, bwOpts); - Connector connector = opts.getConnector(); - MultiTableBatchWriter mtbw = connector.createMultiTableBatchWriter(bwOpts.getBatchWriterConfig()); + Connector connector = Connector.builder().usingProperties("conf/accumulo-client.properties").build(); - if (!connector.tableOperations().exists(opts.getTableName())) - connector.tableOperations().create(opts.getTableName()); - BatchWriter bw = mtbw.getBatchWriter(opts.getTableName()); + if (!connector.tableOperations().exists("hellotable")) { + connector.tableOperations().create("hellotable"); Review comment: A better pattern for this is to call create and catch a table exists exception. Can do nothing when the exception is caught. Calling exists and then create is susceptible to race conditions. This could be changed in another PR. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services