This is an automated email from the ASF dual-hosted git repository.

jinrongtong pushed a commit to branch dledger-controller-snapshot
in repository https://gitbox.apache.org/repos/asf/rocketmq.git


The following commit(s) were added to refs/heads/dledger-controller-snapshot by 
this push:
     new dabdfc177 [ISSUE #5585] Add snapshotable metadata manager interface 
(#5598)
dabdfc177 is described below

commit dabdfc17790b86b6a05f8a80f78ab922ccd47843
Author: hzh0425 <[email protected]>
AuthorDate: Sat Nov 26 21:52:55 2022 +0800

    [ISSUE #5585] Add snapshotable metadata manager interface (#5598)
    
    * add SnapshotAbleMetadataManager interface
    
    * Add apache header
---
 .../impl/manager/MetadataManagerType.java          | 46 ++++++++++++++++++++++
 .../impl/manager/SnapshotAbleMetadataManager.java  | 46 ++++++++++++++++++++++
 2 files changed, 92 insertions(+)

diff --git 
a/controller/src/main/java/org/apache/rocketmq/controller/impl/manager/MetadataManagerType.java
 
b/controller/src/main/java/org/apache/rocketmq/controller/impl/manager/MetadataManagerType.java
new file mode 100644
index 000000000..8f4f8446c
--- /dev/null
+++ 
b/controller/src/main/java/org/apache/rocketmq/controller/impl/manager/MetadataManagerType.java
@@ -0,0 +1,46 @@
+/*
+ * 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.rocketmq.controller.impl.manager;
+
+public enum MetadataManagerType {
+
+    REPLICAS_INFO_MANAGER("ReplicasInfoManager", (short) 1);
+
+    private final String name;
+    private final short id;
+
+    MetadataManagerType(String name, short id) {
+        this.name = name;
+        this.id = id;
+    }
+
+    public static MetadataManagerType from(short id) {
+        switch (id) {
+            case 1:
+                return REPLICAS_INFO_MANAGER;
+        }
+        return null;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public short getId() {
+        return id;
+    }
+}
diff --git 
a/controller/src/main/java/org/apache/rocketmq/controller/impl/manager/SnapshotAbleMetadataManager.java
 
b/controller/src/main/java/org/apache/rocketmq/controller/impl/manager/SnapshotAbleMetadataManager.java
new file mode 100644
index 000000000..b3e763985
--- /dev/null
+++ 
b/controller/src/main/java/org/apache/rocketmq/controller/impl/manager/SnapshotAbleMetadataManager.java
@@ -0,0 +1,46 @@
+/*
+ * 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.rocketmq.controller.impl.manager;
+
+/**
+ * The interface of MetadataManager. Subclasses can support snapshot metadata.
+ */
+public interface SnapshotAbleMetadataManager {
+
+    /**
+     * Encode the metadata contained in this MetadataManager.
+     * @return encoded metadata
+     */
+    byte[] encodeMetadata();
+
+
+    /**
+     *
+     * According to the param data, load metadata into the MetadataManager.
+     * @param data encoded metadata
+     * @return true if load metadata success.
+     */
+    boolean loadMetadata(byte[] data);
+
+
+    /**
+     * Get the type of this MetadataManager.
+     * @return MetadataManagerType
+     */
+    MetadataManagerType getMetadataManagerType();
+
+}

Reply via email to