frankgh commented on code in PR #66:
URL: https://github.com/apache/cassandra-sidecar/pull/66#discussion_r1302012779


##########
common/src/main/java/org/apache/cassandra/sidecar/common/data/HealthResponse.java:
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.sidecar.common.data;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.cassandra.sidecar.client.request.CassandraHealthRequest;
+import org.apache.cassandra.sidecar.client.request.SidecarHealthRequest;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Objects;
+
+/**
+ * A class representing a response for a health request
+ * (either {@link SidecarHealthRequest} or {@link CassandraHealthRequest})
+ */
+public class HealthResponse
+{
+    @NotNull
+    private final String status;
+
+    /**
+     * Constructs a {@link HealthResponse} object with the given {@code status}
+     *
+     * @param status the status
+     */
+    public HealthResponse(@NotNull @JsonProperty("status") String status)
+    {
+        this.status = Objects.requireNonNull(status, "status must not be 
null").toUpperCase();
+    }
+
+    /**
+     * @return the status
+     */
+    @JsonProperty("status")
+    public String status()
+    {
+        return status;
+    }
+
+    /**
+     * @return whether the status is OK
+     */
+    @JsonIgnore
+    public boolean isOk()
+    {
+        return status.equals("OK");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public int hashCode() {

Review Comment:
   formatting?



##########
common/src/main/java/org/apache/cassandra/sidecar/common/data/HealthResponse.java:
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.sidecar.common.data;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.cassandra.sidecar.client.request.CassandraHealthRequest;
+import org.apache.cassandra.sidecar.client.request.SidecarHealthRequest;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Objects;
+
+/**
+ * A class representing a response for a health request
+ * (either {@link SidecarHealthRequest} or {@link CassandraHealthRequest})
+ */
+public class HealthResponse
+{
+    @NotNull
+    private final String status;
+
+    /**
+     * Constructs a {@link HealthResponse} object with the given {@code status}
+     *
+     * @param status the status
+     */
+    public HealthResponse(@NotNull @JsonProperty("status") String status)
+    {
+        this.status = Objects.requireNonNull(status, "status must not be 
null").toUpperCase();
+    }
+
+    /**
+     * @return the status
+     */
+    @JsonProperty("status")
+    public String status()
+    {
+        return status;
+    }
+
+    /**
+     * @return whether the status is OK
+     */
+    @JsonIgnore
+    public boolean isOk()
+    {
+        return status.equals("OK");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public int hashCode() {
+        return status.hashCode();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean equals(Object other) {

Review Comment:
   formatting is off here, can we move this bracket to the next line?



##########
client/src/main/java/org/apache/cassandra/sidecar/client/SidecarClient.java:
##########
@@ -68,6 +69,26 @@ public SidecarClient(SidecarInstancesProvider 
instancesProvider,
         executor = requestExecutor;
     }
 
+    /**
+     * Executes the Sidecar health request using the default retry policy and 
configured selection policy
+     *
+     * @return a completable future of the Sidecar health response
+     */
+    public CompletableFuture<HealthResponse> sidecarHealth()
+    {
+        return 
executor.executeRequestAsync(requestBuilder().sidecarHealthRequest().build());
+    }
+
+    /**
+     * Executes the Cassandra health request using the default retry policy 
and configured selection policy
+     *
+     * @return a completable future of the Cassandra health response
+     */
+    public CompletableFuture<HealthResponse> cassandraHealth()
+    {
+        return 
executor.executeRequestAsync(requestBuilder().cassandraHealthRequest().build());

Review Comment:
   same comment as above



##########
client/src/main/java/org/apache/cassandra/sidecar/client/SidecarClient.java:
##########
@@ -68,6 +69,26 @@ public SidecarClient(SidecarInstancesProvider 
instancesProvider,
         executor = requestExecutor;
     }
 
+    /**
+     * Executes the Sidecar health request using the default retry policy and 
configured selection policy
+     *
+     * @return a completable future of the Sidecar health response
+     */
+    public CompletableFuture<HealthResponse> sidecarHealth()
+    {
+        return 
executor.executeRequestAsync(requestBuilder().sidecarHealthRequest().build());

Review Comment:
   I think for these calls we need a custom retry policy. We probably want to 
limit the number or retries, I think we also need to support sidecar health 
checks on a specific instance, and a list of instances



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to