turboFei commented on code in PR #2839:
URL: https://github.com/apache/celeborn/pull/2839#discussion_r1817439836
##########
master/src/main/java/org/apache/celeborn/service/deploy/master/clustermeta/AbstractMetaManager.java:
##########
@@ -90,6 +94,129 @@ public abstract class AbstractMetaManager implements
IMetadataHandler {
public final ConcurrentHashMap<String, ApplicationMeta> applicationMetas =
JavaUtils.newConcurrentHashMap();
+ public Collection<WorkerInfo> getWorkers() {
+ return Collections.unmodifiableCollection(workersMap.values());
+ }
+
+ public <T> T synchronizedWorkers(Supplier<T> s) {
+ synchronized (workersMap) {
+ return s.get();
+ }
+ }
+
+ public boolean containsWorker(WorkerInfo worker) {
+ return workersMap.containsKey(worker.toUniqueId());
+ }
+
+ public WorkerInfo getWorker(WorkerInfo worker) {
+ return workersMap.get(worker.toUniqueId());
+ }
+
+ @VisibleForTesting
+ public void updateWorker(WorkerInfo worker) {
+ workersMap.put(worker.toUniqueId(), worker);
+ }
+
+ @VisibleForTesting
+ public void clearWorkers() {
+ workersMap.clear();
+ }
+
+ private WorkerInfo getFromWorkerInfoPool(String workerUniqueId) {
+ return workerInfoPool.computeIfAbsent(workerUniqueId, id ->
WorkerInfo.fromUniqueId(id));
+ }
+
+ private void recycleToWorkerInfoPool(String workerUniqueId, WorkerInfo
workerInfo) {
+ workerInfoPool.putIfAbsent(workerUniqueId, workerInfo);
+ }
+
+ private void releaseFromWorkerInfoPool(String workerUniqueId) {
+ workerInfoPool.remove(workerUniqueId);
+ }
+
+ public Set<String> getManuallyExcludedWorkerIds() {
+ return Collections.unmodifiableSet(manuallyExcludedWorkers);
+ }
+
+ public Set<WorkerInfo> getManuallyExcludedWorkerInfos() {
+ return manuallyExcludedWorkers.stream()
+ .map(this::getFromWorkerInfoPool)
+ .collect(Collectors.toSet());
+ }
+
+ public Set<String> getShutdownWorkerIds() {
+ return Collections.unmodifiableSet(shutdownWorkers);
+ }
+
+ public Set<WorkerInfo> getShutdownWorkerInfos() {
+ return
shutdownWorkers.stream().map(this::getFromWorkerInfoPool).collect(Collectors.toSet());
+ }
+
+ public Set<String> getDecommissionWorkerIds() {
+ return Collections.unmodifiableSet(decommissionWorkers);
Review Comment:
unmodified
##########
master/src/main/java/org/apache/celeborn/service/deploy/master/clustermeta/AbstractMetaManager.java:
##########
@@ -90,6 +94,129 @@ public abstract class AbstractMetaManager implements
IMetadataHandler {
public final ConcurrentHashMap<String, ApplicationMeta> applicationMetas =
JavaUtils.newConcurrentHashMap();
+ public Collection<WorkerInfo> getWorkers() {
+ return Collections.unmodifiableCollection(workersMap.values());
+ }
+
+ public <T> T synchronizedWorkers(Supplier<T> s) {
+ synchronized (workersMap) {
+ return s.get();
+ }
+ }
+
+ public boolean containsWorker(WorkerInfo worker) {
+ return workersMap.containsKey(worker.toUniqueId());
+ }
+
+ public WorkerInfo getWorker(WorkerInfo worker) {
+ return workersMap.get(worker.toUniqueId());
+ }
+
+ @VisibleForTesting
+ public void updateWorker(WorkerInfo worker) {
+ workersMap.put(worker.toUniqueId(), worker);
+ }
+
+ @VisibleForTesting
+ public void clearWorkers() {
+ workersMap.clear();
+ }
+
+ private WorkerInfo getFromWorkerInfoPool(String workerUniqueId) {
+ return workerInfoPool.computeIfAbsent(workerUniqueId, id ->
WorkerInfo.fromUniqueId(id));
+ }
+
+ private void recycleToWorkerInfoPool(String workerUniqueId, WorkerInfo
workerInfo) {
+ workerInfoPool.putIfAbsent(workerUniqueId, workerInfo);
+ }
+
+ private void releaseFromWorkerInfoPool(String workerUniqueId) {
+ workerInfoPool.remove(workerUniqueId);
+ }
+
+ public Set<String> getManuallyExcludedWorkerIds() {
+ return Collections.unmodifiableSet(manuallyExcludedWorkers);
+ }
+
+ public Set<WorkerInfo> getManuallyExcludedWorkerInfos() {
+ return manuallyExcludedWorkers.stream()
+ .map(this::getFromWorkerInfoPool)
+ .collect(Collectors.toSet());
+ }
+
+ public Set<String> getShutdownWorkerIds() {
+ return Collections.unmodifiableSet(shutdownWorkers);
Review Comment:
unmodified
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]