drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arina-ielchiieva <...@git.apache.org>
Subject [GitHub] drill pull request #482: DRILL-4604: Generate warning on Web UI if drillbits...
Date Wed, 02 Nov 2016 10:14:40 GMT
Github user arina-ielchiieva commented on a diff in the pull request:

    https://github.com/apache/drill/pull/482#discussion_r86107203
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRoot.java
---
    @@ -55,44 +59,89 @@ public Viewable getStats() {
       @GET
       @Path("/stats.json")
       @Produces(MediaType.APPLICATION_JSON)
    -  public List<Stat> getStatsJSON() {
    -    List<Stat> stats = Lists.newLinkedList();
    -    stats.add(new Stat("Number of Drill Bits", work.getContext().getBits().size()));
    -    int number = 0;
    -    for (CoordinationProtos.DrillbitEndpoint bit : work.getContext().getBits()) {
    -      String initialized = bit.isInitialized() ? " initialized" : " not initialized";
    -      stats.add(new Stat("Bit #" + number, bit.getAddress() + initialized));
    -      ++number;
    +  public Stats getStatsJSON() {
    +    final String version = work.getContext().getOptionManager().getOption(ExecConstants.CLUSTER_VERSION).string_val;
    +
    +    final Map<String, Object> props = Maps.newLinkedHashMap();
    +    props.put("Cluster Version", version);
    +    props.put("Number of Drillbits", work.getContext().getBits().size());
    +    CoordinationProtos.DrillbitEndpoint currentEndpoint = work.getContext().getEndpoint();
    +    final String address = currentEndpoint.getAddress();
    +    props.put("Data Port Address", address + ":" + currentEndpoint.getDataPort());
    +    props.put("User Port Address", address + ":" + currentEndpoint.getUserPort());
    +    props.put("Control Port Address", address + ":" + currentEndpoint.getControlPort());
    +    props.put("Maximum Direct Memory", DrillConfig.getMaxDirectMemory());
    +
    +    return new Stats(props, collectDrillbits(version));
    +  }
    +
    +  private Collection<DrillbitInfo> collectDrillbits(String version) {
    +    Set<DrillbitInfo> drillbits = Sets.newTreeSet();
    +    for (CoordinationProtos.DrillbitEndpoint endpoint : work.getContext().getBits())
{
    +      boolean versionMatch = version.equals(endpoint.getVersion());
    +      DrillbitInfo drillbit = new DrillbitInfo(endpoint.getAddress(), endpoint.isInitialized(),
endpoint.getVersion(), versionMatch);
    +      drillbits.add(drillbit);
         }
    -    stats.add(new Stat("Data Port Address", work.getContext().getEndpoint().getAddress()
+
    -      ":" + work.getContext().getEndpoint().getDataPort()));
    -    stats.add(new Stat("User Port Address", work.getContext().getEndpoint().getAddress()
+
    -      ":" + work.getContext().getEndpoint().getUserPort()));
    -    stats.add(new Stat("Control Port Address", work.getContext().getEndpoint().getAddress()
+
    -      ":" + work.getContext().getEndpoint().getControlPort()));
    -    stats.add(new Stat("Maximum Direct Memory", DrillConfig.getMaxDirectMemory()));
    -
    -    return stats;
    +    return drillbits;
       }
     
       @XmlRootElement
    -  public class Stat {
    -    private String name;
    -    private Object value;
    +  public static class Stats {
    --- End diff --
    
    Renamed to ClusterInfo


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