|
|
@ -177,29 +177,38 @@ public class LogClient implements AutoCloseable { |
|
|
|
* |
|
|
|
* |
|
|
|
* @param host host |
|
|
|
* @param host host |
|
|
|
* @param path path |
|
|
|
* @param path path |
|
|
|
* @return remove task status |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Boolean removeTaskLog(@NonNull Host host, String path) { |
|
|
|
public void removeTaskLog(@NonNull Host host, String path) { |
|
|
|
logger.info("Remove task log from host: {} logPath {}", host, path); |
|
|
|
logger.info("Begin remove task log from host: {} logPath {}", host, path); |
|
|
|
RemoveTaskLogRequestCommand request = new RemoveTaskLogRequestCommand(path); |
|
|
|
RemoveTaskLogRequestCommand request = new RemoveTaskLogRequestCommand(path); |
|
|
|
try { |
|
|
|
try { |
|
|
|
Command command = request.convert2Command(); |
|
|
|
Command command = request.convert2Command(); |
|
|
|
Command response = this.client.sendSync(host, command, LOG_REQUEST_TIMEOUT); |
|
|
|
client.sendAsync(host, command, LOG_REQUEST_TIMEOUT, responseFuture -> { |
|
|
|
if (response != null) { |
|
|
|
if (responseFuture.getCause() != null) { |
|
|
|
RemoveTaskLogResponseCommand taskLogResponse = |
|
|
|
logger.error("Remove task log from host: {} logPath {} error, meet an unknown exception", host, |
|
|
|
|
|
|
|
path, responseFuture.getCause()); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Command response = responseFuture.getResponseCommand(); |
|
|
|
|
|
|
|
if (response == null) { |
|
|
|
|
|
|
|
logger.error("Remove task log from host: {} logPath {} error, response is null", host, path); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
RemoveTaskLogResponseCommand removeTaskLogResponse = |
|
|
|
JSONUtils.parseObject(response.getBody(), RemoveTaskLogResponseCommand.class); |
|
|
|
JSONUtils.parseObject(response.getBody(), RemoveTaskLogResponseCommand.class); |
|
|
|
return taskLogResponse.getStatus(); |
|
|
|
if (removeTaskLogResponse.getStatus()) { |
|
|
|
|
|
|
|
logger.info("Success remove task log from host: {} logPath {}", host, path); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
logger.error("Remove task log from host: {} logPath {} error", host, path); |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
}); |
|
|
|
} catch (InterruptedException ex) { |
|
|
|
} catch (InterruptedException interruptedException) { |
|
|
|
Thread.currentThread().interrupt(); |
|
|
|
Thread.currentThread().interrupt(); |
|
|
|
logger.error( |
|
|
|
logger.error("Remove task log from host: {} logPath {} error, the current thread has been interrupted", |
|
|
|
"Remove task log from host: {}, logPath: {} error, the current thread has been interrupted", |
|
|
|
host, |
|
|
|
host, path, ex); |
|
|
|
path, interruptedException); |
|
|
|
return false; |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("Remove task log from host: {}, logPath: {} error", host, path, e); |
|
|
|
logger.error("Remove task log from host: {}, logPath: {} error", host, path, e); |
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|