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
6 changes: 6 additions & 0 deletions fe/src/main/java/org/apache/doris/catalog/Catalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,12 @@ public static Catalog getCurrentCatalog() {
}
}

// NOTICE: in most case, we should use getCurrentCatalog() to get the right catalog.
// but in some cases, we should get the serving catalog explicitly.
public static Catalog getServingCatalog() {
return SingletonHolder.INSTANCE;
}

public PullLoadJobMgr getPullLoadJobMgr() {
return pullLoadJobMgr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public MasterDaemon(String name, long intervalMs) {

@Override
protected final void runOneCycle() {
while (!Catalog.getCurrentCatalog().isReady()) {
// here we use getInstance(), not getCurrentCatalog() because we truly want the Catalog instance,
while (!Catalog.getServingCatalog().isReady()) {
// here we use getServingCatalog(), not getCurrentCatalog() because we truly want the Catalog instance,
// not the Checkpoint catalog instance.
// and if catalog is not ready, do not run
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ public synchronized void open() {
* This is the very first time to open. Usually, we will open a new database named "1".
* But when we start cluster with an image file copied from other cluster,
* here we should open database with name image max journal id + 1.
* (default Catalog.getInstance().getReplayedJournalId() is 0)
* (default Catalog.getCurrentCatalog().getReplayedJournalId() is 0)
*/
String dbName = Long.toString(Catalog.getCurrentCatalog().getReplayedJournalId() + 1);
LOG.info("the very first time to open bdb, dbname is {}", dbName);
Expand Down
8 changes: 4 additions & 4 deletions fe/src/main/java/org/apache/doris/master/Checkpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class Checkpoint extends MasterDaemon {

public Checkpoint(EditLog editLog) {
super("leaderCheckpointer", FeConstants.checkpoint_interval_second * 1000L);
this.imageDir = Catalog.getCurrentCatalog().getImageDir();
this.imageDir = Catalog.getServingCatalog().getImageDir();
this.editLog = editLog;
}

Expand Down Expand Up @@ -124,14 +124,14 @@ protected void runAfterCatalogReady() {

// push image file to all the other non master nodes
// DO NOT get other nodes from HaProtocol, because node may not in bdbje replication group yet.
List<Frontend> allFrontends = Catalog.getCurrentCatalog().getFrontends(null);
List<Frontend> allFrontends = Catalog.getServingCatalog().getFrontends(null);
int successPushed = 0;
int otherNodesCount = 0;
if (!allFrontends.isEmpty()) {
otherNodesCount = allFrontends.size() - 1; // skip master itself
for (Frontend fe : allFrontends) {
String host = fe.getHost();
if (host.equals(Catalog.getCurrentCatalog().getMasterIp())) {
if (host.equals(Catalog.getServingCatalog().getMasterIp())) {
// skip master itself
continue;
}
Expand Down Expand Up @@ -160,7 +160,7 @@ protected void runAfterCatalogReady() {
if (successPushed > 0) {
for (Frontend fe : allFrontends) {
String host = fe.getHost();
if (host.equals(Catalog.getCurrentCatalog().getMasterIp())) {
if (host.equals(Catalog.getServingCatalog().getMasterIp())) {
// skip master itself
continue;
}
Expand Down
4 changes: 0 additions & 4 deletions fe/src/test/java/org/apache/doris/alter/RollupJobV2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ public void setUp() throws InstantiationException, IllegalAccessException, Illeg
AgentTaskQueue.clearAllTasks();

new MockUp<Catalog>() {
@Mock
public Catalog getInstance() {
return masterCatalog;
}
@Mock
public Catalog getCurrentCatalog() {
return masterCatalog;
Expand Down
11 changes: 3 additions & 8 deletions fe/src/test/java/org/apache/doris/analysis/DescribeStmtTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@

package org.apache.doris.analysis;

import mockit.Expectations;
import mockit.Mock;
import mockit.MockUp;
import org.apache.doris.catalog.Catalog;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.UserException;
import org.apache.doris.qe.ConnectContext;

Expand All @@ -30,6 +26,9 @@
import org.junit.Ignore;
import org.junit.Test;

import mockit.Mock;
import mockit.MockUp;

public class DescribeStmtTest {
private Analyzer analyzer;
private Catalog catalog;
Expand All @@ -52,10 +51,6 @@ public ConnectContext get() {
};

new MockUp<Catalog>() {
@Mock
Catalog getInstance() {
return catalog;
}
@Mock
Catalog getCurrentCatalog() {
return catalog;
Expand Down
4 changes: 0 additions & 4 deletions fe/src/test/java/org/apache/doris/http/DorisHttpTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,6 @@ MaterializedViewHandler getRollupHandler() {
return new MaterializedViewHandler();
}
@Mock
Catalog getInstance() {
return catalog;
}
@Mock
Catalog getCurrentCatalog() {
return catalog;
}
Expand Down
11 changes: 4 additions & 7 deletions fe/src/test/java/org/apache/doris/qe/ShowExecutorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

package org.apache.doris.qe;

import mockit.Expectations;
import mockit.Mock;
import mockit.MockUp;
import org.apache.doris.analysis.AccessTestUtil;
import org.apache.doris.analysis.Analyzer;
import org.apache.doris.analysis.DescribeStmt;
Expand Down Expand Up @@ -69,6 +66,10 @@
import java.net.URL;
import java.util.List;

import mockit.Expectations;
import mockit.Mock;
import mockit.MockUp;

public class ShowExecutorTest {
private ConnectContext ctx;
private Catalog catalog;
Expand Down Expand Up @@ -295,10 +296,6 @@ public void testDescribe() {
Catalog catalog = AccessTestUtil.fetchAdminCatalog();

new MockUp<Catalog>() {
@Mock
Catalog getInstance() {
return catalog;
}
@Mock
Catalog getCurrentCatalog() {
return catalog;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ public ByteBuffer pread(TBrokerFD fd, long offset, long length) {
throw new BrokerException(TBrokerOperationStatusCode.END_OF_FILE,
"end of file reached");
}
if (logger.isDebugEnable()) {
if (logger.isDebugEnabled()) {
logger.debug("read buffer from input stream, buffer size:" + buf.capacity() + ", read length:" + readLength);
}
return buf;
Expand Down