에이전트 정보 수신 진행중

데이터 수신 완료
main
semin.baek 5 months ago
parent 5b977d602f
commit 75828ce439

@ -38,7 +38,7 @@ CREATE TABLE TB_DFX_AGENT_INFO (
, POSTMAN_COUNT DECIMAL(9) , POSTMAN_COUNT DECIMAL(9)
, DROPBOX_COUNT DECIMAL(9) , DROPBOX_COUNT DECIMAL(9)
, STATUS_CODE VARCHAR(64) NOT NULL , STATUS_CODE VARCHAR(64) NOT NULL
, LAST_STATUS_TS TIMESTAMP NOT NULL , LAST_STATUS_TS TIMESTAMPTZ(3) NOT NULL
, SETTINGS_DATA TEXT , SETTINGS_DATA TEXT
, CONSTRAINT PK_DFX_AGENT_CONFIG PRIMARY KEY (AGENT_ID) , CONSTRAINT PK_DFX_AGENT_CONFIG PRIMARY KEY (AGENT_ID)
); );
@ -74,12 +74,12 @@ COMMENT ON COLUMN TB_DFX_DROPBOX.DESCRIPTION IS 'DESCRIPTION';
CREATE TABLE TB_DFX_AGENT_MESSAGE_HISTORY ( CREATE TABLE TB_DFX_AGENT_MESSAGE_HISTORY (
SENDER_AGENT_ID VARCHAR(256) NOT NULL SENDER_AGENT_ID VARCHAR(256) NOT NULL
, SENDER_TS TIMESTAMP , SENDER_TS TIMESTAMPTZ(3)
, RECIPIENT_AGENT_ID VARCHAR(256) NOT NULL , RECIPIENT_AGENT_ID VARCHAR(256) NOT NULL
, RECIPIENT_TS TIMESTAMP , RECIPIENT_TS TIMESTAMPTZ(3)
, MESSAGE_UUID VARCHAR(36) NOT NULL , MESSAGE_UUID VARCHAR(36) NOT NULL
, MESSAGE_TYPE_CODE VARCHAR(64) , MESSAGE_TYPE_CODE VARCHAR(64)
, CONSOLE_RECEIVE_TS TIMESTAMP , CONSOLE_RECEIVE_TS TIMESTAMPTZ(3)
, PROCESS_STATUS_CODE VARCHAR(64) , PROCESS_STATUS_CODE VARCHAR(64)
, MESSAGE_DATA TEXT , MESSAGE_DATA TEXT
, MESSAGE_DATA_COUNT DECIMAL(9) DEFAULT 0 , MESSAGE_DATA_COUNT DECIMAL(9) DEFAULT 0

@ -41,7 +41,7 @@ async function loginProcess() {
<label for="floatingInput">Email address</label> <label for="floatingInput">Email address</label>
</div> </div>
<div class="form-floating"> <div class="form-floating">
<input type="password" class="form-control" id="floatingPassword" placeholder="Password" v-model="loginForm.password" @keydown.enter="loginProcess" /> <input type="password" class="form-control" id="floatingPassword" placeholder="Password" v-model="loginForm.password" />
<label for="floatingPassword">Password</label> <label for="floatingPassword">Password</label>
</div> </div>

@ -180,7 +180,8 @@ public class MessageUtils {
else { else {
CommandDto.CommandType commandType = EnumUtils.getEnum(CommandDto.CommandType.class, String.valueOf(map.get("commandType"))); CommandDto.CommandType commandType = EnumUtils.getEnum(CommandDto.CommandType.class, String.valueOf(map.get("commandType")));
String messageUuid = String.valueOf(map.get("messageUuid")); String messageUuid = String.valueOf(map.get("messageUuid"));
commandDto = CommandDto.builder().commandType(commandType).messageUuid(messageUuid).build(); String data = String.valueOf(map.get("data"));
commandDto = CommandDto.builder().commandType(commandType).messageUuid(messageUuid).data(data).build();
} }
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
throw new IllegalMessageException(e.getMessage()); throw new IllegalMessageException(e.getMessage());

@ -12,6 +12,7 @@ public class DfxAgentInfoDto {
private String agentId; private String agentId;
private String hostName; private String hostName;
private int listenPort; private int listenPort;
private String description;
private int postmanCount; private int postmanCount;
private int dropboxCount; private int dropboxCount;
private String statusCode; private String statusCode;

@ -6,12 +6,14 @@ import com.bsmlab.dfx.dfxconsole.app.communicate.service.ListenerService;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException; import java.io.IOException;
@Controller @RestController
@Slf4j @Slf4j
@RequiredArgsConstructor @RequiredArgsConstructor
public class ListenerController { public class ListenerController {
@ -24,7 +26,7 @@ public class ListenerController {
* @return * @return
*/ */
@PostMapping(value = "/listen") @PostMapping(value = "/listen")
public AckDto listener(HttpServletRequest request) { public ResponseEntity<AckDto> listener(HttpServletRequest request) {
AckDto ackDto = AckDto.builder().build(); AckDto ackDto = AckDto.builder().build();
try { try {
String bodyString = ServletUtils.getBodyString(request); String bodyString = ServletUtils.getBodyString(request);
@ -32,14 +34,14 @@ public class ListenerController {
} catch (IOException e) { } catch (IOException e) {
ackDto = AckDto.builder().result(AckDto.ResultType.RECEIVE_FAIL).resultText(e.getLocalizedMessage()).messageUuid("").build(); ackDto = AckDto.builder().result(AckDto.ResultType.RECEIVE_FAIL).resultText(e.getLocalizedMessage()).messageUuid("").build();
} }
return ackDto; return ResponseEntity.ok().body(ackDto);
} }
/** /**
* command . * command .
*/ */
@PostMapping(value = "/command") @PostMapping(value = "/command")
public AckDto command(HttpServletRequest request) { public ResponseEntity<AckDto> command(HttpServletRequest request) {
AckDto ackDto = AckDto.builder().build(); AckDto ackDto = AckDto.builder().build();
try { try {
String bodyString = ServletUtils.getBodyString(request); String bodyString = ServletUtils.getBodyString(request);
@ -47,6 +49,6 @@ public class ListenerController {
} catch (IOException e) { } catch (IOException e) {
ackDto = AckDto.builder().result(AckDto.ResultType.RECEIVE_FAIL).resultText(e.getLocalizedMessage()).messageUuid("").build(); ackDto = AckDto.builder().result(AckDto.ResultType.RECEIVE_FAIL).resultText(e.getLocalizedMessage()).messageUuid("").build();
} }
return ackDto; return ResponseEntity.ok().body(ackDto);
} }
} }

@ -56,7 +56,8 @@ public class ListenerService {
AgentConfigDto agentConfigDto = objectMapper.readValue(commandDto.getData(), new TypeReference<AgentConfigDto>(){}); AgentConfigDto agentConfigDto = objectMapper.readValue(commandDto.getData(), new TypeReference<AgentConfigDto>(){});
if(agentConfigDto != null && StringUtils.isNotEmpty(agentConfigDto.getMyHostId())) { if(agentConfigDto != null && StringUtils.isNotEmpty(agentConfigDto.getMyHostId())) {
DfxAgentInfoDto dfxAgentInfoDto = DfxAgentInfoDto.builder() DfxAgentInfoDto dfxAgentInfoDto = DfxAgentInfoDto.builder()
.agentId(agentConfigDto.getMyHostId()).hostName(agentConfigDto.getMyHostName()).listenPort(agentConfigDto.getMyListenPort()) .agentId(agentConfigDto.getMyHostId()).hostName(agentConfigDto.getMyHostName())
.listenPort(agentConfigDto.getMyListenPort()).description(agentConfigDto.getDescription())
.postmanCount(agentConfigDto.getPostmanConfig().getPostmanList().size()) .postmanCount(agentConfigDto.getPostmanConfig().getPostmanList().size())
.dropboxCount(agentConfigDto.getDropBoxConfig().getDropBoxList().size()) .dropboxCount(agentConfigDto.getDropBoxConfig().getDropBoxList().size())
.settingsData(commandDto.getData()).lastStatusTs(System.currentTimeMillis()).statusCode("STATUS_OK") .settingsData(commandDto.getData()).lastStatusTs(System.currentTimeMillis()).statusCode("STATUS_OK")

@ -0,0 +1,35 @@
package com.bsmlab.dfx.dfxconsole.framework.support.mybatis.handler;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
import java.sql.*;
@MappedTypes(Long.class)
@MappedJdbcTypes(JdbcType.TIMESTAMP_WITH_TIMEZONE)
public class EpochMillisWithTimeZoneTypeHandler extends BaseTypeHandler<Long> {
@Override
public void setNonNullParameter(PreparedStatement ps, int i, Long parameter, JdbcType jdbcType) throws SQLException {
ps.setTimestamp(i, new Timestamp(parameter)); // 밀리초 → java.sql.Timestamp
}
@Override
public Long getNullableResult(ResultSet rs, String columnName) throws SQLException {
Timestamp ts = rs.getTimestamp(columnName);
return ts == null ? null : ts.getTime(); // Timestamp → 밀리초 long
}
@Override
public Long getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
Timestamp ts = rs.getTimestamp(columnIndex);
return ts == null ? null : ts.getTime();
}
@Override
public Long getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
Timestamp ts = cs.getTimestamp(columnIndex);
return ts == null ? null : ts.getTime();
}
}

@ -39,7 +39,7 @@ server:
include-stacktrace: always include-stacktrace: always
port: 17443 port: 17443
ssl: ssl:
enabled: true enabled: false
certificate: ${user.home}/.vite-plugin-mkcert/bsm-lab.dev.pem certificate: ${user.home}/.vite-plugin-mkcert/bsm-lab.dev.pem
certificate-private-key: ${user.home}/.vite-plugin-mkcert/bsm-lab.dev-key.pem certificate-private-key: ${user.home}/.vite-plugin-mkcert/bsm-lab.dev-key.pem
@ -49,22 +49,25 @@ mybatis:
call-setters-on-nulls: true call-setters-on-nulls: true
jdbc-type-for-null: NULL jdbc-type-for-null: NULL
use-generated-keys: true use-generated-keys: true
mapper-locations: /mapper/**/*.xml mapper-locations: classpath*:/mapper/**/*.xml
type-handlers-package: com.bsmlab.dfx.dfxconsole.framework.support.mybatis.handler
logging: logging:
level: level:
log4jdbc.log4j2: WARN
com: com:
zaxxer: zaxxer:
hikari: INFO hikari: INFO
javax: javax:
sql: sql:
DataSource: OFF DataSource: OFF
org.mybatis: WARN
jdbc: jdbc:
audit: OFF audit: OFF
resultset: OFF resultset: OFF
resultsettable: INFO #SQL 결과 데이터 Table을 로그로 남긴다. resultsettable: INFO #SQL 결과 데이터 Table을 로그로 남긴다.
sqlonly: OFF #SQL만 로그로 남긴다. sqlonly: OFF #SQL만 로그로 남긴다.
sqltiming: INFO #SQL과 소요시간을 표기한다. sqltiming: DEBUG #SQL과 소요시간을 표기한다.
connection : OFF # 커넥션 확인가능 connection : OFF # 커넥션 확인가능
com.bsmlab.dfx: DEBUG com.bsmlab.dfx: DEBUG
org.springframework: INFO org.springframework: INFO

@ -0,0 +1,7 @@
log4jdbc.spylogdelegator.name=net.sf.log4jdbc.log.slf4j.Slf4jSpyLogDelegator
log4jdbc.dump.sql.maxlinelength=-1
log4jdbc.dump.sql.select=true
log4jdbc.dump.sql.insert=true
log4jdbc.dump.sql.update=true
log4jdbc.dump.sql.delete=true
log4jdbc.trim.sql=true

@ -4,7 +4,9 @@
<select id="selectDfxAgentInfoList" resultType="com.bsmlab.dfx.dfxconsole.app.agent.service.DfxAgentInfoDto"> <select id="selectDfxAgentInfoList" resultType="com.bsmlab.dfx.dfxconsole.app.agent.service.DfxAgentInfoDto">
<![CDATA[ <![CDATA[
SELECT AGENT_ID, HOST_NAME, LISTEN_PORT, DESCRIPTION, POSTMAN_COUNT, DROPBOX_COUNT, STATUS_CODE, LAST_STATUS_TS, SETTINGS_DATA SELECT AGENT_ID, HOST_NAME, LISTEN_PORT, DESCRIPTION, POSTMAN_COUNT, DROPBOX_COUNT, STATUS_CODE
, (EXTRACT(EPOCH FROM LAST_STATUS_TS) * 1000)::BIGINT AS LAST_STATUS_TS
, SETTINGS_DATA
, TO_CHAR(LAST_STATUS_TS, 'YYYY-MM-DD HH24:MI:SS') AS LAST_STATUS_TIME_STRING , TO_CHAR(LAST_STATUS_TS, 'YYYY-MM-DD HH24:MI:SS') AS LAST_STATUS_TIME_STRING
FROM TB_DFX_AGENT_INFO FROM TB_DFX_AGENT_INFO
ORDER BY HOST_NAME, AGENT_ID ORDER BY HOST_NAME, AGENT_ID
@ -13,7 +15,9 @@
<select id="selectDfxAgentInfoByAgentId" parameterType="com.bsmlab.dfx.dfxconsole.app.agent.service.DfxAgentInfoDto" resultType="com.bsmlab.dfx.dfxconsole.app.agent.service.DfxAgentInfoDto"> <select id="selectDfxAgentInfoByAgentId" parameterType="com.bsmlab.dfx.dfxconsole.app.agent.service.DfxAgentInfoDto" resultType="com.bsmlab.dfx.dfxconsole.app.agent.service.DfxAgentInfoDto">
<![CDATA[ <![CDATA[
SELECT AGENT_ID, HOST_NAME, LISTEN_PORT, DESCRIPTION, POSTMAN_COUNT, DROPBOX_COUNT, STATUS_CODE, LAST_STATUS_TS, SETTINGS_DATA SELECT AGENT_ID, HOST_NAME, LISTEN_PORT, DESCRIPTION, POSTMAN_COUNT, DROPBOX_COUNT, STATUS_CODE
, (EXTRACT(EPOCH FROM LAST_STATUS_TS) * 1000)::BIGINT AS LAST_STATUS_TS
, SETTINGS_DATA
, TO_CHAR(LAST_STATUS_TS, 'YYYY-MM-DD HH24:MI:SS') AS LAST_STATUS_TIME_STRING , TO_CHAR(LAST_STATUS_TS, 'YYYY-MM-DD HH24:MI:SS') AS LAST_STATUS_TIME_STRING
FROM TB_DFX_AGENT_INFO FROM TB_DFX_AGENT_INFO
WHERE 1 = 1 WHERE 1 = 1
@ -24,10 +28,14 @@
<insert id="insertDfxAgentInfo" parameterType="com.bsmlab.dfx.dfxconsole.app.agent.service.DfxAgentInfoDto"> <insert id="insertDfxAgentInfo" parameterType="com.bsmlab.dfx.dfxconsole.app.agent.service.DfxAgentInfoDto">
<![CDATA[ <![CDATA[
INSERT INTO TB_DFX_AGENT_INFO ( INSERT INTO TB_DFX_AGENT_INFO (
AGENT_ID, HOST_NAME, LISTEN_PORT, DESCRIPTION, POSTMAN_COUNT, DROPBOX_COUNT, STATUS_CODE, LAST_STATUS_TS, SETTINGS_DATA AGENT_ID, HOST_NAME, LISTEN_PORT, DESCRIPTION, POSTMAN_COUNT, DROPBOX_COUNT, STATUS_CODE
, LAST_STATUS_TS
, SETTINGS_DATA
) )
VALUES ( VALUES (
#{agentId}, #{hostName}, #{listenPort}, #{description}, #{postmanCount}, #{dropboxCount}, #{statusCode}, #{lastStatusTs}, #{settingsData} #{agentId}, #{hostName}, #{listenPort}, #{description}, #{postmanCount}, #{dropboxCount}, #{statusCode}
, #{lastStatusTs, jdbcType=TIMESTAMP_WITH_TIMEZONE, javaType=long}
, #{settingsData}
) )
]]> ]]>
</insert> </insert>
@ -41,7 +49,7 @@
, POSTMAN_COUNT = #{postmanCount} , POSTMAN_COUNT = #{postmanCount}
, DROPBOX_COUNT = #{dropboxCount} , DROPBOX_COUNT = #{dropboxCount}
, STATUS_CODE = #{statusCode} , STATUS_CODE = #{statusCode}
, LAST_STATUS_TS = #{lastStatusTs} , LAST_STATUS_TS = #{lastStatusTs, jdbcType=TIMESTAMP_WITH_TIMEZONE, javaType=long}
, SETTINGS_DATA = #{settingsData} , SETTINGS_DATA = #{settingsData}
WHERE 1 = 1 WHERE 1 = 1
AND AGENT_ID = #{agentId} AND AGENT_ID = #{agentId}

@ -41,7 +41,7 @@
SENDER_AGENT_ID, SENDER_TS, RECIPIENT_AGENT_ID, RECIPIENT_TS, MESSAGE_UUID, MESSAGE_TYPE_CODE, CONSOLE_RECEIVE_TS, PROCESS_STATUS_CODE, MESSAGE_DATA, MESSAGE_DATA_COUNT SENDER_AGENT_ID, SENDER_TS, RECIPIENT_AGENT_ID, RECIPIENT_TS, MESSAGE_UUID, MESSAGE_TYPE_CODE, CONSOLE_RECEIVE_TS, PROCESS_STATUS_CODE, MESSAGE_DATA, MESSAGE_DATA_COUNT
) )
VALUES ( VALUES (
#{senderAgentId}, #{senderTs}, #{recipientAgentId}, #{recipientTs}, #{messageUuid}, #{messageTypeCode}, #{consoleReceiveTs}, #{processStatusCode}, #{messageData}, #{messageDataCount} #{senderAgentId}, #{senderTs, jdbcType=TIMESTAMP_WITH_TIMEZONE, javaType=long}, #{recipientAgentId}, #{recipientTs, jdbcType=TIMESTAMP_WITH_TIMEZONE, javaType=long}, #{messageUuid}, #{messageTypeCode}, #{consoleReceiveTs, jdbcType=TIMESTAMP_WITH_TIMEZONE, javaType=long}, #{processStatusCode}, #{messageData}, #{messageDataCount}
) )
]]> ]]>
</insert> </insert>

Loading…
Cancel
Save