private void replyErrorIfMessageNeedReply(Message msg, String errStr) { if (msg instanceof NeedReplyMessage) { ErrorCode err = inerr(errStr); replyErrorIfMessageNeedReply(msg, err); } else { DebugUtils.dumpStackTrace(String.format("An error happened when dealing with message[%s], because this message doesn't need a reply, we call it out loudly\nerror: %s\nmessage dump: %s", msg.getClass().getName(), errStr, wire.dumpMessage(msg))); } }
private void replyErrorIfMessageNeedReply(Message msg, String errStr) { if (msg instanceof NeedReplyMessage) { ErrorCode err = inerr(errStr); replyErrorIfMessageNeedReply(msg, err); } else { DebugUtils.dumpStackTrace(String.format("An error happened when dealing with message[%s], because this message doesn't need a reply, we call it out loudly\nerror: %s\nmessage dump: %s", msg.getClass().getName(), errStr, dumpMessage(msg))); } }
private ErrorCode doInstantiateErrorCode(String code, String details, List<ErrorCode> causes) { ErrorCodeInfo info = codes.get(code); if (info == null) { throw new CloudRuntimeException(String.format("cannot find error code[%s]", code)); } if (details != null && details.length() > 4096) { details = details.substring(0, 4093) + "..."; } ErrorCodeList err = (ErrorCodeList) info.code.copy(); if (SysErrors.INTERNAL.toString().equals(code)) { if (details != null && details.trim().contains(", {\"code\":") && details.trim().endsWith("}")) { replaceSystemError(err, details); } else { err.setDetails(details); } } else { err.setDetails(Platform.toI18nString(details)); } err.setCauses(causes); if (dumpOnError) { DebugUtils.dumpStackTrace(String.format("An error code%s is instantiated," + " for tracing the place error happened, dump stack as below", err)); } return err; }
public synchronized TakeSnapshotResponse takeSnapshot(TakeSnapshotCmd cmd) { Qcow2 current = findByInstallPath(cmd.getVolumeInstallPath()); if (cmd.isFullSnapshot() && current == null) { dumpAllQcow2(); String err = String.format("cannot find snapshot[%s] and it's full snapshot", cmd.getVolumeInstallPath()); DebugUtils.dumpStackTrace(err); Assert.fail(err); } if (current == null) { current = Qcow2.newQcow2(cmd.getVolumeInstallPath()); snapshots.put(current.getInstallPath(), current); } else { if (cmd.isFullSnapshot()) { String dir = PathUtil.parentFolder(cmd.getVolumeInstallPath()); String newVolumePath = String.format("%s/%s.qcow2", dir, Platform.getUuid()); current = Qcow2.newQcow2(newVolumePath); snapshots.put(current.getInstallPath(), current); } } Qcow2 n = Qcow2.newQcow2(cmd.getInstallPath(), current); logger.debug(String.format("created new volume[%s] for taking snapshot", n.getInstallPath())); dumpQcow2Tree(current, "Taking Snapshot"); TakeSnapshotResponse rsp = new TakeSnapshotResponse(); rsp.setSize(100000); rsp.setNewVolumeInstallPath(n.getInstallPath()); rsp.setSnapshotInstallPath(current.getInstallPath()); return rsp; }
@Override public void dealWithUnknownMessage(Message msg) { String details = String.format("No service deals with message: %s", dumpMessage(msg)); if (msg instanceof APISyncCallMessage) { APIReply reply = new APIReply(); reply.setError(err(SysErrors.UNKNOWN_MESSAGE_ERROR, details)); reply.setSuccess(false); reply(msg, reply); } else if (msg instanceof APIMessage) { APIEvent evt = new APIEvent(msg.getId()); evt.setError(err(SysErrors.UNKNOWN_MESSAGE_ERROR, details)); publish(evt); } else if (msg instanceof NeedReplyMessage) { MessageReply reply = new MessageReply(); reply.setError(err(SysErrors.UNKNOWN_MESSAGE_ERROR, details)); reply.setSuccess(false); reply(msg, reply); } DebugUtils.dumpStackTrace("Dropped an unknown message, " + details); }
@Override public void dealWithUnknownMessage(Message msg) { String details = String.format("No service deals with message: %s", wire.dumpMessage(msg)); if (msg instanceof APISyncCallMessage) { APIReply reply = new APIReply(); reply.setError(err(SysErrors.UNKNOWN_MESSAGE_ERROR, details)); reply.setSuccess(false); this.reply(msg, reply); } else if (msg instanceof APIMessage) { APIEvent evt = new APIEvent(msg.getId()); evt.setError(err(SysErrors.UNKNOWN_MESSAGE_ERROR, details)); this.publish(evt); } else if (msg instanceof NeedReplyMessage) { MessageReply reply = new MessageReply(); reply.setError(err(SysErrors.UNKNOWN_MESSAGE_ERROR, details)); reply.setSuccess(false); this.reply(msg, reply); } DebugUtils.dumpStackTrace("Dropped an unknown message, " + details); }