com.alibaba.schedulerx.worker.discovery.GroupManager Maven / Gradle / Ivy
package com.alibaba.schedulerx.worker.discovery;
import akka.actor.ActorSystem;
import com.alibaba.schedulerx.common.domain.AppGroupInfo;
import com.alibaba.schedulerx.common.domain.enums.AppVersion;
import com.alibaba.schedulerx.worker.SchedulerxWorker;
import com.alibaba.schedulerx.worker.log.LogFactory;
import com.alibaba.schedulerx.worker.log.Logger;
import com.alibaba.schedulerx.worker.util.ConsoleUtil;
import com.google.common.collect.Maps;
import org.apache.commons.lang.StringUtils;
import java.io.IOException;
import java.util.List;
import java.util.Map;
public enum GroupManager {
INSTANCE;
private String namespace;
private String namespaceSource;
private Map groupId2AppGroupIdMap = Maps.newConcurrentMap();
private Map parentGroupId2CountMap = Maps.newConcurrentMap();
private Map groupId2ParentAppGroupMap = Maps.newConcurrentMap();
private Map groupId2AppKeyMap = Maps.newConcurrentMap();
private static final Logger LOGGER = LogFactory.getLogger(SchedulerxWorker.class);
public void init(String namespace, String namespaceSource, List groupIds, List appKeys) {
this.namespace = namespace;
this.namespaceSource = namespaceSource;
if (groupIds == null || appKeys == null || groupIds.size() == 0 || groupIds.size() != appKeys.size()) {
throw new IllegalArgumentException("Invalid Config, GroupId:"+StringUtils.join(groupIds, ",")
+" AppKey:"+StringUtils.join(appKeys, ","));
}
for (int i=0; i