Skip to content

Commit 002111e

Browse files
committed
make asyncback as a mandotry constructor parameter for callbacks
1 parent 0991deb commit 002111e

File tree

151 files changed

+182
-4865
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+182
-4865
lines changed

image/src/main/java/org/zstack/image/ImageBase.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ private void returnBackupStorageCapacity(final String bsUuid, final long size) {
243243
msg.setBackupStorageUuid(bsUuid);
244244
msg.setSize(size);
245245
bus.makeTargetServiceIdByResourceUuid(msg, BackupStorageConstant.SERVICE_ID, bsUuid);
246-
bus.send(msg, new CloudBusCallBack() {
246+
bus.send(msg, new CloudBusCallBack(null) {
247247
@Override
248248
public void run(MessageReply reply) {
249249
if (!reply.isSuccess()) {
@@ -573,7 +573,6 @@ private void scheduleGcJob(final ExpungeImageMsg msg) {
573573
context.setName("gc-expunge-image");
574574
context.setInterval(10);
575575
context.setTimeUnit(TimeUnit.SECONDS);
576-
577576
gcf.schedule(context);
578577
}
579578

image/src/main/java/org/zstack/image/ImageManagerImpl.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ public ReturnBackupStorageMsg call(BackupStorageInventory arg) {
305305
}
306306
});
307307

308-
bus.send(rmsgs, new CloudBusListCallBack() {
308+
bus.send(rmsgs, new CloudBusListCallBack(null) {
309309
@Override
310310
public void run(List<MessageReply> replies) {
311311
for (MessageReply r : replies) {
@@ -1133,7 +1133,7 @@ public boolean run() {
11331133
msg.setImageUuid(imageUuid);
11341134
msg.setBackupStorageUuid(bsUuid);
11351135
bus.makeTargetServiceIdByResourceUuid(msg, ImageConstant.SERVICE_ID, imageUuid);
1136-
bus.send(msg, new CloudBusCallBack() {
1136+
bus.send(msg, new CloudBusCallBack(null) {
11371137
@Override
11381138
public void run(MessageReply reply) {
11391139
if (!reply.isSuccess()) {

image/src/main/java/org/zstack/image/ImageUpgradeExtension.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public SyncImageSizeMsg call(ImageInventory arg) {
131131
}
132132
});
133133

134-
bus.send(msgs, new CloudBusListCallBack() {
134+
bus.send(msgs, new CloudBusListCallBack(null) {
135135
@Override
136136
public void run(List<MessageReply> replies) {
137137
Map<String, Long> res = new HashMap<>();

plugin/applianceVm/src/main/java/org/zstack/appliancevm/ApplianceVmFacadeImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public void run(MessageReply reply) {
163163

164164
@Override
165165
public void destroyApplianceVm(String vmUuid) {
166-
destroyApplianceVm(vmUuid, new ReturnValueCompletion<ApplianceVmInventory>() {
166+
destroyApplianceVm(vmUuid, new ReturnValueCompletion<ApplianceVmInventory>(null) {
167167
@Override
168168
public void success(ApplianceVmInventory returnValue) {
169169
}

plugin/ceph/src/main/java/org/zstack/storage/ceph/backup/CephBackupStorageBase.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ void call() {
451451
}
452452

453453
CephBackupStorageMonBase base = it.next();
454-
base.httpCall(path, cmd, retClass, new ReturnValueCompletion<T>() {
454+
base.httpCall(path, cmd, retClass, new ReturnValueCompletion<T>(callback) {
455455
@Override
456456
public void success(T ret) {
457457
if (!ret.success) {
@@ -587,7 +587,8 @@ public void success(CheckImageMetaDataFileExistRsp ret) {
587587
deleteCmd.setImageUuid(msg.getImg().getUuid());
588588
deleteCmd.setBackupStorageUuid(msg.getBackupStorageUuid());
589589
deleteCmd.setPoolName(msg.getPoolName());
590-
httpCall(DELETE_IMAGES_METADATA, deleteCmd, DeleteImageInfoFromMetaDataFileRsp.class, new ReturnValueCompletion<DeleteImageInfoFromMetaDataFileRsp>() {
590+
httpCall(DELETE_IMAGES_METADATA, deleteCmd, DeleteImageInfoFromMetaDataFileRsp.class,
591+
new ReturnValueCompletion<DeleteImageInfoFromMetaDataFileRsp>(msg, chain) {
591592
@Override
592593
public void success(DeleteImageInfoFromMetaDataFileRsp returnValue) {
593594
bus.reply(msg, reply);
@@ -759,7 +760,7 @@ protected void handle(final DeleteBitsOnBackupStorageMsg msg) {
759760
DeleteCmd cmd = new DeleteCmd();
760761
cmd.installPath = msg.getInstallPath();
761762

762-
httpCall(DELETE_IMAGE_PATH, cmd, DeleteRsp.class, new ReturnValueCompletion<DeleteRsp>() {
763+
httpCall(DELETE_IMAGE_PATH, cmd, DeleteRsp.class, new ReturnValueCompletion<DeleteRsp>(msg) {
763764
@Override
764765
public void fail(ErrorCode err) {
765766
//TODO

plugin/ceph/src/main/java/org/zstack/storage/ceph/backup/CephBackupStorageMetaDataMaker.java

100644100755
+4-4
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ protected void dumpImagesBackupStorageInfoToMetaDataFile(ImageInventory img, bo
173173
}
174174
Integer monPort = CephGlobalProperty.BACKUP_STORAGE_AGENT_PORT;
175175
restf.asyncJsonPost(buildUrl(hostName, monPort, CephBackupStorageBase.DUMP_IMAGE_METADATA_TO_FILE), dumpCmd,
176-
new JsonAsyncRESTCallback<CephBackupStorageBase.DumpImageInfoToMetaDataFileRsp >() {
176+
new JsonAsyncRESTCallback<CephBackupStorageBase.DumpImageInfoToMetaDataFileRsp >(null) {
177177
@Override
178178
public void fail(ErrorCode err) {
179179
logger.error("Dump image metadata failed" + err.toString());
@@ -221,7 +221,7 @@ public void afterAddImage(ImageInventory img) {
221221
msg.setBackupStorageUuid(getBackupStorageUuidFromImageInventory(img));
222222
msg.setPoolName(inv.getPoolName());
223223
bus.makeLocalServiceId(msg, BackupStorageConstant.SERVICE_ID);
224-
bus.send(msg, new CloudBusCallBack() {
224+
bus.send(msg, new CloudBusCallBack(msg) {
225225
@Override
226226
public void run(MessageReply reply) {
227227
if (reply.isSuccess()) {
@@ -266,7 +266,7 @@ public void afterAddBackupStorage(AddBackupStorageStruct backupStorage) {
266266
msg.setOperation(CephConstants.AFTER_ADD_BACKUPSTORAGE);
267267
msg.setPoolName(inv.getPoolName());
268268
bus.makeLocalServiceId(msg, BackupStorageConstant.SERVICE_ID);
269-
bus.send(msg, new CloudBusCallBack() {
269+
bus.send(msg, new CloudBusCallBack(msg) {
270270
@Override
271271
public void run(MessageReply reply) {
272272
if (reply.isSuccess()) {
@@ -308,7 +308,7 @@ public void afterExpungeImage(ImageInventory img, String backupStorageUuid) {
308308
msg.setOperation(CephConstants.AFTER_EXPUNGE_IMAGE);
309309
msg.setPoolName(inv.getPoolName());
310310
bus.makeLocalServiceId(msg, BackupStorageConstant.SERVICE_ID);
311-
bus.send(msg, new CloudBusCallBack() {
311+
bus.send(msg, new CloudBusCallBack(msg) {
312312
@Override
313313
public void run(MessageReply reply) {
314314
if (reply.isSuccess()) {

plugin/ceph/src/main/java/org/zstack/storage/ceph/backup/CephBackupStorageMonBase.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public void changeStatus(MonStatus status) {
101101

102102
@Override
103103
public void connect(final Completion completion) {
104-
thdf.chainSubmit(new ChainTask() {
104+
thdf.chainSubmit(new ChainTask(completion) {
105105
@Override
106106
public String getSyncSignature() {
107107
return syncId;
@@ -252,7 +252,7 @@ public Class<T> getReturnClass() {
252252

253253
@Override
254254
public void ping(final ReturnValueCompletion<PingResult> completion) {
255-
thdf.chainSubmit(new ChainTask() {
255+
thdf.chainSubmit(new ChainTask(completion) {
256256
@Override
257257
public String getSyncSignature() {
258258
return syncId;

plugin/ceph/src/main/java/org/zstack/storage/ceph/primary/CephPrimaryStorageBase.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,7 @@ public void rollback(FlowRollback trigger, Map data) {
12021202
if (deleteOnRollback && cachePath != null) {
12031203
DeleteCmd cmd = new DeleteCmd();
12041204
cmd.installPath = cachePath;
1205-
httpCall(DELETE_PATH, cmd, DeleteRsp.class, new ReturnValueCompletion<DeleteRsp>() {
1205+
httpCall(DELETE_PATH, cmd, DeleteRsp.class, new ReturnValueCompletion<DeleteRsp>(null) {
12061206
@Override
12071207
public void success(DeleteRsp returnValue) {
12081208
logger.debug(String.format("successfully deleted %s", cachePath));
@@ -1250,7 +1250,7 @@ public void rollback(FlowRollback trigger, Map data) {
12501250
if (needCleanup) {
12511251
DeleteSnapshotCmd cmd = new DeleteSnapshotCmd();
12521252
cmd.snapshotPath = snapshotPath;
1253-
httpCall(DELETE_SNAPSHOT_PATH, cmd, DeleteSnapshotRsp.class, new ReturnValueCompletion<DeleteSnapshotRsp>() {
1253+
httpCall(DELETE_SNAPSHOT_PATH, cmd, DeleteSnapshotRsp.class, new ReturnValueCompletion<DeleteSnapshotRsp>(null) {
12541254
@Override
12551255
public void success(DeleteSnapshotRsp returnValue) {
12561256
logger.debug(String.format("successfully deleted the snapshot %s", snapshotPath));
@@ -1935,7 +1935,7 @@ public void done() {
19351935
}
19361936
}
19371937

1938-
mon.connect(new Completion() {
1938+
mon.connect(new Completion(releaseLock) {
19391939
@Override
19401940
public void success() {
19411941
logger.debug(String.format("successfully reconnected the mon[uuid:%s] of the ceph primary" +
@@ -2545,7 +2545,7 @@ public void run(FlowTrigger trigger, Map data) {
25452545
if (sq.count() == 0) {
25462546
DeleteCmd cmd = new DeleteCmd();
25472547
cmd.installPath = originalVolumePath;
2548-
httpCall(DELETE_PATH, cmd, DeleteRsp.class, new ReturnValueCompletion<DeleteRsp>() {
2548+
httpCall(DELETE_PATH, cmd, DeleteRsp.class, new ReturnValueCompletion<DeleteRsp>(null) {
25492549
@Override
25502550
public void success(DeleteRsp returnValue) {
25512551
logger.debug(String.format("successfully deleted %s", originalVolumePath));
@@ -2637,7 +2637,7 @@ public void run(FlowTrigger trigger, Map data) {
26372637
if (sq.count() == 0) {
26382638
DeleteCmd cmd = new DeleteCmd();
26392639
cmd.installPath = originalVolumePath;
2640-
httpCall(DELETE_PATH, cmd, DeleteRsp.class, new ReturnValueCompletion<DeleteRsp>() {
2640+
httpCall(DELETE_PATH, cmd, DeleteRsp.class, new ReturnValueCompletion<DeleteRsp>(null) {
26412641
@Override
26422642
public void success(DeleteRsp returnValue) {
26432643
logger.debug(String.format("successfully deleted %s", originalVolumePath));
@@ -2808,7 +2808,7 @@ public void deleteHook() {
28082808
if (CephGlobalConfig.PRIMARY_STORAGE_DELETE_POOL.value(Boolean.class)) {
28092809
DeletePoolCmd cmd = new DeletePoolCmd();
28102810
cmd.poolNames = list(getSelf().getImageCachePoolName(), getSelf().getDataVolumePoolName(), getSelf().getRootVolumePoolName());
2811-
FutureReturnValueCompletion completion = new FutureReturnValueCompletion();
2811+
FutureReturnValueCompletion completion = new FutureReturnValueCompletion(null);
28122812
httpCall(DELETE_POOL_PATH, cmd, DeletePoolRsp.class, completion);
28132813
completion.await(TimeUnit.MINUTES.toMillis(30));
28142814
if (!completion.isSuccess()) {

plugin/ceph/src/main/java/org/zstack/storage/ceph/primary/CephPrimaryStorageMonBase.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public void changeStatus(MonStatus status) {
101101

102102
@Override
103103
public void connect(final Completion completion) {
104-
thdf.chainSubmit(new ChainTask() {
104+
thdf.chainSubmit(new ChainTask(completion) {
105105
@Override
106106
public String getSyncSignature() {
107107
return syncId;
@@ -252,7 +252,7 @@ public Class<T> getReturnClass() {
252252

253253
@Override
254254
public void ping(final ReturnValueCompletion<PingResult> completion) {
255-
thdf.chainSubmit(new ChainTask() {
255+
thdf.chainSubmit(new ChainTask(completion) {
256256
@Override
257257
public String getSyncSignature() {
258258
return syncId;

plugin/flatNetworkProvider/src/main/java/org/zstack/network/service/flat/FlatDhcpBackend.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ public void preMigrateVm(VmInstanceInventory inv, String destHostUuid) {
597597
return;
598598
}
599599

600-
FutureCompletion completion = new FutureCompletion();
600+
FutureCompletion completion = new FutureCompletion(null);
601601
applyDhcpToHosts(info, destHostUuid, false, completion);
602602
completion.await(TimeUnit.MINUTES.toMillis(30));
603603
if (!completion.isSuccess()) {
@@ -778,7 +778,7 @@ public void rollback(FlowRollback trigger, Map data) {
778778
releaseDhcpService(info, vm.getUuid(), struct.getOriginalHostUuid(), new NopeNoErrorCompletion());
779779
}
780780
if (applyHostUuidForRollback != null) {
781-
applyDhcpToHosts(info, struct.getCurrentHostUuid(), false, new Completion() {
781+
applyDhcpToHosts(info, struct.getCurrentHostUuid(), false, new Completion(null) {
782782
@Override
783783
public void success() {
784784
//ignore

plugin/flatNetworkProvider/src/main/java/org/zstack/network/service/flat/FlatDnsBackend.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public void run(MessageReply reply) {
9797

9898
@Override
9999
public void connectionReestablished(HostInventory inv) throws HostException {
100-
setDnsOnHost(inv, new Completion() {
100+
setDnsOnHost(inv, new Completion(null) {
101101
@Override
102102
public void success() {
103103
// ignore

plugin/flatNetworkProvider/src/main/java/org/zstack/network/service/flat/FlatEipBackend.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public void afterMigrateVm(final VmInstanceInventory inv, String srcHostUuid) {
125125
}
126126

127127
batchDeleteEips(eips, srcHostUuid, new NopeCompletion());
128-
batchApplyEips(eips, inv.getHostUuid(), new Completion() {
128+
batchApplyEips(eips, inv.getHostUuid(), new Completion(null) {
129129
@Override
130130
public void success() {
131131
// pass
@@ -278,7 +278,7 @@ public void rollback(FlowRollback trigger, Map data) {
278278
batchDeleteEips(eips, releaseHostUuidForRollback, new NopeCompletion());
279279
}
280280
if (applyHostUuidForRollback != null) {
281-
batchApplyEips(eips, applyHostUuidForRollback, new Completion() {
281+
batchApplyEips(eips, applyHostUuidForRollback, new Completion(null) {
282282
@Override
283283
public void success() {
284284
// pass

plugin/flatNetworkProvider/src/main/java/org/zstack/network/service/flat/FlatUserdataBackend.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ public ErrorCode getError(KvmResponseWrapper w) {
254254
CleanupUserdataRsp rsp = w.getResponse(CleanupUserdataRsp.class);
255255
return rsp.isSuccess() ? null : errf.stringToOperationError(rsp.getError());
256256
}
257-
}, new ReturnValueCompletion<KvmResponseWrapper>() {
257+
}, new ReturnValueCompletion<KvmResponseWrapper>(null) {
258258
@Override
259259
public void success(KvmResponseWrapper w) {
260260
logger.debug(String.format("successfully cleanup userdata service on the host[uuid:%s] for the deleted L3 network[uuid:%s, name:%s]",

plugin/fusionstor/src/main/java/org/zstack/storage/fusionstor/backup/FusionstorBackupStorageBase.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ void call() {
281281
}
282282

283283
FusionstorBackupStorageMonBase base = it.next();
284-
base.httpCall(path, cmd, retClass, new ReturnValueCompletion<T>() {
284+
base.httpCall(path, cmd, retClass, new ReturnValueCompletion<T>(callback) {
285285
@Override
286286
public void success(T ret) {
287287
if (!ret.success) {
@@ -423,7 +423,7 @@ protected void handle(final DeleteBitsOnBackupStorageMsg msg) {
423423
DeleteCmd cmd = new DeleteCmd();
424424
cmd.installPath = msg.getInstallPath();
425425

426-
httpCall(DELETE_IMAGE_PATH, cmd, DeleteRsp.class, new ReturnValueCompletion<DeleteRsp>() {
426+
httpCall(DELETE_IMAGE_PATH, cmd, DeleteRsp.class, new ReturnValueCompletion<DeleteRsp>(msg) {
427427
@Override
428428
public void fail(ErrorCode err) {
429429
//TODO

plugin/fusionstor/src/main/java/org/zstack/storage/fusionstor/backup/FusionstorBackupStorageMonBase.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void changeStatus(MonStatus status) {
8787

8888
@Override
8989
public void connect(final Completion completion) {
90-
thdf.chainSubmit(new ChainTask() {
90+
thdf.chainSubmit(new ChainTask(completion) {
9191
@Override
9292
public String getSyncSignature() {
9393
return syncId;
@@ -238,7 +238,7 @@ public Class<T> getReturnClass() {
238238

239239
@Override
240240
public void ping(final ReturnValueCompletion<PingResult> completion) {
241-
thdf.chainSubmit(new ChainTask() {
241+
thdf.chainSubmit(new ChainTask(completion) {
242242
@Override
243243
public String getSyncSignature() {
244244
return syncId;

0 commit comments

Comments
 (0)