accumulo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lstav <...@git.apache.org>
Subject [GitHub] accumulo pull request #242: ACCUMULO-2181/3005 REST API and new Monitor UI
Date Tue, 11 Apr 2017 13:48:02 GMT
Github user lstav commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/242#discussion_r110905981
  
    --- Diff: server/monitor/src/main/java/org/apache/accumulo/monitor/rest/trace/TracesResource.java
---
    @@ -0,0 +1,372 @@
    +/*
    + * 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.monitor.rest.trace;
    +
    +import static java.lang.Math.min;
    +import static java.nio.charset.StandardCharsets.UTF_8;
    +
    +import java.io.IOException;
    +import java.security.PrivilegedAction;
    +import java.security.PrivilegedExceptionAction;
    +import java.util.Collection;
    +import java.util.Map;
    +import java.util.Map.Entry;
    +import java.util.Set;
    +import java.util.TreeMap;
    +
    +import javax.ws.rs.DefaultValue;
    +import javax.ws.rs.GET;
    +import javax.ws.rs.Path;
    +import javax.ws.rs.PathParam;
    +import javax.ws.rs.Produces;
    +import javax.ws.rs.core.MediaType;
    +
    +import org.apache.accumulo.core.client.AccumuloException;
    +import org.apache.accumulo.core.client.AccumuloSecurityException;
    +import org.apache.accumulo.core.client.Connector;
    +import org.apache.accumulo.core.client.Scanner;
    +import org.apache.accumulo.core.client.TableNotFoundException;
    +import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
    +import org.apache.accumulo.core.client.security.tokens.AuthenticationToken.Properties;
    +import org.apache.accumulo.core.client.security.tokens.KerberosToken;
    +import org.apache.accumulo.core.client.security.tokens.PasswordToken;
    +import org.apache.accumulo.core.conf.AccumuloConfiguration;
    +import org.apache.accumulo.core.conf.Property;
    +import org.apache.accumulo.core.data.Key;
    +import org.apache.accumulo.core.data.Range;
    +import org.apache.accumulo.core.data.Value;
    +import org.apache.accumulo.core.util.Pair;
    +import org.apache.accumulo.monitor.Monitor;
    +import org.apache.accumulo.server.client.HdfsZooInstance;
    +import org.apache.accumulo.server.security.SecurityUtil;
    +import org.apache.accumulo.tracer.SpanTree;
    +import org.apache.accumulo.tracer.SpanTreeVisitor;
    +import org.apache.accumulo.tracer.TraceDump;
    +import org.apache.accumulo.tracer.TraceFormatter;
    +import org.apache.accumulo.tracer.thrift.Annotation;
    +import org.apache.accumulo.tracer.thrift.RemoteSpan;
    +import org.apache.hadoop.io.Text;
    +import org.apache.hadoop.security.UserGroupInformation;
    +
    +/**
    + *
    + * Generates a list of traces with the summary, by type, and trace details
    + *
    + * @since 2.0.0
    + *
    + */
    +@Path("/trace")
    +@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    +public class TracesResource {
    +
    +  /**
    +   * Generates a trace summary
    +   *
    +   * @param minutes
    +   *          Range of minutes to filter traces
    +   * @return Trace summary in specified range
    +   */
    +  @Path("summary/{minutes}")
    +  @GET
    +  public RecentTracesList getTraces(@DefaultValue("10") @PathParam("minutes") int minutes)
throws Exception {
    +
    +    RecentTracesList recentTraces = new RecentTracesList();
    +
    +    Pair<Scanner,UserGroupInformation> pair = getScanner();
    +    final Scanner scanner = pair.getFirst();
    +    if (scanner == null) {
    +      return recentTraces;
    +    }
    +
    +    Range range = getRangeForTrace(minutes);
    +    scanner.setRange(range);
    +
    +    final Map<String,RecentTracesInformation> summary = new TreeMap<>();
    +    if (null != pair.getSecond()) {
    +      pair.getSecond().doAs(new PrivilegedAction<Void>() {
    --- End diff --
    
    Sure thing, thanks for asking


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message