This is an automated email from the ASF dual-hosted git repository. mmiller pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/accumulo-examples.git
The following commit(s) were added to refs/heads/main by this push: new 10e6e1a Drop TraceDumpExample. Closes #35 (#71) 10e6e1a is described below commit 10e6e1ad59ff93ca6f7254d44e20268ee476da2c Author: Mike Miller <mmil...@apache.org> AuthorDate: Tue Mar 30 15:00:26 2021 -0400 Drop TraceDumpExample. Closes #35 (#71) --- contrib/import-control.xml | 8 +- .../accumulo/examples/client/TraceDumpExample.java | 97 ---------------------- 2 files changed, 1 insertion(+), 104 deletions(-) diff --git a/contrib/import-control.xml b/contrib/import-control.xml index f4628ff..e8b98dc 100644 --- a/contrib/import-control.xml +++ b/contrib/import-control.xml @@ -29,15 +29,9 @@ <allow pkg="org.apache.accumulo.minicluster"/> <allow pkg="org.apache.accumulo.hadoop.mapreduce"/> - <!-- exceptions for this project --> - <allow pkg="org.apache.accumulo.core.conf"/> + <!-- exception for the constraints example --> <allow class="org.apache.accumulo.core.constraints.Constraint"/> - <!-- TODO refactor code to remove the following exceptions --> - <allow class="org.apache.accumulo.tracer.TraceDump"/> - <allow class="org.apache.accumulo.core.trace.DistributedTrace"/> - <!-- End TODO section --> - <!-- disallow everything else coming from accumulo --> <disallow pkg="org.apache.accumulo"/> </import-control> diff --git a/src/main/java/org/apache/accumulo/examples/client/TraceDumpExample.java b/src/main/java/org/apache/accumulo/examples/client/TraceDumpExample.java deleted file mode 100644 index 36bff49..0000000 --- a/src/main/java/org/apache/accumulo/examples/client/TraceDumpExample.java +++ /dev/null @@ -1,97 +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. - */ -package org.apache.accumulo.examples.client; - -import org.apache.accumulo.core.client.AccumuloClient; -import org.apache.accumulo.core.client.AccumuloException; -import org.apache.accumulo.core.client.AccumuloSecurityException; -import org.apache.accumulo.core.client.Scanner; -import org.apache.accumulo.core.client.TableNotFoundException; -import org.apache.accumulo.core.conf.ClientProperty; -import org.apache.accumulo.core.data.Range; -import org.apache.accumulo.core.security.TablePermission; -import org.apache.accumulo.examples.cli.ClientOnDefaultTable; -import org.apache.accumulo.examples.cli.ScannerOpts; -import org.apache.accumulo.tracer.TraceDump; -import org.apache.hadoop.io.Text; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.beust.jcommander.Parameter; - -/** - * Example of using the TraceDump class to print a formatted view of a Trace - */ -public class TraceDumpExample { - private static final Logger log = LoggerFactory.getLogger(TraceDumpExample.class); - - static class Opts extends ClientOnDefaultTable { - public Opts() { - super("trace"); - } - - @Parameter(names = {"--traceid"}, - description = "The hex string id of a given trace, for example 16cfbbd7beec4ae3") - public String traceId = ""; - } - - public void dump(Opts opts) - throws TableNotFoundException, AccumuloException, AccumuloSecurityException { - - if (opts.traceId.isEmpty()) { - throw new IllegalArgumentException("--traceid option is required"); - } - - try (AccumuloClient client = opts.createAccumuloClient()) { - final String principal = ClientProperty.AUTH_PRINCIPAL.getValue(opts.getClientProperties()); - final String table = opts.getTableName(); - if (!client.securityOperations().hasTablePermission(principal, table, TablePermission.READ)) { - client.securityOperations().grantTablePermission(principal, table, TablePermission.READ); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new RuntimeException(e); - } - while (!client.securityOperations().hasTablePermission(principal, table, - TablePermission.READ)) { - log.info("{} didn't propagate read permission on {}", principal, table); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new RuntimeException(e); - } - } - } - Scanner scanner = client.createScanner(table, opts.auths); - scanner.setRange(new Range(new Text(opts.traceId))); - TraceDump.printTrace(scanner, System.out::println); - } - } - - public static void main(String[] args) - throws TableNotFoundException, AccumuloException, AccumuloSecurityException { - TraceDumpExample traceDumpExample = new TraceDumpExample(); - Opts opts = new Opts(); - ScannerOpts scannerOpts = new ScannerOpts(); - opts.parseArgs(TraceDumpExample.class.getName(), args, scannerOpts); - - traceDumpExample.dump(opts); - } - -}