-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ISSUE #9111] Broker Support export RocksDB Config to json file and e…
…nhance admin tools
- Loading branch information
1 parent
9ce8345
commit 51b4fb5
Showing
13 changed files
with
431 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
.../org/apache/rocketmq/remoting/protocol/header/ExportRocksDBConfigToJsonRequestHeader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* 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.remoting.protocol.header; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.apache.rocketmq.common.action.Action; | ||
import org.apache.rocketmq.common.action.RocketMQAction; | ||
import org.apache.rocketmq.remoting.CommandCustomHeader; | ||
import org.apache.rocketmq.remoting.annotation.CFNotNull; | ||
import org.apache.rocketmq.remoting.exception.RemotingCommandException; | ||
import org.apache.rocketmq.remoting.protocol.RequestCode; | ||
|
||
@RocketMQAction(value = RequestCode.EXPORT_ROCKSDB_CONFIG_TO_JSON, action = Action.GET) | ||
public class ExportRocksDBConfigToJsonRequestHeader implements CommandCustomHeader { | ||
private static final String CONFIG_TYPE_SEPARATOR = ";"; | ||
|
||
public enum ConfigType { | ||
topics, | ||
subscriptionGroups, | ||
consumerOffsets; | ||
|
||
public static List<ConfigType> fromString(String ordinal) { | ||
String[] configTypeStrings = StringUtils.split(ordinal, CONFIG_TYPE_SEPARATOR); | ||
List<ConfigType> configTypes = new ArrayList<>(); | ||
for (String configTypeString : configTypeStrings) { | ||
if (StringUtils.isNotEmpty(configTypeString)) { | ||
configTypes.add(ConfigType.valueOf(configTypeString)); | ||
} | ||
} | ||
return configTypes; | ||
} | ||
|
||
public static String toString(List<ConfigType> configTypes) { | ||
StringBuilder sb = new StringBuilder(); | ||
for (ConfigType configType : configTypes) { | ||
sb.append(configType.name()).append(CONFIG_TYPE_SEPARATOR); | ||
} | ||
return sb.toString(); | ||
} | ||
} | ||
|
||
@CFNotNull | ||
private String configType; | ||
|
||
@Override | ||
public void checkFields() throws RemotingCommandException { | ||
|
||
} | ||
|
||
public List<ConfigType> fetchConfigType() { | ||
return ConfigType.fromString(configType); | ||
} | ||
|
||
public void updateConfigType(List<ConfigType> configType) { | ||
this.configType = ConfigType.toString(configType); | ||
} | ||
|
||
public String getConfigType() { | ||
return configType; | ||
} | ||
|
||
public void setConfigType(String configType) { | ||
this.configType = configType; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
.../apache/rocketmq/remoting/protocol/header/ExportRocksDBConfigToJsonRequestHeaderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* 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.remoting.protocol.header; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.junit.Test; | ||
|
||
public class ExportRocksDBConfigToJsonRequestHeaderTest { | ||
@Test | ||
public void configTypeTest() { | ||
List<ExportRocksDBConfigToJsonRequestHeader.ConfigType> configTypes = new ArrayList<>(); | ||
configTypes.add(ExportRocksDBConfigToJsonRequestHeader.ConfigType.topics); | ||
configTypes.add(ExportRocksDBConfigToJsonRequestHeader.ConfigType.subscriptionGroups); | ||
|
||
String string = ExportRocksDBConfigToJsonRequestHeader.ConfigType.toString(configTypes); | ||
|
||
List<ExportRocksDBConfigToJsonRequestHeader.ConfigType> newConfigTypes = ExportRocksDBConfigToJsonRequestHeader.ConfigType.fromString(string); | ||
assert newConfigTypes.size() == 2; | ||
assert configTypes.equals(newConfigTypes); | ||
|
||
List<ExportRocksDBConfigToJsonRequestHeader.ConfigType> topics = ExportRocksDBConfigToJsonRequestHeader.ConfigType.fromString("topics"); | ||
assert topics.size() == 1; | ||
assert topics.get(0).equals(ExportRocksDBConfigToJsonRequestHeader.ConfigType.topics); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.