From d76cc6154c8477201a48c18c66a1a896b87d66cd Mon Sep 17 00:00:00 2001 From: xwm1992 Date: Mon, 13 Nov 2023 18:00:22 +0800 Subject: [PATCH] add filters --- .../org/apache/eventmesh/api/meta/MetaService.java | 6 ++++++ .../meta/consul/service/ConsulMetaService.java | 8 ++++++++ .../apache/eventmesh/runtime/meta/MetaStorage.java | 11 +++++++++++ 3 files changed, 25 insertions(+) diff --git a/eventmesh-meta/eventmesh-meta-api/src/main/java/org/apache/eventmesh/api/meta/MetaService.java b/eventmesh-meta/eventmesh-meta-api/src/main/java/org/apache/eventmesh/api/meta/MetaService.java index feb0efe5aa..150b63ea83 100644 --- a/eventmesh-meta/eventmesh-meta-api/src/main/java/org/apache/eventmesh/api/meta/MetaService.java +++ b/eventmesh-meta/eventmesh-meta-api/src/main/java/org/apache/eventmesh/api/meta/MetaService.java @@ -71,4 +71,10 @@ default EventMeshAppSubTopicInfo findEventMeshAppSubTopicInfoByGroup(String grou default List findEventMeshServicePubTopicInfos() throws MetaException { return Collections.emptyList(); } + + /** + * addListener + * @param metaServiceListener used for notify when config changed if needed + */ + void addMetaServiceListener(MetaServiceListener metaServiceListener); } diff --git a/eventmesh-meta/eventmesh-meta-consul/src/main/java/org/apache/eventmesh/meta/consul/service/ConsulMetaService.java b/eventmesh-meta/eventmesh-meta-consul/src/main/java/org/apache/eventmesh/meta/consul/service/ConsulMetaService.java index b2ba4564dd..f93957b482 100644 --- a/eventmesh-meta/eventmesh-meta-consul/src/main/java/org/apache/eventmesh/meta/consul/service/ConsulMetaService.java +++ b/eventmesh-meta/eventmesh-meta-consul/src/main/java/org/apache/eventmesh/meta/consul/service/ConsulMetaService.java @@ -19,6 +19,7 @@ import org.apache.eventmesh.api.exception.MetaException; import org.apache.eventmesh.api.meta.MetaService; +import org.apache.eventmesh.api.meta.MetaServiceListener; import org.apache.eventmesh.api.meta.dto.EventMeshDataInfo; import org.apache.eventmesh.api.meta.dto.EventMeshRegisterInfo; import org.apache.eventmesh.api.meta.dto.EventMeshUnRegisterInfo; @@ -66,6 +67,8 @@ public class ConsulMetaService implements MetaService { private ConsulTLSConfig tlsConfig; + private MetaServiceListener metaServiceListener; + @Override public void init() throws MetaException { if (initStatus.compareAndSet(false, true)) { @@ -162,6 +165,11 @@ public boolean unRegister(EventMeshUnRegisterInfo eventMeshUnRegisterInfo) throw return true; } + @Override + public void addMetaServiceListener(MetaServiceListener metaServiceListener) { + this.metaServiceListener = metaServiceListener; + } + @Override public List findEventMeshInfoByCluster(String clusterName) throws MetaException { HealthServicesRequest request = HealthServicesRequest.newBuilder().setPassing(true).setToken(token).build(); diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/meta/MetaStorage.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/meta/MetaStorage.java index c51473253f..29120feb8a 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/meta/MetaStorage.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/meta/MetaStorage.java @@ -19,6 +19,7 @@ import org.apache.eventmesh.api.exception.MetaException; import org.apache.eventmesh.api.meta.MetaService; +import org.apache.eventmesh.api.meta.MetaServiceListener; import org.apache.eventmesh.api.meta.bo.EventMeshAppSubTopicInfo; import org.apache.eventmesh.api.meta.bo.EventMeshServicePubTopicInfo; import org.apache.eventmesh.api.meta.dto.EventMeshDataInfo; @@ -40,6 +41,8 @@ public class MetaStorage { private MetaService metaService; + private MetaServiceListener metaServiceListener; + private final AtomicBoolean inited = new AtomicBoolean(false); private final AtomicBoolean started = new AtomicBoolean(false); @@ -128,4 +131,12 @@ public List findEventMeshServicePubTopicInfos() th public EventMeshAppSubTopicInfo findEventMeshAppSubTopicInfo(String group) throws Exception { return metaService.findEventMeshAppSubTopicInfoByGroup(group); } + + public MetaServiceListener getMetaServiceListener() { + return metaServiceListener; + } + + public void setMetaServiceListener(MetaServiceListener metaServiceListener) { + this.metaServiceListener = metaServiceListener; + } }