-
Notifications
You must be signed in to change notification settings - Fork 0
<feature>[storage]: res sblk #3208
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: zsv_4.10.28
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 |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| package org.zstack.header.storage.primary; | ||
|
|
||
| import org.zstack.header.message.APIEvent; | ||
| import org.zstack.header.rest.RestResponse; | ||
|
|
||
| import java.util.Collections; | ||
|
|
||
| @RestResponse(allTo = "inventory") | ||
| public class APITakeoverPrimaryStorageEvent extends APIEvent { | ||
| private PrimaryStorageInventory inventory; | ||
|
|
||
| public APITakeoverPrimaryStorageEvent() { | ||
| } | ||
|
|
||
| public APITakeoverPrimaryStorageEvent(String apiId) { | ||
| super(apiId); | ||
| } | ||
|
|
||
| public PrimaryStorageInventory getInventory() { | ||
| return inventory; | ||
| } | ||
|
|
||
| public void setInventory(PrimaryStorageInventory inventory) { | ||
| this.inventory = inventory; | ||
| } | ||
|
|
||
| public static APITakeoverPrimaryStorageEvent __example__() { | ||
| APITakeoverPrimaryStorageEvent event = new APITakeoverPrimaryStorageEvent(); | ||
|
|
||
| PrimaryStorageInventory ps = new PrimaryStorageInventory(); | ||
| ps.setName("PS1"); | ||
| ps.setUrl("/zstack_ps"); | ||
| ps.setType("LocalStorage"); | ||
| ps.setAttachedClusterUuids(Collections.singletonList(uuid())); | ||
|
|
||
| event.setInventory(ps); | ||
| return event; | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package org.zstack.header.storage.primary; | ||
|
|
||
| import org.springframework.http.HttpMethod; | ||
| import org.zstack.header.message.APIMessage; | ||
| import org.zstack.header.message.APIParam; | ||
| import org.zstack.header.rest.RestRequest; | ||
|
|
||
| @RestRequest( | ||
| path = "/primary-storage/{uuid}/takeover", | ||
| responseClass = APITakeoverPrimaryStorageEvent.class, | ||
| method = HttpMethod.PUT, | ||
| isAction = true | ||
| ) | ||
| public class APITakeoverPrimaryStorageMsg extends APIMessage implements PrimaryStorageMessage { | ||
| @APIParam(resourceType = PrimaryStorageVO.class) | ||
| private String uuid; | ||
|
|
||
| @Override | ||
| public String getPrimaryStorageUuid() { | ||
| return uuid; | ||
| } | ||
|
|
||
| public String getUuid() { | ||
| return uuid; | ||
| } | ||
|
|
||
| public void setUuid(String uuid) { | ||
| this.uuid = uuid; | ||
| } | ||
|
|
||
| public static APITakeoverPrimaryStorageMsg __example__() { | ||
| APITakeoverPrimaryStorageMsg msg = new APITakeoverPrimaryStorageMsg(); | ||
|
|
||
| msg.setUuid(uuid(PrimaryStorageVO.class)); | ||
|
|
||
| return msg; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package org.zstack.header.storage.primary; | ||
|
|
||
| import org.zstack.header.message.NeedReplyMessage; | ||
|
|
||
| public class TakeoverPrimaryStorageMsg extends NeedReplyMessage implements PrimaryStorageMessage { | ||
| private String primaryStorageUuid; | ||
|
|
||
| @Override | ||
| public String getPrimaryStorageUuid() { | ||
| return primaryStorageUuid; | ||
| } | ||
|
|
||
| public void setPrimaryStorageUuid(String primaryStorageUuid) { | ||
| this.primaryStorageUuid = primaryStorageUuid; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package org.zstack.header.storage.primary; | ||
|
|
||
| import org.zstack.header.message.MessageReply; | ||
|
|
||
| public class TakeoverPrimaryStorageReply extends MessageReply { | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -177,6 +177,10 @@ public void setNewAdded(boolean newAdded) { | |||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| protected abstract void handle(GetVolumeSnapshotEncryptedOnPrimaryStorageMsg msg); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| protected void takeoverHook(Completion completion){ | ||||||||||||||||||||||||||||||||||||||||||||||||
| completion.success(); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| public PrimaryStorageBase(PrimaryStorageVO self) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| this.self = self; | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -603,6 +607,22 @@ public void fail(ErrorCode errorCode) { | |||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| protected void handle(TakeoverPrimaryStorageMsg msg) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| TakeoverPrimaryStorageReply reply = new TakeoverPrimaryStorageReply(); | ||||||||||||||||||||||||||||||||||||||||||||||||
| doTakeover(new ConnectParam(), new Completion(msg) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||||||||||||||||||||||||||
| public void success() { | ||||||||||||||||||||||||||||||||||||||||||||||||
| bus.reply(msg, reply); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||||||||||||||||||||||||||
| public void fail(ErrorCode errorCode) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| reply.setError(errorCode); | ||||||||||||||||||||||||||||||||||||||||||||||||
| bus.reply(msg, reply); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| private void handle(ChangePrimaryStorageStatusMsg msg) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| changeStatus(PrimaryStorageStatus.valueOf(msg.getStatus())); | ||||||||||||||||||||||||||||||||||||||||||||||||
| ChangePrimaryStorageStatusReply reply = new ChangePrimaryStorageStatusReply(); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -695,6 +715,51 @@ public String getName() { | |||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| private void doTakeover(ConnectParam param, final Completion completion) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| thdf.chainSubmit(new ChainTask(completion) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||||||||||||||||||||||||||
| public String getSyncSignature() { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return getSyncId(); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||||||||||||||||||||||||||
| public void run(SyncTaskChain chain) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| takeoverHook(new Completion(chain, completion) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||||||||||||||||||||||||||
| public void success() { | ||||||||||||||||||||||||||||||||||||||||||||||||
| self = dbf.reload(self); | ||||||||||||||||||||||||||||||||||||||||||||||||
| logger.debug(String.format("successfully reload primary storage[uuid:%s]", self.getUuid())); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| tracker.track(self.getUuid()); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| completion.success(); | ||||||||||||||||||||||||||||||||||||||||||||||||
| chain.next(); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||||||||||||||||||||||||||
| public void fail(ErrorCode errorCode) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| tracker.track(self.getUuid()); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| self = dbf.reload(self); | ||||||||||||||||||||||||||||||||||||||||||||||||
| if (changeStatus(PrimaryStorageStatus.Disconnected) && !errorCode.isError(PrimaryStorageErrors.DISCONNECTED)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| fireDisconnectedCanonicalEvent(errorCode); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| logger.debug(String.format("failed to connect primary storage[uuid:%s], %s", self.getUuid(), errorCode)); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| completion.fail(errorCode); | ||||||||||||||||||||||||||||||||||||||||||||||||
| chain.next(); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||||||||||||||||||||||||||
| public String getName() { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return String.format("reconnect-primary-storage-%s", self.getUuid()); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+748
to
+758
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. 日志消息和任务名称与操作不一致 复制自
✏️ 修复建议- logger.debug(String.format("failed to connect primary storage[uuid:%s], %s", self.getUuid(), errorCode));
+ logger.debug(String.format("failed to reload primary storage[uuid:%s], %s", self.getUuid(), errorCode));
completion.fail(errorCode);
chain.next();
}
});
}
`@Override`
public String getName() {
- return String.format("reconnect-primary-storage-%s", self.getUuid());
+ return String.format("reload-primary-storage-%s", self.getUuid());
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| private void handle(final ConnectPrimaryStorageMsg msg) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| final ConnectPrimaryStorageReply reply = new ConnectPrimaryStorageReply(); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1397,6 +1462,27 @@ public void run(MessageReply reply) { | |||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| protected void handle(APITakeoverPrimaryStorageMsg msg) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| final APITakeoverPrimaryStorageEvent evt = new APITakeoverPrimaryStorageEvent(msg.getId()); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| TakeoverPrimaryStorageMsg rmsg = new TakeoverPrimaryStorageMsg(); | ||||||||||||||||||||||||||||||||||||||||||||||||
| rmsg.setPrimaryStorageUuid(msg.getPrimaryStorageUuid()); | ||||||||||||||||||||||||||||||||||||||||||||||||
| bus.makeTargetServiceIdByResourceUuid(rmsg, PrimaryStorageConstant.SERVICE_ID, rmsg.getPrimaryStorageUuid()); | ||||||||||||||||||||||||||||||||||||||||||||||||
| bus.send(rmsg, new CloudBusCallBack(msg) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||||||||||||||||||||||||||
| public void run(MessageReply reply) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| if (!reply.isSuccess()) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| evt.setError(reply.getError()); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| self = dbf.reload(self); | ||||||||||||||||||||||||||||||||||||||||||||||||
| evt.setInventory(getSelfInventory()); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| bus.publish(evt); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // don't use chainTask for this method, the sub-sequential DetachPrimaryStorageFromClusterMsg | ||||||||||||||||||||||||||||||||||||||||||||||||
| // is in the queue | ||||||||||||||||||||||||||||||||||||||||||||||||
| protected void handle(final APIDetachPrimaryStorageFromClusterMsg msg) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.