Skip to content

Commit

Permalink
Add environment name to UI
Browse files Browse the repository at this point in the history
  • Loading branch information
electrum committed Mar 1, 2016
1 parent 6529d91 commit f7ccd58
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
Expand Up @@ -27,11 +27,15 @@
public class ServerInfo
{
private final NodeVersion nodeVersion;
private final String environment;

@JsonCreator
public ServerInfo(@JsonProperty("nodeVersion") NodeVersion nodeVersion)
public ServerInfo(
@JsonProperty("nodeVersion") NodeVersion nodeVersion,
@JsonProperty("environment") String environment)
{
this.nodeVersion = requireNonNull(nodeVersion, "nodeVersion is null");
this.environment = requireNonNull(environment, "environment is null");
}

@JsonProperty
Expand All @@ -40,6 +44,12 @@ public NodeVersion getNodeVersion()
return nodeVersion;
}

@JsonProperty
public String getEnvironment()
{
return environment;
}

@Override
public boolean equals(Object o)
{
Expand All @@ -51,20 +61,22 @@ public boolean equals(Object o)
}

ServerInfo that = (ServerInfo) o;
return Objects.equals(nodeVersion, that.nodeVersion);
return Objects.equals(nodeVersion, that.nodeVersion) &&
Objects.equals(environment, that.environment);
}

@Override
public int hashCode()
{
return Objects.hash(nodeVersion);
return Objects.hash(nodeVersion, environment);
}

@Override
public String toString()
{
return toStringHelper(this)
.add("nodeVersion", nodeVersion)
.add("environment", environment)
.toString();
}
}
1 change: 1 addition & 0 deletions presto-docs/src/main/sphinx/release/release-0.140.rst
Expand Up @@ -6,6 +6,7 @@ General Changes
---------------

* Optimize predicate expressions to minimize redundancies.
* Add environment name to UI.

Hive Changes
------------
Expand Down
Expand Up @@ -97,6 +97,7 @@
import io.airlift.concurrent.BoundedExecutor;
import io.airlift.configuration.AbstractConfigurationAwareModule;
import io.airlift.discovery.client.ServiceDescriptor;
import io.airlift.node.NodeInfo;
import io.airlift.slice.Slice;
import io.airlift.units.Duration;

Expand Down Expand Up @@ -301,7 +302,6 @@ protected void setup(Binder binder)
});

// server info resource
binder.bind(ServerInfo.class).toInstance(new ServerInfo(nodeVersion));
jaxrsBinder(binder).bind(ServerInfoResource.class);

// plugin manager
Expand Down Expand Up @@ -334,6 +334,13 @@ protected void setup(Binder binder)
binder.bind(FinalizerService.class).in(Scopes.SINGLETON);
}

@Provides
@Singleton
public ServerInfo createServerInfo(NodeVersion nodeVersion, NodeInfo nodeInfo)
{
return new ServerInfo(nodeVersion, nodeInfo.getEnvironment());
}

@Provides
@Singleton
@ForExchange
Expand Down
2 changes: 2 additions & 0 deletions presto-main/src/main/resources/webapp/index.html
Expand Up @@ -78,6 +78,7 @@
</a>
</div>
<div class="col-md-3 text-right" id="version"></div>
<div class="col-md-3 text-right" id="environment"></div>
</div>

<div id="queries"></div>
Expand All @@ -86,6 +87,7 @@
<script type="text/jsx">
d3.json("/v1/info", function (info) {
document.getElementById('version').textContent = "Version: " + info.nodeVersion.version;
document.getElementById('environment').textContent = info.environment;
});

var Query = React.createClass({
Expand Down

0 comments on commit f7ccd58

Please sign in to comment.