diff options
17 files changed, 63 insertions, 64 deletions
diff --git a/server/sonar-cluster/src/main/java/org/sonar/cluster/health/NodeDetails.java b/server/sonar-cluster/src/main/java/org/sonar/cluster/health/NodeDetails.java index 000030f8796..be127000e7d 100644 --- a/server/sonar-cluster/src/main/java/org/sonar/cluster/health/NodeDetails.java +++ b/server/sonar-cluster/src/main/java/org/sonar/cluster/health/NodeDetails.java @@ -37,7 +37,7 @@ public class NodeDetails implements Externalizable { private String name; private String host; private int port; - private long started; + private long startedAt; /** * Required for Serialization @@ -50,7 +50,7 @@ public class NodeDetails implements Externalizable { this.name = builder.name; this.host = builder.host; this.port = builder.port; - this.started = builder.started; + this.startedAt = builder.startedAt; } public static Builder newNodeDetailsBuilder() { @@ -73,8 +73,8 @@ public class NodeDetails implements Externalizable { return port; } - public long getStarted() { - return started; + public long getStartedAt() { + return startedAt; } @Override @@ -84,7 +84,7 @@ public class NodeDetails implements Externalizable { ", name='" + name + '\'' + ", host='" + host + '\'' + ", port=" + port + - ", started=" + started + + ", startedAt=" + startedAt + '}'; } @@ -94,7 +94,7 @@ public class NodeDetails implements Externalizable { out.writeUTF(name); out.writeUTF(host); out.writeInt(port); - out.writeLong(started); + out.writeLong(startedAt); } @Override @@ -103,7 +103,7 @@ public class NodeDetails implements Externalizable { this.name = in.readUTF(); this.host = in.readUTF(); this.port = in.readInt(); - this.started = in.readLong(); + this.startedAt = in.readLong(); } @Override @@ -116,7 +116,7 @@ public class NodeDetails implements Externalizable { } NodeDetails that = (NodeDetails) o; return port == that.port && - started == that.started && + startedAt == that.startedAt && type == that.type && name.equals(that.name) && host.equals(that.host); @@ -124,7 +124,7 @@ public class NodeDetails implements Externalizable { @Override public int hashCode() { - return Objects.hash(type, name, host, port, started); + return Objects.hash(type, name, host, port, startedAt); } public static class Builder { @@ -132,7 +132,7 @@ public class NodeDetails implements Externalizable { private String name; private String host; private int port; - private long started; + private long startedAt; private Builder() { // use static factory method @@ -159,9 +159,9 @@ public class NodeDetails implements Externalizable { return this; } - public Builder setStarted(long started) { - checkStarted(started); - this.started = started; + public Builder setStartedAt(long startedAt) { + checkStartedAt(startedAt); + this.startedAt = startedAt; return this; } @@ -170,7 +170,7 @@ public class NodeDetails implements Externalizable { checkString(name, "name"); checkString(host, "host"); checkPort(port); - checkStarted(started); + checkStartedAt(startedAt); return new NodeDetails(this); } @@ -189,8 +189,8 @@ public class NodeDetails implements Externalizable { checkArgument(port > 0, "port must be > 0"); } - private static void checkStarted(long started) { - checkArgument(started > 0, "started must be > 0"); + private static void checkStartedAt(long startedAt) { + checkArgument(startedAt > 0, "startedAt must be > 0"); } } diff --git a/server/sonar-cluster/src/test/java/org/sonar/cluster/health/NodeDetailsTest.java b/server/sonar-cluster/src/test/java/org/sonar/cluster/health/NodeDetailsTest.java index 6ce0be03349..ede86a42577 100644 --- a/server/sonar-cluster/src/test/java/org/sonar/cluster/health/NodeDetailsTest.java +++ b/server/sonar-cluster/src/test/java/org/sonar/cluster/health/NodeDetailsTest.java @@ -107,9 +107,9 @@ public class NodeDetailsTest { @Test public void setStarted_throws_IAE_if_arg_is_less_than_1() { expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("started must be > 0"); + expectedException.expectMessage("startedAt must be > 0"); - builderUnderTest.setStarted(-random.nextInt(5)); + builderUnderTest.setStartedAt(-random.nextInt(5)); } @Test @@ -165,7 +165,7 @@ public class NodeDetailsTest { .setPort(1 + random.nextInt(33)); expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("started must be > 0"); + expectedException.expectMessage("startedAt must be > 0"); builderUnderTest.build(); } @@ -209,18 +209,18 @@ public class NodeDetailsTest { String name = randomAlphanumeric(3); String host = randomAlphanumeric(10); int port = 1 + random.nextInt(10); - int started = 1 + random.nextInt(666); + long startedAt = 1 + random.nextInt(666); NodeDetails underTest = builderUnderTest .setType(randomType) .setName(name) .setHost(host) .setPort(port) - .setStarted(started) + .setStartedAt(startedAt) .build(); assertThat(underTest.toString()) - .isEqualTo("NodeDetails{type=" + randomType + ", name='" + name + "', host='" + host + "', port=" + port + ", started=" + started + "}"); + .isEqualTo("NodeDetails{type=" + randomType + ", name='" + name + "', host='" + host + "', port=" + port + ", startedAt=" + startedAt + "}"); } @Test @@ -228,20 +228,20 @@ public class NodeDetailsTest { String name = randomAlphanumeric(3); String host = randomAlphanumeric(10); int port = 1 + random.nextInt(10); - int started = 1 + random.nextInt(666); + long startedAt = 1 + random.nextInt(666); NodeDetails underTest = builderUnderTest .setType(randomType) .setName(name) .setHost(host) .setPort(port) - .setStarted(started) + .setStartedAt(startedAt) .build(); assertThat(underTest.getType()).isEqualTo(randomType); assertThat(underTest.getName()).isEqualTo(name); assertThat(underTest.getHost()).isEqualTo(host); assertThat(underTest.getPort()).isEqualTo(port); - assertThat(underTest.getStarted()).isEqualTo(started); + assertThat(underTest.getStartedAt()).isEqualTo(startedAt); } } diff --git a/server/sonar-cluster/src/test/java/org/sonar/cluster/health/NodeDetailsTestSupport.java b/server/sonar-cluster/src/test/java/org/sonar/cluster/health/NodeDetailsTestSupport.java index 7337f3ec0b3..100627db98a 100644 --- a/server/sonar-cluster/src/test/java/org/sonar/cluster/health/NodeDetailsTestSupport.java +++ b/server/sonar-cluster/src/test/java/org/sonar/cluster/health/NodeDetailsTestSupport.java @@ -71,7 +71,7 @@ public class NodeDetailsTestSupport { .setName(randomAlphanumeric(3)) .setHost(randomAlphanumeric(10)) .setPort(1 + random.nextInt(10)) - .setStarted(1 + random.nextInt(666)); + .setStartedAt(1 + random.nextInt(666)); } NodeDetails.Type randomType() { diff --git a/server/sonar-cluster/src/test/java/org/sonar/cluster/health/SharedHealthStateImplTest.java b/server/sonar-cluster/src/test/java/org/sonar/cluster/health/SharedHealthStateImplTest.java index 9c3c5d92e9c..0b0ec193d55 100644 --- a/server/sonar-cluster/src/test/java/org/sonar/cluster/health/SharedHealthStateImplTest.java +++ b/server/sonar-cluster/src/test/java/org/sonar/cluster/health/SharedHealthStateImplTest.java @@ -245,7 +245,7 @@ public class SharedHealthStateImplTest { .setName(randomAlphanumeric(30)) .setHost(randomAlphanumeric(10)) .setPort(1 + random.nextInt(666)) - .setStarted(1 + random.nextInt(852)) + .setStartedAt(1 + random.nextInt(852)) .build()) .build(); } diff --git a/server/sonar-main/src/main/java/org/sonar/application/health/SearchNodeHealthProvider.java b/server/sonar-main/src/main/java/org/sonar/application/health/SearchNodeHealthProvider.java index 93657803762..b1f650602fc 100644 --- a/server/sonar-main/src/main/java/org/sonar/application/health/SearchNodeHealthProvider.java +++ b/server/sonar-main/src/main/java/org/sonar/application/health/SearchNodeHealthProvider.java @@ -43,7 +43,7 @@ public class SearchNodeHealthProvider implements NodeHealthProvider { .setName(props.nonNullValue(CLUSTER_NODE_NAME)) .setHost(getHost(props, networkUtils)) .setPort(Integer.valueOf(props.nonNullValue(CLUSTER_NODE_PORT))) - .setStarted(system2.now()) + .setStartedAt(system2.now()) .build(); } diff --git a/server/sonar-main/src/test/java/org/sonar/application/health/SearchNodeHealthProviderTest.java b/server/sonar-main/src/test/java/org/sonar/application/health/SearchNodeHealthProviderTest.java index ae3084db84f..ce6fc6ec450 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/health/SearchNodeHealthProviderTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/health/SearchNodeHealthProviderTest.java @@ -190,14 +190,14 @@ public class SearchNodeHealthProviderTest { NodeHealth nodeHealth = underTest.get(); - assertThat(nodeHealth.getDetails().getStarted()).isEqualTo(now); + assertThat(nodeHealth.getDetails().getStartedAt()).isEqualTo(now); // change now when(system2.now()).thenReturn(now); NodeHealth newNodeHealth = underTest.get(); - assertThat(newNodeHealth.getDetails().getStarted()).isEqualTo(now); + assertThat(newNodeHealth.getDetails().getStartedAt()).isEqualTo(now); } @Test diff --git a/server/sonar-server/src/main/java/org/sonar/server/health/NodeHealthProviderImpl.java b/server/sonar-server/src/main/java/org/sonar/server/health/NodeHealthProviderImpl.java index 1829c36421c..f350b267184 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/health/NodeHealthProviderImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/health/NodeHealthProviderImpl.java @@ -47,7 +47,7 @@ public class NodeHealthProviderImpl implements NodeHealthProvider { .setType(NodeDetails.Type.APPLICATION) .setHost(computeHost(configuration, networkUtils)) .setPort(computePort(configuration)) - .setStarted(server.getStartedAt().getTime()) + .setStartedAt(server.getStartedAt().getTime()) .build(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/ws/HealthActionSupport.java b/server/sonar-server/src/main/java/org/sonar/server/platform/ws/HealthActionSupport.java index 9df0678a9fc..f1459808df1 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/ws/HealthActionSupport.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/ws/HealthActionSupport.java @@ -29,7 +29,6 @@ import org.sonar.server.health.Health; import org.sonar.server.health.HealthChecker; import org.sonarqube.ws.WsSystem; -import static java.lang.String.valueOf; import static org.sonar.api.utils.DateUtils.formatDateTime; public class HealthActionSupport { @@ -102,8 +101,8 @@ public class HealthActionSupport { .setType(WsSystem.NodeType.valueOf(details.getType().name())) .setName(details.getName()) .setHost(details.getHost()) - .setPort(valueOf(details.getPort())) - .setStarted(formatDateTime(details.getStarted())); + .setPort(details.getPort()) + .setStartedAt(formatDateTime(details.getStartedAt())); return nodeBuilder.build(); } diff --git a/server/sonar-server/src/main/resources/org/sonar/server/platform/ws/example-health.json b/server/sonar-server/src/main/resources/org/sonar/server/platform/ws/example-health.json index b1e98f92032..28c8b37cc84 100644 --- a/server/sonar-server/src/main/resources/org/sonar/server/platform/ws/example-health.json +++ b/server/sonar-server/src/main/resources/org/sonar/server/platform/ws/example-health.json @@ -10,8 +10,8 @@ "name": "app-1", "type": "APPLICATION", "host": "192.168.1.1", - "port": "999", - "started": "2015-08-13T23:34:59+0200", + "port": 999, + "startedAt": "2015-08-13T23:34:59+0200", "health": "RED", "causes": [ { @@ -23,8 +23,8 @@ "name": "app-2", "type": "APPLICATION", "host": "192.168.1.2", - "port": "999", - "started": "2015-08-13T23:34:59+0200", + "port": 999, + "startedAt": "2015-08-13T23:34:59+0200", "health": "YELLOW", "causes": [ { @@ -36,8 +36,8 @@ "name": "es-1", "type": "SEARCH", "host": "192.168.1.3", - "port": "999", - "started": "2015-08-13T23:34:59+0200", + "port": 999, + "startedAt": "2015-08-13T23:34:59+0200", "health": "GREEN", "causes": [] }, @@ -45,8 +45,8 @@ "name": "es-2", "type": "SEARCH", "host": "192.168.1.4", - "port": "999", - "started": "2015-08-13T23:34:59+0200", + "port": 999, + "startedAt": "2015-08-13T23:34:59+0200", "health": "GREEN", "causes": [] }, @@ -54,8 +54,8 @@ "name": "es-3", "type": "SEARCH", "host": "192.168.1.5", - "port": "999", - "started": "2015-08-13T23:34:59+0200", + "port": 999, + "startedAt": "2015-08-13T23:34:59+0200", "health": "GREEN", "causes": [] } diff --git a/server/sonar-server/src/test/java/org/sonar/server/health/AppNodeClusterCheckTest.java b/server/sonar-server/src/test/java/org/sonar/server/health/AppNodeClusterCheckTest.java index f10c1e5ff52..b435cff9be3 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/health/AppNodeClusterCheckTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/health/AppNodeClusterCheckTest.java @@ -277,7 +277,7 @@ public class AppNodeClusterCheckTest { .setHost(randomAlphanumeric(32)) .setName(randomAlphanumeric(32)) .setPort(1 + random.nextInt(88)) - .setStarted(1 + random.nextInt(54)) + .setStartedAt(1 + random.nextInt(54)) .build()) .build(); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/health/ClusterHealthTest.java b/server/sonar-server/src/test/java/org/sonar/server/health/ClusterHealthTest.java index 8d60966d08f..494eaf2de5a 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/health/ClusterHealthTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/health/ClusterHealthTest.java @@ -116,7 +116,7 @@ public class ClusterHealthTest { .setName(randomAlphanumeric(3)) .setHost(randomAlphanumeric(4)) .setPort(1 + random.nextInt(344)) - .setStarted(1 + random.nextInt(999)) + .setStartedAt(1 + random.nextInt(999)) .build()) .build()).collect(Collectors.toSet()); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/health/EsStatusClusterCheckTest.java b/server/sonar-server/src/test/java/org/sonar/server/health/EsStatusClusterCheckTest.java index 11a02c20ea1..d24dce584cd 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/health/EsStatusClusterCheckTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/health/EsStatusClusterCheckTest.java @@ -50,7 +50,7 @@ public class EsStatusClusterCheckTest { .setName(randomAlphanumeric(23)) .setHost(randomAlphanumeric(23)) .setPort(1 + random.nextInt(96)) - .setStarted(1 + random.nextInt(966)) + .setStartedAt(1 + random.nextInt(966)) .build()) .build()) .collect(Collectors.toSet()); diff --git a/server/sonar-server/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java index 3c4a89aa433..a3e191951c7 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java @@ -249,7 +249,7 @@ public class HealthCheckerImplTest { .setName(randomAlphanumeric(10)) .setHost(randomAlphanumeric(5)) .setPort(1 + random.nextInt(333)) - .setStarted(1 + random.nextInt(444)) + .setStartedAt(1 + random.nextInt(444)) .build()) .build(); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/health/NodeHealthProviderImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/health/NodeHealthProviderImplTest.java index 02a0df617c8..5cb9914f4b7 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/health/NodeHealthProviderImplTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/health/NodeHealthProviderImplTest.java @@ -221,14 +221,14 @@ public class NodeHealthProviderImplTest { NodeHealth nodeHealth = underTest.get(); - assertThat(nodeHealth.getDetails().getStarted()).isEqualTo(date.getTime()); + assertThat(nodeHealth.getDetails().getStartedAt()).isEqualTo(date.getTime()); // change startedAt value setStartedAt(); NodeHealth newNodeHealth = underTest.get(); - assertThat(newNodeHealth.getDetails().getStarted()).isEqualTo(date.getTime()); + assertThat(newNodeHealth.getDetails().getStartedAt()).isEqualTo(date.getTime()); } private void setStartedAt() { diff --git a/server/sonar-server/src/test/java/org/sonar/server/health/SearchNodeClusterCheckTest.java b/server/sonar-server/src/test/java/org/sonar/server/health/SearchNodeClusterCheckTest.java index 59135f2bfab..88145389f87 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/health/SearchNodeClusterCheckTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/health/SearchNodeClusterCheckTest.java @@ -513,7 +513,7 @@ public class SearchNodeClusterCheckTest { .setHost(randomAlphanumeric(32)) .setName(randomAlphanumeric(32)) .setPort(1 + random.nextInt(88)) - .setStarted(1 + random.nextInt(54)) + .setStartedAt(1 + random.nextInt(54)) .build()) .build(); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/ws/HealthActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/ws/HealthActionTest.java index ab70215d87b..11522e7aabf 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/platform/ws/HealthActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/platform/ws/HealthActionTest.java @@ -96,7 +96,7 @@ public class HealthActionTest { .setType(NodeDetails.Type.APPLICATION) .setHost("192.168.1.1") .setPort(999) - .setStarted(time) + .setStartedAt(time) .build()) .build(), newNodeHealthBuilder() @@ -108,7 +108,7 @@ public class HealthActionTest { .setType(NodeDetails.Type.APPLICATION) .setHost("192.168.1.2") .setPort(999) - .setStarted(time) + .setStartedAt(time) .build()) .build(), newNodeHealthBuilder() @@ -119,7 +119,7 @@ public class HealthActionTest { .setType(NodeDetails.Type.SEARCH) .setHost("192.168.1.3") .setPort(999) - .setStarted(time) + .setStartedAt(time) .build()) .build(), newNodeHealthBuilder() @@ -130,7 +130,7 @@ public class HealthActionTest { .setType(NodeDetails.Type.SEARCH) .setHost("192.168.1.4") .setPort(999) - .setStarted(time) + .setStartedAt(time) .build()) .build(), newNodeHealthBuilder() @@ -141,7 +141,7 @@ public class HealthActionTest { .setType(NodeDetails.Type.SEARCH) .setHost("192.168.1.5") .setPort(999) - .setStarted(time) + .setStartedAt(time) .build()) .build()))); @@ -201,8 +201,8 @@ public class HealthActionTest { .containsOnly(nodeHealth.getCauses().stream().toArray(String[]::new)); assertThat(node.getName()).isEqualTo(nodeHealth.getDetails().getName()); assertThat(node.getHost()).isEqualTo(nodeHealth.getDetails().getHost()); - assertThat(node.getPort()).isEqualTo(String.valueOf(nodeHealth.getDetails().getPort())); - assertThat(node.getStarted()).isEqualTo(formatDateTime(nodeHealth.getDetails().getStarted())); + assertThat(node.getPort()).isEqualTo(nodeHealth.getDetails().getPort()); + assertThat(node.getStartedAt()).isEqualTo(formatDateTime(nodeHealth.getDetails().getStartedAt())); assertThat(node.getType().name()).isEqualTo(nodeHealth.getDetails().getType().name()); } @@ -225,7 +225,7 @@ public class HealthActionTest { randomNodeHealth(NodeDetails.Type.SEARCH, "2_name", "1_host", 2, 28), randomNodeHealth(NodeDetails.Type.SEARCH, "2_name", "2_host", 1, 66), randomNodeHealth(NodeDetails.Type.SEARCH, "2_name", "2_host", 2, 77))); - String[] expected = nodeHealths.stream().map(s -> formatDateTime(new Date(s.getDetails().getStarted()))).toArray(String[]::new); + String[] expected = nodeHealths.stream().map(s -> formatDateTime(new Date(s.getDetails().getStartedAt()))).toArray(String[]::new); Collections.shuffle(nodeHealths); when(webServer.isStandalone()).thenReturn(false); @@ -234,7 +234,7 @@ public class HealthActionTest { WsSystem.HealthResponse response = underTest.newRequest().executeProtobuf(WsSystem.HealthResponse.class); assertThat(response.getNodes().getNodesList()) - .extracting(WsSystem.Node::getStarted) + .extracting(WsSystem.Node::getStartedAt) .containsExactly(expected); } @@ -248,7 +248,7 @@ public class HealthActionTest { .setName(randomAlphanumeric(3)) .setHost(randomAlphanumeric(4)) .setPort(1 + random.nextInt(3)) - .setStarted(1 + random.nextInt(23)) + .setStartedAt(1 + random.nextInt(23)) .build()) .build(); } @@ -263,7 +263,7 @@ public class HealthActionTest { .setName(name) .setHost(host) .setPort(port) - .setStarted(started) + .setStartedAt(started) .build()) .build(); } diff --git a/sonar-ws/src/main/protobuf/ws-system.proto b/sonar-ws/src/main/protobuf/ws-system.proto index 874d838ffc9..5a6cddfe4e8 100644 --- a/sonar-ws/src/main/protobuf/ws-system.proto +++ b/sonar-ws/src/main/protobuf/ws-system.proto @@ -65,8 +65,8 @@ message Node { optional string name = 1; optional NodeType type = 2; optional string host = 3; - optional string port = 4; - optional string started = 5; + optional int32 port = 4; + optional string startedAt = 5; optional Health health = 6; repeated Cause causes = 7; } |