@Override public SimpleFlowChain done(FlowDoneHandler handler) { DebugUtils.Assert(doneHandler==null, "there has been a FlowDoneHandler installed"); doneHandler = handler; return this; }
public static void dumpStackTrace(String msg) { String stack = String.format("%s:\n%s", msg, getStackTrace()); logger.debug(stack); }
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 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))); } }
public SimpleFlowChain error(FlowErrorHandler handler) { DebugUtils.Assert(errorHandler==null, "there has been an FlowErrorHandler installed"); errorHandler = handler; return this; }
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 static void dumpStackTrace() { logger.debug(getStackTrace()); }
@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); }
private ManagementNodeVO node() { DebugUtils.Assert(node != null, "node is set to null!!!"); return node; }
public void setDELETE_DELAY(int DELETE_DELAY) { DebugUtils.Assert(DELETE_DELAY > 0, "DELETE_DELAY must be greater than 0"); this.DELETE_DELAY = DELETE_DELAY; }
public void done() { DebugUtils.Assert(success != null, "you must call successOrNot() before done()"); inners.add(this); } }
protected void batch(AsyncBatchRunner runner) { DebugUtils.Assert(runner != null, "runner cannot be null"); runners.add(runner); }
private void checkParams() { DebugUtils.Assert(hostname != null && !hostname.trim().equals(""), "hostname cannot be null"); DebugUtils.Assert(username != null && !username.trim().equals(""), "username cannot be null"); DebugUtils.Assert(password != null || privateKeyFile != null, "password and privateKeyFile must have at least one set"); }
@Override public PortForwardingBackend getPortForwardingBackend(String providerType) { PortForwardingBackend bkd = backends.get(providerType); DebugUtils.Assert(bkd != null, String.format("cannot find PortForwardingBackend[type:%s]", providerType)); return bkd; }
public ApplianceVmSubTypeFactory getApplianceVmSubTypeFactory(String subtype) { ApplianceVmSubTypeFactory subTypeFactory = subTypeFactories.get(subtype); DebugUtils.Assert(subTypeFactory!=null, String.format("cannot find ApplianceVmSubTypeFactory for type[%s]", subtype)); return subTypeFactory; }
@Override public VipFactory getVipFactory(String networkServiceProviderType) { VipFactory f = factories.get(networkServiceProviderType); DebugUtils.Assert(f != null, String.format("cannot find the VipFactory for the network service provider type[%s]", networkServiceProviderType)); return f; }