accumulo-dev mailing list archives

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

    https://github.com/apache/accumulo/pull/242#discussion_r110288818
  
    --- Diff: server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tables/TablesResource.java
---
    @@ -0,0 +1,232 @@
    +/*
    + * 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.tables;
    +
    +import java.util.ArrayList;
    +import java.util.Collections;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.Map.Entry;
    +import java.util.SortedMap;
    +import java.util.TreeMap;
    +import java.util.TreeSet;
    +import java.util.stream.Collectors;
    +
    +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.Instance;
    +import org.apache.accumulo.core.client.impl.Namespaces;
    +import org.apache.accumulo.core.client.impl.Tables;
    +import org.apache.accumulo.core.data.Range;
    +import org.apache.accumulo.core.data.impl.KeyExtent;
    +import org.apache.accumulo.core.master.thrift.TableInfo;
    +import org.apache.accumulo.core.master.thrift.TabletServerStatus;
    +import org.apache.accumulo.core.metadata.MetadataTable;
    +import org.apache.accumulo.core.metadata.RootTable;
    +import org.apache.accumulo.monitor.Monitor;
    +import org.apache.accumulo.monitor.rest.tservers.TabletServer;
    +import org.apache.accumulo.monitor.rest.tservers.TabletServers;
    +import org.apache.accumulo.server.client.HdfsZooInstance;
    +import org.apache.accumulo.server.master.state.MetaDataTableScanner;
    +import org.apache.accumulo.server.master.state.TabletLocationState;
    +import org.apache.accumulo.server.tables.TableManager;
    +import org.apache.accumulo.server.util.TableInfoUtil;
    +import org.apache.hadoop.io.Text;
    +
    +/**
    + *
    + * Generates a tables list from the Monitor as a JSON object
    + *
    + * @since 2.0.0
    + *
    + */
    +@Path("/tables")
    +@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    +public class TablesResource {
    +
    +  private static final TabletServerStatus NO_STATUS = new TabletServerStatus();
    +
    +  /**
    +   * Generates a table list based on the namespace
    +   *
    +   * @param namespace
    +   *          Namespace used to filter the tables
    +   * @return Table list
    +   */
    +  private TablesList generateTables(String namespace) {
    +    Instance inst = Monitor.getContext().getInstance();
    +    Map<String,String> tidToNameMap = Tables.getIdToNameMap(inst);
    +    SortedMap<String,TableInfo> tableStats = new TreeMap<>();
    +
    +    if (Monitor.getMmi() != null && Monitor.getMmi().tableMap != null)
    +      for (Entry<String,TableInfo> te : Monitor.getMmi().tableMap.entrySet())
    +        tableStats.put(Tables.getPrintableTableNameFromId(tidToNameMap, te.getKey()),
te.getValue());
    +
    +    Map<String,Double> compactingByTable = TableInfoUtil.summarizeTableStats(Monitor.getMmi());
    +    TableManager tableManager = TableManager.getInstance();
    +
    +    SortedMap<String,String> namespaces = Namespaces.getNameToIdMap(Monitor.getContext().getInstance());
    +
    +    TablesList tableNamespace = new TablesList();
    +    List<TableInformation> tables = new ArrayList<>();
    +
    +    // Add the tables that have the selected namespace
    +    for (String key : namespaces.keySet()) {
    +      if (namespace.equals("*") || namespace.equals(key) || (key.equals("") &&
namespace.equals("-"))) {
    --- End diff --
    
    Yes, instead of simply empty string. I was thinking something with reserved chars, like
`_default_`. The benefit here is that we could add a connection namespace context like `use
<namespace>;` in traditional RDBMS for a more intuitive API. If using the `_default_`
namespace, a smarter client could interpret the absence of a fully qualified table name as
relative to the current namespace context, rather than always the default namespace. This
would work in both the current API (whose context is always the default namespace) and a new
API where you can switch namespace contexts.
    
    If I end up working on that API some more, I can elaborate a bit more. For these purposes,
I think it just makes sense to have a better name for UI menus. A dash just doesn't cut it,
I think.


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