FMX commented on code in PR #2839:
URL: https://github.com/apache/celeborn/pull/2839#discussion_r1814731156
##########
master/src/main/java/org/apache/celeborn/service/deploy/master/clustermeta/AbstractMetaManager.java:
##########
@@ -89,6 +94,90 @@ public abstract class AbstractMetaManager implements
IMetadataHandler {
public final ConcurrentHashMap<String, ApplicationMeta> applicationMetas =
JavaUtils.newConcurrentHashMap();
+ public Collection<WorkerInfo> getWorkers() {
+ return 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());
+ }
+
+ public void updateWorker(WorkerInfo worker) {
+ workersMap.put(worker.toUniqueId(), worker);
+ }
+
+ public void removeWorker(WorkerInfo worker) {
+ workersMap.remove(worker.toUniqueId());
+ }
+
+ @VisibleForTesting
+ public void clearWorkers() {
+ workersMap.clear();
+ }
+
+ private WorkerInfo getFromWorkerInfoPool(String workerUniqueId) {
+ return workerInfoPool.getOrDefault(workerUniqueId,
WorkerInfo.fromUniqueId(workerUniqueId));
+ }
+
+ private void recycleToWorkerInfoPool(WorkerInfo workerInfo) {
+ workerInfoPool.putIfAbsent(workerInfo.toUniqueId(), workerInfo);
+ }
+
+ private void releaseFromWorkerInfoPool(WorkerInfo workerInfo) {
+ workerInfoPool.remove(workerInfo.toUniqueId());
+ }
Review Comment:
Yes, I think these changes make sense. I'll review this PR tomorrow.
--
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]