Skip to content

Commit

Permalink
[BugFix] Fix partition live number not update
Browse files Browse the repository at this point in the history
Signed-off-by: wyb <[email protected]>
  • Loading branch information
wyb committed Aug 6, 2024
1 parent 692b5e0 commit 803d85d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -435,20 +435,16 @@ public TableProperty buildReplicationNum() {
}

public TableProperty buildPartitionTTL() {
if (partitionTTLNumber != INVALID) {
return this;
if (properties.containsKey(PropertyAnalyzer.PROPERTIES_PARTITION_TTL_NUMBER)) {
partitionTTLNumber = Integer.parseInt(properties.get(PropertyAnalyzer.PROPERTIES_PARTITION_TTL_NUMBER));
}
partitionTTLNumber = Integer.parseInt(properties.getOrDefault(PropertyAnalyzer.PROPERTIES_PARTITION_TTL_NUMBER,
String.valueOf(INVALID)));
return this;
}

public TableProperty buildPartitionLiveNumber() {
if (partitionTTLNumber != INVALID) {
return this;
if (properties.containsKey(PropertyAnalyzer.PROPERTIES_PARTITION_LIVE_NUMBER)) {
partitionTTLNumber = Integer.parseInt(properties.get(PropertyAnalyzer.PROPERTIES_PARTITION_LIVE_NUMBER));
}
partitionTTLNumber = Integer.parseInt(properties.getOrDefault(PropertyAnalyzer.PROPERTIES_PARTITION_LIVE_NUMBER,
String.valueOf(INVALID)));
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,15 @@ public void testPartitionTTLNumberSerialization() throws IOException {

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

// 3. Update again
properties.put(PropertyAnalyzer.PROPERTIES_PARTITION_LIVE_NUMBER, "3");
newTableProperty.modifyTableProperties(properties);
newTableProperty.buildPartitionLiveNumber();
newTableProperty.buildPartitionTTL();
Assert.assertEquals(3, newTableProperty.getPartitionTTLNumber());
}
}

0 comments on commit 803d85d

Please sign in to comment.