-
Notifications
You must be signed in to change notification settings - Fork 0
<refactor>[zstack]: Refactor extension points #3257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 5.5.6
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,18 @@ | |
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * 内存快照资源配置归档扩展点 | ||
| * | ||
| * <p>触发时机:创建内存快照时,归档与 VM 相关的资源配置</p> | ||
| * <p>调用位置:MemorySnapshotManager.archiveResourceConfig()</p> | ||
| * | ||
| * <h3>使用场景:</h3> | ||
| * <p>当 VM 执行内存快照时,各模块通过此扩展点提供需要归档的资源配置, | ||
| * 以便恢复快照时可以同时恢复相关配置状态。</p> | ||
| * | ||
| * @since 5.0.0 | ||
| */ | ||
|
Comment on lines
+5
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Javadoc 应使用英文编写 根据编码规范,代码中不应包含中文,包括注释和错误消息都应当使用正确的、无拼写错误的英文来编写。请将此 Javadoc 翻译为英文。 建议的英文 Javadoc-/**
- * 内存快照资源配置归档扩展点
- *
- * <p>触发时机:创建内存快照时,归档与 VM 相关的资源配置</p>
- * <p>调用位置:MemorySnapshotManager.archiveResourceConfig()</p>
- *
- * <h3>使用场景:</h3>
- * <p>当 VM 执行内存快照时,各模块通过此扩展点提供需要归档的资源配置,
- * 以便恢复快照时可以同时恢复相关配置状态。</p>
- *
- * `@since` 5.0.0
- */
+/**
+ * Extension point for archiving resource configurations during memory snapshot creation.
+ *
+ * <p>Trigger: When creating a memory snapshot, archive VM-related resource configurations.</p>
+ * <p>Call site: MemorySnapshotManager.archiveResourceConfig()</p>
+ *
+ * <h3>Usage:</h3>
+ * <p>When a VM performs a memory snapshot, modules provide resource configurations
+ * to be archived via this extension point, allowing related configuration states
+ * to be restored when the snapshot is recovered.</p>
+ *
+ * `@since` 5.0.0
+ */根据编码规范:代码里不应当有中文,包括报错、注释等都应当使用正确的、无拼写错误的英文来写。 🤖 Prompt for AI Agents |
||
| public interface ResourceConfigMemorySnapshotExtensionPoint { | ||
| List<ArchiveResourceConfigBundle.ResourceConfigBundle> getNeedToArchiveResourceConfig(String resourceUuid); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,10 @@ | ||
| package org.zstack.header.vm; | ||
|
|
||
| /** | ||
| * @deprecated This interface has no implementations and should be removed. | ||
| * Use {@link org.zstack.header.vm.extensions.VmInstanceAttachL3NetworkExtensionPoint} instead. | ||
| */ | ||
| @Deprecated | ||
| public interface VmInstanceAttachNicExtensionPoint { | ||
| void afterAttachNicToVm(VmNicInventory nic); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,9 @@ | ||
| package org.zstack.header.vm; | ||
|
|
||
| /** | ||
| * Created by Qi Le on 2019-08-21 | ||
| * @deprecated Use {@link org.zstack.header.vm.extensions.VmDbDeleteContext} with a single-phase extension point instead. | ||
| */ | ||
| @Deprecated | ||
|
Comment on lines
3
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 弃用引用不完整:与 同样引用了上下文类 🤖 Prompt for AI Agents |
||
| public interface VmJustAfterDeleteFromDbExtensionPoint { | ||
| void vmJustAfterDeleteFromDbExtensionPoint(VmInstanceInventory inv, String accountUuid); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,9 @@ | ||
| package org.zstack.header.vm; | ||
|
|
||
| /** | ||
| * Created by xing5 on 2017/6/26. | ||
| * @deprecated Use {@link org.zstack.header.vm.extensions.VmDbDeleteContext} with a single-phase extension point instead. | ||
| */ | ||
| @Deprecated | ||
|
Comment on lines
3
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Search for VmDbDeleteContext and related extension point interfaces
echo "=== Searching for VmDbDeleteContext ==="
fd -e java . | xargs rg -l "VmDbDeleteContext" | head -20
echo -e "\n=== Searching for VmDbDelete*ExtensionPoint interfaces ==="
fd -e java . | xargs rg "interface.*VmDbDelete.*ExtensionPoint" -A 2
echo -e "\n=== Checking VmJustBeforeDeleteFromDbExtensionPoint ==="
fd -e java . -name "*VmJustBeforeDeleteFromDb*" -exec cat {} \;
echo -e "\n=== Comparing with similar deprecation patterns ==="
fd -e java . | xargs rg "@Deprecated" -B 2 | grep -A 2 "VmDeleteExtensionPoint\|VmDbDelete" | head -30Repository: MatheMatrix/zstack Length of output: 1558 🏁 Script executed: #!/bin/bash
# Get the full content of VmJustBeforeDeleteFromDbExtensionPoint
echo "=== Full content of VmJustBeforeDeleteFromDbExtensionPoint ==="
cat header/src/main/java/org/zstack/header/vm/VmJustBeforeDeleteFromDbExtensionPoint.java
echo -e "\n=== Full content of VmDbDeleteContext ==="
cat header/src/main/java/org/zstack/header/vm/extensions/VmDbDeleteContext.java
echo -e "\n=== Check for all extension points related to VmDelete ==="
fd -e java . | xargs rg "interface.*ExtensionPoint" | grep -i "vmdelete\|vmdestroy\|vm.*delete" | head -20
echo -e "\n=== Check VmJustAfterDeleteFromDbExtensionPoint ==="
cat header/src/main/java/org/zstack/header/vm/VmJustAfterDeleteFromDbExtensionPoint.javaRepository: MatheMatrix/zstack Length of output: 2425 🏁 Script executed: #!/bin/bash
# Check VmDestroyExtensionPoint to see what it looks like
echo "=== Full content of VmDestroyExtensionPoint ==="
cat header/src/main/java/org/zstack/header/vm/extensions/VmDestroyExtensionPoint.java
echo -e "\n=== Search for VmDbDeleteExtensionPoint ==="
fd -e java . | xargs rg "VmDbDeleteExtensionPoint" 2>/dev/null || echo "Not found"
echo -e "\n=== Search for extension points that use VmDbDeleteContext ==="
fd -e java . | xargs rg "VmDbDeleteContext" -A 5 -B 5Repository: MatheMatrix/zstack Length of output: 4431 🏁 Script executed: #!/bin/bash
# Search for where VmJustBeforeDeleteFromDbExtensionPoint is actually used/implemented
echo "=== Usages of VmJustBeforeDeleteFromDbExtensionPoint ==="
fd -e java . | xargs rg "VmJustBeforeDeleteFromDbExtensionPoint" | grep -v "\.java:-"
echo -e "\n=== Look for recent VM delete/destroy extension point implementations ==="
fd -e java . | xargs rg "implements.*Delete.*ExtensionPoint\|implements.*Destroy.*ExtensionPoint" | head -20
echo -e "\n=== Search for pattern: what is the actual replacement mentioned in code ==="
fd -e java . | xargs rg "single-phase extension point" -B 3 -A 3Repository: MatheMatrix/zstack Length of output: 3216 🏁 Script executed: #!/bin/bash
# Check if there's any mention of what to use instead or if there's documentation
echo "=== Check for VmDbDelete* in extensions package ==="
fd -e java . header/src/main/java/org/zstack/header/vm/extensions/ | xargs ls -la
echo -e "\n=== Check VmDestroyContext to see how it differs ==="
find . -name "VmDestroyContext.java" -exec cat {} \;
echo -e "\n=== Check if there are any recent changes or comments about the replacement ==="
fd -e java . | xargs rg "VmDestroyExtensionPoint\|VmDbDelete" -B 2 -A 2 | grep -E "(TODO|FIXME|NOTE|phase)" | head -20Repository: MatheMatrix/zstack Length of output: 2470 🏁 Script executed: #!/bin/bash
# Check if VmDbDeleteExtensionPoint is planned/mentioned anywhere
echo "=== Search for any TODO, FIXME, or future references to VmDbDelete ==="
fd -e java . | xargs rg "VmDbDelete" -B 3 -A 3
echo -e "\n=== Check git history or comments about when VmDbDeleteContext was added ==="
git log --oneline --all -- "header/src/main/java/org/zstack/header/vm/extensions/VmDbDeleteContext.java" | head -10
echo -e "\n=== Look for pattern in similar deprecated interfaces ==="
fd -e java . | xargs rg "@Deprecated" -B 3 | grep -E "Use.*Context.*extension" -B 3 -A 3Repository: MatheMatrix/zstack Length of output: 3792 🏁 Script executed: #!/bin/bash
# Check if there's any documentation or comments about VmDbDeleteContext usage
echo "=== Search for implementations or usages of VmDbDeleteContext ==="
fd -e java . | xargs rg "VmDbDeleteContext" -A 5 | grep -v "^header/" | head -40
echo -e "\n=== Check the refactor commit message ==="
git show 1a4fa661c --stat | head -50
echo -e "\n=== Check related extension point interfaces with multiple phases ==="
cat header/src/main/java/org/zstack/header/vm/extensions/VmExpungeExtensionPoint.javaRepository: MatheMatrix/zstack Length of output: 3974 弃用说明缺少具体的扩展点接口名称。 当前弃用注释引用了 🤖 Prompt for AI Agents |
||
| public interface VmJustBeforeDeleteFromDbExtensionPoint { | ||
| void vmJustBeforeDeleteFromDb(VmInstanceInventory inv); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| package org.zstack.header.vm.extensions; | ||
|
|
||
| import org.zstack.header.network.l3.L3NetworkInventory; | ||
| import org.zstack.header.vm.VmInstanceInventory; | ||
| import org.zstack.header.vm.VmNicInventory; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * Context object for VM L3 Network attachment operations. | ||
| * | ||
| * <p>This context is passed through all lifecycle phases (pre/before/after/failedTo) | ||
| * allowing extensions to share state between phases.</p> | ||
| */ | ||
| public class VmAttachL3NetworkContext { | ||
| private VmInstanceInventory vm; | ||
| private L3NetworkInventory l3; | ||
| private VmNicInventory nic; | ||
| private String accountUuid; | ||
| private Map<String, Object> additionalData = new HashMap<>(); | ||
|
|
||
| public VmInstanceInventory getVm() { | ||
| return vm; | ||
| } | ||
|
|
||
| public void setVm(VmInstanceInventory vm) { | ||
| this.vm = vm; | ||
| } | ||
|
|
||
| public L3NetworkInventory getL3() { | ||
| return l3; | ||
| } | ||
|
|
||
| public void setL3(L3NetworkInventory l3) { | ||
| this.l3 = l3; | ||
| } | ||
|
|
||
| public VmNicInventory getNic() { | ||
| return nic; | ||
| } | ||
|
|
||
| public void setNic(VmNicInventory nic) { | ||
| this.nic = nic; | ||
| } | ||
|
|
||
| public String getAccountUuid() { | ||
| return accountUuid; | ||
| } | ||
|
|
||
| public void setAccountUuid(String accountUuid) { | ||
| this.accountUuid = accountUuid; | ||
| } | ||
|
|
||
| public Map<String, Object> getAdditionalData() { | ||
| return additionalData; | ||
| } | ||
|
|
||
| public void putData(String key, Object value) { | ||
| additionalData.put(key, value); | ||
| } | ||
|
|
||
| @SuppressWarnings("unchecked") | ||
| public <T> T getData(String key) { | ||
| return (T) additionalData.get(key); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package org.zstack.header.vm.extensions; | ||
|
|
||
| import org.zstack.header.vm.VmInstanceInventory; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| public class VmDbDeleteContext { | ||
| private VmInstanceInventory vm; | ||
| private String accountUuid; | ||
| private Map<String, Object> additionalData = new HashMap<>(); | ||
|
|
||
| public VmInstanceInventory getVm() { return vm; } | ||
| public void setVm(VmInstanceInventory vm) { this.vm = vm; } | ||
| public String getAccountUuid() { return accountUuid; } | ||
| public void setAccountUuid(String accountUuid) { this.accountUuid = accountUuid; } | ||
| public Map<String, Object> getAdditionalData() { return additionalData; } | ||
| public void putData(String key, Object value) { additionalData.put(key, value); } | ||
| @SuppressWarnings("unchecked") | ||
| public <T> T getData(String key) { return (T) additionalData.get(key); } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package org.zstack.header.vm.extensions; | ||
|
|
||
| import org.zstack.header.errorcode.ErrorCode; | ||
| import org.zstack.header.vm.VmInstanceInventory; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| public class VmDestroyContext { | ||
| private VmInstanceInventory vm; | ||
| private String accountUuid; | ||
| private ErrorCode error; | ||
| private Map<String, Object> additionalData = new HashMap<>(); | ||
|
|
||
| public VmInstanceInventory getVm() { return vm; } | ||
| public void setVm(VmInstanceInventory vm) { this.vm = vm; } | ||
| public String getAccountUuid() { return accountUuid; } | ||
| public void setAccountUuid(String accountUuid) { this.accountUuid = accountUuid; } | ||
| public ErrorCode getError() { return error; } | ||
| public void setError(ErrorCode error) { this.error = error; } | ||
| public Map<String, Object> getAdditionalData() { return additionalData; } | ||
| public void putData(String key, Object value) { additionalData.put(key, value); } | ||
| @SuppressWarnings("unchecked") | ||
| public <T> T getData(String key) { return (T) additionalData.get(key); } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package org.zstack.header.vm.extensions; | ||
|
|
||
| import org.zstack.header.core.Completion; | ||
|
|
||
| /** | ||
| * VM Instance Destroy Extension Point (unified) | ||
| * | ||
| * <p>Trigger: When user calls DestroyVmInstance API</p> | ||
| * <p>Call site: VmInstanceBase via VmInstanceExtensionPointEmitter</p> | ||
| * | ||
| * <h3>Phase Description:</h3> | ||
| * <ul> | ||
| * <li>preDestroy - Can reject the destroy operation</li> | ||
| * <li>beforeDestroy - Preparation before destroy</li> | ||
| * <li>afterDestroy - Post-processing after destroy</li> | ||
| * <li>failedToDestroy - Cleanup on failure</li> | ||
| * </ul> | ||
| */ | ||
| public interface VmDestroyExtensionPoint { | ||
| default String preDestroy(VmDestroyContext ctx) { return null; } | ||
| default void beforeDestroy(VmDestroyContext ctx) {} | ||
| default void afterDestroy(VmDestroyContext ctx, Completion completion) { completion.success(); } | ||
| default void failedToDestroy(VmDestroyContext ctx) {} | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| package org.zstack.header.vm.extensions; | ||
|
|
||
| import org.zstack.header.errorcode.ErrorCode; | ||
| import org.zstack.header.vm.VmInstanceInventory; | ||
| import org.zstack.header.vm.VmNicInventory; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * Context object for VM NIC detachment operations. | ||
| * | ||
| * <p>This context is passed through all lifecycle phases (pre/before/after/failedTo) | ||
| * allowing extensions to share state between phases.</p> | ||
| */ | ||
| public class VmDetachNicContext { | ||
| private VmInstanceInventory vm; | ||
| private VmNicInventory nic; | ||
| private String accountUuid; | ||
| private ErrorCode error; | ||
| private Map<String, Object> additionalData = new HashMap<>(); | ||
|
|
||
| public VmInstanceInventory getVm() { | ||
| return vm; | ||
| } | ||
|
|
||
| public void setVm(VmInstanceInventory vm) { | ||
| this.vm = vm; | ||
| } | ||
|
|
||
| public VmNicInventory getNic() { | ||
| return nic; | ||
| } | ||
|
|
||
| public void setNic(VmNicInventory nic) { | ||
| this.nic = nic; | ||
| } | ||
|
|
||
| public String getAccountUuid() { | ||
| return accountUuid; | ||
| } | ||
|
|
||
| public void setAccountUuid(String accountUuid) { | ||
| this.accountUuid = accountUuid; | ||
| } | ||
|
|
||
| public ErrorCode getError() { | ||
| return error; | ||
| } | ||
|
|
||
| public void setError(ErrorCode error) { | ||
| this.error = error; | ||
| } | ||
|
|
||
| public Map<String, Object> getAdditionalData() { | ||
| return additionalData; | ||
| } | ||
|
|
||
| public void putData(String key, Object value) { | ||
| additionalData.put(key, value); | ||
| } | ||
|
|
||
| @SuppressWarnings("unchecked") | ||
| public <T> T getData(String key) { | ||
| return (T) additionalData.get(key); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Javadoc 应使用英文编写
根据编码规范,代码中不应包含中文,包括注释和错误消息都应当使用正确的、无拼写错误的英文来编写。请将此 Javadoc 翻译为英文。
建议的英文 Javadoc
根据编码规范:代码里不应当有中文,包括报错、注释等都应当使用正确的、无拼写错误的英文来写。
🤖 Prompt for AI Agents