MQAdminExt.java 15.2 KB
Newer Older
1
/*
2 3 4 5 6 7
 * 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
8 9 10
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
11 12 13 14 15 16
 * 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.
 */
17
package org.apache.rocketmq.tools.admin;
18

Y
yukon 已提交
19 20 21 22 23
import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
24 25 26
import org.apache.rocketmq.client.MQAdmin;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
27
import org.apache.rocketmq.common.AclConfig;
28
import org.apache.rocketmq.common.PlainAccessConfig;
29 30 31 32 33 34
import org.apache.rocketmq.common.TopicConfig;
import org.apache.rocketmq.common.admin.ConsumeStats;
import org.apache.rocketmq.common.admin.RollbackStats;
import org.apache.rocketmq.common.admin.TopicStatsTable;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.common.message.MessageQueue;
Y
yukon 已提交
35
import org.apache.rocketmq.common.protocol.body.BrokerStatsData;
36
import org.apache.rocketmq.common.protocol.body.ClusterAclVersionInfo;
Y
yukon 已提交
37 38 39 40 41 42 43 44
import org.apache.rocketmq.common.protocol.body.ClusterInfo;
import org.apache.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult;
import org.apache.rocketmq.common.protocol.body.ConsumeStatsList;
import org.apache.rocketmq.common.protocol.body.ConsumerConnection;
import org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo;
import org.apache.rocketmq.common.protocol.body.GroupList;
import org.apache.rocketmq.common.protocol.body.KVTable;
import org.apache.rocketmq.common.protocol.body.ProducerConnection;
45
import org.apache.rocketmq.common.protocol.body.QueryConsumeQueueResponseBody;
Y
yukon 已提交
46 47 48 49
import org.apache.rocketmq.common.protocol.body.QueueTimeSpan;
import org.apache.rocketmq.common.protocol.body.SubscriptionGroupWrapper;
import org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper;
import org.apache.rocketmq.common.protocol.body.TopicList;
50 51
import org.apache.rocketmq.common.protocol.route.TopicRouteData;
import org.apache.rocketmq.common.subscription.SubscriptionGroupConfig;
Y
yukon 已提交
52 53 54 55 56
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
import org.apache.rocketmq.remoting.exception.RemotingConnectException;
import org.apache.rocketmq.remoting.exception.RemotingException;
import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
57
import org.apache.rocketmq.tools.admin.api.MessageTrack;
58 59 60 61 62 63 64

public interface MQAdminExt extends MQAdmin {
    void start() throws MQClientException;

    void shutdown();

    void updateBrokerConfig(final String brokerAddr, final Properties properties) throws RemotingConnectException,
Y
yukon 已提交
65
        RemotingSendRequestException, RemotingTimeoutException, UnsupportedEncodingException, InterruptedException, MQBrokerException;
66 67

    Properties getBrokerConfig(final String brokerAddr) throws RemotingConnectException,
Y
yukon 已提交
68
        RemotingSendRequestException, RemotingTimeoutException, UnsupportedEncodingException, InterruptedException, MQBrokerException;
69

Y
yukon 已提交
70 71
    void createAndUpdateTopicConfig(final String addr,
        final TopicConfig config) throws RemotingException, MQBrokerException,
Y
yukon 已提交
72
        InterruptedException, MQClientException;
73

74 75 76 77 78 79 80 81 82 83 84
    void createAndUpdatePlainAccessConfig(final String addr, final PlainAccessConfig plainAccessConfig) throws RemotingException, MQBrokerException,
        InterruptedException, MQClientException;

    void deletePlainAccessConfig(final String addr, final String accessKey) throws RemotingException, MQBrokerException,
        InterruptedException, MQClientException;

    void updateGlobalWhiteAddrConfig(final String addr, final String globalWhiteAddrs)throws RemotingException, MQBrokerException,
        InterruptedException, MQClientException;

    ClusterAclVersionInfo examineBrokerClusterAclVersionInfo(final String addr) throws RemotingException, MQBrokerException,
        InterruptedException, MQClientException;
85 86 87

    AclConfig examineBrokerClusterAclConfig(final String addr) throws RemotingException, MQBrokerException,
        InterruptedException, MQClientException;
88

Y
yukon 已提交
89 90
    void createAndUpdateSubscriptionGroupConfig(final String addr,
        final SubscriptionGroupConfig config) throws RemotingException,
Y
yukon 已提交
91
        MQBrokerException, InterruptedException, MQClientException;
92

93
    SubscriptionGroupConfig examineSubscriptionGroupConfig(final String addr, final String group) throws InterruptedException, RemotingException, MQClientException, MQBrokerException;
94

95
    TopicConfig examineTopicConfig(final String addr, final String topic) throws RemotingException, InterruptedException, MQBrokerException;
96

Y
yukon 已提交
97 98
    TopicStatsTable examineTopicStats(
        final String topic) throws RemotingException, MQClientException, InterruptedException,
Y
yukon 已提交
99
        MQBrokerException;
100 101 102

    TopicList fetchAllTopicList() throws RemotingException, MQClientException, InterruptedException;

Y
yukon 已提交
103 104
    TopicList fetchTopicsByCLuster(
        String clusterName) throws RemotingException, MQClientException, InterruptedException;
105

Y
yukon 已提交
106 107
    KVTable fetchBrokerRuntimeStats(
        final String brokerAddr) throws RemotingConnectException, RemotingSendRequestException,
Y
yukon 已提交
108
        RemotingTimeoutException, InterruptedException, MQBrokerException;
109

Y
yukon 已提交
110 111
    ConsumeStats examineConsumeStats(
        final String consumerGroup) throws RemotingException, MQClientException, InterruptedException,
Y
yukon 已提交
112
        MQBrokerException;
113

Y
yukon 已提交
114 115
    ConsumeStats examineConsumeStats(final String consumerGroup,
        final String topic) throws RemotingException, MQClientException,
Y
yukon 已提交
116
        InterruptedException, MQBrokerException;
117 118

    ClusterInfo examineBrokerClusterInfo() throws InterruptedException, MQBrokerException, RemotingTimeoutException,
Y
yukon 已提交
119
        RemotingSendRequestException, RemotingConnectException;
120

Y
yukon 已提交
121 122
    TopicRouteData examineTopicRouteInfo(
        final String topic) throws RemotingException, MQClientException, InterruptedException;
123 124

    ConsumerConnection examineConsumerConnectionInfo(final String consumerGroup) throws RemotingConnectException,
Y
yukon 已提交
125 126
        RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException, RemotingException,
        MQClientException;
127

Y
yukon 已提交
128 129
    ProducerConnection examineProducerConnectionInfo(final String producerGroup,
        final String topic) throws RemotingException,
Y
yukon 已提交
130
        MQClientException, InterruptedException, MQBrokerException;
131 132 133 134

    List<String> getNameServerAddressList();

    int wipeWritePermOfBroker(final String namesrvAddr, String brokerName) throws RemotingCommandException,
Y
yukon 已提交
135
        RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQClientException;
136

C
coder-zzzz 已提交
137 138 139
    int addWritePermOfBroker(final String namesrvAddr, String brokerName) throws RemotingCommandException,
            RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQClientException;

140 141
    void putKVConfig(final String namespace, final String key, final String value);

Y
yukon 已提交
142 143
    String getKVConfig(final String namespace,
        final String key) throws RemotingException, MQClientException, InterruptedException;
144

Y
yukon 已提交
145 146
    KVTable getKVListByNamespace(
        final String namespace) throws RemotingException, MQClientException, InterruptedException;
147 148

    void deleteTopicInBroker(final Set<String> addrs, final String topic) throws RemotingException, MQBrokerException,
Y
yukon 已提交
149
        InterruptedException, MQClientException;
150

Y
yukon 已提交
151 152
    void deleteTopicInNameServer(final Set<String> addrs,
        final String topic) throws RemotingException, MQBrokerException,
Y
yukon 已提交
153
        InterruptedException, MQClientException;
154 155

    void deleteSubscriptionGroup(final String addr, String groupName) throws RemotingException, MQBrokerException,
Y
yukon 已提交
156
        InterruptedException, MQClientException;
157

158 159 160
    void deleteSubscriptionGroup(final String addr, String groupName, boolean removeOffset) throws RemotingException, MQBrokerException,
        InterruptedException, MQClientException;

Y
yukon 已提交
161 162
    void createAndUpdateKvConfig(String namespace, String key,
        String value) throws RemotingException, MQBrokerException,
Y
yukon 已提交
163
        InterruptedException, MQClientException;
164 165

    void deleteKvConfig(String namespace, String key) throws RemotingException, MQBrokerException, InterruptedException,
Y
yukon 已提交
166
        MQClientException;
167 168

    List<RollbackStats> resetOffsetByTimestampOld(String consumerGroup, String topic, long timestamp, boolean force)
Y
yukon 已提交
169
        throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
170 171

    Map<MessageQueue, Long> resetOffsetByTimestamp(String topic, String group, long timestamp, boolean isForce)
Y
yukon 已提交
172
        throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
173 174

    void resetOffsetNew(String consumerGroup, String topic, long timestamp) throws RemotingException, MQBrokerException,
Y
yukon 已提交
175
        InterruptedException, MQClientException;
176

Y
yukon 已提交
177 178
    Map<String, Map<MessageQueue, Long>> getConsumeStatus(String topic, String group,
        String clientAddr) throws RemotingException,
Y
yukon 已提交
179
        MQBrokerException, InterruptedException, MQClientException;
180

Y
yukon 已提交
181 182
    void createOrUpdateOrderConf(String key, String value,
        boolean isCluster) throws RemotingException, MQBrokerException,
Y
yukon 已提交
183
        InterruptedException, MQClientException;
184 185

    GroupList queryTopicConsumeByWho(final String topic) throws RemotingConnectException, RemotingSendRequestException,
Y
yukon 已提交
186
        RemotingTimeoutException, InterruptedException, MQBrokerException, RemotingException, MQClientException;
187

Y
yukon 已提交
188 189
    List<QueueTimeSpan> queryConsumeTimeSpan(final String topic,
        final String group) throws InterruptedException, MQBrokerException,
Y
yukon 已提交
190
        RemotingException, MQClientException;
191 192

    boolean cleanExpiredConsumerQueue(String cluster) throws RemotingConnectException, RemotingSendRequestException,
Y
yukon 已提交
193
        RemotingTimeoutException, MQClientException, InterruptedException;
194 195

    boolean cleanExpiredConsumerQueueByAddr(String addr) throws RemotingConnectException, RemotingSendRequestException,
Y
yukon 已提交
196
        RemotingTimeoutException, MQClientException, InterruptedException;
197 198

    boolean cleanUnusedTopic(String cluster) throws RemotingConnectException, RemotingSendRequestException,
Y
yukon 已提交
199
        RemotingTimeoutException, MQClientException, InterruptedException;
200 201

    boolean cleanUnusedTopicByAddr(String addr) throws RemotingConnectException, RemotingSendRequestException,
Y
yukon 已提交
202
        RemotingTimeoutException, MQClientException, InterruptedException;
203 204

    ConsumerRunningInfo getConsumerRunningInfo(final String consumerGroup, final String clientId, final boolean jstack)
Y
yukon 已提交
205
        throws RemotingException, MQClientException, InterruptedException;
206 207

    ConsumeMessageDirectlyResult consumeMessageDirectly(String consumerGroup,
Y
yukon 已提交
208 209
        String clientId,
        String msgId) throws RemotingException, MQClientException, InterruptedException, MQBrokerException;
210 211

    ConsumeMessageDirectlyResult consumeMessageDirectly(String consumerGroup,
Y
yukon 已提交
212 213 214
        String clientId,
        String topic,
        String msgId) throws RemotingException, MQClientException, InterruptedException, MQBrokerException;
215

Y
yukon 已提交
216 217
    List<MessageTrack> messageTrackDetail(
        MessageExt msg) throws RemotingException, MQClientException, InterruptedException,
Y
yukon 已提交
218
        MQBrokerException;
219 220

    void cloneGroupOffset(String srcGroup, String destGroup, String topic, boolean isOffline) throws RemotingException,
Y
yukon 已提交
221
        MQClientException, InterruptedException, MQBrokerException;
222 223

    BrokerStatsData viewBrokerStatsData(final String brokerAddr, final String statsName, final String statsKey)
Y
yukon 已提交
224 225
        throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, MQClientException,
        InterruptedException;
226 227

    Set<String> getClusterList(final String topic) throws RemotingConnectException, RemotingSendRequestException,
Y
yukon 已提交
228
        RemotingTimeoutException, MQClientException, InterruptedException;
229

Y
yukon 已提交
230 231 232
    ConsumeStatsList fetchConsumeStatsInBroker(final String brokerAddr, boolean isOrder,
        long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException,
        RemotingTimeoutException, MQClientException, InterruptedException;
233

Y
yukon 已提交
234 235
    Set<String> getTopicClusterList(
        final String topic) throws InterruptedException, MQBrokerException, MQClientException, RemotingException;
236

Y
yukon 已提交
237 238 239
    SubscriptionGroupWrapper getAllSubscriptionGroup(final String brokerAddr,
        long timeoutMillis) throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException,
        RemotingConnectException, MQBrokerException;
240

Y
yukon 已提交
241 242 243
    TopicConfigSerializeWrapper getAllTopicGroup(final String brokerAddr,
        long timeoutMillis) throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException,
        RemotingConnectException, MQBrokerException;
244

Y
yukon 已提交
245 246
    void updateConsumeOffset(String brokerAddr, String consumeGroup, MessageQueue mq,
        long offset) throws RemotingException, InterruptedException, MQBrokerException;
247 248 249 250 251 252 253 254

    /**
     * Update name server config.
     * <br>
     * Command Code : RequestCode.UPDATE_NAMESRV_CONFIG
     *
     * <br> If param(nameServers) is null or empty, will use name servers from ns!
     */
Y
yukon 已提交
255 256
    void updateNameServerConfig(final Properties properties,
        final List<String> nameServers) throws InterruptedException, RemotingConnectException,
Y
yukon 已提交
257 258
        UnsupportedEncodingException, RemotingSendRequestException, RemotingTimeoutException,
        MQClientException, MQBrokerException;
259 260 261 262 263 264 265 266 267 268

    /**
     * Get name server config.
     * <br>
     * Command Code : RequestCode.GET_NAMESRV_CONFIG
     * <br> If param(nameServers) is null or empty, will use name servers from ns!
     *
     * @return The fetched name server config
     */
    Map<String, Properties> getNameServerConfig(final List<String> nameServers) throws InterruptedException,
Y
yukon 已提交
269 270
        RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException,
        MQClientException, UnsupportedEncodingException;
271 272 273 274 275 276 277 278 279 280 281 282

    /**
     * query consume queue data
     *
     * @param brokerAddr broker ip address
     * @param topic topic
     * @param queueId id of queue
     * @param index start offset
     * @param count how many
     * @param consumerGroup group
     */
    QueryConsumeQueueResponseBody queryConsumeQueue(final String brokerAddr,
Y
yukon 已提交
283 284
        final String topic, final int queueId,
        final long index, final int count, final String consumerGroup)
285
        throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException;
286 287 288 289 290

    boolean resumeCheckHalfMessage(String msgId)
            throws RemotingException, MQClientException, InterruptedException, MQBrokerException;

    boolean resumeCheckHalfMessage(final String topic, final String msgId) throws RemotingException, MQClientException, InterruptedException, MQBrokerException;
291
}