Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cluster stats should not render empty http/transport types #23735

Conversation

tlrx
Copy link
Member

@tlrx tlrx commented Mar 24, 2017

This commit changes ClusterStatsNodes.NetworkTypes so that is does
not print out empty field names when no Transport or HTTP type is defined:

{
      ...
      "network_types": {
        ...
        "http_types": {
          "": 2
        }
      }
}

is now rendered as:

{
      ...
      "network_types": {
        ...
        "http_types": {
        }
      }
}

This should almost never happen because transport-netty4 is shipped by default, but we can have integration tests that use mocked transport plugins without registering HTTP transport types.

@tlrx tlrx force-pushed the do-not-render-empty-field-names-in-transport-type-stats branch 2 times, most recently from 37514c6 to ee83445 Compare March 28, 2017 11:15
@tlrx tlrx requested a review from pickypg March 28, 2017 12:19
@tlrx tlrx force-pushed the do-not-render-empty-field-names-in-transport-type-stats branch 6 times, most recently from 9bca46c to 67cac31 Compare March 30, 2017 18:18
This commit changes the ClusterStatsNodes.NetworkTypes so that is does
not print out empty field names when no Transport or HTTP type is defined:

```
{
"network_types": {
        ...
        "http_types": {
          "": 2
        }
      }
}
```

is now rendered as:

```
{
"network_types": {
        ...
        "http_types": {
        }
      }
}
```
@tlrx tlrx force-pushed the do-not-render-empty-field-names-in-transport-type-stats branch from 67cac31 to 442ed82 Compare March 31, 2017 07:42
@@ -560,12 +571,16 @@ private NetworkTypes(final List<NodeInfo> nodeInfos) {
public XContentBuilder toXContent(final XContentBuilder builder, final Params params) throws IOException {
builder.startObject("transport_types");
for (final Map.Entry<String, AtomicInteger> entry : transportTypes.entrySet()) {
builder.field(entry.getKey(), entry.getValue().get());
if (Strings.hasText(entry.getKey())) {
Copy link
Contributor

@spinscale spinscale Mar 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the check be done here, or should such an element never get added to the map at the first place?

Copy link
Contributor

@spinscale spinscale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM in general, left one comment regarding the check and if we might want to not populate the list in the first place

@tlrx tlrx merged commit 2809916 into elastic:master Mar 31, 2017
@tlrx
Copy link
Member Author

tlrx commented Mar 31, 2017

Thanks @spinscale !

tlrx added a commit that referenced this pull request Mar 31, 2017
This commit changes the ClusterStatsNodes.NetworkTypes so that is does
not print out empty field names when no Transport or HTTP type is defined:

```
{
"network_types": {
        ...
        "http_types": {
          "": 2
        }
      }
}
```

is now rendered as:

```
{
"network_types": {
        ...
        "http_types": {
        }
      }
}
```
tlrx added a commit that referenced this pull request Mar 31, 2017
This commit changes the ClusterStatsNodes.NetworkTypes so that is does
not print out empty field names when no Transport or HTTP type is defined:

```
{
"network_types": {
        ...
        "http_types": {
          "": 2
        }
      }
}
```

is now rendered as:

```
{
"network_types": {
        ...
        "http_types": {
        }
      }
}
```
tlrx added a commit that referenced this pull request Mar 31, 2017
This commit changes the ClusterStatsNodes.NetworkTypes so that is does
not print out empty field names when no Transport or HTTP type is defined:

```
{
"network_types": {
        ...
        "http_types": {
          "": 2
        }
      }
}
```

is now rendered as:

```
{
"network_types": {
        ...
        "http_types": {
        }
      }
}
```
@tlrx tlrx deleted the do-not-render-empty-field-names-in-transport-type-stats branch April 1, 2017 11:46
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Apr 1, 2017
* master:
  Fix language in some docs
  CONSOLEify lang-analyzer docs
  Stricter parsing of remote node attribute
  Fix cross-cluster remote node gateway attributes
  FieldCapabilitiesRequest should implements Replaceable since it accepts index patterns
  Cleanup: Remove unused FieldMappers class (elastic#23851)
  Fix FieldCapabilities compilation in Eclipse (elastic#23855)
  Add extra debugging to reindex cancel tests
  Cluster stats should not render empty http/transport types (elastic#23735)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants