aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-09-04 18:03:04 +0200
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-09-13 15:50:53 +0200
commit4b0d1ba16eccdc9e79154f31549d437ad1be6e0b (patch)
tree24ebfa43ffbed47cdca32746addb7022396cf4e3 /server
parentfc4fcf2ceb0572e3b5b2862563285daf65ff0b97 (diff)
downloadsonarqube-4b0d1ba16eccdc9e79154f31549d437ad1be6e0b.tar.gz
sonarqube-4b0d1ba16eccdc9e79154f31549d437ad1be6e0b.zip
SONAR-9741 remove NodeHealth#date field
Diffstat (limited to 'server')
-rw-r--r--server/sonar-cluster/src/main/java/org/sonar/cluster/health/NodeHealth.java23
-rw-r--r--server/sonar-cluster/src/test/java/org/sonar/cluster/health/NodeDetailsTestSupport.java3
-rw-r--r--server/sonar-cluster/src/test/java/org/sonar/cluster/health/NodeHealthTest.java38
-rw-r--r--server/sonar-cluster/src/test/java/org/sonar/cluster/health/SharedHealthStateImplTest.java1
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/health/SearchNodeHealthProvider.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/health/NodeHealthProviderImpl.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/health/AppNodeClusterCheckTest.java1
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/health/ClusterHealthTest.java1
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/health/EsStatusClusterCheckTest.java1
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java1
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/health/SearchNodeClusterCheckTest.java1
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/platform/ws/HealthActionTest.java7
12 files changed, 7 insertions, 75 deletions
diff --git a/server/sonar-cluster/src/main/java/org/sonar/cluster/health/NodeHealth.java b/server/sonar-cluster/src/main/java/org/sonar/cluster/health/NodeHealth.java
index b85f1c221f5..5c835650791 100644
--- a/server/sonar-cluster/src/main/java/org/sonar/cluster/health/NodeHealth.java
+++ b/server/sonar-cluster/src/main/java/org/sonar/cluster/health/NodeHealth.java
@@ -38,7 +38,6 @@ public class NodeHealth implements Externalizable {
private Status status;
private Set<String> causes;
private NodeDetails details;
- private long date;
/**
* Required for Serialization
@@ -50,7 +49,6 @@ public class NodeHealth implements Externalizable {
this.status = builder.status;
this.causes = ImmutableSet.copyOf(builder.causes);
this.details = builder.details;
- this.date = builder.date;
}
public static Builder newNodeHealthBuilder() {
@@ -69,10 +67,6 @@ public class NodeHealth implements Externalizable {
return details;
}
- public long getDate() {
- return date;
- }
-
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeInt(status.ordinal());
@@ -81,7 +75,6 @@ public class NodeHealth implements Externalizable {
out.writeUTF(cause);
}
out.writeObject(details);
- out.writeLong(date);
}
@Override
@@ -98,7 +91,6 @@ public class NodeHealth implements Externalizable {
this.causes = ImmutableSet.of();
}
this.details = (NodeDetails) in.readObject();
- this.date = in.readLong();
}
@Override
@@ -110,15 +102,14 @@ public class NodeHealth implements Externalizable {
return false;
}
NodeHealth that = (NodeHealth) o;
- return date == that.date &&
- status == that.status &&
+ return status == that.status &&
causes.equals(that.causes) &&
details.equals(that.details);
}
@Override
public int hashCode() {
- return Objects.hash(status, causes, details, date);
+ return Objects.hash(status, causes, details);
}
@Override
@@ -127,19 +118,16 @@ public class NodeHealth implements Externalizable {
"status=" + status +
", causes=" + causes +
", details=" + details +
- ", date=" + date +
'}';
}
public static class Builder {
private static final String STATUS_CANT_BE_NULL = "status can't be null";
private static final String DETAILS_CANT_BE_NULL = "details can't be null";
- private static final String DATE_MUST_BE_MORE_THAN_0 = "date must be > 0";
private Status status;
private Set<String> causes = new HashSet<>(0);
private NodeDetails details;
- private long date;
private Builder() {
// use static factory method
@@ -169,16 +157,9 @@ public class NodeHealth implements Externalizable {
return this;
}
- public Builder setDate(long date) {
- checkArgument(date > 0, DATE_MUST_BE_MORE_THAN_0);
- this.date = date;
- return this;
- }
-
public NodeHealth build() {
requireNonNull(status, STATUS_CANT_BE_NULL);
requireNonNull(details, DETAILS_CANT_BE_NULL);
- checkArgument(date > 0, DATE_MUST_BE_MORE_THAN_0);
return new NodeHealth(this);
}
}
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 99b0011f6e9..7337f3ec0b3 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
@@ -55,8 +55,7 @@ public class NodeDetailsTestSupport {
NodeHealth.Builder randomBuilder(int minCauseCount) {
NodeHealth.Builder builder = newNodeHealthBuilder()
.setStatus(randomStatus())
- .setDetails(randomNodeDetails())
- .setDate(1 + random.nextInt(33));
+ .setDetails(randomNodeDetails());
IntStream.range(0, minCauseCount + random.nextInt(2)).mapToObj(i -> randomAlphanumeric(4)).forEach(builder::addCause);
return builder;
}
diff --git a/server/sonar-cluster/src/test/java/org/sonar/cluster/health/NodeHealthTest.java b/server/sonar-cluster/src/test/java/org/sonar/cluster/health/NodeHealthTest.java
index 0484fa6883d..a2a275460dc 100644
--- a/server/sonar-cluster/src/test/java/org/sonar/cluster/health/NodeHealthTest.java
+++ b/server/sonar-cluster/src/test/java/org/sonar/cluster/health/NodeHealthTest.java
@@ -59,14 +59,6 @@ public class NodeHealthTest {
}
@Test
- public void setDate_throws_IAR_if_arg_is_less_then_0() {
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("date must be > 0");
-
- builderUnderTest.setDate(-random.nextInt(22));
- }
-
- @Test
public void build_throws_NPE_if_status_is_null() {
expectedException.expect(NullPointerException.class);
expectedException.expectMessage("status can't be null");
@@ -85,18 +77,6 @@ public class NodeHealthTest {
}
@Test
- public void build_throws_IAE_if_date_is_less_than_1() {
- builderUnderTest
- .setStatus(randomStatus)
- .setDetails(testSupport.randomNodeDetails());
-
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("date must be > 0");
-
- builderUnderTest.build();
- }
-
- @Test
public void clearClauses_clears_clauses_of_builder() {
NodeHealth.Builder underTest = testSupport.randomBuilder();
NodeHealth original = underTest
@@ -107,7 +87,6 @@ public class NodeHealthTest {
NodeHealth second = underTest.build();
assertThat(second.getStatus()).isEqualTo(original.getStatus());
- assertThat(second.getDate()).isEqualTo(original.getDate());
assertThat(second.getDetails()).isEqualTo(original.getDetails());
assertThat(second.getCauses()).isEmpty();
}
@@ -120,12 +99,10 @@ public class NodeHealthTest {
NodeHealth.Status newRandomStatus = NodeHealth.Status.values()[random.nextInt(NodeHealth.Status.values().length)];
NodeDetails newNodeDetails = testSupport.randomNodeDetails();
- long newDate = 1 + random.nextInt(666);
builder
.clearCauses()
.setStatus(newRandomStatus)
- .setDetails(newNodeDetails)
- .setDate(newDate);
+ .setDetails(newNodeDetails);
String[] newCauses = IntStream.range(0, 1 + random.nextInt(2)).mapToObj(i -> randomAlphanumeric(4)).toArray(String[]::new);
Arrays.stream(newCauses).forEach(builder::addCause);
@@ -133,7 +110,6 @@ public class NodeHealthTest {
assertThat(second).isEqualTo(original);
assertThat(newNodeHealth.getStatus()).isEqualTo(newRandomStatus);
- assertThat(newNodeHealth.getDate()).isEqualTo(newDate);
assertThat(newNodeHealth.getDetails()).isEqualTo(newNodeDetails);
assertThat(newNodeHealth.getCauses()).containsOnly(newCauses);
}
@@ -176,8 +152,7 @@ public class NodeHealthTest {
public void class_is_serializable_without_causes() throws IOException, ClassNotFoundException {
NodeHealth.Builder builder = newNodeHealthBuilder()
.setStatus(randomStatus)
- .setDetails(testSupport.randomNodeDetails())
- .setDate(1 + random.nextInt(999));
+ .setDetails(testSupport.randomNodeDetails());
NodeHealth source = builder.build();
byte[] bytes = testSupport.serialize(source);
@@ -189,28 +164,24 @@ public class NodeHealthTest {
@Test
public void verify_toString() {
NodeDetails nodeDetails = testSupport.randomNodeDetails();
- int date = 1 + random.nextInt(999);
String cause = randomAlphanumeric(4);
NodeHealth.Builder builder = builderUnderTest
.setStatus(randomStatus)
.setDetails(nodeDetails)
- .setDate(date)
.addCause(cause);
NodeHealth underTest = builder.build();
assertThat(underTest.toString())
- .isEqualTo("NodeHealth{status=" + randomStatus + ", causes=[" + cause + "], details=" + nodeDetails + ", date=" + date + "}");
+ .isEqualTo("NodeHealth{status=" + randomStatus + ", causes=[" + cause + "], details=" + nodeDetails + "}");
}
@Test
public void verify_getters() {
NodeDetails nodeDetails = testSupport.randomNodeDetails();
- int date = 1 + random.nextInt(999);
NodeHealth.Builder builder = builderUnderTest
.setStatus(randomStatus)
- .setDetails(nodeDetails)
- .setDate(date);
+ .setDetails(nodeDetails);
String[] causes = IntStream.range(0, random.nextInt(10)).mapToObj(i -> randomAlphanumeric(4)).toArray(String[]::new);
Arrays.stream(causes).forEach(builder::addCause);
@@ -218,7 +189,6 @@ public class NodeHealthTest {
assertThat(underTest.getStatus()).isEqualTo(randomStatus);
assertThat(underTest.getDetails()).isEqualTo(nodeDetails);
- assertThat(underTest.getDate()).isEqualTo(date);
assertThat(underTest.getCauses()).containsOnly(causes);
}
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 4dcbebe9974..5b74e5579dc 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
@@ -165,7 +165,6 @@ public class SharedHealthStateImplTest {
.setPort(1 + random.nextInt(666))
.setStarted(1 + random.nextInt(852))
.build())
- .setDate(1 + random.nextInt(999))
.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 d1e184ad436..93657803762 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
@@ -33,12 +33,10 @@ import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_NAME;
import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_PORT;
public class SearchNodeHealthProvider implements NodeHealthProvider {
- private final System2 system2;
private final ClusterAppState clusterAppState;
private final NodeDetails nodeDetails;
public SearchNodeHealthProvider(Props props, System2 system2, ClusterAppState clusterAppState, NetworkUtils networkUtils) {
- this.system2 = system2;
this.clusterAppState = clusterAppState;
this.nodeDetails = NodeDetails.newNodeDetailsBuilder()
.setType(NodeDetails.Type.SEARCH)
@@ -68,7 +66,6 @@ public class SearchNodeHealthProvider implements NodeHealthProvider {
}
return builder
.setDetails(nodeDetails)
- .setDate(system2.now())
.build();
}
}
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 0c3b263c752..1829c36421c 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
@@ -19,7 +19,6 @@
*/
package org.sonar.server.health;
-import java.util.Date;
import java.util.function.Supplier;
import org.sonar.NetworkUtils;
import org.sonar.api.config.Configuration;
@@ -81,7 +80,6 @@ public class NodeHealthProviderImpl implements NodeHealthProvider {
nodeHealth.getCauses().forEach(this.nodeHealthBuilder::addCause);
return this.nodeHealthBuilder
- .setDate(new Date().getTime())
.setDetails(nodeDetails)
.build();
}
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 a138a705c50..f10c1e5ff52 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
@@ -279,7 +279,6 @@ public class AppNodeClusterCheckTest {
.setPort(1 + random.nextInt(88))
.setStarted(1 + random.nextInt(54))
.build())
- .setDate(1 + random.nextInt(2323))
.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 47d215e6ee2..8d60966d08f 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
@@ -110,7 +110,6 @@ public class ClusterHealthTest {
private Set<NodeHealth> randomNodeHealths() {
return IntStream.range(0, random.nextInt(4)).mapToObj(i -> NodeHealth.newNodeHealthBuilder()
.setStatus(NodeHealth.Status.values()[random.nextInt(NodeHealth.Status.values().length)])
- .setDate(1 + random.nextInt(951))
.setDetails(
NodeDetails.newNodeDetailsBuilder()
.setType(random.nextBoolean() ? NodeDetails.Type.SEARCH : NodeDetails.Type.APPLICATION)
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 e91143f5016..11a02c20ea1 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
@@ -52,7 +52,6 @@ public class EsStatusClusterCheckTest {
.setPort(1 + random.nextInt(96))
.setStarted(1 + random.nextInt(966))
.build())
- .setDate(1 + random.nextInt(23))
.build())
.collect(Collectors.toSet());
Health health = underTest.check(nodeHealths);
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 2fa4d352cfa..3c4a89aa433 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
@@ -244,7 +244,6 @@ public class HealthCheckerImplTest {
private NodeHealth randomNodeHealth() {
return newNodeHealthBuilder()
.setStatus(NodeHealth.Status.values()[random.nextInt(NodeHealth.Status.values().length)])
- .setDate(1 + random.nextInt(222))
.setDetails(newNodeDetailsBuilder()
.setType(random.nextBoolean() ? NodeDetails.Type.APPLICATION : NodeDetails.Type.SEARCH)
.setName(randomAlphanumeric(10))
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 67eadaf503a..59135f2bfab 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
@@ -515,7 +515,6 @@ public class SearchNodeClusterCheckTest {
.setPort(1 + random.nextInt(88))
.setStarted(1 + random.nextInt(54))
.build())
- .setDate(1 + random.nextInt(2323))
.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 e98f5433520..ab70215d87b 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
@@ -98,7 +98,6 @@ public class HealthActionTest {
.setPort(999)
.setStarted(time)
.build())
- .setDate(1 + random.nextInt(888))
.build(),
newNodeHealthBuilder()
.setStatus(NodeHealth.Status.YELLOW)
@@ -111,7 +110,6 @@ public class HealthActionTest {
.setPort(999)
.setStarted(time)
.build())
- .setDate(1 + random.nextInt(888))
.build(),
newNodeHealthBuilder()
.setStatus(NodeHealth.Status.GREEN)
@@ -123,7 +121,6 @@ public class HealthActionTest {
.setPort(999)
.setStarted(time)
.build())
- .setDate(1 + random.nextInt(888))
.build(),
newNodeHealthBuilder()
.setStatus(NodeHealth.Status.GREEN)
@@ -135,7 +132,6 @@ public class HealthActionTest {
.setPort(999)
.setStarted(time)
.build())
- .setDate(1 + random.nextInt(888))
.build(),
newNodeHealthBuilder()
.setStatus(NodeHealth.Status.GREEN)
@@ -147,7 +143,6 @@ public class HealthActionTest {
.setPort(999)
.setStarted(time)
.build())
- .setDate(1 + random.nextInt(888))
.build())));
TestResponse response = underTest.newRequest().execute();
@@ -255,7 +250,6 @@ public class HealthActionTest {
.setPort(1 + random.nextInt(3))
.setStarted(1 + random.nextInt(23))
.build())
- .setDate(1 + random.nextInt(343))
.build();
}
@@ -271,7 +265,6 @@ public class HealthActionTest {
.setPort(port)
.setStarted(started)
.build())
- .setDate(1 + random.nextInt(23))
.build();
}