Skip to content
Draft
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
11 changes: 11 additions & 0 deletions broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@

public class BrokerStartup {

static final String DLEDGER_COMMIT_LOG_DEPRECATION_WARNING =
"Broker DLedger mode is deprecated and may be removed in a future release. " +
"Use Controller mode for new deployments.";

public static Logger log;

public static void main(String[] args) {
Expand Down Expand Up @@ -228,6 +232,7 @@ public static BrokerController buildBrokerController(ConfigContext configContext
}

log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
warnIfDLedgerCommitLogEnabled(messageStoreConfig, log);
MixAll.printObjectProperties(log, brokerConfig);
MixAll.printObjectProperties(log, nettyServerConfig);
MixAll.printObjectProperties(log, nettyClientConfig);
Expand All @@ -248,6 +253,12 @@ public static BrokerController buildBrokerController(ConfigContext configContext
return controller;
}

static void warnIfDLedgerCommitLogEnabled(MessageStoreConfig messageStoreConfig, Logger logger) {
if (messageStoreConfig.isEnableDLegerCommitLog()) {
logger.warn(DLEDGER_COMMIT_LOG_DEPRECATION_WARNING);
}
}

public static Runnable buildShutdownHook(BrokerController brokerController) {
return new Runnable() {
private volatile boolean hasShutdown = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
import java.lang.reflect.Method;
import java.util.Properties;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.logging.org.slf4j.Logger;
import org.apache.rocketmq.store.config.MessageStoreConfig;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;

public class BrokerStartupTest {

Expand Down Expand Up @@ -52,4 +55,25 @@ public void testProperties2SystemEnv() throws NoSuchMethodException, InvocationT


}
}

@Test
public void testWarnIfDLedgerCommitLogEnabled() {
MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
messageStoreConfig.setEnableDLegerCommitLog(true);
Logger logger = Mockito.mock(Logger.class);

BrokerStartup.warnIfDLedgerCommitLogEnabled(messageStoreConfig, logger);

Mockito.verify(logger).warn(BrokerStartup.DLEDGER_COMMIT_LOG_DEPRECATION_WARNING);
}

@Test
public void testDoesNotWarnIfDLedgerCommitLogDisabled() {
MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
Logger logger = Mockito.mock(Logger.class);

BrokerStartup.warnIfDLedgerCommitLogEnabled(messageStoreConfig, logger);

Mockito.verifyNoInteractions(logger);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -892,10 +892,18 @@ public void setStorePathCommitLog(String storePathCommitLog) {
this.storePathCommitLog = storePathCommitLog;
}

/**
* @deprecated Broker DLedger mode is deprecated. Use Controller mode for new deployments.
*/
@Deprecated
public String getStorePathDLedgerCommitLog() {
return storePathDLedgerCommitLog;
}

/**
* @deprecated Broker DLedger mode is deprecated. Use Controller mode for new deployments.
*/
@Deprecated
public void setStorePathDLedgerCommitLog(String storePathDLedgerCommitLog) {
this.storePathDLedgerCommitLog = storePathDLedgerCommitLog;
}
Expand Down Expand Up @@ -1364,50 +1372,98 @@ public void setReadOnlyCommitLogStorePaths(String readOnlyCommitLogStorePaths) {
this.readOnlyCommitLogStorePaths = readOnlyCommitLogStorePaths;
}

/**
* @deprecated Broker DLedger mode is deprecated. Use Controller mode for new deployments.
*/
@Deprecated
public String getdLegerGroup() {
return dLegerGroup;
}

/**
* @deprecated Broker DLedger mode is deprecated. Use Controller mode for new deployments.
*/
@Deprecated
public void setdLegerGroup(String dLegerGroup) {
this.dLegerGroup = dLegerGroup;
}

/**
* @deprecated Broker DLedger mode is deprecated. Use Controller mode for new deployments.
*/
@Deprecated
public String getdLegerPeers() {
return dLegerPeers;
}

/**
* @deprecated Broker DLedger mode is deprecated. Use Controller mode for new deployments.
*/
@Deprecated
public void setdLegerPeers(String dLegerPeers) {
this.dLegerPeers = dLegerPeers;
}

/**
* @deprecated Broker DLedger mode is deprecated. Use Controller mode for new deployments.
*/
@Deprecated
public String getdLegerSelfId() {
return dLegerSelfId;
}

/**
* @deprecated Broker DLedger mode is deprecated. Use Controller mode for new deployments.
*/
@Deprecated
public void setdLegerSelfId(String dLegerSelfId) {
this.dLegerSelfId = dLegerSelfId;
}

/**
* @deprecated Broker DLedger mode is deprecated. Use Controller mode for new deployments.
*/
@Deprecated
public boolean isEnableDLegerCommitLog() {
return enableDLegerCommitLog;
}

/**
* @deprecated Broker DLedger mode is deprecated. Use Controller mode for new deployments.
*/
@Deprecated
public void setEnableDLegerCommitLog(boolean enableDLegerCommitLog) {
this.enableDLegerCommitLog = enableDLegerCommitLog;
}

/**
* @deprecated Broker DLedger mode is deprecated. Use Controller mode for new deployments.
*/
@Deprecated
public String getPreferredLeaderId() {
return preferredLeaderId;
}

/**
* @deprecated Broker DLedger mode is deprecated. Use Controller mode for new deployments.
*/
@Deprecated
public void setPreferredLeaderId(String preferredLeaderId) {
this.preferredLeaderId = preferredLeaderId;
}

/**
* @deprecated Broker DLedger mode is deprecated. Use Controller mode for new deployments.
*/
@Deprecated
public boolean isEnableBatchPush() {
return enableBatchPush;
}

/**
* @deprecated Broker DLedger mode is deprecated. Use Controller mode for new deployments.
*/
@Deprecated
public void setEnableBatchPush(boolean enableBatchPush) {
this.enableBatchPush = enableBatchPush;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@

/**
* Store all metadata downtime for recovery, data protection reliability
*
* @deprecated Use Controller mode for automatic Broker failover in new deployments.
*/
@Deprecated
public class DLedgerCommitLog extends CommitLog {

static {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* 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.rocketmq.store.dledger;

import java.lang.reflect.Method;
import org.apache.rocketmq.store.config.MessageStoreConfig;
import org.junit.Assert;
import org.junit.Test;

public class DLedgerDeprecationTest {

@Test
public void testDLedgerCommitLogIsDeprecated() {
Assert.assertTrue(DLedgerCommitLog.class.isAnnotationPresent(Deprecated.class));
}

@Test
public void testDLedgerMessageStoreConfigAccessorsAreDeprecated() throws Exception {
assertDeprecated(MessageStoreConfig.class.getMethod("getStorePathDLedgerCommitLog"));
assertDeprecated(MessageStoreConfig.class.getMethod("setStorePathDLedgerCommitLog", String.class));
assertDeprecated(MessageStoreConfig.class.getMethod("getdLegerGroup"));
assertDeprecated(MessageStoreConfig.class.getMethod("setdLegerGroup", String.class));
assertDeprecated(MessageStoreConfig.class.getMethod("getdLegerPeers"));
assertDeprecated(MessageStoreConfig.class.getMethod("setdLegerPeers", String.class));
assertDeprecated(MessageStoreConfig.class.getMethod("getdLegerSelfId"));
assertDeprecated(MessageStoreConfig.class.getMethod("setdLegerSelfId", String.class));
assertDeprecated(MessageStoreConfig.class.getMethod("isEnableDLegerCommitLog"));
assertDeprecated(MessageStoreConfig.class.getMethod("setEnableDLegerCommitLog", boolean.class));
assertDeprecated(MessageStoreConfig.class.getMethod("getPreferredLeaderId"));
assertDeprecated(MessageStoreConfig.class.getMethod("setPreferredLeaderId", String.class));
assertDeprecated(MessageStoreConfig.class.getMethod("isEnableBatchPush"));
assertDeprecated(MessageStoreConfig.class.getMethod("setEnableBatchPush", boolean.class));
}

private void assertDeprecated(Method method) {
Assert.assertTrue(method.getName() + " should be deprecated",
method.isAnnotationPresent(Deprecated.class));
}
}
Loading