Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public static boolean isValid(String value) {
*/
public static BalanceTypeEnum getCloudWarmUpForRebalanceTypeEnum() {
return fromString(Config.cloud_warm_up_for_rebalance_type) == null
? ComputeGroup.DEFAULT_COMPUTE_GROUP_BALANCE_ENUM : fromString(Config.cloud_warm_up_for_rebalance_type);
? CloudComputeGroupMeta.DEFAULT_COMPUTE_GROUP_BALANCE_ENUM
: fromString(Config.cloud_warm_up_for_rebalance_type);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,26 @@
import java.util.List;
import java.util.Map;

public class ComputeGroup {
private static final Logger LOG = LogManager.getLogger(ComputeGroup.class);
/**
* FE-side in-memory metadata for a cloud compute group.
*
* <p>This class models both physical and virtual cloud compute groups and keeps cloud-only
* control-plane state, including the compute group type, active-standby policy, sub compute
* groups, availability timestamps, and cache warm-up properties. Its instances are refreshed
* from the meta service by {@link CloudInstanceStatusChecker} and
* {@link org.apache.doris.cloud.system.CloudSystemInfoService}.
*
* <p>Do not confuse this class with {@link org.apache.doris.resource.computegroup.ComputeGroup}.
* The resource-layer class is a runtime routing abstraction shared by cloud and non-cloud
* deployments: it selects backends and resolves the workload group namespace for a request.
* In contrast, this class is the long-lived cloud control-plane metadata consulted during
* routing, failover, and cache warm-up.
*
* <p>The meta service is the source of truth. This class is only an FE in-memory mirror and is
* not persisted in the FE edit log or image.
*/
public class CloudComputeGroupMeta {
private static final Logger LOG = LogManager.getLogger(CloudComputeGroupMeta.class);

public static final String BALANCE_TYPE = "balance_type";

Expand Down Expand Up @@ -139,7 +157,7 @@ public Cloud.ClusterPolicy toPb() {
@Setter
private Map<String, String> properties = new LinkedHashMap<>(ALL_PROPERTIES_DEFAULT_VALUE_MAP);

public ComputeGroup(String id, String name, ComputeTypeEnum type) {
public CloudComputeGroupMeta(String id, String name, ComputeTypeEnum type) {
this.id = id;
this.name = name;
this.type = type;
Expand Down Expand Up @@ -305,10 +323,10 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof ComputeGroup)) {
if (!(o instanceof CloudComputeGroupMeta)) {
return false;
}
ComputeGroup that = (ComputeGroup) o;
CloudComputeGroupMeta that = (CloudComputeGroupMeta) o;
return unavailableSince == that.unavailableSince
&& availableSince == that.availableSince
&& id.equals(that.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private void processVirtualClusters(List<Cloud.ClusterPB> clusters) {

private void handleComputeClusters(List<Cloud.ClusterPB> computeClusters) {
for (Cloud.ClusterPB computeClusterInMs : computeClusters) {
ComputeGroup computeGroupInFe = cloudSystemInfoService
CloudComputeGroupMeta computeGroupInFe = cloudSystemInfoService
.getComputeGroupById(computeClusterInMs.getClusterId());
if (computeGroupInFe == null) {
// cluster checker will sync it
Expand All @@ -131,7 +131,7 @@ private void handleComputeClusters(List<Cloud.ClusterPB> computeClusters) {
* Compare properties between compute cluster in MS and compute group in FE,
* update only the changed key-value pairs to avoid unnecessary updates.
*/
private void updatePropertiesIfChanged(ComputeGroup computeGroupInFe, Cloud.ClusterPB computeClusterInMs) {
private void updatePropertiesIfChanged(CloudComputeGroupMeta computeGroupInFe, Cloud.ClusterPB computeClusterInMs) {
Map<String, String> propertiesInMs = computeClusterInMs.getPropertiesMap();
Map<String, String> propertiesInFe = computeGroupInFe.getProperties();

Expand Down Expand Up @@ -181,7 +181,7 @@ private void categorizeClusters(List<Cloud.ClusterPB> clusters,

private void handleVirtualClusters(List<Cloud.ClusterPB> virtualGroups, List<Cloud.ClusterPB> computeClusters) {
for (Cloud.ClusterPB virtualGroupInMs : virtualGroups) {
ComputeGroup virtualGroupInFe = cloudSystemInfoService
CloudComputeGroupMeta virtualGroupInFe = cloudSystemInfoService
.getComputeGroupById(virtualGroupInMs.getClusterId());
if (virtualGroupInFe != null) {
handleExistingVirtualComputeGroup(virtualGroupInMs, virtualGroupInFe);
Expand All @@ -203,7 +203,7 @@ private void handleVirtualClusters(List<Cloud.ClusterPB> virtualGroups, List<Clo
}
}

private void cancelCacheJobs(ComputeGroup vcgInFe, List<String> jobIds) {
private void cancelCacheJobs(CloudComputeGroupMeta vcgInFe, List<String> jobIds) {
CacheHotspotManager cacheHotspotManager = ((CloudEnv) Env.getCurrentEnv()).getCacheHotspotMgr();
if (!jobIds.isEmpty()) {
LOG.info("warmup-vcg cancel-cache-jobs vcgName={} activeComputeGroup={} standbyComputeGroup={} "
Expand All @@ -224,7 +224,7 @@ private void cancelCacheJobs(ComputeGroup vcgInFe, List<String> jobIds) {
}
}

private void checkNeedRebuildFileCache(ComputeGroup virtualGroupInFe, List<String> jobIdsInMs) {
private void checkNeedRebuildFileCache(CloudComputeGroupMeta virtualGroupInFe, List<String> jobIdsInMs) {
CacheHotspotManager cacheHotspotManager = ((CloudEnv) Env.getCurrentEnv()).getCacheHotspotMgr();
// check jobIds in Ms valid, if been cancelled, start new jobs
for (String jobId : jobIdsInMs) {
Expand Down Expand Up @@ -272,7 +272,8 @@ private void checkNeedRebuildFileCache(ComputeGroup virtualGroupInFe, List<Strin
/**
* Generates and synchronizes file cache related tasks for virtual computing groups on the FE master.
*/
private void syncFileCacheTasksForVirtualGroup(Cloud.ClusterPB virtualGroupInMs, ComputeGroup virtualGroupInFe) {
private void syncFileCacheTasksForVirtualGroup(
Cloud.ClusterPB virtualGroupInMs, CloudComputeGroupMeta virtualGroupInFe) {
if (!virtualGroupInMs.hasClusterPolicy()) {
LOG.warn("virtual compute err, clusterName {}, no cluster policy {}",
virtualGroupInFe.getName(), virtualGroupInMs);
Expand Down Expand Up @@ -339,7 +340,8 @@ private void syncFileCacheTasksForVirtualGroup(Cloud.ClusterPB virtualGroupInMs,
}
}

private void handleExistingVirtualComputeGroup(Cloud.ClusterPB clusterInMs, ComputeGroup virtualGroupInFe) {
private void handleExistingVirtualComputeGroup(
Cloud.ClusterPB clusterInMs, CloudComputeGroupMeta virtualGroupInFe) {
if (!isClusterIdConsistent(clusterInMs, virtualGroupInFe)) {
return;
}
Expand All @@ -355,7 +357,7 @@ private void handleExistingVirtualComputeGroup(Cloud.ClusterPB clusterInMs, Comp
diffAndUpdateComputeGroup(clusterInMs, virtualGroupInFe);
}

private boolean isClusterIdConsistent(Cloud.ClusterPB cluster, ComputeGroup computeGroup) {
private boolean isClusterIdConsistent(Cloud.ClusterPB cluster, CloudComputeGroupMeta computeGroup) {
if (!cluster.getClusterId().equals(computeGroup.getId())) {
LOG.warn("virtual compute err, group id changed, in fe={} but in ms={}, "
+ "verbose {}, please check it",
Expand All @@ -382,7 +384,7 @@ private boolean isClusterPolicyValid(Cloud.ClusterPB cluster) {
return true;
}

private boolean areSubComputeGroupsValid(Cloud.ClusterPB clusterInMs, ComputeGroup virtualGroupInFe) {
private boolean areSubComputeGroupsValid(Cloud.ClusterPB clusterInMs, CloudComputeGroupMeta virtualGroupInFe) {
List<String> subComputeGroups = clusterInMs.getClusterNamesList();
if (subComputeGroups.isEmpty() || virtualGroupInFe.getSubComputeGroups() == null) {
LOG.warn("virtual compute err, please check it, verbose {}", virtualGroupInFe);
Expand All @@ -396,7 +398,7 @@ private boolean areSubComputeGroupsValid(Cloud.ClusterPB clusterInMs, ComputeGro
return true;
}

private void diffAndUpdateComputeGroup(Cloud.ClusterPB cluster, ComputeGroup computeGroup) {
private void diffAndUpdateComputeGroup(Cloud.ClusterPB cluster, CloudComputeGroupMeta computeGroup) {
// vcg rename logic, here cluster_id same, but cluster_name changed, so vcg renamed
String clusterNameInMs = cluster.getClusterName();
String computeGroupNameInFe = computeGroup.getName();
Expand Down Expand Up @@ -490,10 +492,10 @@ private void handleNewVirtualComputeGroup(Cloud.ClusterPB cluster, List<Cloud.Cl
return;
}
checkSubClusters(subComputeGroups, cluster, computeClusters);
ComputeGroup computeGroup = new ComputeGroup(cluster.getClusterId(),
cluster.getClusterName(), ComputeGroup.ComputeTypeEnum.VIRTUAL);
CloudComputeGroupMeta computeGroup = new CloudComputeGroupMeta(cluster.getClusterId(),
cluster.getClusterName(), CloudComputeGroupMeta.ComputeTypeEnum.VIRTUAL);
computeGroup.setSubComputeGroups(new ArrayList<>(subComputeGroups));
ComputeGroup.Policy policy = new ComputeGroup.Policy();
CloudComputeGroupMeta.Policy policy = new CloudComputeGroupMeta.Policy();
policy.setActiveComputeGroup(cluster.getClusterPolicy().getActiveClusterName());
policy.setStandbyComputeGroup(cluster.getClusterPolicy().getStandbyClusterNames(0));
policy.setFailoverFailureThreshold(cluster.getClusterPolicy().getFailoverFailureThreshold());
Expand Down Expand Up @@ -541,7 +543,7 @@ private void handleFailedSync(Cloud.ClusterPB cluster, String subClusterName,
private void removeObsoleteVirtualGroups(List<Cloud.ClusterPB> virtualClusters) {
List<String> msVirtualClusters = virtualClusters.stream().map(Cloud.ClusterPB::getClusterId)
.collect(Collectors.toList());
for (ComputeGroup computeGroup : cloudSystemInfoService.getComputeGroups(true)) {
for (CloudComputeGroupMeta computeGroup : cloudSystemInfoService.getComputeGroups(true)) {
// in fe mem, but not in meta server
if (!msVirtualClusters.contains(computeGroup.getId())) {
LOG.info("virtual compute group {} will be removed.", computeGroup.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public int hashCode() {
* Get the current balance type for a compute group, falling back to global balance type if not found
*/
private BalanceTypeEnum getCurrentBalanceType(String clusterId) {
ComputeGroup cg = cloudSystemInfoService.getComputeGroupById(clusterId);
CloudComputeGroupMeta cg = cloudSystemInfoService.getComputeGroupById(clusterId);
if (cg == null) {
LOG.debug("compute group not found, use global balance type, id {}", clusterId);
return globalBalanceTypeEnum;
Expand All @@ -219,7 +219,7 @@ private BalanceTypeEnum getCurrentBalanceType(String clusterId) {
* Get the current task timeout for a compute group, falling back to global timeout if not found
*/
private int getCurrentTaskTimeout(String clusterId) {
ComputeGroup cg = cloudSystemInfoService.getComputeGroupById(clusterId);
CloudComputeGroupMeta cg = cloudSystemInfoService.getComputeGroupById(clusterId);
if (cg == null) {
return Config.cloud_pre_heating_time_limit_sec;
}
Expand All @@ -233,15 +233,15 @@ private int getCurrentTaskTimeout(String clusterId) {
}

private boolean isComputeGroupBalanceChanged(String clusterId) {
ComputeGroup cg = cloudSystemInfoService.getComputeGroupById(clusterId);
CloudComputeGroupMeta cg = cloudSystemInfoService.getComputeGroupById(clusterId);
if (cg == null) {
return false;
}

BalanceTypeEnum computeGroupBalanceType = cg.getBalanceType();
int computeGroupTimeout = cg.getBalanceWarmUpTaskTimeout();
return computeGroupBalanceType != ComputeGroup.DEFAULT_COMPUTE_GROUP_BALANCE_ENUM
|| computeGroupTimeout != ComputeGroup.DEFAULT_BALANCE_WARM_UP_TASK_TIMEOUT;
return computeGroupBalanceType != CloudComputeGroupMeta.DEFAULT_COMPUTE_GROUP_BALANCE_ENUM
|| computeGroupTimeout != CloudComputeGroupMeta.DEFAULT_BALANCE_WARM_UP_TASK_TIMEOUT;
}

public CloudTabletRebalancer(CloudSystemInfoService cloudSystemInfoService) {
Expand Down
Loading
Loading