本文整理了Java中org.zstack.core.asyncbatch.While
类的一些代码示例,展示了While
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。While
类的具体详情如下:
包路径:org.zstack.core.asyncbatch.While
类名称:While
[英]Created by xing5 on 2017/3/5.
[中]由兴5于2017年3月5日创建。
代码示例来源:origin: zstackio/zstack
private void detachIpFromVmNicCascade(List
if (msgs.isEmpty()) {
completion.success();
return;
}
new While<>(msgs).all((msg, compl) -> bus.send(msg, new CloudBusCallBack(compl) {
@Override
public void run(MessageReply reply) {
if (!reply.isSuccess()) {
logger.warn(String.format("failed to detach ip[uuid:%s] from vmNic [uuid:%s], %s." +
" However, detaching will go on", msg.getUsedIpUuid(), msg.getVmNicUuid(), reply.getError()));
}
compl.done();
}
})).run(new NoErrorCompletion(completion) {
@Override
public void done() {
completion.success();
}
});
}
代码示例来源:origin: zstackio/zstack
private void pingFilter(PrimaryStorageInventory inv, int count, int oneStepLimit, Completion completion){
List
for(int i = 0; i <= count/oneStepLimit; i ++){
stepCount.add(i);
}
List
new While<>(stepCount).each((currentStep, compl) -> {
pingFilterStep(inv, currentStep, oneStepLimit, new Completion(compl) {
@Override
public void success() {
compl.allDone();
}
@Override
public void fail(ErrorCode errorCode) {
errs.add(errorCode);
compl.done();
}
});
}).run(new NoErrorCompletion(completion) {
@Override
public void done() {
if(errs.size() == stepCount.size()){
completion.fail(errs.get(0));
}else {
completion.success();
}
}
});
}
代码示例来源:origin: zstackio/zstack
@Override
public void send(List extends NeedReplyMessage> msgs, int parallelLevel, CloudBusSteppingCallback callback) {
DebugUtils.Assert(!msgs.isEmpty(), "you cannot pass an empty message list to me");
msgs.forEach(this::evaluateMessageTimeout);
new While<>(msgs).step((msg, completion) -> send(msg, new CloudBusCallBack(completion) {
@Override
public void run(MessageReply reply) {
callback.run(msg, reply);
completion.done();
}
}), parallelLevel).run(new NopeNoErrorCompletion());
}
代码示例来源:origin: zstackio/zstack
public void run(NoErrorCompletion completion) {
DebugUtils.Assert(consumer != null, "each() or all() or step() must be called before run()");
if (items.isEmpty()) {
completion.done();
return;
}
if (mode == EACH) {
run(items.iterator(), completion);
} else if (mode == ALL) {
runAll(completion);
} else if (mode == STEP) {
runStep(completion);
} else {
DebugUtils.Assert(false, "should be here");
}
}
代码示例来源:origin: zstackio/zstack
new While<>(vmUuids).step((vmUuid, compl) -> {
MigrateVmMsg msg = new MigrateVmMsg();
msg.setVmInstanceUuid(vmUuid);
List
List
new While<>(vmUuids).step((vmUuid, coml) -> {
StopVmInstanceMsg msg = new StopVmInstanceMsg();
msg.setVmInstanceUuid(vmUuid);
代码示例来源:origin: zstackio/zstack
new While<>(mons).each((mon, compl) -> {
GetFactsCmd cmd = new GetFactsCmd();
cmd.uuid = self.getUuid();
代码示例来源:origin: zstackio/zstack
new While<>(msgs).all((msg, compl) -> bus.send(msg, new CloudBusCallBack(compl) {
@Override
public void run(MessageReply reply) {
})).run(new NoErrorCompletion(completion) {
@Override
public void done() {
代码示例来源:origin: zstackio/zstack
List
List
new While<>(hosts).each((h, wcmpl) -> {
reserveHost(h, new Completion(wcmpl) {
@Override
}).run(new NoErrorCompletion(completion) {
@Override
public void done() {
代码示例来源:origin: zstackio/zstack
@Override
public void send(List extends NeedReplyMessage> msgs, int parallelLevel, CloudBusListCallBack callBack) {
DebugUtils.Assert(!msgs.isEmpty(), "you cannot pass an empty message list to me");
msgs.forEach(this::evaluateMessageTimeout);
Map
new While<>(msgs).step((msg, completion) -> send(msg, new CloudBusCallBack(completion) {
@Override
public void run(MessageReply reply) {
replies.put(msg.getId(), reply);
completion.done();
}
}), parallelLevel).run(new NoErrorCompletion(callBack) {
@Override
public void done() {
List
assert msgs.size() == replies.size();
msgs.forEach(msg -> results.add(replies.get(msg.getId())));
callBack.run(results);
}
});
}
代码示例来源:origin: zstackio/zstack
new While<>(detachIsoFromVmInstanceMsgs).all((detachIsoFromVmInstanceMsg, completion) -> {
bus.send(detachIsoFromVmInstanceMsg, new CloudBusCallBack(completion) {
@Override
代码示例来源:origin: zstackio/zstack
new While<>(msgs).all((msg, whileCompletion) -> {
bus.send(msg, new CloudBusCallBack(whileCompletion) {
@Override
}).run(new NoErrorCompletion(completion) {
@Override
public void done() {
代码示例来源:origin: zstackio/zstack
new While<>(ps).each((pvo, completion) -> {
mount(PrimaryStorageInventory.valueOf(pvo), inv.getUuid(), new Completion(completion){
}).run(new NoErrorCompletion() {
@Override
public void done() {
代码示例来源:origin: zstackio/zstack
private void syncVolumeSize(){
new While<>(volumeUuids).step((volUuid, completion) -> {
if (!volumeInTracking.add(volUuid)) {
completion.done();
return;
}
SyncVolumeSizeMsg msg = new SyncVolumeSizeMsg();
msg.setVolumeUuid(volUuid);
bus.makeTargetServiceIdByResourceUuid(msg, VolumeConstant.SERVICE_ID, volUuid);
bus.send(msg, new CloudBusCallBack(msg) {
@Override
public void run(MessageReply reply) {
volumeInTracking.remove(msg.getVolumeUuid());
if (!reply.isSuccess()) {
logger.warn(String.format("fail to refresh volume[uuid:%s] size, try again soon", volUuid));
}
completion.done();
}
});
}, 50).run(new NopeNoErrorCompletion());
}
代码示例来源:origin: zstackio/zstack
new While<>(msgs).all((msg, whileCompletion) -> {
bus.send(msg, new CloudBusCallBack(whileCompletion) {
@Override
}).run(new NoErrorCompletion(completion) {
@Override
public void done() {
代码示例来源:origin: zstackio/zstack
new While<>(stepCount).each((currentStep, compl) -> pingHook(new Completion(compl) {
@Override
public void success() {
})).run(new NoErrorCompletion(msg) {
@Override
public void done() {
代码示例来源:origin: zstackio/zstack
@Override
public void afterHostConnected(HostInventory inv) {
if (inv.getStatus().equals(HostStatus.Connected.toString())){
List
.eq(VmInstanceVO_.hostUuid, inv.getUuid())
.listValues();
if(vmUuids.isEmpty()){
return;
}
new While<>(vmUuids).step((vmUuid, completion) -> {
VmCheckOwnStateMsg msg = new VmCheckOwnStateMsg();
msg.setVmInstanceUuid(vmUuid);
bus.makeTargetServiceIdByResourceUuid(msg, VmInstanceConstant.SERVICE_ID, vmUuid);
bus.send(msg, new CloudBusCallBack(completion) {
@Override
public void run(MessageReply reply) {
if(!reply.isSuccess()){
logger.warn(String.format("the host[uuid:%s] connected, but the vm[uuid:%s] fails to " +
"update it's state , %s", inv.getUuid(), vmUuid, reply.getError()));
}
completion.done();
}
});
}, 200).run(new NopeNoErrorCompletion());
}
}
}
代码示例来源:origin: zstackio/zstack
new While<>(msgs).all((msg, noErrorCompletion) -> {
bus.send(msg, new CloudBusCallBack(noErrorCompletion) {
@Override
}).run(new NoErrorCompletion(completion) {
@Override
public void done() {
代码示例来源:origin: zstackio/zstack
private void rollbackCertificate(VirtualRouterVmInventory vr, List
Set
new While<>(certificateUuids).each((uuid, wcmpl) -> {
VirtualRouterAsyncHttpCallMsg msg = new VirtualRouterAsyncHttpCallMsg();
msg.setVmInstanceUuid(vr.getUuid());
msg.setPath(DELETE_CERTIFICATE_PATH);
CertificateCmd cmd = new CertificateCmd();
cmd.setUuid(uuid);
msg.setCommand(cmd);
bus.makeTargetServiceIdByResourceUuid(msg, VmInstanceConstant.SERVICE_ID, vr.getUuid());
bus.send(msg, new CloudBusCallBack(wcmpl) {
@Override
public void run(MessageReply reply) {
wcmpl.done();
}
});
}).run(new NoErrorCompletion(completion) {
@Override
public void done() {
completion.done();
}
});
}
代码示例来源:origin: zstackio/zstack
@Override
public void afterChangeHostStatus(String hostUuid, HostStatus before, HostStatus next) {
if(next == HostStatus.Disconnected) {
List
.eq(VmInstanceVO_.hostUuid, hostUuid)
.listValues();
if(vmUuids.isEmpty()){
return;
}
new While<>(vmUuids).step((vmUuid, completion) -> {
VmStateChangedOnHostMsg msg = new VmStateChangedOnHostMsg();
msg.setVmInstanceUuid(vmUuid);
msg.setHostUuid(hostUuid);
msg.setStateOnHost(VmInstanceState.Unknown);
bus.makeTargetServiceIdByResourceUuid(msg, VmInstanceConstant.SERVICE_ID, vmUuid);
bus.send(msg, new CloudBusCallBack(completion) {
@Override
public void run(MessageReply reply) {
if(!reply.isSuccess()){
logger.warn(String.format("the host[uuid:%s] disconnected, but the vm[uuid:%s] fails to " +
"change it's state to Unknown, %s", hostUuid, vmUuid, reply.getError()));
} else {
logger.debug(String.format("the host[uuid:%s] disconnected, change the VM[uuid:%s]' state to Unknown", hostUuid, vmUuid));
}
completion.done();
}
});
}, 200).run(new NopeNoErrorCompletion());
}
}
代码示例来源:origin: zstackio/zstack
new While<>(msgs).all((msg, com) -> bus.send(msg, new CloudBusCallBack(com) {
@Override
public void run(MessageReply reply) {
})).run(new NoErrorCompletion() {
@Override
public void done() {