Skip to content

Commit

Permalink
[BugFix] Fix partition live number not working (backport #49213) (#49241
Browse files Browse the repository at this point in the history
)

Co-authored-by: wyb <[email protected]>
  • Loading branch information
mergify[bot] and wyb committed Aug 8, 2024
1 parent b9b8d58 commit bc25ed1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,9 @@ public TableProperty buildReplicationNum() {
}

public TableProperty buildPartitionTTL() {
if (partitionTTLNumber != INVALID) {
return this;
}
partitionTTLNumber = Integer.parseInt(properties.getOrDefault(PropertyAnalyzer.PROPERTIES_PARTITION_TTL_NUMBER,
String.valueOf(INVALID)));
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public void testNormal() throws IOException {
in.close();
}


@Test
public void testBuildDataCachePartitionDuration() throws IOException {
// 1. Write objects to file
Expand All @@ -97,4 +96,27 @@ public void testBuildDataCachePartitionDuration() throws IOException {
in.close();
}

@Test
public void testPartitionTTLNumberSerialization() throws IOException {
// 1. Write objects to file
File file = new File(fileName);
file.createNewFile();
DataOutputStream out = new DataOutputStream(new FileOutputStream(file));

HashMap<String, String> properties = new HashMap<>();
properties.put(PropertyAnalyzer.PROPERTIES_PARTITION_LIVE_NUMBER, "2");
TableProperty tableProperty = new TableProperty(properties);
tableProperty.buildPartitionLiveNumber();
tableProperty.buildPartitionTTL();
Assert.assertEquals(2, tableProperty.getPartitionTTLNumber());
tableProperty.write(out);
out.flush();
out.close();

// 2. Read objects from file
DataInputStream in = new DataInputStream(new FileInputStream(file));
TableProperty readTableProperty = TableProperty.read(in);
Assert.assertEquals(2, readTableProperty.getPartitionTTLNumber());
in.close();
}
}

0 comments on commit bc25ed1

Please sign in to comment.