Skip to content

Commit

Permalink
correct code style
Browse files Browse the repository at this point in the history
  • Loading branch information
scwlkq committed Oct 30, 2023
1 parent 3dc506c commit c7bfe8e
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void handle(HttpExchange httpExchange) throws IOException {
} catch (Exception e) {
log.error("clientManage|redirectClientByIpPort|fail|ip={}|port={}|destEventMeshIp"
+
"={}|destEventMeshPort={},errMsg={}", ip, port, destEventMeshIp, destEventMeshPort, e);
"={}|destEventMeshPort={}", ip, port, destEventMeshIp, destEventMeshPort, e);
result = String.format("redirectClientByIpPort fail! sessionMap size {%d}, {clientIp=%s clientPort=%s "
+
"destEventMeshIp=%s destEventMeshPort=%s}, result {%s}, errorMsg : %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void handle(HttpExchange httpExchange) throws IOException {
} catch (Exception e) {
log.error("clientManage|redirectClientByPath|fail|path={}|destEventMeshIp"
+
"={}|destEventMeshPort={},errMsg={}", path, destEventMeshIp, destEventMeshPort, e);
"={}|destEventMeshPort={}", path, destEventMeshIp, destEventMeshPort, e);
result = String.format("redirectClientByPath fail! sessionMap size {%d}, {path=%s "
+
"destEventMeshIp=%s destEventMeshPort=%s}, result {%s}, errorMsg : %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void handle(HttpExchange httpExchange) throws IOException {
}
}
} catch (Exception e) {
log.error("clientManage|rejectClientByIpPort|fail|ip={}|port={},errMsg={}", ip, port, e);
log.error("clientManage|rejectClientByIpPort|fail|ip={}|port={}", ip, port, e);
result = String.format("rejectClientByIpPort fail! {ip=%s port=%s}, had reject {%s}, errorMsg : %s", ip,
port, NetUtils.addressToString(successRemoteAddrs), e.getMessage());
NetUtils.sendSuccessResponseHeaders(httpExchange);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void handle(HttpExchange httpExchange) throws IOException {
}
}
} catch (Exception e) {
log.error("clientManage|rejectClientBySubSystem|fail|subSystemId={},errMsg={}", subSystem, e);
log.error("clientManage|rejectClientBySubSystem|fail|subSystemId={}", subSystem, e);
result = String.format("rejectClientBySubSystem fail! sessionMap size {%d}, had reject {%s} , {"
+
"subSystemId=%s}, errorMsg : %s", sessionMap.size(), printClients(successRemoteAddrs),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ private void validateMsg(Package pkg) throws Exception {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
Session session = clientSessionGroupMapping.getSession(ctx);
UserAgent client = session == null ? null : session.getClient();
log.error("exceptionCaught, push goodbye to client|user={},errMsg={}", client, cause.fillInStackTrace());
log.error("exceptionCaught, push goodbye to client|user={}, errMsg={}", client, cause.fillInStackTrace());
String errMsg;
if (cause.toString().contains("value not one of declared Enum instance names")) {
errMsg = "Unknown Command type";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void process(final Package pkg, final ChannelHandlerContext ctx, long sta
pkg.getHeader().getSeq()));
Utils.writeAndFlush(res, startTime, taskExecuteTime, session.getContext(), session);
} catch (Throwable e) {
MESSAGE_LOGGER.error("HelloTask failed|address={},errMsg={}", ctx.channel().remoteAddress(), e);
MESSAGE_LOGGER.error("HelloTask failed|address={}", ctx.channel().remoteAddress(), e);
res.setHeader(new Header(HELLO_RESPONSE, OPStatus.FAIL.getCode(), Arrays.toString(e.getStackTrace()), pkg
.getHeader().getSeq()));
ctx.writeAndFlush(res).addListener(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void finish(Package msg) {

public static RequestContext context(Object key, Package request, CountDownLatch latch) throws Exception {
RequestContext c = new RequestContext(key, request, latch);
LogUtils.info(log, "_RequestContext|create|key=" + key);
LogUtils.info(log, "_RequestContext|create|key=", key);
return c;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void handle(Package msg, ChannelHandlerContext ctx) {
if (msg.getHeader().getCommand() == Command.BROADCAST_MESSAGE_TO_CLIENT) {
if (msg.getBody() instanceof EventMeshMessage) {
String body = ((EventMeshMessage) msg.getBody()).getBody();
LogUtils.info(log, "receive message -------------------------------" + body);
LogUtils.info(log, "receive message -------------------------------", body);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public static void main(String[] args) throws Exception {
Package rr = pubClient.rr(MessageUtils.rrMesssage("TEST-TOPIC-TCP-SYNC", i), 3000);
if (rr.getBody() instanceof EventMeshMessage) {
String body = ((EventMeshMessage) rr.getBody()).getBody();
LogUtils.info(log, "rrMessage: " + body + " "
+ "rr-reply-------------------------------------------------" + rr);
LogUtils.info(log, "rrMessage: " ,body ," "
,"rr-reply-------------------------------------------------", rr);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public EventMeshGrpcProducer(EventMeshGrpcClientConfig clientConfig) {
}

public <T> Response publish(T message) {
LogUtils.info(log, "Publish message " + message.toString());
LogUtils.info(log, "Publish message ", message.toString());
if (message instanceof CloudEvent) {
return cloudEventProducer.publish((CloudEvent) message);
} else if (message instanceof EventMeshMessage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,6 @@ public FileWebHookConfigOperation(final Properties properties) throws FileNotFou
this.webHookFilePath = webHookFilePath;
}

public static boolean writeToFile(final File webhookConfigFile, final WebHookConfig webHookConfig) {
// Wait for the previous cacheInit to complete in case of concurrency
synchronized (SharedLatchHolder.lock) {
try (FileOutputStream fos = new FileOutputStream(webhookConfigFile);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, StandardCharsets.UTF_8))) {
// Lock this file to prevent concurrent modification and it will be automatically unlocked when fos closes
fos.getChannel().lock();
bw.write(Objects.requireNonNull(JsonUtils.toJSONString(webHookConfig)));
} catch (IOException e) {
LogUtils.error(log, "write webhookConfig {} to file error", webHookConfig.getCallbackPath());
return false;
}
return true;
}
}

@Override
public Integer insertWebHookConfig(final WebHookConfig webHookConfig) {
if (!webHookConfig.getCallbackPath().startsWith(WebHookOperationConstant.CALLBACK_PATH_PREFIX)) {
Expand Down Expand Up @@ -178,6 +162,22 @@ private WebHookConfig getWebHookConfigFromFile(final File webhookConfigFile) {
return JsonUtils.parseObject(fileContent.toString(), WebHookConfig.class);
}

public static boolean writeToFile(final File webhookConfigFile, final WebHookConfig webHookConfig) {
// Wait for the previous cacheInit to complete in case of concurrency
synchronized (SharedLatchHolder.lock) {
try (FileOutputStream fos = new FileOutputStream(webhookConfigFile);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, StandardCharsets.UTF_8))) {
// Lock this file to prevent concurrent modification and it will be automatically unlocked when fos closes
fos.getChannel().lock();
bw.write(Objects.requireNonNull(JsonUtils.toJSONString(webHookConfig)));
} catch (IOException e) {
LogUtils.error(log, "write webhookConfig {} to file error", webHookConfig.getCallbackPath());
return false;
}
return true;
}
}

private String getWebhookConfigManuDir(final WebHookConfig webHookConfig) {
return webHookFilePath + WebHookOperationConstant.FILE_SEPARATOR + webHookConfig.getManufacturerName();
}
Expand Down

0 comments on commit c7bfe8e

Please sign in to comment.