本文整理了Java中org.zstack.core.asyncbatch.While.step()
方法的一些代码示例,展示了While.step()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。While.step()
方法的具体详情如下:
包路径:org.zstack.core.asyncbatch.While
类名称:While
方法名:step
暂无
代码示例来源: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<String, MessageReply> replies = Collections.synchronizedMap(new HashMap<>(msgs.size()));
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<MessageReply> results = new ArrayList<>();
assert msgs.size() == replies.size();
msgs.forEach(msg -> results.add(replies.get(msg.getId())));
callBack.run(results);
}
});
}
代码示例来源: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
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
@Override
public void afterHostConnected(HostInventory inv) {
if (inv.getStatus().equals(HostStatus.Connected.toString())){
List<String> vmUuids = Q.New(VmInstanceVO.class).select(VmInstanceVO_.uuid)
.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<>(vminvs).step((inv, noErrorCompletion) -> {
VmInstanceDeletionMsg msg = new VmInstanceDeletionMsg();
if (PrimaryStorageVO.class.getSimpleName().equals(action.getParentIssuer()) ||
代码示例来源:origin: zstackio/zstack
@Override
public void afterChangeHostStatus(String hostUuid, HostStatus before, HostStatus next) {
if(next == HostStatus.Disconnected) {
List<String> vmUuids = Q.New(VmInstanceVO.class).select(VmInstanceVO_.uuid)
.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());
}
}
内容来源于网络,如有侵权,请联系作者删除!