Skip to content

Commit

Permalink
something rename
Browse files Browse the repository at this point in the history
  • Loading branch information
周倬贤 committed Mar 8, 2024
1 parent 886c754 commit e6081f6
Show file tree
Hide file tree
Showing 18 changed files with 96 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
@Mapper
public interface ConnectionMapper {

@Select("select COUNT(*) from connection where cluster_id=#{clusterId}")
Integer selectConnectionNumByCluster(ConnectionEntity connectionEntity);

@Select("SELECT * FROM connection")
List<ConnectionEntity> selectAll();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public interface StoreMapper {
+ "#{clusterId},#{storeId},#{storeType},#{host},#{runtimeId},#{topicList},#{diffType},#{port},#{jmxPort}"
+ ",#{startTimestamp},#{rack},#{status},#{endpointMap})")
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
void addStorage(StoreEntity storeEntity);
void addStore(StoreEntity storeEntity);

@Update("UPDATE store SET is_delete=1 WHERE cluster_id=#{clusterId} AND store_id=#{storeId}")
void deleteStoreByUnique(StoreEntity storeEntity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.springframework.stereotype.Service;

@Service
public class ConnectorConfigController {
public class ConnectorConfigService {

public List<ConfigEntity> getConnectorConfigFromInstance(Long clusterId, Long id) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.springframework.stereotype.Service;

@Service
public class RuntimeConfigController {
public class RuntimeConfigService {

public List<ConfigEntity> getRuntimeConfigFromInstance(Long clusterId, String host) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.springframework.stereotype.Service;

@Service
public class StorageConfigController {
public class StoreConfigService {

public List<ConfigEntity> getStorageConfigFromInstance(Long clusterId, String storeId) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.springframework.stereotype.Service;

@Service
public class TopicConfigController {
public class TopicConfigService {

public List<ConfigEntity> getTopicConfigFromInstance(Long clusterId, String name) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity;
import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity;
import org.apache.eventmesh.dashboard.console.service.config.ConfigService;
import org.apache.eventmesh.dashboard.console.service.config.instanceoperation.ConnectorConfigController;
import org.apache.eventmesh.dashboard.console.service.config.instanceoperation.ConnectorConfigService;
import org.apache.eventmesh.dashboard.console.service.connector.ConnectorDataService;

import java.util.List;
Expand All @@ -29,14 +29,17 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* Synchronous DB To Instance
*/
@Service
public class SynchronousConnectorConfigDBToInstanceTask {
public class SyncConnectorConfigTask {

@Autowired
private ConnectorDataService connectorDataService;

@Autowired
private ConnectorConfigController connectorConfigController;
private ConnectorConfigService connectorConfigService;
@Autowired
private ConfigService configService;

Expand All @@ -45,7 +48,7 @@ public void synchronousConnectorConfig(Long clusterId) {
for (ConnectorEntity connectorEntity : connectorEntities) {

ConcurrentHashMap<String, String> connectorConfigMapFromInstance = this.configListToMap(
connectorConfigController.getConnectorConfigFromInstance(clusterId, connectorEntity.getId()));
connectorConfigService.getConnectorConfigFromInstance(clusterId, connectorEntity.getId()));

ConfigEntity configEntity = this.getConfigEntityBelongInstance(clusterId, connectorEntity.getId());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity;
import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity;
import org.apache.eventmesh.dashboard.console.service.config.ConfigService;
import org.apache.eventmesh.dashboard.console.service.config.instanceoperation.RuntimeConfigController;
import org.apache.eventmesh.dashboard.console.service.config.instanceoperation.RuntimeConfigService;
import org.apache.eventmesh.dashboard.console.service.runtime.RuntimeService;

import java.util.List;
Expand All @@ -30,14 +30,18 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* Synchronous DB To Instance
*/

@Service
public class SynchronousRuntimeConfigDBToInstanceTask {
public class SyncRuntimeConfigTask {

@Autowired
private RuntimeService runtimeService;

@Autowired
private RuntimeConfigController runtimeConfigController;
private RuntimeConfigService runtimeConfigService;

@Autowired
private ConfigService configService;
Expand All @@ -47,7 +51,7 @@ public void synchronousRuntimeConfig(Long clusterId) {
for (RuntimeEntity runtimeEntity : runtimeEntityList) {

ConcurrentHashMap<String, String> runtimeConfigMapFromInstance = this.configListToMap(
runtimeConfigController.getRuntimeConfigFromInstance(clusterId, runtimeEntity.getHost()));
runtimeConfigService.getRuntimeConfigFromInstance(clusterId, runtimeEntity.getHost()));

ConfigEntity configEntity = this.getConfigEntityBelongInstance(clusterId, runtimeEntity.getId());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,67 +18,71 @@
package org.apache.eventmesh.dashboard.console.service.config.synchronous;

import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity;
import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity;
import org.apache.eventmesh.dashboard.console.entity.storage.StoreEntity;
import org.apache.eventmesh.dashboard.console.service.config.ConfigService;
import org.apache.eventmesh.dashboard.console.service.config.instanceoperation.StorageConfigController;
import org.apache.eventmesh.dashboard.console.service.runtime.RuntimeService;
import org.apache.eventmesh.dashboard.console.service.config.instanceoperation.StoreConfigService;
import org.apache.eventmesh.dashboard.console.service.store.StoreService;

import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* Synchronous DB To Instance
*/

@Service
public class SynchronousStorageConfigDBToInstanceTask {
public class SyncStoreConfigTask {

@Autowired
private RuntimeService runtimeService;
private StoreService storeService;

@Autowired
private StorageConfigController storageConfigController;
private StoreConfigService storeConfigService;

@Autowired
private ConfigService configService;

public void synchronousRuntimeConfig(Long clusterId) {
List<RuntimeEntity> runtimeEntityList = runtimeService.getRuntimeByClusterId(clusterId);
for (RuntimeEntity runtimeEntity : runtimeEntityList) {
public void synchronousStoreConfig(Long clusterId) {
List<StoreEntity> storeEntityList = storeService.selectStoreByCluster(clusterId);
for (StoreEntity storeEntity : storeEntityList) {

ConcurrentHashMap<String, String> runtimeConfigMapFromInstance = this.configListToMap(
storageConfigController.getStorageConfigFromInstance(clusterId, runtimeEntity.getHost()));
ConcurrentHashMap<String, String> storeConfigMapFromInstance = this.configListToMap(
storeConfigService.getStorageConfigFromInstance(clusterId, storeEntity.getHost()));

ConfigEntity configEntity = this.getConfigEntityBelongInstance(clusterId, runtimeEntity.getId());
ConfigEntity configEntity = this.getConfigEntityBelongInstance(clusterId, storeEntity.getId());

ConcurrentHashMap<String, String> runtimeConfigMapFromDb = this.configListToMap(configService.selectByInstanceId(configEntity));
ConcurrentHashMap<String, String> storeConfigMapFromDb = this.configListToMap(configService.selectByInstanceId(configEntity));

ConcurrentHashMap<String, String> updateConfigMap = new ConcurrentHashMap<>();

runtimeConfigMapFromInstance.entrySet().forEach(n -> {
if (runtimeConfigMapFromDb.remove(n.getKey(), n.getValue())) {
runtimeConfigMapFromInstance.remove(n.getKey());
storeConfigMapFromInstance.entrySet().forEach(n -> {
if (storeConfigMapFromDb.remove(n.getKey(), n.getValue())) {
storeConfigMapFromInstance.remove(n.getKey());
}
if (runtimeConfigMapFromDb.get(n.getKey()) != null) {
updateConfigMap.put(n.getKey(), runtimeConfigMapFromDb.get(n.getKey()));
runtimeConfigMapFromInstance.remove(n.getKey());
runtimeConfigMapFromDb.remove(n.getKey());
if (storeConfigMapFromDb.get(n.getKey()) != null) {
updateConfigMap.put(n.getKey(), storeConfigMapFromDb.get(n.getKey()));
storeConfigMapFromInstance.remove(n.getKey());
storeConfigMapFromDb.remove(n.getKey());
}
});
//add runtimeConfigMapFromDb
//add storeConfigMapFromDb

//update updateConfigMap

//delete runtimeConfigMapFromInstance
//delete storeConfigMapFromInstance
}
}

private ConcurrentHashMap<String, String> configListToMap(List<ConfigEntity> configEntityList) {
ConcurrentHashMap<String, String> runtimeConfigMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String, String> storeConfigMap = new ConcurrentHashMap<>();
configEntityList.forEach(n -> {
runtimeConfigMap.put(n.getConfigName(), n.getConfigValue());
storeConfigMap.put(n.getConfigName(), n.getConfigValue());
}
);
return runtimeConfigMap;
return storeConfigMap;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity;
import org.apache.eventmesh.dashboard.console.entity.topic.TopicEntity;
import org.apache.eventmesh.dashboard.console.service.config.ConfigService;
import org.apache.eventmesh.dashboard.console.service.config.instanceoperation.TopicConfigController;
import org.apache.eventmesh.dashboard.console.service.config.instanceoperation.TopicConfigService;
import org.apache.eventmesh.dashboard.console.service.topic.TopicService;

import java.util.List;
Expand All @@ -29,15 +29,18 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* Synchronous DB To Instance
*/

@Service
public class SynchronousTopicConfigDBToInstanceTask {
public class SyncTopicConfigTask {

@Autowired
private TopicService topicService;

@Autowired
private TopicConfigController topicConfigController;
private TopicConfigService topicConfigService;

@Autowired
private ConfigService configService;
Expand All @@ -47,7 +50,7 @@ public void synchronousTopicConfig(Long clusterId) {
for (TopicEntity topicEntity : topicEntityList) {

ConcurrentHashMap<String, String> topicConfigMapFromInstance = this.configListToMap(
topicConfigController.getTopicConfigFromInstance(clusterId, topicEntity.getTopicName()));
topicConfigService.getTopicConfigFromInstance(clusterId, topicEntity.getTopicName()));

ConfigEntity configEntity = this.getConfigEntityBelongInstance(clusterId, topicEntity.getId());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@
import java.util.List;

/**
* Service providing data of connections.
* Service providing ConnectionEntity data.
*/
public interface ConnectionDataService {

Integer selectConnectionNumByCluster(Long clusterId);

List<ConnectionEntity> getAllConnections();

List<ConnectionEntity> getAllConnectionsByClusterId(Long clusterId);

void replaceAllConnections(List<ConnectionEntity> connectionEntityList);
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,22 @@ public class ConnectionDataServiceDatabaseImpl implements ConnectionDataService
@Autowired
private ConnectionMapper connectionMapper;


@Override
public List<ConnectionEntity> getAllConnectionsByClusterId(Long clusterId) {
ConnectionEntity connectionEntity = new ConnectionEntity();
connectionEntity.setClusterId(clusterId);
return connectionMapper.selectByClusterId(connectionEntity);
}


@Override
public Integer selectConnectionNumByCluster(Long clusterId) {
ConnectionEntity connectionEntity = new ConnectionEntity();
connectionEntity.setClusterId(clusterId);
return connectionMapper.selectConnectionNumByCluster(connectionEntity);
}

@Override
public List<ConnectionEntity> getAllConnections() {
return connectionMapper.selectAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.List;

/**
* Service providing data of connectors.
* Service providing ConnectorEntity data.
*/
public interface ConnectorDataService {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public class StoreServiceImpl implements StoreService {
private StoreMapper storeMapper;

@Override
public void addStorage(StoreEntity storeEntity) {
storeMapper.addStorage(storeEntity);
public void addStore(StoreEntity storeEntity) {
storeMapper.addStore(storeEntity);
}

@Override
Expand All @@ -43,7 +43,9 @@ public void deleteStoreByUnique(StoreEntity storeEntity) {
}

@Override
public List<StoreEntity> selectStoreByCluster(StoreEntity storeEntity) {
public List<StoreEntity> selectStoreByCluster(Long clusterId) {
StoreEntity storeEntity = new StoreEntity();
storeEntity.setClusterId(clusterId);
return storeMapper.selectStoreByCluster(storeEntity);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
*/
public interface StoreService {

void addStorage(StoreEntity storeEntity);
void addStore(StoreEntity storeEntity);

void deleteStoreByUnique(StoreEntity storeEntity);

List<StoreEntity> selectStoreByCluster(StoreEntity storeEntity);
List<StoreEntity> selectStoreByCluster(Long clusterId);

void updateStoreByUnique(StoreEntity storeEntity);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
* Service about Topic
*/
public interface TopicService {

Integer selectTopicNumByCluster(Long clusterId);

List<TopicEntity> getTopicList(TopicEntity topicEntity);

void addTopic(TopicEntity topicEntity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ public class TopicServiceImpl implements TopicService {
OprGroupMemberMapper oprGroupMemberMapper;


@Override
public Integer selectTopicNumByCluster(Long clusterId) {
TopicEntity topicEntity = new TopicEntity();
topicEntity.setClusterId(clusterId);
return topicMapper.selectTopicNumByCluster(topicEntity);
}

@Override
public List<TopicEntity> getTopicList(TopicEntity topicEntity) {
return topicMapper.getTopicList(topicEntity);
Expand Down
Loading

0 comments on commit e6081f6

Please sign in to comment.