@ -22,6 +22,7 @@ import org.springframework.web.client.RestTemplate;
import javax.sql.DataSource ;
import javax.sql.DataSource ;
import java.sql.Connection ;
import java.sql.Connection ;
import java.sql.SQLException ;
import java.sql.SQLException ;
import java.util.HashMap ;
import java.util.List ;
import java.util.List ;
import java.util.Map ;
import java.util.Map ;
import java.util.UUID ;
import java.util.UUID ;
@ -83,7 +84,9 @@ public class DfxAgentRunner implements ApplicationRunner {
this . print ( "상대 agent 설정 점검" ) ;
this . print ( "상대 agent 설정 점검" ) ;
List < AgentConfigDto . KnownAgent > knownAgentList = agentConfigReader . getAgentConfigDto ( ) . getKnownAgentList ( ) ;
List < AgentConfigDto . KnownAgent > knownAgentList = agentConfigReader . getAgentConfigDto ( ) . getKnownAgentList ( ) ;
if ( knownAgentList ! = null & & ! knownAgentList . isEmpty ( ) ) {
if ( knownAgentList ! = null & & ! knownAgentList . isEmpty ( ) ) {
Map < String , AgentConfigDto . KnownAgent > knownAgentMap = new HashMap < > ( ) ;
for ( AgentConfigDto . KnownAgent knownAgent : knownAgentList ) {
for ( AgentConfigDto . KnownAgent knownAgent : knownAgentList ) {
knownAgentMap . put ( knownAgent . getHostId ( ) , knownAgent ) ;
try {
try {
String messageUuid = UUID . randomUUID ( ) . toString ( ) ;
String messageUuid = UUID . randomUUID ( ) . toString ( ) ;
CommandDto commandDto = CommandDto . builder ( ) . commandType ( CommandDto . CommandType . ALIVE ) . messageUuid ( messageUuid ) . build ( ) ;
CommandDto commandDto = CommandDto . builder ( ) . commandType ( CommandDto . CommandType . ALIVE ) . messageUuid ( messageUuid ) . build ( ) ;
@ -99,25 +102,87 @@ public class DfxAgentRunner implements ApplicationRunner {
ackDto = objectMapper . readValue ( response , new TypeReference < AckDto > ( ) { } ) ;
ackDto = objectMapper . readValue ( response , new TypeReference < AckDto > ( ) { } ) ;
if ( AckDto . ResultType . PROCESS_SUCCESS = = ackDto . getResult ( ) ) {
if ( AckDto . ResultType . PROCESS_SUCCESS = = ackDto . getResult ( ) ) {
this . print ( "상대 agent " + knownAgent . getHostId ( ) + "(" + knownAgent . getHostName ( ) + "가 정상 동작합니다." ) ;
this . print ( "상대 agent " + knownAgent . getHostId ( ) + "(" + knownAgent . getHostName ( ) + "가 정상 동작합니다." ) ;
commandDto . setCommandType ( CommandDto . CommandType . INFORMATION ) ;
bodyEntity = new HttpEntity < > ( commandDto , httpHeaders ) ;
this . print ( "상대 agent " + knownAgent . getHostId ( ) + "(" + knownAgent . getHostName ( ) + ":" + knownAgent . getListenPort ( ) + ") DropBox 점검" ) ;
response = restTemplate . postForObject ( url , bodyEntity , String . class ) ;
ackDto = objectMapper . readValue ( response , new TypeReference < AckDto > ( ) { } ) ;
AgentConfigDto knownAgentConfigDto = objectMapper . readValue ( ackDto . getResultText ( ) , new TypeReference < AgentConfigDto > ( ) { } ) ;
List < AgentConfigDto . DropBox > knownAgentDropBoxList = knownAgentConfigDto . getDropBoxConfig ( ) . getDropBoxList ( ) ;
if ( knownAgent . getDropBoxIdList ( ) ! = null ) {
if ( knownAgentDropBoxList ! = null ) {
for ( String dropBoxId : knownAgent . getDropBoxIdList ( ) ) {
boolean isHasDropBoxId = false ;
for ( AgentConfigDto . DropBox knwonAgentDropBox : knownAgentDropBoxList ) {
if ( dropBoxId . equals ( knwonAgentDropBox . getDropBoxId ( ) ) ) {
isHasDropBoxId = true ;
}
}
if ( ! isHasDropBoxId ) {
this . print ( "DropBoxId " + dropBoxId + "에 해당하는 상대 agent " + knownAgent . getHostId ( ) + "(" + knownAgent . getHostName ( ) + ")의 DropBoxId가 존재하지 않습니다." ) ;
isValid = false ;
}
}
}
else {
this . print ( "상대 agent " + knownAgent . getHostId ( ) + "(" + knownAgent . getHostName ( ) + ")의 DropBox 설정이 존재하지 않습니다." ) ;
isValid = false ;
}
}
}
}
else {
else {
this . print ( "상대 agent " + knownAgent . getHostId ( ) + "(" + knownAgent . getHostName ( ) + "가 응답하였으나 정상 동작하지 않습니다." ) ;
this . print ( "상대 agent " + knownAgent . getHostId ( ) + "(" + knownAgent . getHostName ( ) + " ) 가 응답하였으나 정상 동작하지 않습니다.") ;
isValid = false ;
isValid = false ;
}
}
}
}
catch ( JsonProcessingException e ) {
catch ( JsonProcessingException e ) {
this . print ( "상대 agent " + knownAgent . getHostId ( ) + "(" + knownAgent . getHostName ( ) + "가 응답메시지가 정상적이지 않습니다. (" + e . getLocalizedMessage ( ) + ")" ) ;
this . print ( "상대 agent " + knownAgent . getHostId ( ) + "(" + knownAgent . getHostName ( ) + " ) 가 응답메시지가 정상적이지 않습니다. (" + e . getLocalizedMessage ( ) + ")" ) ;
isValid = false ;
isValid = false ;
}
}
catch ( ResourceAccessException e ) {
catch ( ResourceAccessException e ) {
this . print ( "상대 agent " + knownAgent . getHostId ( ) + "(" + knownAgent . getHostName ( ) + "가 응답하지 않습니다. (" + e . getLocalizedMessage ( ) + ")" ) ;
this . print ( "상대 agent " + knownAgent . getHostId ( ) + "(" + knownAgent . getHostName ( ) + " ) 가 응답하지 않습니다. (" + e . getLocalizedMessage ( ) + ")" ) ;
isValid = false ;
isValid = false ;
}
}
catch ( Exception e ) {
catch ( Exception e ) {
this . print ( "상대 agent " + knownAgent . getHostId ( ) + "(" + knownAgent . getHostName ( ) + "상태를 알 수 없습니다. (" + e . getLocalizedMessage ( ) + ")" ) ;
this . print ( "상대 agent " + knownAgent . getHostId ( ) + "(" + knownAgent . getHostName ( ) + " ) 상태를 알 수 없습니다. (" + e . getLocalizedMessage ( ) + ")" ) ;
isValid = false ;
isValid = false ;
}
}
}
}
this . print ( "" ) ;
this . print ( "Postman 설정 점검" ) ;
if ( agentConfigReader . getAgentConfigDto ( ) . getPostmanConfig ( ) ! = null ) {
this . print ( "Postman thread pool size: " + agentConfigReader . getAgentConfigDto ( ) . getPostmanConfig ( ) . getThreadPoolSize ( ) ) ;
List < AgentConfigDto . Postman > postManList = agentConfigReader . getAgentConfigDto ( ) . getPostmanConfig ( ) . getPostmanList ( ) ;
if ( postManList ! = null ) {
for ( AgentConfigDto . Postman postman : postManList ) {
AgentConfigDto . KnownAgent knownAgent = knownAgentMap . get ( postman . getRecipientHostId ( ) ) ;
if ( knownAgent ! = null ) {
boolean isHasDropBoxId = false ;
for ( String knownAgentDropBoxId : knownAgent . getDropBoxIdList ( ) ) {
if ( postman . getRecipientDropBoxId ( ) . equals ( knownAgentDropBoxId ) ) {
isHasDropBoxId = true ;
}
}
if ( ! isHasDropBoxId ) {
this . print ( "postman " + postman . getPostmanId ( ) + "에 대한 recipientDropBoxId(" + postman . getRecipientDropBoxId ( ) + ")가 knownAgent(" + knownAgent . getHostId ( ) + ") dropBoxIdList 목록에 존재하지 않습니다." ) ;
isValid = false ;
}
}
else {
this . print ( "postman " + postman . getPostmanId ( ) + "에 대한 recipientHostId(" + postman . getRecipientHostId ( ) + ")가 knownAgent 목록에 존재하지 않습니다." ) ;
isValid = false ;
}
}
}
else {
this . print ( "Postman 목록 없음" ) ;
}
}
else {
this . print ( "Postman 설정 없음" ) ;
isValid = false ;
}
}
}
else {
else {
this . print ( "상대 agent 설정은 포함되어 있지 않습니다." ) ;
this . print ( "상대 agent 설정은 포함되어 있지 않습니다." ) ;