This is an automated email from the ASF dual-hosted git repository.
ycai pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra-sidecar.git
The following commit(s) were added to refs/heads/trunk by this push:
new 92efda39 CASSSIDECAR-184: Rename field in ListCdcSegmentsResponse
(#170)
92efda39 is described below
commit 92efda39990f2f9426405d8702c31f7c3e1760f5
Author: Yifan Cai <[email protected]>
AuthorDate: Mon Jan 6 11:33:24 2025 -0800
CASSSIDECAR-184: Rename field in ListCdcSegmentsResponse (#170)
Patch by Yifan Cai; Reviewed by Francisco Guerrero for CASSSIDECAR-184
---
CHANGES.txt | 1 +
.../common/response/ListCdcSegmentsResponse.java | 16 ++++++++--------
.../common/response/ListCdcSegmentsResponseTest.java | 19 +++++++++++++++----
.../ClusterLeaseClaimTaskIntegrationTest.java | 2 ++
.../sidecar/routes/cdc/ListCdcDirHandlerTest.java | 6 +++---
5 files changed, 29 insertions(+), 15 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index ffbd3cc6..0e71aa10 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,5 +1,6 @@
1.0.0
-----
+ * Rename field in ListCdcSegmentsResponse (CASSSIDECAR-184)
* Ensure memory consistency from PeriodicTask executions and expose richer
ScheduleDecision (CASSSIDECAR-181)
* Refactor access to delegate methods to simplify (CASSSIDECAR-182)
* Renaming InstancesConfig to InstancesMetadata (CASSSIDECAR-175)
diff --git
a/client-common/src/main/java/org/apache/cassandra/sidecar/common/response/ListCdcSegmentsResponse.java
b/client-common/src/main/java/org/apache/cassandra/sidecar/common/response/ListCdcSegmentsResponse.java
index 27d66f8b..6fe812cb 100644
---
a/client-common/src/main/java/org/apache/cassandra/sidecar/common/response/ListCdcSegmentsResponse.java
+++
b/client-common/src/main/java/org/apache/cassandra/sidecar/common/response/ListCdcSegmentsResponse.java
@@ -37,16 +37,16 @@ public class ListCdcSegmentsResponse
{
private final String host;
private final int port;
- private final List<CdcSegmentInfo> segmentInfos;
+ private final List<CdcSegmentInfo> segmentsInfo;
@JsonCreator
public ListCdcSegmentsResponse(@JsonProperty("host") String host,
@JsonProperty("port") int port,
- @JsonProperty("segmentInfos")
List<CdcSegmentInfo> segmentsInfo)
+ @JsonProperty("segmentsInfo")
List<CdcSegmentInfo> segmentsInfo)
{
this.host = host;
this.port = port;
- this.segmentInfos = Collections.unmodifiableList(segmentsInfo);
+ this.segmentsInfo = segmentsInfo == null ? Collections.emptyList() :
Collections.unmodifiableList(segmentsInfo);
}
@JsonProperty("host")
@@ -61,10 +61,10 @@ public class ListCdcSegmentsResponse
return port;
}
- @JsonProperty("segmentInfos")
- public List<CdcSegmentInfo> segmentInfos()
+ @JsonProperty("segmentsInfo")
+ public List<CdcSegmentInfo> segmentsInfo()
{
- return segmentInfos;
+ return segmentsInfo;
}
@Override
@@ -79,12 +79,12 @@ public class ListCdcSegmentsResponse
return false;
}
ListCdcSegmentsResponse that = (ListCdcSegmentsResponse) o;
- return port == that.port && Objects.equals(host, that.host) &&
Objects.equals(segmentInfos, that.segmentInfos);
+ return port == that.port && Objects.equals(host, that.host) &&
Objects.equals(segmentsInfo, that.segmentsInfo);
}
@Override
public int hashCode()
{
- return Objects.hash(host, port, segmentInfos);
+ return Objects.hash(host, port, segmentsInfo);
}
}
diff --git
a/client-common/src/test/java/org/apache/cassandra/sidecar/common/response/ListCdcSegmentsResponseTest.java
b/client-common/src/test/java/org/apache/cassandra/sidecar/common/response/ListCdcSegmentsResponseTest.java
index d057c55d..6471f616 100644
---
a/client-common/src/test/java/org/apache/cassandra/sidecar/common/response/ListCdcSegmentsResponseTest.java
+++
b/client-common/src/test/java/org/apache/cassandra/sidecar/common/response/ListCdcSegmentsResponseTest.java
@@ -43,14 +43,25 @@ class ListCdcSegmentsResponseTest
String json = mapper.writeValueAsString(response);
assertThat(json).isEqualTo("{\"host\":\"localhost\"," +
"\"port\":9043," +
- "\"segmentInfos\":[" +
+ "\"segmentsInfo\":[" +
"{\"name\":\"commit-log1\",\"size\":100,\"idx\":100,\"completed\":true,\"lastModifiedTimestamp\":1732148713725},"
+
"{\"name\":\"commit-log2\",\"size\":100,\"idx\":10,\"completed\":false,\"lastModifiedTimestamp\":1732148713725}]}");
ListCdcSegmentsResponse deserialized = mapper.readValue(json,
ListCdcSegmentsResponse.class);
assertThat(deserialized.host()).isEqualTo("localhost");
assertThat(deserialized.port()).isEqualTo(9043);
- assertThat(deserialized.segmentInfos()).hasSize(2);
-
assertThat(deserialized.segmentInfos().get(0).name).isEqualTo("commit-log1");
-
assertThat(deserialized.segmentInfos().get(1).name).isEqualTo("commit-log2");
+ assertThat(deserialized.segmentsInfo()).hasSize(2);
+
assertThat(deserialized.segmentsInfo().get(0).name).isEqualTo("commit-log1");
+
assertThat(deserialized.segmentsInfo().get(1).name).isEqualTo("commit-log2");
+ }
+
+ @Test
+ void testHandleNoSegmentsInfoInDeserialization() throws Exception
+ {
+ String json = "{\"host\":\"localhost\",\"port\":9043}";
+ ObjectMapper mapper = new ObjectMapper();
+ ListCdcSegmentsResponse deserialized = mapper.readValue(json,
ListCdcSegmentsResponse.class);
+ assertThat(deserialized.host()).isEqualTo("localhost");
+ assertThat(deserialized.port()).isEqualTo(9043);
+ assertThat(deserialized.segmentsInfo()).isEmpty();
}
}
diff --git
a/server/src/test/integration/org/apache/cassandra/sidecar/coordination/ClusterLeaseClaimTaskIntegrationTest.java
b/server/src/test/integration/org/apache/cassandra/sidecar/coordination/ClusterLeaseClaimTaskIntegrationTest.java
index 900d5b24..7b7ad471 100644
---
a/server/src/test/integration/org/apache/cassandra/sidecar/coordination/ClusterLeaseClaimTaskIntegrationTest.java
+++
b/server/src/test/integration/org/apache/cassandra/sidecar/coordination/ClusterLeaseClaimTaskIntegrationTest.java
@@ -34,6 +34,7 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.StreamSupport;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.slf4j.Logger;
@@ -84,6 +85,7 @@ import static org.mockito.Mockito.when;
/**
* Integration tests for the {@link ClusterLeaseClaimTask}
*/
+@Tag("heavy")
class ClusterLeaseClaimTaskIntegrationTest
{
private static final Logger LOGGER =
LoggerFactory.getLogger(ClusterLeaseClaimTaskIntegrationTest.class);
diff --git
a/server/src/test/java/org/apache/cassandra/sidecar/routes/cdc/ListCdcDirHandlerTest.java
b/server/src/test/java/org/apache/cassandra/sidecar/routes/cdc/ListCdcDirHandlerTest.java
index ac206275..d137e294 100644
---
a/server/src/test/java/org/apache/cassandra/sidecar/routes/cdc/ListCdcDirHandlerTest.java
+++
b/server/src/test/java/org/apache/cassandra/sidecar/routes/cdc/ListCdcDirHandlerTest.java
@@ -93,8 +93,8 @@ class ListCdcDirHandlerTest
.send(context.succeeding(resp -> {
context.verify(() -> {
ListCdcSegmentsResponse listCDCSegmentsResponse =
resp.bodyAsJson(ListCdcSegmentsResponse.class);
-
assertThat(listCDCSegmentsResponse.segmentInfos().size()).isEqualTo(2);
- for (CdcSegmentInfo segmentInfo :
listCDCSegmentsResponse.segmentInfos())
+
assertThat(listCDCSegmentsResponse.segmentsInfo().size()).isEqualTo(2);
+ for (CdcSegmentInfo segmentInfo :
listCDCSegmentsResponse.segmentsInfo())
{
if (segmentInfo.name.equals("CommitLog-1-1.log"))
{
@@ -120,7 +120,7 @@ class ListCdcDirHandlerTest
.send(context.succeeding(resp -> {
context.verify(() -> {
ListCdcSegmentsResponse listCDCSegmentsResponse =
resp.bodyAsJson(ListCdcSegmentsResponse.class);
- for (CdcSegmentInfo segmentInfo :
listCDCSegmentsResponse.segmentInfos())
+ for (CdcSegmentInfo segmentInfo :
listCDCSegmentsResponse.segmentsInfo())
{
assertThat(segmentInfo.name).isNotEqualTo("CommitLog-1-3.log");
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]