SendResult sendMessageToServer(final Message message, final long timeout, final TimeUnit unit,
final boolean saveToLocalWhileForbidden) throws MetaClientException, InterruptedException,
MetaOpeartionTimeoutException {
final SendResult sendResult = this.sendMessageToServer(message, timeout, unit);
if (this.needSaveToLocalWhenSendFailed(sendResult)
|| this.needSaveToLocalWhenForbidden(saveToLocalWhileForbidden, sendResult)) {
log.warn("send to server fail,save to local." + sendResult.getErrorMessage());
return this.saveMessageToLocal(message, Partition.RandomPartiton, timeout, unit);
}
else {
return sendResult;
}