| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package com.sig.comm.server.cluster;
- import com.its.common.cluster.service.AbstractClusterMasterService;
- import com.its.common.cluster.vo.ClusterMessage;
- import com.its.common.cluster.vo.ClusterMessageData;
- import com.sig.comm.server.cluster.dto.ClusterNodeDto;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.stereotype.Service;
- import java.util.ArrayList;
- import java.util.List;
- @Slf4j
- @Service
- public class ClusterMasterService extends AbstractClusterMasterService {
- private final int clusterId;
- public ClusterMasterService(ClusterConfig clusterConfig) {
- super(clusterConfig);
- this.clusterId = clusterConfig.getId();
- }
- @Override
- public void election(int clusterId, boolean isMaster, boolean isMasterChanged) {
- if (isMasterChanged) {
- log.info("ClusterMasterService:election: master state changed: clusterId: {}, master: {}", clusterId, isMaster);
- }
- }
- @Override
- public void onClusterMessage(ClusterMessage message) {
- // 슬래이브로 부터 수신되는 메시지 처리
- List<ClusterNodeDto> infos = new ArrayList<>();
- for (ClusterMessageData info : message.getInfos()) {
- if (info instanceof ClusterNodeDto) {
- infos.add((ClusterNodeDto)info);
- }
- }
- // log.info("onClusterMessage: nodeId = {}, master = {}, serverTime = {}, infos = {} EA.",
- // message.getNodeId(), message.isMaster(), message.getServerTime(), infos.size());
- // for (ClusterNodeDto center : infos) {
- // CenterDto centerDto = ApplicationRepository.CENTER_MAP.get(center.getCenterId());
- // if (centerDto == null) {
- // continue;
- // }
- // // 서버 모드이기 때문에 클러스터의 연결정보를 확인하고 메모리를 업데이트 한다.
- // }
- }
- }
|