User agent 명명

main
semin.baek 7 months ago
parent 7923c52d49
commit 9a70ed8474

@ -5,7 +5,28 @@ plugins {
}
group = 'com.bsmlab.dfx'
version = '0.0.1-SNAPSHOT'
version = '1.0.1'
// git commit hash -> application.yml
def gitCommitId = ''
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = stdout;
}
gitCommitId = stdout.toString().trim()
}
catch (Exception ignored) {
print "git commit ID is not available."
}
// gradle project properties -> application.yml
processResources {
filesMatching('**/application.yml') {
expand(project.properties + [commitId: gitCommitId])
}
}
java {
toolchain {

@ -92,6 +92,7 @@ public class DfxAgentRunner implements ApplicationRunner {
CommandDto commandDto = CommandDto.builder().commandType(CommandDto.CommandType.ALIVE).messageUuid(messageUuid).build();
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
httpHeaders.set("User-Agent", agentConfigReader.getApplicationName() + ", version: " + agentConfigReader.getApplicationVersion() + "(" + agentConfigReader.getApplicationCommitId() + ")" + ", host ID: " + agentConfigReader.getAgentConfigDto().getMyHostId());
HttpEntity<CommandDto> bodyEntity = new HttpEntity<>(commandDto, httpHeaders);
RestTemplate restTemplate = new RestTemplate();
String url = "http://" + knownAgent.getHostName() + ":" + knownAgent.getListenPort() + "/command";

@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.DatabindException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.File;
@ -19,6 +20,12 @@ import java.util.Map;
public class AgentConfigReader {
private AgentConfigDto agentConfigDto = null;
private Map<String, String> knownAgentStatusMap;
@Value("${spring.application.name}")
private String applicationName;
@Value("${spring.application.version}")
private String applicationVersion;
@Value("${spring.application.commitId}")
private String applicationCommitId;
public void loadConfigFile(String configFilePath) {
try {

@ -135,6 +135,7 @@ public class DropBoxSchedulerService {
AckDto ackDto = AckDto.builder().result(resultType).messageUuid(receiveMessageDto.getMessageUuid()).resultText(processMessage).build();
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
httpHeaders.set("User-Agent", agentConfigReader.getApplicationName() + ", version: " + agentConfigReader.getApplicationVersion() + "(" + agentConfigReader.getApplicationCommitId() + ")" + ", host ID: " + agentConfigReader.getAgentConfigDto().getMyHostId());
HttpEntity<AckDto> bodyEntity = new HttpEntity<>(ackDto, httpHeaders);
RestTemplate restTemplate = new RestTemplate();
AgentConfigDto.KnownAgent knownAgent = agentConfigReader.getKnownAgent(receiveMessageDto.getSenderHostId());

@ -91,6 +91,7 @@ public class PostmanSchedulerService {
.data(dataString).build();
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
httpHeaders.set("User-Agent", agentConfigReader.getApplicationName() + ", version: " + agentConfigReader.getApplicationVersion() + "(" + agentConfigReader.getApplicationCommitId() + ")" + ", host ID: " + agentConfigReader.getAgentConfigDto().getMyHostId());
HttpEntity<ReceiveMessageDto> bodyEntity = new HttpEntity<>(receiveMessageDto, httpHeaders);
RestTemplate restTemplate = new RestTemplate();
String url = "http://" + knownAgent.getHostName() + ":" + knownAgent.getListenPort() + "/listen";
@ -169,6 +170,7 @@ public class PostmanSchedulerService {
// http 준비
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.MULTIPART_FORM_DATA);
httpHeaders.set("User-Agent", agentConfigReader.getApplicationName() + ", version: " + agentConfigReader.getApplicationVersion() + "(" + agentConfigReader.getApplicationCommitId() + ")" + ", host ID: " + agentConfigReader.getAgentConfigDto().getMyHostId());
MultiValueMap<String, Object> body = new LinkedMultiValueMap<>();
// 첫 번째 멀티파트는 message json
body.add("json", new HttpEntity<>(messageString, httpHeaders));

@ -46,6 +46,7 @@ public class StatusCheckerSchedulerService {
CommandDto commandDto = CommandDto.builder().commandType(CommandDto.CommandType.ALIVE).messageUuid(messageUuid).build();
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
httpHeaders.set("User-Agent", agentConfigReader.getApplicationName() + ", version: " + agentConfigReader.getApplicationVersion() + "(" + agentConfigReader.getApplicationCommitId() + ")" + ", host ID: " + agentConfigReader.getAgentConfigDto().getMyHostId());
HttpEntity<CommandDto> bodyEntity = new HttpEntity<>(commandDto, httpHeaders);
RestTemplate restTemplate = new RestTemplate();
String url = "http://" + knownAgent.getHostName() + ":" + knownAgent.getListenPort() + "/command";

@ -1,6 +1,8 @@
spring:
application:
name: DFX Agent
name: DFXAgent
version: ${version}
commitId: ${commitId}
servlet:
multipart:
max-file-size: 1GB

Loading…
Cancel
Save