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 @@ -96,6 +96,10 @@ public CloudTabletRebalancer getCloudTabletRebalancer() {
return this.cloudTabletRebalancer;
}

public boolean isRebalancerInited() {
return this.cloudTabletRebalancer.isInited();
}

public CloudUpgradeMgr getCloudUpgradeMgr() {
return this.upgradeMgr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public class CloudTabletRebalancer extends MasterDaemon {

private boolean tableBalanced = true;

private volatile boolean inited = false;

private LinkedBlockingQueue<Pair<Long, Long>> tabletsMigrateTasks = new LinkedBlockingQueue<Pair<Long, Long>>();

private Map<InfightTablet, InfightTask> tabletToInfightTask = new HashMap<>();
Expand Down Expand Up @@ -254,6 +256,7 @@ protected void runAfterCatalogReady() {
performBalancing();

checkDecommissionState(clusterToBes);
inited = true;
LOG.info("finished to rebalancer. cost: {} ms", (System.currentTimeMillis() - start));
}

Expand Down Expand Up @@ -1297,4 +1300,8 @@ private List<UpdateCloudReplicaInfo> batchUpdateCloudReplicaInfoEditlogs(List<Up
}
return rets;
}

public boolean isInited() {
return inited;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public void tabletReport(long backendId, Map<Long, TTablet> backendTablets,
long start = System.currentTimeMillis();
LOG.info("backend[{}] have {} tablet(s), {} need deal tablet(s). report version: {}",
backendId, numTablets, backendTablets.size(), backendReportVersion);
if (!((CloudEnv) Env.getCurrentEnv()).isRebalancerInited()) {
LOG.warn("TabletRebalancer has not been initialized, so skip do report for {}", backendId);
return;
}
// current be useful
Set<Long> tabletIdsInFe = ((CloudEnv) Env.getCurrentEnv()).getCloudTabletRebalancer()
.getSnapshotTabletsInPrimaryAndSecondaryByBeId(backendId);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// 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.doris.cloud.master;

import org.apache.doris.catalog.Env;
import org.apache.doris.cloud.catalog.CloudEnv;

import mockit.Expectations;
import mockit.Mock;
import mockit.MockUp;
import mockit.Mocked;
import mockit.Verifications;
import org.junit.Test;

import java.util.HashMap;

public class CloudReportHandlerTest {

@Mocked
private CloudEnv mockCloudEnv;

@Test
public void testTabletReportWhenTabletRebalancerNotInitialized() {
new MockUp<Env>() {
@Mock
public Env getCurrentEnv() {
return mockCloudEnv;
}
};
new Expectations() {
{
mockCloudEnv.isRebalancerInited();
result = false;
}
};

CloudReportHandler handler = new CloudReportHandler();
handler.tabletReport(1001L, new HashMap<>(), new HashMap<>(), 1L, 10L);
// If the tabletRebalancer is not initialized,
// the tabletReport should not call mockCloudEnv.getCurrentSystemInfo
new Verifications() {
{
mockCloudEnv.getCurrentSystemInfo();
times = 0;
}
};
}
}
Loading