This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 5d56fe6d32 [fix](meta)(recover) fix recover info persist bug (#13948)
5d56fe6d32 is described below
commit 5d56fe6d32e48eff2d0de295d017b0f882fb0413
Author: Mingyu Chen <[email protected]>
AuthorDate: Fri Nov 4 07:40:21 2022 +0800
[fix](meta)(recover) fix recover info persist bug (#13948)
introduced from #13830
---
.../java/org/apache/doris/persist/RecoverInfo.java | 10 ++----
...opInfoTest.java => DropAndRecoverInfoTest.java} | 36 ++++++++++++++++++++--
2 files changed, 36 insertions(+), 10 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/persist/RecoverInfo.java
b/fe/fe-core/src/main/java/org/apache/doris/persist/RecoverInfo.java
index 9c4302a14d..7809b05d0e 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/persist/RecoverInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/persist/RecoverInfo.java
@@ -43,7 +43,7 @@ public class RecoverInfo implements Writable {
@SerializedName(value = "newPartitionName")
private String newPartitionName;
- public RecoverInfo() {
+ private RecoverInfo() {
// for persist
}
@@ -83,13 +83,7 @@ public class RecoverInfo implements Writable {
@Override
public void write(DataOutput out) throws IOException {
- out.writeLong(dbId);
- out.writeLong(tableId);
- out.writeLong(partitionId);
-
- Text.writeString(out, newDbName);
- Text.writeString(out, newTableName);
- Text.writeString(out, newPartitionName);
+ Text.writeString(out, GsonUtils.GSON.toJson(this));
}
public static RecoverInfo read(DataInput in) throws IOException {
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/persist/DropInfoTest.java
b/fe/fe-core/src/test/java/org/apache/doris/persist/DropAndRecoverInfoTest.java
similarity index 67%
rename from fe/fe-core/src/test/java/org/apache/doris/persist/DropInfoTest.java
rename to
fe/fe-core/src/test/java/org/apache/doris/persist/DropAndRecoverInfoTest.java
index ffbdcb362d..039488fe13 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/persist/DropInfoTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/persist/DropAndRecoverInfoTest.java
@@ -29,9 +29,9 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
-public class DropInfoTest {
+public class DropAndRecoverInfoTest {
@Test
- public void testSerialization() throws Exception {
+ public void testDropInfoSerialization() throws Exception {
MetaContext metaContext = new MetaContext();
metaContext.setMetaVersion(FeMetaVersion.VERSION_CURRENT);
metaContext.setThreadLocalInfo();
@@ -74,4 +74,36 @@ public class DropInfoTest {
dis.close();
file.delete();
}
+
+ @Test
+ public void testRecoveryInfoSerialization() throws Exception {
+ MetaContext metaContext = new MetaContext();
+ metaContext.setMetaVersion(FeMetaVersion.VERSION_CURRENT);
+ metaContext.setThreadLocalInfo();
+
+ // 1. Write objects to file
+ File file = new File("./recoverInfo");
+ file.createNewFile();
+ DataOutputStream dos = new DataOutputStream(new
FileOutputStream(file));
+
+ RecoverInfo info1 = new RecoverInfo(1, 2, 3, "a", "b", "c");
+ info1.write(dos);
+ dos.flush();
+ dos.close();
+
+ // 2. Read objects from file
+ DataInputStream dis = new DataInputStream(new FileInputStream(file));
+ RecoverInfo rInfo1 = RecoverInfo.read(dis);
+
+ Assert.assertEquals(1, rInfo1.getDbId());
+ Assert.assertEquals(2, rInfo1.getTableId());
+ Assert.assertEquals(3, rInfo1.getPartitionId());
+ Assert.assertEquals("a", rInfo1.getNewDbName());
+ Assert.assertEquals("b", rInfo1.getNewTableName());
+ Assert.assertEquals("c", rInfo1.getNewPartitionName());
+
+ // 3. delete files
+ dis.close();
+ file.delete();
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]