-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into pil0txia/ci_134
- Loading branch information
Showing
154 changed files
with
4,647 additions
and
762 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
...oard-console/src/main/java/org/apache/eventmesh/dashboard/console/cache/ClusterCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.eventmesh.dashboard.console.cache; | ||
|
||
|
||
import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
import lombok.Getter; | ||
|
||
public class ClusterCache { | ||
|
||
@Getter | ||
private static final ClusterCache INSTANCE = new ClusterCache(); | ||
|
||
//cluster name | ||
private HashMap<String, ClusterEntity> clusterNameMap = new HashMap<>(); | ||
|
||
private HashMap<Long, ClusterEntity> clusterIdMap = new HashMap<>(); | ||
|
||
private static final Object lock = new Object(); | ||
|
||
public ClusterEntity getClusterById(Long id) { | ||
return INSTANCE.clusterIdMap.get(id); | ||
} | ||
|
||
public ClusterEntity getClusterByName(String name) { | ||
return INSTANCE.clusterNameMap.get(name); | ||
} | ||
|
||
public ClusterEntity getClusterByRegistryAddress(String registryAddress) { | ||
for (ClusterEntity clusterEntity : INSTANCE.clusterIdMap.values()) { | ||
if (clusterEntity.getRegistryAddress().equals(registryAddress)) { | ||
return clusterEntity; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
public List<ClusterEntity> getClusters() { | ||
return new ArrayList<>(INSTANCE.clusterIdMap.values()); | ||
} | ||
|
||
public void addCluster(ClusterEntity clusterEntity) { | ||
synchronized (lock) { | ||
if (INSTANCE.clusterIdMap.containsKey(clusterEntity.getId()) | ||
|| INSTANCE.clusterNameMap.containsKey(clusterEntity.getName())) { | ||
return; | ||
} | ||
INSTANCE.clusterIdMap.put(clusterEntity.getId(), clusterEntity); | ||
INSTANCE.clusterNameMap.put(clusterEntity.getName(), clusterEntity); | ||
} | ||
} | ||
|
||
public void deleteClusterById(Long id) { | ||
synchronized (lock) { | ||
ClusterEntity clusterEntity = INSTANCE.clusterIdMap.get(id); | ||
INSTANCE.clusterIdMap.remove(id); | ||
INSTANCE.clusterNameMap.remove(clusterEntity.getName()); | ||
} | ||
} | ||
|
||
public void deleteClusterByName(String name) { | ||
synchronized (lock) { | ||
ClusterEntity clusterEntity = INSTANCE.clusterNameMap.get(name); | ||
INSTANCE.clusterNameMap.remove(name); | ||
INSTANCE.clusterIdMap.remove(clusterEntity.getId()); | ||
} | ||
} | ||
|
||
public void syncClusters(List<ClusterEntity> clusters) { | ||
synchronized (lock) { | ||
INSTANCE.clusterIdMap.clear(); | ||
INSTANCE.clusterNameMap.clear(); | ||
for (ClusterEntity clusterEntity : clusters) { | ||
INSTANCE.clusterIdMap.put(clusterEntity.getId(), clusterEntity); | ||
INSTANCE.clusterNameMap.put(clusterEntity.getName(), clusterEntity); | ||
} | ||
} | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
...oard-console/src/main/java/org/apache/eventmesh/dashboard/console/cache/RuntimeCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.eventmesh.dashboard.console.cache; | ||
|
||
import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
public class RuntimeCache { | ||
|
||
private static final RuntimeCache INSTANCE = new RuntimeCache(); | ||
|
||
public static final RuntimeCache getInstance() { | ||
return INSTANCE; | ||
} | ||
|
||
// ip:port -> runtime | ||
private Map<String, RuntimeEntity> runtimeMap = new ConcurrentHashMap<>(); | ||
|
||
private RuntimeCache() { | ||
} | ||
|
||
public void addRuntime(RuntimeEntity runtimeEntity) { | ||
runtimeMap.put(runtimeEntity.getHost() + ":" + runtimeEntity.getPort(), runtimeEntity); | ||
} | ||
|
||
public Collection<RuntimeEntity> getRuntimeList() { | ||
return runtimeMap.values(); | ||
} | ||
|
||
public void deleteRuntime(RuntimeEntity runtimeEntity) { | ||
runtimeMap.remove(runtimeEntity.getHost() + ":" + runtimeEntity.getPort()); | ||
} | ||
|
||
public void replaceAllRuntime(List<RuntimeEntity> runtimeEntities) { | ||
Map<String, RuntimeEntity> newRuntimeList = new ConcurrentHashMap<>(); | ||
runtimeEntities.forEach(runtimeEntity -> { | ||
newRuntimeList.put(runtimeEntity.getHost() + ":" + runtimeEntity.getPort(), runtimeEntity); | ||
}); | ||
runtimeMap = newRuntimeList; | ||
} | ||
} |
Oops, something went wrong.