Github user ctubbsii commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/242#discussion_r110252042
  
    --- 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 --
    
    I've previously tossed around the idea of creating a proper name for the 
default namespace, and leaving empty string as an alias. Cleaning up the 
namespace utility classes to do this is probably a bit tedious. If it helps 
with this interface, it may help prioritize giving it a real name.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to