提交 97aa813e 编写于 作者: Y yukon

Reformat code globally second time

上级 7f96008c
......@@ -19,7 +19,6 @@ package org.apache.rocketmq.broker;
import java.io.File;
public class BrokerPathConfigHelper {
private static String brokerConfigPath = System.getProperty("user.home") + File.separator + "store"
+ File.separator + "config" + File.separator + "broker.properties";
......
......@@ -122,7 +122,8 @@ public class ConsumerManager {
return r1 || r2;
}
public void unregisterConsumer(final String group, final ClientChannelInfo clientChannelInfo, boolean isNotifyConsumerIdsChangedEnable) {
public void unregisterConsumer(final String group, final ClientChannelInfo clientChannelInfo,
boolean isNotifyConsumerIdsChangedEnable) {
ConsumerGroupInfo consumerGroupInfo = this.consumerTable.get(group);
if (null != consumerGroupInfo) {
consumerGroupInfo.unregisterChannel(clientChannelInfo);
......
......@@ -54,9 +54,6 @@ public class ConsumerFilterData {
/**
* Check this filter data has been used to calculate bit map when msg was stored in server.
*
* @param msgStoreTime
* @return
*/
public boolean isMsgInLive(long msgStoreTime) {
return msgStoreTime > getBornTime();
......
......@@ -72,16 +72,11 @@ public class ConsumerFilterManager extends ConfigManager {
/**
* Build consumer filter data.Be care, bloom filter data is not included.
*
* @param topic
* @param consumerGroup
* @param expression
* @param type
* @param clientVersion
* @return maybe null
*/
public static ConsumerFilterData build(final String topic, final String consumerGroup,
final String expression, final String type,
final long clientVersion) {
final String expression, final String type,
final long clientVersion) {
if (ExpressionType.isTagType(type)) {
return null;
}
......@@ -140,7 +135,7 @@ public class ConsumerFilterManager extends ConfigManager {
}
public boolean register(final String topic, final String consumerGroup, final String expression,
final String type, final long clientVersion) {
final String type, final long clientVersion) {
if (ExpressionType.isTagType(type)) {
return false;
}
......@@ -357,7 +352,8 @@ public class ConsumerFilterManager extends ConfigManager {
data.setDeadTime(now);
}
public boolean register(String consumerGroup, String expression, String type, BloomFilterData bloomFilterData, long clientVersion) {
public boolean register(String consumerGroup, String expression, String type, BloomFilterData bloomFilterData,
long clientVersion) {
ConsumerFilterData old = this.groupFilterData.get(consumerGroup);
if (old == null) {
......
......@@ -17,7 +17,6 @@
package org.apache.rocketmq.broker.filter;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.filter.ExpressionType;
import org.apache.rocketmq.common.message.MessageConst;
......@@ -32,7 +31,8 @@ import java.util.Map;
* <br>It will decode properties first in order to get real topic.
*/
public class ExpressionForRetryMessageFilter extends ExpressionMessageFilter {
public ExpressionForRetryMessageFilter(SubscriptionData subscriptionData, ConsumerFilterData consumerFilterData, ConsumerFilterManager consumerFilterManager) {
public ExpressionForRetryMessageFilter(SubscriptionData subscriptionData, ConsumerFilterData consumerFilterData,
ConsumerFilterManager consumerFilterManager) {
super(subscriptionData, consumerFilterData, consumerFilterManager);
}
......
......@@ -41,7 +41,7 @@ public class ExpressionMessageFilter implements MessageFilter {
protected final boolean bloomDataValid;
public ExpressionMessageFilter(SubscriptionData subscriptionData, ConsumerFilterData consumerFilterData,
ConsumerFilterManager consumerFilterManager) {
ConsumerFilterManager consumerFilterManager) {
this.subscriptionData = subscriptionData;
this.consumerFilterData = consumerFilterData;
this.consumerFilterManager = consumerFilterManager;
......
......@@ -111,7 +111,6 @@ public class FilterServerManager {
}
}
public void scanNotActiveChannel() {
Iterator<Entry<Channel, FilterServerInfo>> it = this.filterServerTable.entrySet().iterator();
......
......@@ -103,6 +103,7 @@ public class BrokerFastFailure {
}
}
}
public void shutdown() {
this.scheduledExecutorService.shutdown();
}
......
......@@ -25,23 +25,28 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class BrokerFixedThreadPoolExecutor extends ThreadPoolExecutor {
public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime, final TimeUnit unit,
public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime,
final TimeUnit unit,
final BlockingQueue<Runnable> workQueue) {
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);
}
public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime, final TimeUnit unit,
public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime,
final TimeUnit unit,
final BlockingQueue<Runnable> workQueue, final ThreadFactory threadFactory) {
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory);
}
public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime, final TimeUnit unit,
public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime,
final TimeUnit unit,
final BlockingQueue<Runnable> workQueue, final RejectedExecutionHandler handler) {
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, handler);
}
public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime, final TimeUnit unit,
final BlockingQueue<Runnable> workQueue, final ThreadFactory threadFactory, final RejectedExecutionHandler handler) {
public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime,
final TimeUnit unit,
final BlockingQueue<Runnable> workQueue, final ThreadFactory threadFactory,
final RejectedExecutionHandler handler) {
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory, handler);
}
......
......@@ -30,7 +30,7 @@ public class NotifyMessageArrivingListener implements MessageArrivingListener {
@Override
public void arriving(String topic, int queueId, long logicOffset, long tagsCode,
long msgStoreTime, byte[] filterBitMap, Map<String, String> properties) {
long msgStoreTime, byte[] filterBitMap, Map<String, String> properties) {
this.pullRequestHoldService.notifyMessageArriving(topic, queueId, logicOffset, tagsCode,
msgStoreTime, filterBitMap, properties);
}
......
......@@ -114,7 +114,7 @@ public class PullRequestHoldService extends ServiceThread {
}
public void notifyMessageArriving(final String topic, final int queueId, final long maxOffset, final Long tagsCode,
long msgStoreTime, byte[] filterBitMap, Map<String, String> properties) {
long msgStoreTime, byte[] filterBitMap, Map<String, String> properties) {
String key = this.buildKey(topic, queueId);
ManyPullRequest mpr = this.pullRequestTable.get(key);
if (mpr != null) {
......
......@@ -118,7 +118,8 @@ public class ConsumerOffsetManager extends ConfigManager {
return groups;
}
public void commitOffset(final String clientHost, final String group, final String topic, final int queueId, final long offset) {
public void commitOffset(final String clientHost, final String group, final String topic, final int queueId,
final long offset) {
// topic@group
String key = topic + TOPIC_GROUP_SEPARATOR + group;
this.commitOffset(clientHost, key, queueId, offset);
......
......@@ -231,7 +231,8 @@ public class BrokerOuterAPI {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
public TopicConfigSerializeWrapper getAllTopicConfig(final String addr) throws RemotingConnectException, RemotingSendRequestException,
public TopicConfigSerializeWrapper getAllTopicConfig(
final String addr) throws RemotingConnectException, RemotingSendRequestException,
RemotingTimeoutException, InterruptedException, MQBrokerException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_TOPIC_CONFIG, null);
......@@ -248,7 +249,8 @@ public class BrokerOuterAPI {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
public ConsumerOffsetSerializeWrapper getAllConsumerOffset(final String addr) throws InterruptedException, RemotingTimeoutException,
public ConsumerOffsetSerializeWrapper getAllConsumerOffset(
final String addr) throws InterruptedException, RemotingTimeoutException,
RemotingSendRequestException, RemotingConnectException, MQBrokerException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_CONSUMER_OFFSET, null);
RemotingCommand response = this.remotingClient.invokeSync(addr, request, 3000);
......@@ -264,7 +266,8 @@ public class BrokerOuterAPI {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
public String getAllDelayOffset(final String addr) throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException,
public String getAllDelayOffset(
final String addr) throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException,
RemotingConnectException, MQBrokerException, UnsupportedEncodingException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_DELAY_OFFSET, null);
RemotingCommand response = this.remotingClient.invokeSync(addr, request, 3000);
......@@ -280,7 +283,8 @@ public class BrokerOuterAPI {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
public SubscriptionGroupWrapper getAllSubscriptionGroupConfig(final String addr) throws InterruptedException, RemotingTimeoutException,
public SubscriptionGroupWrapper getAllSubscriptionGroupConfig(
final String addr) throws InterruptedException, RemotingTimeoutException,
RemotingSendRequestException, RemotingConnectException, MQBrokerException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_SUBSCRIPTIONGROUP_CONFIG, null);
RemotingCommand response = this.remotingClient.invokeSync(addr, request, 3000);
......
......@@ -28,7 +28,9 @@ public class ManyMessageTransfer extends AbstractReferenceCounted implements Fil
private final ByteBuffer byteBufferHeader;
private final GetMessageResult getMessageResult;
/** Bytes which were transferred already. */
/**
* Bytes which were transferred already.
*/
private long transferred;
public ManyMessageTransfer(ByteBuffer byteBufferHeader, GetMessageResult getMessageResult) {
......
......@@ -27,7 +27,9 @@ public class OneMessageTransfer extends AbstractReferenceCounted implements File
private final ByteBuffer byteBufferHeader;
private final SelectMappedBufferResult selectMappedBufferResult;
/** Bytes which were transferred already. */
/**
* Bytes which were transferred already.
*/
private long transferred;
public OneMessageTransfer(ByteBuffer byteBufferHeader, SelectMappedBufferResult selectMappedBufferResult) {
......
......@@ -28,7 +28,9 @@ public class QueryMessageTransfer extends AbstractReferenceCounted implements Fi
private final ByteBuffer byteBufferHeader;
private final QueryMessageResult queryMessageResult;
/** Bytes which were transferred already. */
/**
* Bytes which were transferred already.
*/
private long transferred;
public QueryMessageTransfer(ByteBuffer byteBufferHeader, QueryMessageResult queryMessageResult) {
......
......@@ -87,7 +87,7 @@ public abstract class AbstractPluginMessageStore implements MessageStore {
@Override
public GetMessageResult getMessage(String group, String topic, int queueId, long offset,
int maxMsgNums, final MessageFilter messageFilter) {
int maxMsgNums, final MessageFilter messageFilter) {
return next.getMessage(group, topic, queueId, offset, maxMsgNums, messageFilter);
}
......
......@@ -116,7 +116,6 @@ import org.apache.rocketmq.store.SelectMappedBufferResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AdminBrokerProcessor implements NettyRequestProcessor {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final BrokerController brokerController;
......@@ -126,7 +125,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
}
@Override
public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
public RemotingCommand processRequest(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
switch (request.getCode()) {
case RequestCode.UPDATE_AND_CREATE_TOPIC:
return this.updateAndCreateTopic(ctx, request);
......@@ -212,7 +212,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
return false;
}
private RemotingCommand updateAndCreateTopic(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand updateAndCreateTopic(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final CreateTopicRequestHeader requestHeader =
(CreateTopicRequestHeader) request.decodeCommandCustomHeader(CreateTopicRequestHeader.class);
......@@ -249,7 +250,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
return null;
}
private RemotingCommand deleteTopic(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand deleteTopic(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
DeleteTopicRequestHeader requestHeader =
(DeleteTopicRequestHeader) request.decodeCommandCustomHeader(DeleteTopicRequestHeader.class);
......@@ -355,7 +357,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand searchOffsetByTimestamp(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand searchOffsetByTimestamp(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(SearchOffsetResponseHeader.class);
final SearchOffsetResponseHeader responseHeader = (SearchOffsetResponseHeader) response.readCustomHeader();
final SearchOffsetRequestHeader requestHeader =
......@@ -371,7 +374,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand getMaxOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand getMaxOffset(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(GetMaxOffsetResponseHeader.class);
final GetMaxOffsetResponseHeader responseHeader = (GetMaxOffsetResponseHeader) response.readCustomHeader();
final GetMaxOffsetRequestHeader requestHeader =
......@@ -386,7 +390,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand getMinOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand getMinOffset(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(GetMinOffsetResponseHeader.class);
final GetMinOffsetResponseHeader responseHeader = (GetMinOffsetResponseHeader) response.readCustomHeader();
final GetMinOffsetRequestHeader requestHeader =
......@@ -400,7 +405,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand getEarliestMsgStoretime(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand getEarliestMsgStoretime(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(GetEarliestMsgStoretimeResponseHeader.class);
final GetEarliestMsgStoretimeResponseHeader responseHeader = (GetEarliestMsgStoretimeResponseHeader) response.readCustomHeader();
final GetEarliestMsgStoretimeRequestHeader requestHeader =
......@@ -429,7 +435,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand lockBatchMQ(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand lockBatchMQ(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
LockBatchRequestBody requestBody = LockBatchRequestBody.decode(request.getBody(), LockBatchRequestBody.class);
......@@ -447,7 +454,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand unlockBatchMQ(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand unlockBatchMQ(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
UnlockBatchRequestBody requestBody = UnlockBatchRequestBody.decode(request.getBody(), UnlockBatchRequestBody.class);
......@@ -477,7 +485,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand getAllSubscriptionGroup(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand getAllSubscriptionGroup(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
String content = this.brokerController.getSubscriptionGroupManager().encode();
if (content != null && content.length() > 0) {
......@@ -503,7 +512,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand deleteSubscriptionGroup(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand deleteSubscriptionGroup(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
DeleteSubscriptionGroupRequestHeader requestHeader =
(DeleteSubscriptionGroupRequestHeader) request.decodeCommandCustomHeader(DeleteSubscriptionGroupRequestHeader.class);
......@@ -517,7 +527,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand getTopicStatsInfo(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand getTopicStatsInfo(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetTopicStatsInfoRequestHeader requestHeader =
(GetTopicStatsInfoRequestHeader) request.decodeCommandCustomHeader(GetTopicStatsInfoRequestHeader.class);
......@@ -565,7 +576,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand getConsumerConnectionList(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand getConsumerConnectionList(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetConsumerConnectionListRequestHeader requestHeader =
(GetConsumerConnectionListRequestHeader) request.decodeCommandCustomHeader(GetConsumerConnectionListRequestHeader.class);
......@@ -604,7 +616,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand getProducerConnectionList(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand getProducerConnectionList(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetProducerConnectionListRequestHeader requestHeader =
(GetProducerConnectionListRequestHeader) request.decodeCommandCustomHeader(GetProducerConnectionListRequestHeader.class);
......@@ -637,7 +650,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand getConsumeStats(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand getConsumeStats(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetConsumeStatsRequestHeader requestHeader =
(GetConsumeStatsRequestHeader) request.decodeCommandCustomHeader(GetConsumeStatsRequestHeader.class);
......@@ -658,7 +672,6 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
continue;
}
{
SubscriptionData findSubscriptionData =
this.brokerController.getConsumerManager().findSubscriptionData(requestHeader.getConsumerGroup(), topic);
......@@ -770,7 +783,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
return response;
}
public RemotingCommand resetOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
public RemotingCommand resetOffset(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final ResetOffsetRequestHeader requestHeader =
(ResetOffsetRequestHeader) request.decodeCommandCustomHeader(ResetOffsetRequestHeader.class);
log.info("[reset-offset] reset offset started by {}. topic={}, group={}, timestamp={}, isForce={}",
......@@ -787,7 +801,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
requestHeader.getTimestamp(), requestHeader.isForce(), isC);
}
public RemotingCommand getConsumerStatus(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
public RemotingCommand getConsumerStatus(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final GetConsumerStatusRequestHeader requestHeader =
(GetConsumerStatusRequestHeader) request.decodeCommandCustomHeader(GetConsumerStatusRequestHeader.class);
......@@ -798,7 +813,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
requestHeader.getClientAddr());
}
private RemotingCommand queryTopicConsumeByWho(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand queryTopicConsumeByWho(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
QueryTopicConsumeByWhoRequestHeader requestHeader =
(QueryTopicConsumeByWhoRequestHeader) request.decodeCommandCustomHeader(QueryTopicConsumeByWhoRequestHeader.class);
......@@ -820,7 +836,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand registerFilterServer(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand registerFilterServer(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(RegisterFilterServerResponseHeader.class);
final RegisterFilterServerResponseHeader responseHeader = (RegisterFilterServerResponseHeader) response.readCustomHeader();
final RegisterFilterServerRequestHeader requestHeader =
......@@ -836,7 +853,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand queryConsumeTimeSpan(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand queryConsumeTimeSpan(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
QueryConsumeTimeSpanRequestHeader requestHeader =
(QueryConsumeTimeSpanRequestHeader) request.decodeCommandCustomHeader(QueryConsumeTimeSpanRequestHeader.class);
......@@ -924,8 +942,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand getConsumerRunningInfo(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand getConsumerRunningInfo(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final GetConsumerRunningInfoRequestHeader requestHeader =
(GetConsumerRunningInfoRequestHeader) request.decodeCommandCustomHeader(GetConsumerRunningInfoRequestHeader.class);
......@@ -933,7 +951,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
requestHeader.getClientId());
}
private RemotingCommand queryCorrectionOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand queryCorrectionOffset(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
QueryCorrectionOffsetHeader requestHeader =
(QueryCorrectionOffsetHeader) request.decodeCommandCustomHeader(QueryCorrectionOffsetHeader.class);
......@@ -960,7 +979,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand consumeMessageDirectly(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand consumeMessageDirectly(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final ConsumeMessageDirectlyResultRequestHeader requestHeader = (ConsumeMessageDirectlyResultRequestHeader) request
.decodeCommandCustomHeader(ConsumeMessageDirectlyResultRequestHeader.class);
......@@ -984,7 +1004,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
requestHeader.getClientId());
}
private RemotingCommand cloneGroupOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand cloneGroupOffset(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
CloneGroupOffsetRequestHeader requestHeader =
(CloneGroupOffsetRequestHeader) request.decodeCommandCustomHeader(CloneGroupOffsetRequestHeader.class);
......@@ -1004,7 +1025,6 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
continue;
}
if (!requestHeader.isOffline()) {
SubscriptionData findSubscriptionData =
......@@ -1025,7 +1045,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand ViewBrokerStatsData(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand ViewBrokerStatsData(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final ViewBrokerStatsDataRequestHeader requestHeader =
(ViewBrokerStatsDataRequestHeader) request.decodeCommandCustomHeader(ViewBrokerStatsDataRequestHeader.class);
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
......@@ -1249,7 +1270,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
}
}
private RemotingCommand queryConsumeQueue(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand queryConsumeQueue(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
QueryConsumeQueueRequestHeader requestHeader =
(QueryConsumeQueueRequestHeader) request.decodeCommandCustomHeader(QueryConsumeQueueRequestHeader.class);
......
......@@ -46,7 +46,8 @@ public class EndTransactionProcessor implements NettyRequestProcessor {
}
@Override
public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
public RemotingCommand processRequest(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final EndTransactionRequestHeader requestHeader =
(EndTransactionRequestHeader) request.decodeCommandCustomHeader(EndTransactionRequestHeader.class);
......
......@@ -76,7 +76,8 @@ public class PullMessageProcessor implements NettyRequestProcessor {
}
@Override
public RemotingCommand processRequest(final ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
public RemotingCommand processRequest(final ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
return this.processRequest(ctx.channel(), request, true);
}
......@@ -138,7 +139,7 @@ public class PullMessageProcessor implements NettyRequestProcessor {
if (requestHeader.getQueueId() < 0 || requestHeader.getQueueId() >= topicConfig.getReadQueueNums()) {
String errorInfo = String.format("queueId[%d] is illegal, topic:[%s] topicConfig.readQueueNums:[%d] consumer:[%s]",
requestHeader.getQueueId(), requestHeader.getTopic(), topicConfig.getReadQueueNums(), channel.remoteAddress());
requestHeader.getQueueId(), requestHeader.getTopic(), topicConfig.getReadQueueNums(), channel.remoteAddress());
log.warn(errorInfo);
response.setCode(ResponseCode.SYSTEM_ERROR);
response.setRemark(errorInfo);
......@@ -286,11 +287,11 @@ public class PullMessageProcessor implements NettyRequestProcessor {
// XXX: warn and notify me
log.info("the broker store no queue data, fix the request offset {} to {}, Topic: {} QueueId: {} Consumer Group: {}",
requestHeader.getQueueOffset(),
getMessageResult.getNextBeginOffset(),
requestHeader.getTopic(),
requestHeader.getQueueId(),
requestHeader.getConsumerGroup()
requestHeader.getQueueOffset(),
getMessageResult.getNextBeginOffset(),
requestHeader.getTopic(),
requestHeader.getQueueId(),
requestHeader.getConsumerGroup()
);
} else {
response.setCode(ResponseCode.PULL_NOT_FOUND);
......@@ -314,8 +315,8 @@ public class PullMessageProcessor implements NettyRequestProcessor {
case OFFSET_TOO_SMALL:
response.setCode(ResponseCode.PULL_OFFSET_MOVED);
log.info("the request offset too small. group={}, topic={}, requestOffset={}, brokerMinOffset={}, clientIp={}",
requestHeader.getConsumerGroup(), requestHeader.getTopic(), requestHeader.getQueueOffset(),
getMessageResult.getMinOffset(), channel.remoteAddress());
requestHeader.getConsumerGroup(), requestHeader.getTopic(), requestHeader.getQueueOffset(),
getMessageResult.getMinOffset(), channel.remoteAddress());
break;
default:
assert false;
......@@ -437,15 +438,15 @@ public class PullMessageProcessor implements NettyRequestProcessor {
event.setOffsetNew(getMessageResult.getNextBeginOffset());
this.generateOffsetMovedEvent(event);
log.warn(
"PULL_OFFSET_MOVED:correction offset. topic={}, groupId={}, requestOffset={}, newOffset={}, suggestBrokerId={}",
requestHeader.getTopic(), requestHeader.getConsumerGroup(), event.getOffsetRequest(), event.getOffsetNew(),
responseHeader.getSuggestWhichBrokerId());
"PULL_OFFSET_MOVED:correction offset. topic={}, groupId={}, requestOffset={}, newOffset={}, suggestBrokerId={}",
requestHeader.getTopic(), requestHeader.getConsumerGroup(), event.getOffsetRequest(), event.getOffsetNew(),
responseHeader.getSuggestWhichBrokerId());
} else {
responseHeader.setSuggestWhichBrokerId(subscriptionGroupConfig.getBrokerId());
response.setCode(ResponseCode.PULL_RETRY_IMMEDIATELY);
log.warn("PULL_OFFSET_MOVED:none correction. topic={}, groupId={}, requestOffset={}, suggestBrokerId={}",
requestHeader.getTopic(), requestHeader.getConsumerGroup(), requestHeader.getQueueOffset(),
responseHeader.getSuggestWhichBrokerId());
requestHeader.getTopic(), requestHeader.getConsumerGroup(), requestHeader.getQueueOffset(),
responseHeader.getSuggestWhichBrokerId());
}
break;
......@@ -483,7 +484,8 @@ public class PullMessageProcessor implements NettyRequestProcessor {
}
}
private byte[] readGetMessageResult(final GetMessageResult getMessageResult, final String group, final String topic, final int queueId) {
private byte[] readGetMessageResult(final GetMessageResult getMessageResult, final String group, final String topic,
final int queueId) {
final ByteBuffer byteBuffer = ByteBuffer.allocate(getMessageResult.getBufferTotalSize());
long storeTimestamp = 0;
......@@ -528,7 +530,8 @@ public class PullMessageProcessor implements NettyRequestProcessor {
}
}
public void executeRequestWhenWakeup(final Channel channel, final RemotingCommand request) throws RemotingCommandException {
public void executeRequestWhenWakeup(final Channel channel,
final RemotingCommand request) throws RemotingCommandException {
Runnable run = new Runnable() {
@Override
public void run() {
......
......@@ -60,7 +60,8 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
}
@Override
public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
public RemotingCommand processRequest(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
SendMessageContext mqtraceContext;
switch (request.getCode()) {
case RequestCode.CONSUMER_SEND_MSG_BACK:
......@@ -245,8 +246,8 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
return response;
}
private boolean handleRetryAndDLQ(SendMessageRequestHeader requestHeader, RemotingCommand response, RemotingCommand request,
private boolean handleRetryAndDLQ(SendMessageRequestHeader requestHeader, RemotingCommand response,
RemotingCommand request,
MessageExt msg, TopicConfig topicConfig) {
String newTopic = requestHeader.getTopic();
if (null != newTopic && newTopic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
......@@ -319,8 +320,6 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
final byte[] body = request.getBody();
int queueIdInt = requestHeader.getQueueId();
TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(requestHeader.getTopic());
......@@ -361,13 +360,14 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
}
private RemotingCommand handlePutMessageResult(PutMessageResult putMessageResult, RemotingCommand response, RemotingCommand request, MessageExt msg,
SendMessageResponseHeader responseHeader, SendMessageContext sendMessageContext, ChannelHandlerContext ctx, int queueIdInt) {
private RemotingCommand handlePutMessageResult(PutMessageResult putMessageResult, RemotingCommand response,
RemotingCommand request, MessageExt msg,
SendMessageResponseHeader responseHeader, SendMessageContext sendMessageContext, ChannelHandlerContext ctx,
int queueIdInt) {
if (putMessageResult == null) {
response.setCode(ResponseCode.SYSTEM_ERROR);
response.setRemark("store putMessage return null");
return response;
return response;
}
boolean sendOK = false;
......@@ -462,17 +462,17 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
sendMessageContext.setCommercialOwner(owner);
}
}
return response;
return response;
}
private RemotingCommand sendBatchMessage(final ChannelHandlerContext ctx,
final RemotingCommand request,
final SendMessageContext sendMessageContext,
final SendMessageRequestHeader requestHeader) throws RemotingCommandException {
final RemotingCommand request,
final SendMessageContext sendMessageContext,
final SendMessageRequestHeader requestHeader) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(SendMessageResponseHeader.class);
final SendMessageResponseHeader responseHeader = (SendMessageResponseHeader) response.readCustomHeader();
response.setOpaque(request.getOpaque());
response.addExtField(MessageConst.PROPERTY_MSG_REGION, this.brokerController.getBrokerConfig().getRegionId());
......@@ -493,7 +493,6 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
return response;
}
int queueIdInt = requestHeader.getQueueId();
TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(requestHeader.getTopic());
......@@ -509,7 +508,7 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
if (requestHeader.getTopic() != null && requestHeader.getTopic().startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
response.setCode(ResponseCode.MESSAGE_ILLEGAL);
response.setRemark("batch request does not support retry group " + requestHeader.getTopic());
response.setRemark("batch request does not support retry group " + requestHeader.getTopic());
return response;
}
MessageExtBatch messageExtBatch = new MessageExtBatch();
......
......@@ -143,7 +143,7 @@ public class SubscriptionGroupManager extends ConfigManager {
@Override
public String configFilePath() {
return BrokerPathConfigHelper.getSubscriptionGroupPath(this.brokerController.getMessageStoreConfig()
.getStorePathRootDir());
.getStorePathRootDir());
}
@Override
......
......@@ -272,7 +272,7 @@ public class TopicConfigManager extends ConfigManager {
}
log.info("update topic sys flag. oldTopicSysFlag={}, newTopicSysFlag", oldTopicSysFlag,
topicConfig.getTopicSysFlag());
topicConfig.getTopicSysFlag());
this.topicConfigTable.put(topic, topicConfig);
......@@ -292,7 +292,7 @@ public class TopicConfigManager extends ConfigManager {
}
log.info("update topic sys flag. oldTopicSysFlag={}, newTopicSysFlag", oldTopicSysFlag,
topicConfig.getTopicSysFlag());
topicConfig.getTopicSysFlag());
this.topicConfigTable.put(topic, topicConfig);
......@@ -384,7 +384,7 @@ public class TopicConfigManager extends ConfigManager {
@Override
public String configFilePath() {
return BrokerPathConfigHelper.getTopicConfigPath(this.brokerController.getMessageStoreConfig()
.getStorePathRootDir());
.getStorePathRootDir());
}
@Override
......
......@@ -50,7 +50,7 @@ public class BrokerControllerTest {
}
@After
public void destory(){
public void destory() {
UtilAll.deleteFile(new File(new MessageStoreConfig().getStorePathRootDir()));
}
}
......@@ -51,7 +51,6 @@ public class CommitLogDispatcherCalcBitMapTest {
ConsumerFilterData nullBloomData = filterManager.get("topic0", "CID_1");
nullBloomData.setBloomFilterData(null);
CommitLogDispatcherCalcBitMap calcBitMap = new CommitLogDispatcherCalcBitMap(brokerConfig,
filterManager);
......
......@@ -97,7 +97,7 @@ public class MessageStoreWithFilterTest {
}
public MessageStoreConfig buildStoreConfig(int commitLogFileSize, int cqFileSize,
boolean enableCqExt, int cqExtFileSize) {
boolean enableCqExt, int cqExtFileSize) {
MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
messageStoreConfig.setMapedFileSizeCommitLog(commitLogFileSize);
messageStoreConfig.setMapedFileSizeConsumeQueue(cqFileSize);
......@@ -127,7 +127,7 @@ public class MessageStoreWithFilterTest {
new MessageArrivingListener() {
@Override
public void arriving(String topic, int queueId, long logicOffset, long tagsCode,
long msgStoreTime, byte[] filterBitMap, Map<String, String> properties) {
long msgStoreTime, byte[] filterBitMap, Map<String, String> properties) {
// System.out.println(String.format("Msg coming: %s, %d, %d, %d",
// topic, queueId, logicOffset, tagsCode));
}
......@@ -154,7 +154,8 @@ public class MessageStoreWithFilterTest {
return master;
}
protected List<MessageExtBrokerInner> putMsg(DefaultMessageStore master, int topicCount, int msgCountPerTopic) throws Exception {
protected List<MessageExtBrokerInner> putMsg(DefaultMessageStore master, int topicCount,
int msgCountPerTopic) throws Exception {
List<MessageExtBrokerInner> msgs = new ArrayList<MessageExtBrokerInner>();
for (int i = 0; i < topicCount; i++) {
String realTopic = topic + i;
......
......@@ -142,15 +142,18 @@ public class PullMessageProcessorTest {
List<ConsumeMessageHook> consumeMessageHookList = new ArrayList<>();
final ConsumeMessageContext[] messageContext = new ConsumeMessageContext[1];
ConsumeMessageHook consumeMessageHook = new ConsumeMessageHook() {
@Override public String hookName() {
@Override
public String hookName() {
return "TestHook";
}
@Override public void consumeMessageBefore(ConsumeMessageContext context) {
@Override
public void consumeMessageBefore(ConsumeMessageContext context) {
messageContext[0] = context;
}
@Override public void consumeMessageAfter(ConsumeMessageContext context) {
@Override
public void consumeMessageAfter(ConsumeMessageContext context) {
}
};
consumeMessageHookList.add(consumeMessageHook);
......
......@@ -94,15 +94,18 @@ public class SendMessageProcessorTest {
List<SendMessageHook> sendMessageHookList = new ArrayList<>();
final SendMessageContext[] sendMessageContext = new SendMessageContext[1];
SendMessageHook sendMessageHook = new SendMessageHook() {
@Override public String hookName() {
@Override
public String hookName() {
return null;
}
@Override public void sendMessageBefore(SendMessageContext context) {
@Override
public void sendMessageBefore(SendMessageContext context) {
sendMessageContext[0] = context;
}
@Override public void sendMessageAfter(SendMessageContext context) {
@Override
public void sendMessageAfter(SendMessageContext context) {
}
};
......@@ -115,7 +118,6 @@ public class SendMessageProcessorTest {
assertThat(sendMessageContext[0].getProducerGroup()).isEqualTo(group);
}
@Test
public void testProcessRequest_FlushTimeOut() throws RemotingCommandException {
when(messageStore.putMessage(any(MessageExtBrokerInner.class))).thenReturn(new PutMessageResult(PutMessageStatus.FLUSH_DISK_TIMEOUT, new AppendMessageResult(AppendMessageStatus.UNKNOWN_ERROR)));
......@@ -210,7 +212,8 @@ public class SendMessageProcessorTest {
final RemotingCommand request = createSendMsgCommand(RequestCode.SEND_MESSAGE);
final RemotingCommand[] response = new RemotingCommand[1];
doAnswer(new Answer() {
@Override public Object answer(InvocationOnMock invocation) throws Throwable {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
response[0] = invocation.getArgument(0);
return null;
}
......
......@@ -32,7 +32,6 @@ public interface MQAdmin {
* @param key accesskey
* @param newTopic topic name
* @param queueNum topic's queue number
* @throws MQClientException
*/
void createTopic(final String key, final String newTopic, final int queueNum)
throws MQClientException;
......@@ -44,7 +43,6 @@ public interface MQAdmin {
* @param newTopic topic name
* @param queueNum topic's queue number
* @param topicSysFlag topic system flag
* @throws MQClientException
*/
void createTopic(String key, String newTopic, int queueNum, int topicSysFlag)
throws MQClientException;
......@@ -56,7 +54,6 @@ public interface MQAdmin {
* @param mq Instance of MessageQueue
* @param timestamp from when in milliseconds.
* @return offset
* @throws MQClientException
*/
long searchOffset(final MessageQueue mq, final long timestamp) throws MQClientException;
......@@ -65,7 +62,6 @@ public interface MQAdmin {
*
* @param mq Instance of MessageQueue
* @return the max offset
* @throws MQClientException
*/
long maxOffset(final MessageQueue mq) throws MQClientException;
......@@ -74,7 +70,6 @@ public interface MQAdmin {
*
* @param mq Instance of MessageQueue
* @return the minimum offset
* @throws MQClientException
*/
long minOffset(final MessageQueue mq) throws MQClientException;
......@@ -83,7 +78,6 @@ public interface MQAdmin {
*
* @param mq Instance of MessageQueue
* @return the time in microseconds
* @throws MQClientException
*/
long earliestMsgStoreTime(final MessageQueue mq) throws MQClientException;
......@@ -92,10 +86,6 @@ public interface MQAdmin {
*
* @param offsetMsgId message id
* @return message
* @throws InterruptedException
* @throws MQBrokerException
* @throws RemotingException
* @throws MQClientException
*/
MessageExt viewMessage(final String offsetMsgId) throws RemotingException, MQBrokerException,
InterruptedException, MQClientException;
......@@ -109,21 +99,14 @@ public interface MQAdmin {
* @param begin from when
* @param end to when
* @return Instance of QueryResult
* @throws MQClientException
* @throws InterruptedException
*/
QueryResult queryMessage(final String topic, final String key, final int maxNum, final long begin,
final long end) throws MQClientException, InterruptedException;
/**
* @param topic
* @param msgId
* @return The {@code MessageExt} of given msgId
* @throws RemotingException
* @throws MQBrokerException
* @throws InterruptedException
* @throws MQClientException
*/
MessageExt viewMessage(String topic, String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
MessageExt viewMessage(String topic,
String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
}
\ No newline at end of file
......@@ -41,7 +41,6 @@ public class MQHelper {
* @param consumerGroup consumer group
* @param topic topic
* @param timestamp time
* @throws Exception
*/
public static void resetOffsetByTimestamp(
final MessageModel messageModel,
......
......@@ -35,8 +35,6 @@ public class Validators {
public static final int CHARACTER_MAX_LENGTH = 255;
/**
* @param origin
* @param patternStr
* @return The resulting {@code String}
*/
public static String getGroupWithRegularExpression(String origin, String patternStr) {
......@@ -50,9 +48,6 @@ public class Validators {
/**
* Validate group
*
* @param group
* @throws MQClientException
*/
public static void checkGroup(String group) throws MQClientException {
if (UtilAll.isBlank(group)) {
......@@ -69,8 +64,6 @@ public class Validators {
}
/**
* @param origin
* @param pattern
* @return <tt>true</tt> if, and only if, the entire origin sequence matches this matcher's pattern
*/
public static boolean regularExpressionMatcher(String origin, Pattern pattern) {
......@@ -83,10 +76,6 @@ public class Validators {
/**
* Validate message
*
* @param msg
* @param defaultMQProducer
* @throws MQClientException
*/
public static void checkMessage(Message msg, DefaultMQProducer defaultMQProducer)
throws MQClientException {
......@@ -113,9 +102,6 @@ public class Validators {
/**
* Validate topic
*
* @param topic
* @throws MQClientException
*/
public static void checkTopic(String topic) throws MQClientException {
if (UtilAll.isBlank(topic)) {
......
......@@ -264,7 +264,8 @@ public class DefaultMQPullConsumer extends ClientConfig implements MQPullConsume
}
@Override
public void pull(MessageQueue mq, String subExpression, long offset, int maxNums, PullCallback pullCallback, long timeout)
public void pull(MessageQueue mq, String subExpression, long offset, int maxNums, PullCallback pullCallback,
long timeout)
throws MQClientException, RemotingException, InterruptedException {
this.defaultMQPullConsumerImpl.pull(mq, subExpression, offset, maxNums, pullCallback, timeout);
}
......@@ -276,7 +277,8 @@ public class DefaultMQPullConsumer extends ClientConfig implements MQPullConsume
}
@Override
public void pullBlockIfNotFound(MessageQueue mq, String subExpression, long offset, int maxNums, PullCallback pullCallback)
public void pullBlockIfNotFound(MessageQueue mq, String subExpression, long offset, int maxNums,
PullCallback pullCallback)
throws MQClientException, RemotingException, InterruptedException {
this.defaultMQPullConsumerImpl.pullBlockIfNotFound(mq, subExpression, offset, maxNums, pullCallback);
}
......@@ -297,7 +299,8 @@ public class DefaultMQPullConsumer extends ClientConfig implements MQPullConsume
}
@Override
public MessageExt viewMessage(String topic, String uniqKey) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
public MessageExt viewMessage(String topic,
String uniqKey) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
try {
MessageDecoder.decodeMessageId(uniqKey);
return this.viewMessage(uniqKey);
......
......@@ -51,7 +51,7 @@ import org.apache.rocketmq.remoting.exception.RemotingException;
* </p>
*
* <p>
* <strong>Thread Safety:</strong> After initialization, the instance can be regarded as thread-safe.
* <strong>Thread Safety:</strong> After initialization, the instance can be regarded as thread-safe.
* </p>
*/
public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsumer {
......@@ -90,29 +90,29 @@ public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsume
*
* There are three consuming points:
* <ul>
* <li>
* <code>CONSUME_FROM_LAST_OFFSET</code>: consumer clients pick up where it stopped previously.
* If it were a newly booting up consumer client, according aging of the consumer group, there are two
* cases:
* <ol>
* <li>
* if the consumer group is created so recently that the earliest message being subscribed has yet
* expired, which means the consumer group represents a lately launched business, consuming will
* start from the very beginning;
* </li>
* <li>
* if the earliest message being subscribed has expired, consuming will start from the latest
* messages, meaning messages born prior to the booting timestamp would be ignored.
* </li>
* </ol>
* </li>
* <li>
* <code>CONSUME_FROM_FIRST_OFFSET</code>: Consumer client will start from earliest messages available.
* </li>
* <li>
* <code>CONSUME_FROM_TIMESTAMP</code>: Consumer client will start from specified timestamp, which means
* messages born prior to {@link #consumeTimestamp} will be ignored
* </li>
* <li>
* <code>CONSUME_FROM_LAST_OFFSET</code>: consumer clients pick up where it stopped previously.
* If it were a newly booting up consumer client, according aging of the consumer group, there are two
* cases:
* <ol>
* <li>
* if the consumer group is created so recently that the earliest message being subscribed has yet
* expired, which means the consumer group represents a lately launched business, consuming will
* start from the very beginning;
* </li>
* <li>
* if the earliest message being subscribed has expired, consuming will start from the latest
* messages, meaning messages born prior to the booting timestamp would be ignored.
* </li>
* </ol>
* </li>
* <li>
* <code>CONSUME_FROM_FIRST_OFFSET</code>: Consumer client will start from earliest messages available.
* </li>
* <li>
* <code>CONSUME_FROM_TIMESTAMP</code>: Consumer client will start from specified timestamp, which means
* messages born prior to {@link #consumeTimestamp} will be ignored
* </li>
* </ul>
*/
private ConsumeFromWhere consumeFromWhere = ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET;
......@@ -223,11 +223,13 @@ public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsume
/**
* Constructor specifying consumer group, RPC hook and message queue allocating algorithm.
*
* @param consumerGroup Consume queue.
* @param rpcHook RPC hook to execute before each remoting command.
* @param allocateMessageQueueStrategy message queue allocating algorithm.
*/
public DefaultMQPushConsumer(final String consumerGroup, RPCHook rpcHook, AllocateMessageQueueStrategy allocateMessageQueueStrategy) {
public DefaultMQPushConsumer(final String consumerGroup, RPCHook rpcHook,
AllocateMessageQueueStrategy allocateMessageQueueStrategy) {
this.consumerGroup = consumerGroup;
this.allocateMessageQueueStrategy = allocateMessageQueueStrategy;
defaultMQPushConsumerImpl = new DefaultMQPushConsumerImpl(this, rpcHook);
......@@ -235,6 +237,7 @@ public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsume
/**
* Constructor specifying RPC hook.
*
* @param rpcHook RPC hook to execute before each remoting command.
*/
public DefaultMQPushConsumer(RPCHook rpcHook) {
......@@ -243,6 +246,7 @@ public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsume
/**
* Constructor specifying consumer group.
*
* @param consumerGroup Consumer group.
*/
public DefaultMQPushConsumer(final String consumerGroup) {
......@@ -280,7 +284,8 @@ public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsume
}
@Override
public MessageExt viewMessage(String offsetMsgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
public MessageExt viewMessage(
String offsetMsgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
return this.defaultMQPushConsumerImpl.viewMessage(offsetMsgId);
}
......@@ -291,7 +296,8 @@ public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsume
}
@Override
public MessageExt viewMessage(String topic, String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
public MessageExt viewMessage(String topic,
String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
try {
MessageDecoder.decodeMessageId(msgId);
return this.viewMessage(msgId);
......@@ -411,6 +417,7 @@ public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsume
/**
* Send message back to broker which will be re-delivered in future.
*
* @param msg Message to send back.
* @param delayLevel delay level.
* @throws RemotingException if there is any network-tier error.
......@@ -449,6 +456,7 @@ public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsume
/**
* This method gets internal infrastructure readily to serve. Instances must call this method after configuration.
*
* @throws MQClientException if there is any client error.
*/
@Override
......@@ -498,7 +506,7 @@ public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsume
*
* @param topic topic to subscribe.
* @param subExpression subscription expression.it only support or operation such as "tag1 || tag2 || tag3" <br>
* if null or * expression,meaning subscribe all
* if null or * expression,meaning subscribe all
* @throws MQClientException if there is any client error.
*/
@Override
......@@ -508,10 +516,10 @@ public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsume
/**
* Subscribe a topic to consuming subscription.
*
* @param topic topic to consume.
* @param fullClassName full class name,must extend org.apache.rocketmq.common.filter. MessageFilter
* @param filterClassSource class source code,used UTF-8 file encoding,must be responsible for your code safety
* @throws MQClientException
*/
@Override
public void subscribe(String topic, String fullClassName, String filterClassSource) throws MQClientException {
......@@ -521,12 +529,10 @@ public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsume
/**
* Subscribe a topic by message selector.
*
* @see org.apache.rocketmq.client.consumer.MessageSelector#bySql
* @see org.apache.rocketmq.client.consumer.MessageSelector#byTag
*
* @param topic topic to consume.
* @param messageSelector {@link org.apache.rocketmq.client.consumer.MessageSelector}
* @throws MQClientException
* @see org.apache.rocketmq.client.consumer.MessageSelector#bySql
* @see org.apache.rocketmq.client.consumer.MessageSelector#byTag
*/
@Override
public void subscribe(final String topic, final MessageSelector messageSelector) throws MQClientException {
......@@ -535,6 +541,7 @@ public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsume
/**
* Un-subscribe the specified topic from subscription.
*
* @param topic message topic
*/
@Override
......
......@@ -30,13 +30,6 @@ import org.apache.rocketmq.remoting.exception.RemotingException;
public interface MQConsumer extends MQAdmin {
/**
* If consuming failure,message will be send back to the brokers,and delay consuming some time
*
* @param msg
* @param delayLevel
* @throws InterruptedException
* @throws MQBrokerException
* @throws RemotingException
* @throws MQClientException
*/
@Deprecated
void sendMessageBack(final MessageExt msg, final int delayLevel) throws RemotingException,
......@@ -44,14 +37,6 @@ public interface MQConsumer extends MQAdmin {
/**
* If consuming failure,message will be send back to the broker,and delay consuming some time
*
* @param msg
* @param delayLevel
* @param brokerName
* @throws RemotingException
* @throws MQBrokerException
* @throws InterruptedException
* @throws MQClientException
*/
void sendMessageBack(final MessageExt msg, final int delayLevel, final String brokerName)
throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
......@@ -61,7 +46,6 @@ public interface MQConsumer extends MQAdmin {
*
* @param topic message topic
* @return queue set
* @throws MQClientException
*/
Set<MessageQueue> fetchSubscribeMessageQueues(final String topic) throws MQClientException;
}
......@@ -29,8 +29,6 @@ import org.apache.rocketmq.remoting.exception.RemotingException;
public interface MQPullConsumer extends MQConsumer {
/**
* Start the consumer
*
* @throws MQClientException
*/
void start() throws MQClientException;
......@@ -41,9 +39,6 @@ public interface MQPullConsumer extends MQConsumer {
/**
* Register the message queue listener
*
* @param topic
* @param listener
*/
void registerMessageQueueListener(final String topic, final MessageQueueListener listener);
......@@ -51,15 +46,12 @@ public interface MQPullConsumer extends MQConsumer {
* Pulling the messages,not blocking
*
* @param mq from which message queue
* @param subExpression subscription expression.it only support or operation such as "tag1 || tag2 || tag3" <br> if null or * expression,meaning subscribe
* @param subExpression subscription expression.it only support or operation such as "tag1 || tag2 || tag3" <br> if
* null or * expression,meaning subscribe
* all
* @param offset from where to pull
* @param maxNums max pulling numbers
* @return The resulting {@code PullRequest}
* @throws MQClientException
* @throws InterruptedException
* @throws MQBrokerException
* @throws RemotingException
*/
PullResult pull(final MessageQueue mq, final String subExpression, final long offset,
final int maxNums) throws MQClientException, RemotingException, MQBrokerException,
......@@ -68,16 +60,7 @@ public interface MQPullConsumer extends MQConsumer {
/**
* Pulling the messages in the specified timeout
*
* @param mq
* @param subExpression
* @param offset
* @param maxNums
* @param timeout
* @return The resulting {@code PullRequest}
* @throws MQClientException
* @throws RemotingException
* @throws MQBrokerException
* @throws InterruptedException
*/
PullResult pull(final MessageQueue mq, final String subExpression, final long offset,
final int maxNums, final long timeout) throws MQClientException, RemotingException,
......@@ -85,15 +68,6 @@ public interface MQPullConsumer extends MQConsumer {
/**
* Pulling the messages in a async. way
*
* @param mq
* @param subExpression
* @param offset
* @param maxNums
* @param pullCallback
* @throws MQClientException
* @throws RemotingException
* @throws InterruptedException
*/
void pull(final MessageQueue mq, final String subExpression, final long offset, final int maxNums,
final PullCallback pullCallback) throws MQClientException, RemotingException,
......@@ -101,16 +75,6 @@ public interface MQPullConsumer extends MQConsumer {
/**
* Pulling the messages in a async. way
*
* @param mq
* @param subExpression
* @param offset
* @param maxNums
* @param pullCallback
* @param timeout
* @throws MQClientException
* @throws RemotingException
* @throws InterruptedException
*/
void pull(final MessageQueue mq, final String subExpression, final long offset, final int maxNums,
final PullCallback pullCallback, long timeout) throws MQClientException, RemotingException,
......@@ -119,15 +83,7 @@ public interface MQPullConsumer extends MQConsumer {
/**
* Pulling the messages,if no message arrival,blocking some time
*
* @param mq
* @param subExpression
* @param offset
* @param maxNums
* @return The resulting {@code PullRequest}
* @throws MQClientException
* @throws RemotingException
* @throws MQBrokerException
* @throws InterruptedException
*/
PullResult pullBlockIfNotFound(final MessageQueue mq, final String subExpression,
final long offset, final int maxNums) throws MQClientException, RemotingException,
......@@ -135,15 +91,6 @@ public interface MQPullConsumer extends MQConsumer {
/**
* Pulling the messages through callback function,if no message arrival,blocking.
*
* @param mq
* @param subExpression
* @param offset
* @param maxNums
* @param pullCallback
* @throws MQClientException
* @throws RemotingException
* @throws InterruptedException
*/
void pullBlockIfNotFound(final MessageQueue mq, final String subExpression, final long offset,
final int maxNums, final PullCallback pullCallback) throws MQClientException, RemotingException,
......@@ -151,20 +98,13 @@ public interface MQPullConsumer extends MQConsumer {
/**
* Update the offset
*
* @param mq
* @param offset
* @throws MQClientException
*/
void updateConsumeOffset(final MessageQueue mq, final long offset) throws MQClientException;
/**
* Fetch the offset
*
* @param mq
* @param fromStore
* @return The fetched offset of given queue
* @throws MQClientException
*/
long fetchConsumeOffset(final MessageQueue mq, final boolean fromStore) throws MQClientException;
......@@ -173,22 +113,12 @@ public interface MQPullConsumer extends MQConsumer {
*
* @param topic message topic
* @return message queue set
* @throws MQClientException
*/
Set<MessageQueue> fetchMessageQueuesInBalance(final String topic) throws MQClientException;
/**
* If consuming failure,message will be send back to the broker,and delay consuming in some time later.<br>
* Mind! message can only be consumed in the same group.
*
* @param msg
* @param delayLevel
* @param brokerName
* @param consumerGroup
* @throws RemotingException
* @throws MQBrokerException
* @throws InterruptedException
* @throws MQClientException
*/
void sendMessageBack(MessageExt msg, int delayLevel, String brokerName, String consumerGroup)
throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
......
......@@ -27,8 +27,6 @@ import org.apache.rocketmq.client.exception.MQClientException;
public interface MQPushConsumer extends MQConsumer {
/**
* Start the consumer
*
* @throws MQClientException
*/
void start() throws MQClientException;
......@@ -39,8 +37,6 @@ public interface MQPushConsumer extends MQConsumer {
/**
* Register the message listener
*
* @param messageListener
*/
@Deprecated
void registerMessageListener(MessageListener messageListener);
......@@ -52,22 +48,20 @@ public interface MQPushConsumer extends MQConsumer {
/**
* Subscribe some topic
*
* @param topic
* @param subExpression subscription expression.it only support or operation such as "tag1 || tag2 || tag3" <br> if null or * expression,meaning subscribe
* @param subExpression subscription expression.it only support or operation such as "tag1 || tag2 || tag3" <br> if
* null or * expression,meaning subscribe
* all
* @throws MQClientException
*/
void subscribe(final String topic, final String subExpression) throws MQClientException;
/**
* Subscribe some topic
*
* @param topic
* @param fullClassName full class name,must extend org.apache.rocketmq.common.filter. MessageFilter
* @param filterClassSource class source code,used UTF-8 file encoding,must be responsible for your code safety
* @throws MQClientException
*/
void subscribe(final String topic, final String fullClassName, final String filterClassSource) throws MQClientException;
void subscribe(final String topic, final String fullClassName,
final String filterClassSource) throws MQClientException;
/**
* Subscribe some topic with selector.
......@@ -84,9 +78,7 @@ public interface MQPushConsumer extends MQConsumer {
* Choose SQL92: {@link MessageSelector#bySql(java.lang.String)}
* </p>
*
* @param topic
* @param selector message selector({@link MessageSelector}), can be null.
* @throws MQClientException
*/
void subscribe(final String topic, final MessageSelector selector) throws MQClientException;
......@@ -99,8 +91,6 @@ public interface MQPushConsumer extends MQConsumer {
/**
* Update the consumer thread pool size Dynamically
*
* @param corePoolSize
*/
void updateCorePoolSize(int corePoolSize);
......
......@@ -20,14 +20,13 @@ package org.apache.rocketmq.client.consumer;
import org.apache.rocketmq.common.filter.ExpressionType;
/**
*
* Message selector: select message at server.
* <p>
* Now, support:
* <li>Tag: {@link org.apache.rocketmq.common.filter.ExpressionType#TAG}
* </li>
* <li>SQL92: {@link org.apache.rocketmq.common.filter.ExpressionType#SQL92}
* </li>
* Now, support:
* <li>Tag: {@link org.apache.rocketmq.common.filter.ExpressionType#TAG}
* </li>
* <li>SQL92: {@link org.apache.rocketmq.common.filter.ExpressionType#SQL92}
* </li>
* </p>
*/
public class MessageSelector {
......@@ -51,7 +50,6 @@ public class MessageSelector {
* Use SLQ92 to select message.
*
* @param sql if null or empty, will be treated as select all message.
* @return
*/
public static MessageSelector bySql(String sql) {
return new MessageSelector(ExpressionType.SQL92, sql);
......@@ -61,7 +59,6 @@ public class MessageSelector {
* Use tag to select message.
*
* @param tag if null or empty or "*", will be treated as select all message.
* @return
*/
public static MessageSelector byTag(String tag) {
return new MessageSelector(ExpressionType.TAG, tag);
......
......@@ -24,10 +24,10 @@ import org.apache.rocketmq.common.message.MessageExt;
*/
public interface MessageListenerConcurrently extends MessageListener {
/**
* It is not recommend to throw exception,rather than returning ConsumeConcurrentlyStatus.RECONSUME_LATER if consumption failure
* It is not recommend to throw exception,rather than returning ConsumeConcurrentlyStatus.RECONSUME_LATER if
* consumption failure
*
* @param msgs msgs.size() >= 1<br> DefaultMQPushConsumer.consumeMessageBatchMaxSize=1,you can modify here
* @param context
* @return The consume status
*/
ConsumeConcurrentlyStatus consumeMessage(final List<MessageExt> msgs,
......
......@@ -20,14 +20,15 @@ import java.util.List;
import org.apache.rocketmq.common.message.MessageExt;
/**
* A MessageListenerConcurrently object is used to receive asynchronously delivered messages orderly.one queue,one thread
* A MessageListenerConcurrently object is used to receive asynchronously delivered messages orderly.one queue,one
* thread
*/
public interface MessageListenerOrderly extends MessageListener {
/**
* It is not recommend to throw exception,rather than returning ConsumeOrderlyStatus.SUSPEND_CURRENT_QUEUE_A_MOMENT if consumption failure
* It is not recommend to throw exception,rather than returning ConsumeOrderlyStatus.SUSPEND_CURRENT_QUEUE_A_MOMENT
* if consumption failure
*
* @param msgs msgs.size() >= 1<br> DefaultMQPushConsumer.consumeMessageBatchMaxSize=1,you can modify here
* @param context
* @return The consume status
*/
ConsumeOrderlyStatus consumeMessage(final List<MessageExt> msgs,
......
......@@ -30,7 +30,7 @@ import org.slf4j.Logger;
/**
* Consistent Hashing queue algorithm
*/
public class AllocateMessageQueueConsistentHash implements AllocateMessageQueueStrategy {
public class AllocateMessageQueueConsistentHash implements AllocateMessageQueueStrategy {
private final Logger log = ClientLogger.getLog();
private final int virtualNodeCnt;
......@@ -41,7 +41,7 @@ public class AllocateMessageQueueConsistentHash implements AllocateMessageQueue
}
public AllocateMessageQueueConsistentHash(int virtualNodeCnt) {
this(virtualNodeCnt,null);
this(virtualNodeCnt, null);
}
public AllocateMessageQueueConsistentHash(int virtualNodeCnt, HashFunction customHashFunction) {
......@@ -75,7 +75,6 @@ public class AllocateMessageQueueConsistentHash implements AllocateMessageQueue
return result;
}
Collection<ClientNode> cidNodes = new ArrayList<ClientNode>();
for (String cid : cidAll) {
cidNodes.add(new ClientNode(cid));
......@@ -105,7 +104,6 @@ public class AllocateMessageQueueConsistentHash implements AllocateMessageQueue
return "CONSISTENT_HASH";
}
private static class ClientNode implements Node {
private final String clientID;
......@@ -119,6 +117,4 @@ public class AllocateMessageQueueConsistentHash implements AllocateMessageQueue
}
}
}
......@@ -29,52 +29,37 @@ import org.apache.rocketmq.remoting.exception.RemotingException;
public interface OffsetStore {
/**
* Load
*
* @throws MQClientException
*/
void load() throws MQClientException;
/**
* Update the offset,store it in memory
*
* @param mq
* @param offset
* @param increaseOnly
*/
void updateOffset(final MessageQueue mq, final long offset, final boolean increaseOnly);
/**
* Get offset from local storage
*
* @param mq
* @param type
* @return The fetched offset
*/
long readOffset(final MessageQueue mq, final ReadOffsetType type);
/**
* Persist all offsets,may be in local storage or remote name server
*
* @param mqs
*/
void persistAll(final Set<MessageQueue> mqs);
/**
* Persist the offset,may be in local storage or remote name server
*
* @param mq
*/
void persist(final MessageQueue mq);
/**
* Remove offset
*
* @param mq
*/
void removeOffset(MessageQueue mq);
/**
* @param topic
* @return The cloned offset table of given topic
*/
Map<MessageQueue, Long> cloneOffsetTable(String topic);
......
......@@ -55,7 +55,8 @@ public class ClientRemotingProcessor implements NettyRequestProcessor {
}
@Override
public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
public RemotingCommand processRequest(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
switch (request.getCode()) {
case RequestCode.CHECK_TRANSACTION_STATE:
return this.checkTransactionState(ctx, request);
......@@ -82,7 +83,8 @@ public class ClientRemotingProcessor implements NettyRequestProcessor {
return false;
}
public RemotingCommand checkTransactionState(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
public RemotingCommand checkTransactionState(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final CheckTransactionStateRequestHeader requestHeader =
(CheckTransactionStateRequestHeader) request.decodeCommandCustomHeader(CheckTransactionStateRequestHeader.class);
final ByteBuffer byteBuffer = ByteBuffer.wrap(request.getBody());
......@@ -107,7 +109,8 @@ public class ClientRemotingProcessor implements NettyRequestProcessor {
return null;
}
public RemotingCommand notifyConsumerIdsChanged(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
public RemotingCommand notifyConsumerIdsChanged(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
try {
final NotifyConsumerIdsChangedRequestHeader requestHeader =
(NotifyConsumerIdsChangedRequestHeader) request.decodeCommandCustomHeader(NotifyConsumerIdsChangedRequestHeader.class);
......@@ -121,12 +124,13 @@ public class ClientRemotingProcessor implements NettyRequestProcessor {
return null;
}
public RemotingCommand resetOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
public RemotingCommand resetOffset(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final ResetOffsetRequestHeader requestHeader =
(ResetOffsetRequestHeader) request.decodeCommandCustomHeader(ResetOffsetRequestHeader.class);
log.info("invoke reset offset operation from broker. brokerAddr={}, topic={}, group={}, timestamp={}",
RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup(),
requestHeader.getTimestamp());
RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup(),
requestHeader.getTimestamp());
Map<MessageQueue, Long> offsetTable = new HashMap<MessageQueue, Long>();
if (request.getBody() != null) {
ResetOffsetBody body = ResetOffsetBody.decode(request.getBody(), ResetOffsetBody.class);
......@@ -137,7 +141,8 @@ public class ClientRemotingProcessor implements NettyRequestProcessor {
}
@Deprecated
public RemotingCommand getConsumeStatus(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
public RemotingCommand getConsumeStatus(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetConsumerStatusRequestHeader requestHeader =
(GetConsumerStatusRequestHeader) request.decodeCommandCustomHeader(GetConsumerStatusRequestHeader.class);
......@@ -150,7 +155,8 @@ public class ClientRemotingProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand getConsumerRunningInfo(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand getConsumerRunningInfo(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetConsumerRunningInfoRequestHeader requestHeader =
(GetConsumerRunningInfoRequestHeader) request.decodeCommandCustomHeader(GetConsumerRunningInfoRequestHeader.class);
......@@ -173,7 +179,8 @@ public class ClientRemotingProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand consumeMessageDirectly(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand consumeMessageDirectly(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final ConsumeMessageDirectlyResultRequestHeader requestHeader =
(ConsumeMessageDirectlyResultRequestHeader) request
......
......@@ -240,7 +240,8 @@ public class MQAdminImpl {
throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
}
public MessageExt viewMessage(String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
public MessageExt viewMessage(
String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
MessageId messageId = null;
try {
......@@ -252,12 +253,14 @@ public class MQAdminImpl {
messageId.getOffset(), timeoutMillis);
}
public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end) throws MQClientException,
public QueryResult queryMessage(String topic, String key, int maxNum, long begin,
long end) throws MQClientException,
InterruptedException {
return queryMessage(topic, key, maxNum, begin, end, false);
}
public MessageExt queryMessageByUniqKey(String topic, String uniqKey) throws InterruptedException, MQClientException {
public MessageExt queryMessageByUniqKey(String topic,
String uniqKey) throws InterruptedException, MQClientException {
QueryResult qr = this.queryMessage(topic, uniqKey, 32,
MessageClientIDSetter.getNearlyTimeFromID(uniqKey).getTime() - 1000, Long.MAX_VALUE, true);
......@@ -268,7 +271,8 @@ public class MQAdminImpl {
}
}
protected QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end, boolean isUniqKey) throws MQClientException,
protected QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end,
boolean isUniqKey) throws MQClientException,
InterruptedException {
TopicRouteData topicRouteData = this.mQClientFactory.getAnExistTopicRouteData(topic);
if (null == topicRouteData) {
......
......@@ -62,7 +62,8 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
private final ScheduledExecutorService scheduledExecutorService;
private volatile boolean stopped = false;
public ConsumeMessageOrderlyService(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl, MessageListenerOrderly messageListener) {
public ConsumeMessageOrderlyService(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl,
MessageListenerOrderly messageListener) {
this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
this.messageListener = messageListener;
......@@ -204,7 +205,8 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
}
}
public void tryLockLaterAndReconsume(final MessageQueue mq, final ProcessQueue processQueue, final long delayMills) {
public void tryLockLaterAndReconsume(final MessageQueue mq, final ProcessQueue processQueue,
final long delayMills) {
this.scheduledExecutorService.schedule(new Runnable() {
@Override
public void run() {
......
......@@ -55,7 +55,8 @@ public abstract class RebalanceImpl {
protected AllocateMessageQueueStrategy allocateMessageQueueStrategy;
protected MQClientInstance mQClientFactory;
public RebalanceImpl(String consumerGroup, MessageModel messageModel, AllocateMessageQueueStrategy allocateMessageQueueStrategy,
public RebalanceImpl(String consumerGroup, MessageModel messageModel,
AllocateMessageQueueStrategy allocateMessageQueueStrategy,
MQClientInstance mQClientFactory) {
this.consumerGroup = consumerGroup;
this.messageModel = messageModel;
......@@ -327,7 +328,8 @@ public abstract class RebalanceImpl {
}
}
private boolean updateProcessQueueTableInRebalance(final String topic, final Set<MessageQueue> mqSet, final boolean isOrder) {
private boolean updateProcessQueueTableInRebalance(final String topic, final Set<MessageQueue> mqSet,
final boolean isOrder) {
boolean changed = false;
Iterator<Entry<MessageQueue, ProcessQueue>> it = this.processQueueTable.entrySet().iterator();
......@@ -400,7 +402,8 @@ public abstract class RebalanceImpl {
return changed;
}
public abstract void messageQueueChanged(final String topic, final Set<MessageQueue> mqAll, final Set<MessageQueue> mqDivided);
public abstract void messageQueueChanged(final String topic, final Set<MessageQueue> mqAll,
final Set<MessageQueue> mqDivided);
public abstract boolean removeUnnecessaryMessageQueue(final MessageQueue mq, final ProcessQueue pq);
......
......@@ -32,7 +32,8 @@ public class RebalancePullImpl extends RebalanceImpl {
this(null, null, null, null, defaultMQPullConsumerImpl);
}
public RebalancePullImpl(String consumerGroup, MessageModel messageModel, AllocateMessageQueueStrategy allocateMessageQueueStrategy,
public RebalancePullImpl(String consumerGroup, MessageModel messageModel,
AllocateMessageQueueStrategy allocateMessageQueueStrategy,
MQClientInstance mQClientFactory, DefaultMQPullConsumerImpl defaultMQPullConsumerImpl) {
super(consumerGroup, messageModel, allocateMessageQueueStrategy, mQClientFactory);
this.defaultMQPullConsumerImpl = defaultMQPullConsumerImpl;
......
......@@ -40,7 +40,8 @@ public class RebalancePushImpl extends RebalanceImpl {
this(null, null, null, null, defaultMQPushConsumerImpl);
}
public RebalancePushImpl(String consumerGroup, MessageModel messageModel, AllocateMessageQueueStrategy allocateMessageQueueStrategy,
public RebalancePushImpl(String consumerGroup, MessageModel messageModel,
AllocateMessageQueueStrategy allocateMessageQueueStrategy,
MQClientInstance mQClientFactory, DefaultMQPushConsumerImpl defaultMQPushConsumerImpl) {
super(consumerGroup, messageModel, allocateMessageQueueStrategy, mQClientFactory);
this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
......
......@@ -584,7 +584,8 @@ public class MQClientInstance {
}
}
public boolean updateTopicRouteInfoFromNameServer(final String topic, boolean isDefault, DefaultMQProducer defaultMQProducer) {
public boolean updateTopicRouteInfoFromNameServer(final String topic, boolean isDefault,
DefaultMQProducer defaultMQProducer) {
try {
if (this.lockNamesrv.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
try {
......@@ -719,7 +720,8 @@ public class MQClientInstance {
return false;
}
private void uploadFilterClassToAllFilterServer(final String consumerGroup, final String fullClassName, final String topic,
private void uploadFilterClassToAllFilterServer(final String consumerGroup, final String fullClassName,
final String topic,
final String filterClassSource) throws UnsupportedEncodingException {
byte[] classBody = null;
int classCRC = 0;
......
......@@ -248,7 +248,8 @@ public class DefaultMQProducerImpl implements MQProducerInner {
}
@Override
public void checkTransactionState(final String addr, final MessageExt msg, final CheckTransactionStateRequestHeader header) {
public void checkTransactionState(final String addr, final MessageExt msg,
final CheckTransactionStateRequestHeader header) {
Runnable request = new Runnable() {
private final String brokerAddr = addr;
private final MessageExt message = msg;
......@@ -386,7 +387,8 @@ public class DefaultMQProducerImpl implements MQProducerInner {
return this.mQClientFactory.getMQAdminImpl().earliestMsgStoreTime(mq);
}
public MessageExt viewMessage(String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
public MessageExt viewMessage(
String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
this.makeSureStateOK();
return this.mQClientFactory.getMQAdminImpl().viewMessage(msgId);
......@@ -407,7 +409,8 @@ public class DefaultMQProducerImpl implements MQProducerInner {
/**
* DEFAULT ASYNC -------------------------------------------------------
*/
public void send(Message msg, SendCallback sendCallback) throws MQClientException, RemotingException, InterruptedException {
public void send(Message msg,
SendCallback sendCallback) throws MQClientException, RemotingException, InterruptedException {
send(msg, sendCallback, this.defaultMQProducer.getSendMsgTimeout());
}
......@@ -863,7 +866,8 @@ public class DefaultMQProducerImpl implements MQProducerInner {
/**
* KERNEL ONEWAY -------------------------------------------------------
*/
public void sendOneway(Message msg, MessageQueue mq) throws MQClientException, RemotingException, InterruptedException {
public void sendOneway(Message msg,
MessageQueue mq) throws MQClientException, RemotingException, InterruptedException {
this.makeSureStateOK();
Validators.checkMessage(msg, this.defaultMQProducer);
......@@ -945,7 +949,8 @@ public class DefaultMQProducerImpl implements MQProducerInner {
}
}
public TransactionSendResult sendMessageInTransaction(final Message msg, final LocalTransactionExecuter tranExecuter, final Object arg)
public TransactionSendResult sendMessageInTransaction(final Message msg,
final LocalTransactionExecuter tranExecuter, final Object arg)
throws MQClientException {
if (null == tranExecuter) {
throw new MQClientException("tranExecutor is null", null);
......@@ -1013,7 +1018,8 @@ public class DefaultMQProducerImpl implements MQProducerInner {
/**
* DEFAULT SYNC -------------------------------------------------------
*/
public SendResult send(Message msg) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
public SendResult send(
Message msg) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
return send(msg, this.defaultMQProducer.getSendMsgTimeout());
}
......@@ -1054,7 +1060,8 @@ public class DefaultMQProducerImpl implements MQProducerInner {
this.defaultMQProducer.getSendMsgTimeout());
}
public SendResult send(Message msg, long timeout) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
public SendResult send(Message msg,
long timeout) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
return this.sendDefaultImpl(msg, CommunicationMode.SYNC, null, timeout);
}
......
......@@ -36,7 +36,7 @@ public class ClientLogger {
private static Logger createLogger(final String loggerName) {
String logConfigFilePath =
System.getProperty("rocketmq.client.log.configFile",
System.getenv("ROCKETMQ_CLIENT_LOG_CONFIGFILE"));
System.getenv("ROCKETMQ_CLIENT_LOG_CONFIGFILE"));
Boolean isloadconfig =
Boolean.parseBoolean(System.getProperty("rocketmq.client.log.loadconfig", "true"));
......
......@@ -48,8 +48,8 @@ import org.apache.rocketmq.remoting.exception.RemotingException;
* </p>
*
* <p>
* <strong>Thread Safety:</strong> After configuring and starting process, this class can be regarded as thread-safe
* and used among multiple threads context.
* <strong>Thread Safety:</strong> After configuring and starting process, this class can be regarded as thread-safe
* and used among multiple threads context.
* </p>
*/
public class DefaultMQProducer extends ClientConfig implements MQProducer {
......@@ -137,6 +137,7 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
/**
* Constructor specifying producer group.
*
* @param producerGroup Producer group, see the name-sake field.
*/
public DefaultMQProducer(final String producerGroup) {
......@@ -145,6 +146,7 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
/**
* Constructor specifying the RPC hook.
*
* @param rpcHook RPC hook to execute per each remoting command execution.
*/
public DefaultMQProducer(RPCHook rpcHook) {
......@@ -178,6 +180,7 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
/**
* Fetch message queues of topic <code>topic</code>, to which we may send/publish messages.
*
* @param topic Topic to fetch.
* @return List of message queues readily to send messages to
* @throws MQClientException if there is any client error.
......@@ -204,12 +207,14 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
* @throws InterruptedException if the sending thread is interrupted.
*/
@Override
public SendResult send(Message msg) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
public SendResult send(
Message msg) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
return this.defaultMQProducerImpl.send(msg);
}
/**
* Same to {@link #send(Message)} with send timeout specified in addition.
*
* @param msg Message to send.
* @param timeout send timeout.
* @return {@link SendResult} instance to inform senders details of the deliverable, say Message ID of the message,
......@@ -220,7 +225,8 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
* @throws InterruptedException if the sending thread is interrupted.
*/
@Override
public SendResult send(Message msg, long timeout) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
public SendResult send(Message msg,
long timeout) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
return this.defaultMQProducerImpl.send(msg, timeout);
}
......@@ -234,6 +240,7 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
* Similar to {@link #send(Message)}, internal implementation would potentially retry up to
* {@link #retryTimesWhenSendAsyncFailed} times before claiming sending failure, which may yield message duplication
* and application developers are the one to resolve this potential issue.
*
* @param msg Message to send.
* @param sendCallback Callback to execute on sending completed, either successful or unsuccessful.
* @throws MQClientException if there is any client error.
......@@ -241,12 +248,14 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
* @throws InterruptedException if the sending thread is interrupted.
*/
@Override
public void send(Message msg, SendCallback sendCallback) throws MQClientException, RemotingException, InterruptedException {
public void send(Message msg,
SendCallback sendCallback) throws MQClientException, RemotingException, InterruptedException {
this.defaultMQProducerImpl.send(msg, sendCallback);
}
/**
* Same to {@link #send(Message, SendCallback)} with send timeout specified in addition.
*
* @param msg message to send.
* @param sendCallback Callback to execute.
* @param timeout send timeout.
......@@ -263,6 +272,7 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
/**
* Similar to <a href="https://en.wikipedia.org/wiki/User_Datagram_Protocol">UDP</a>, this method won't wait for
* acknowledgement from broker before return. Obviously, it has maximums throughput yet potentials of message loss.
*
* @param msg Message to send.
* @throws MQClientException if there is any client error.
* @throws RemotingException if there is any network-tier error.
......@@ -275,6 +285,7 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
/**
* Same to {@link #send(Message)} with target message queue specified in addition.
*
* @param msg Message to send.
* @param mq Target message queue.
* @return {@link SendResult} instance to inform senders details of the deliverable, say Message ID of the message,
......@@ -327,6 +338,7 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
/**
* Same to {@link #send(Message, SendCallback)} with target message queue and send timeout specified.
*
* @param msg Message to send.
* @param mq Target message queue.
* @param sendCallback Callback to execute on sending completed, either successful or unsuccessful.
......@@ -343,6 +355,7 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
/**
* Same to {@link #sendOneway(Message)} with target message queue specified.
*
* @param msg Message to send.
* @param mq Target message queue.
* @throws MQClientException if there is any client error.
......@@ -350,12 +363,13 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
* @throws InterruptedException if the sending thread is interrupted.
*/
@Override
public void sendOneway(Message msg, MessageQueue mq) throws MQClientException, RemotingException, InterruptedException {
public void sendOneway(Message msg,
MessageQueue mq) throws MQClientException, RemotingException, InterruptedException {
this.defaultMQProducerImpl.sendOneway(msg, mq);
}
/**
* Same to {@link #send(Message)} with message queue selector specified.
* Same to {@link #send(Message)} with message queue selector specified.
*
* @param msg Message to send.
* @param selector Message queue selector, through which we get target message queue to deliver message to.
......@@ -430,6 +444,7 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
/**
* Same to {@link #sendOneway(Message)} with message queue selector specified.
*
* @param msg Message to send.
* @param selector Message queue selector, through which to determine target message queue to deliver message
* @param arg Argument used along with message queue selector.
......@@ -453,13 +468,15 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
* @throws MQClientException if there is any client error.
*/
@Override
public TransactionSendResult sendMessageInTransaction(Message msg, LocalTransactionExecuter tranExecuter, final Object arg)
public TransactionSendResult sendMessageInTransaction(Message msg, LocalTransactionExecuter tranExecuter,
final Object arg)
throws MQClientException {
throw new RuntimeException("sendMessageInTransaction not implement, please use TransactionMQProducer class");
}
/**
* Create a topic on broker.
*
* @param key accesskey
* @param newTopic topic name
* @param queueNum topic's queue number
......@@ -472,6 +489,7 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
/**
* Create a topic on broker.
*
* @param key accesskey
* @param newTopic topic name
* @param queueNum topic's queue number
......@@ -485,6 +503,7 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
/**
* Search consume queue offset of the given time stamp.
*
* @param mq Instance of MessageQueue
* @param timestamp from when in milliseconds.
* @return Consume queue offset.
......@@ -509,6 +528,7 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
/**
* Query minimum offset of the given message queue.
*
* @param mq Instance of MessageQueue
* @return minimum offset of the given message queue.
* @throws MQClientException if there is any client error.
......@@ -520,6 +540,7 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
/**
* Query earliest message store time.
*
* @param mq Instance of MessageQueue
* @return earliest message store time.
* @throws MQClientException if there is any client error.
......@@ -531,6 +552,7 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
/**
* Query message of the given offset message ID.
*
* @param offsetMsgId message id
* @return Message specified.
* @throws MQBrokerException if there is any broker error.
......@@ -539,12 +561,14 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
* @throws InterruptedException if the sending thread is interrupted.
*/
@Override
public MessageExt viewMessage(String offsetMsgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
public MessageExt viewMessage(
String offsetMsgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
return this.defaultMQProducerImpl.viewMessage(offsetMsgId);
}
/**
* Query message by key.
*
* @param topic message topic
* @param key message key index word
* @param maxNum max message number
......@@ -572,7 +596,8 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
* @throws InterruptedException if the sending thread is interrupted.
*/
@Override
public MessageExt viewMessage(String topic, String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
public MessageExt viewMessage(String topic,
String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
try {
MessageId oldMsgId = MessageDecoder.decodeMessageId(msgId);
return this.viewMessage(msgId);
......@@ -582,22 +607,26 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
}
@Override
public SendResult send(Collection<Message> msgs) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
public SendResult send(
Collection<Message> msgs) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
return this.defaultMQProducerImpl.send(batch(msgs));
}
@Override
public SendResult send(Collection<Message> msgs, long timeout) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
public SendResult send(Collection<Message> msgs,
long timeout) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
return this.defaultMQProducerImpl.send(batch(msgs), timeout);
}
@Override
public SendResult send(Collection<Message> msgs, MessageQueue messageQueue) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
public SendResult send(Collection<Message> msgs,
MessageQueue messageQueue) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
return this.defaultMQProducerImpl.send(batch(msgs), messageQueue);
}
@Override
public SendResult send(Collection<Message> msgs, MessageQueue messageQueue, long timeout) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
public SendResult send(Collection<Message> msgs, MessageQueue messageQueue,
long timeout) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
return this.defaultMQProducerImpl.send(batch(msgs), messageQueue, timeout);
}
......@@ -615,6 +644,7 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
}
return msgBatch;
}
public String getProducerGroup() {
return producerGroup;
}
......
......@@ -32,7 +32,8 @@ public class SendResult {
public SendResult() {
}
public SendResult(SendStatus sendStatus, String msgId, String offsetMsgId, MessageQueue messageQueue, long queueOffset) {
public SendResult(SendStatus sendStatus, String msgId, String offsetMsgId, MessageQueue messageQueue,
long queueOffset) {
this.sendStatus = sendStatus;
this.msgId = msgId;
this.offsetMsgId = offsetMsgId;
......@@ -40,7 +41,8 @@ public class SendResult {
this.queueOffset = queueOffset;
}
public SendResult(final SendStatus sendStatus, final String msgId, final MessageQueue messageQueue, final long queueOffset, final String transactionId,
public SendResult(final SendStatus sendStatus, final String msgId, final MessageQueue messageQueue,
final long queueOffset, final String transactionId,
final String offsetMsgId, final String regionId) {
this.sendStatus = sendStatus;
this.msgId = msgId;
......
......@@ -86,7 +86,8 @@ public class DefaultMQPullConsumerTest {
@Test
public void testPullMessage_Success() throws Exception {
doAnswer(new Answer() {
@Override public Object answer(InvocationOnMock mock) throws Throwable {
@Override
public Object answer(InvocationOnMock mock) throws Throwable {
PullMessageRequestHeader requestHeader = mock.getArgument(1);
return createPullResult(requestHeader, PullStatus.FOUND, Collections.singletonList(new MessageExt()));
}
......@@ -103,9 +104,10 @@ public class DefaultMQPullConsumerTest {
}
@Test
public void testPullMessage_NotFound() throws Exception{
public void testPullMessage_NotFound() throws Exception {
doAnswer(new Answer() {
@Override public Object answer(InvocationOnMock mock) throws Throwable {
@Override
public Object answer(InvocationOnMock mock) throws Throwable {
PullMessageRequestHeader requestHeader = mock.getArgument(1);
return createPullResult(requestHeader, PullStatus.NO_NEW_MSG, new ArrayList<MessageExt>());
}
......@@ -119,7 +121,8 @@ public class DefaultMQPullConsumerTest {
@Test
public void testPullMessageAsync_Success() throws Exception {
doAnswer(new Answer() {
@Override public Object answer(InvocationOnMock mock) throws Throwable {
@Override
public Object answer(InvocationOnMock mock) throws Throwable {
PullMessageRequestHeader requestHeader = mock.getArgument(1);
PullResult pullResult = createPullResult(requestHeader, PullStatus.FOUND, Collections.singletonList(new MessageExt()));
......@@ -131,7 +134,8 @@ public class DefaultMQPullConsumerTest {
MessageQueue messageQueue = new MessageQueue(topic, brokerName, 0);
pullConsumer.pull(messageQueue, "*", 1024, 3, new PullCallback() {
@Override public void onSuccess(PullResult pullResult) {
@Override
public void onSuccess(PullResult pullResult) {
assertThat(pullResult).isNotNull();
assertThat(pullResult.getPullStatus()).isEqualTo(PullStatus.FOUND);
assertThat(pullResult.getNextBeginOffset()).isEqualTo(1024 + 1);
......@@ -140,13 +144,15 @@ public class DefaultMQPullConsumerTest {
assertThat(pullResult.getMsgFoundList()).isEqualTo(new ArrayList<Object>());
}
@Override public void onException(Throwable e) {
@Override
public void onException(Throwable e) {
}
});
}
private PullResultExt createPullResult(PullMessageRequestHeader requestHeader, PullStatus pullStatus, List<MessageExt> messageExtList) throws Exception {
private PullResultExt createPullResult(PullMessageRequestHeader requestHeader, PullStatus pullStatus,
List<MessageExt> messageExtList) throws Exception {
return new PullResultExt(pullStatus, requestHeader.getQueueOffset() + messageExtList.size(), 123, 2048, messageExtList, 0, new byte[] {});
}
}
\ No newline at end of file
......@@ -90,7 +90,8 @@ public class DefaultMQPushConsumerTest {
pushConsumer.setPullInterval(60 * 1000);
pushConsumer.registerMessageListener(new MessageListenerConcurrently() {
@Override public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
@Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
ConsumeConcurrentlyContext context) {
return null;
}
......@@ -109,7 +110,6 @@ public class DefaultMQPushConsumerTest {
field.setAccessible(true);
field.set(pushConsumerImpl, mQClientFactory);
field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl");
field.setAccessible(true);
field.set(mQClientFactory, mQClientAPIImpl);
......@@ -125,21 +125,22 @@ public class DefaultMQPushConsumerTest {
when(mQClientFactory.getMQClientAPIImpl().pullMessage(anyString(), any(PullMessageRequestHeader.class),
anyLong(), any(CommunicationMode.class), nullable(PullCallback.class)))
.thenAnswer(new Answer<Object>() {
@Override public Object answer(InvocationOnMock mock) throws Throwable {
PullMessageRequestHeader requestHeader = mock.getArgument(1);
MessageClientExt messageClientExt = new MessageClientExt();
messageClientExt.setTopic(topic);
messageClientExt.setQueueId(0);
messageClientExt.setMsgId("123");
messageClientExt.setBody(new byte[] {'a'});
messageClientExt.setOffsetMsgId("234");
messageClientExt.setBornHost(new InetSocketAddress(8080));
messageClientExt.setStoreHost(new InetSocketAddress(8080));
PullResult pullResult = createPullResult(requestHeader, PullStatus.FOUND, Collections.<MessageExt>singletonList(messageClientExt));
((PullCallback)mock.getArgument(4)).onSuccess(pullResult);
return pullResult;
}
});
@Override
public Object answer(InvocationOnMock mock) throws Throwable {
PullMessageRequestHeader requestHeader = mock.getArgument(1);
MessageClientExt messageClientExt = new MessageClientExt();
messageClientExt.setTopic(topic);
messageClientExt.setQueueId(0);
messageClientExt.setMsgId("123");
messageClientExt.setBody(new byte[] {'a'});
messageClientExt.setOffsetMsgId("234");
messageClientExt.setBornHost(new InetSocketAddress(8080));
messageClientExt.setStoreHost(new InetSocketAddress(8080));
PullResult pullResult = createPullResult(requestHeader, PullStatus.FOUND, Collections.<MessageExt>singletonList(messageClientExt));
((PullCallback) mock.getArgument(4)).onSuccess(pullResult);
return pullResult;
}
});
doReturn(new FindBrokerResult("127.0.0.1:10911", false)).when(mQClientFactory).findBrokerAddressInSubscribe(anyString(), anyLong(), anyBoolean());
doReturn(Collections.singletonList(mQClientFactory.getClientId())).when(mQClientFactory).findConsumerIdList(anyString(), anyString());
......@@ -159,7 +160,8 @@ public class DefaultMQPushConsumerTest {
final CountDownLatch countDownLatch = new CountDownLatch(1);
final MessageExt[] messageExts = new MessageExt[1];
pushConsumer.getDefaultMQPushConsumerImpl().setConsumeMessageService(new ConsumeMessageConcurrentlyService(pushConsumer.getDefaultMQPushConsumerImpl(), new MessageListenerConcurrently() {
@Override public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
@Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
ConsumeConcurrentlyContext context) {
messageExts[0] = msgs.get(0);
countDownLatch.countDown();
......@@ -217,7 +219,8 @@ public class DefaultMQPushConsumerTest {
return pullRequest;
}
private PullResultExt createPullResult(PullMessageRequestHeader requestHeader, PullStatus pullStatus, List<MessageExt> messageExtList) throws Exception {
private PullResultExt createPullResult(PullMessageRequestHeader requestHeader, PullStatus pullStatus,
List<MessageExt> messageExtList) throws Exception {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
for (MessageExt messageExt : messageExtList) {
outputStream.write(MessageDecoder.encode(messageExt, false));
......
......@@ -29,7 +29,6 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
public class AllocateMessageQueueConsitentHashTest {
private String topic;
......@@ -40,8 +39,6 @@ public class AllocateMessageQueueConsitentHashTest {
topic = "topic_test";
}
public void printMessageQueue(List<MessageQueue> messageQueueList, String name) {
if (messageQueueList == null || messageQueueList.size() < 1)
return;
......@@ -85,28 +82,27 @@ public class AllocateMessageQueueConsitentHashTest {
@Test
public void testAllocate1() {
testAllocate(20,10);
testAllocate(20, 10);
}
@Test
public void testAllocate2() {
testAllocate(10,20);
testAllocate(10, 20);
}
@Test
public void testRun100RandomCase(){
for(int i=0;i<100;i++){
int consumerSize = new Random().nextInt(200)+1;//1-200
int queueSize = new Random().nextInt(100)+1;//1-100
testAllocate(queueSize,consumerSize);
public void testRun100RandomCase() {
for (int i = 0; i < 100; i++) {
int consumerSize = new Random().nextInt(200) + 1;//1-200
int queueSize = new Random().nextInt(100) + 1;//1-100
testAllocate(queueSize, consumerSize);
try {
Thread.sleep(1);
} catch (InterruptedException e) {}
} catch (InterruptedException e) {
}
}
}
public void testAllocate(int queueSize, int consumerSize) {
AllocateMessageQueueStrategy allocateMessageQueueConsistentHash = new AllocateMessageQueueConsistentHash(3);
......@@ -133,7 +129,7 @@ public class AllocateMessageQueueConsitentHashTest {
}
Assert.assertTrue(
verifyAllocateAll(cidBegin,mqAll, allocatedResAll));
verifyAllocateAll(cidBegin, mqAll, allocatedResAll));
}
Map<MessageQueue, String> allocateToAllAfterRemoveOne = new TreeMap<MessageQueue, String>();
......@@ -162,7 +158,7 @@ public class AllocateMessageQueueConsitentHashTest {
//System.out.println("rs[" + cid + "]:" + "[" + rs.size() + "]" + rs.toString());
}
Assert.assertTrue("queueSize"+queueSize+"consumerSize:"+consumerSize+"\nmqAll:"+mqAll+"\nallocatedResAllAfterRemove"+allocatedResAllAfterRemove,
Assert.assertTrue("queueSize" + queueSize + "consumerSize:" + consumerSize + "\nmqAll:" + mqAll + "\nallocatedResAllAfterRemove" + allocatedResAllAfterRemove,
verifyAllocateAll(cidAfterRemoveOne, mqAll, allocatedResAllAfterRemove));
verifyAfterRemove(allocateToAllOrigin, allocateToAllAfterRemoveOne, removeCID);
}
......@@ -170,7 +166,7 @@ public class AllocateMessageQueueConsitentHashTest {
List<String> cidAfterAdd = new ArrayList<String>(cidAfterRemoveOne);
//test allocate add one more cid
{
String newCid = CID_PREFIX+"NEW";
String newCid = CID_PREFIX + "NEW";
//System.out.println("add one more cid "+newCid);
cidAfterAdd.add(newCid);
List<MessageQueue> mqShouldOnlyChanged = new ArrayList<MessageQueue>();
......@@ -182,7 +178,7 @@ public class AllocateMessageQueueConsitentHashTest {
allocatedResAllAfterAdd.addAll(rs);
for (MessageQueue mq : rs) {
allocateToAll3.put(mq, cid);
if (cid.equals(newCid)){
if (cid.equals(newCid)) {
mqShouldOnlyChanged.add(mq);
}
}
......@@ -190,19 +186,21 @@ public class AllocateMessageQueueConsitentHashTest {
}
Assert.assertTrue(
verifyAllocateAll(cidAfterAdd,mqAll, allocatedResAllAfterAdd));
verifyAllocateAll(cidAfterAdd, mqAll, allocatedResAllAfterAdd));
verifyAfterAdd(allocateToAllAfterRemoveOne, allocateToAll3, newCid);
}
}
private boolean verifyAllocateAll(List<String> cidAll,List<MessageQueue> mqAll, List<MessageQueue> allocatedResAll) {
if (cidAll.isEmpty()){
private boolean verifyAllocateAll(List<String> cidAll, List<MessageQueue> mqAll,
List<MessageQueue> allocatedResAll) {
if (cidAll.isEmpty()) {
return allocatedResAll.isEmpty();
}
return mqAll.containsAll(allocatedResAll) && allocatedResAll.containsAll(mqAll);
}
private void verifyAfterRemove(Map<MessageQueue, String> allocateToBefore, Map<MessageQueue, String> allocateAfter, String removeCID) {
private void verifyAfterRemove(Map<MessageQueue, String> allocateToBefore, Map<MessageQueue, String> allocateAfter,
String removeCID) {
for (MessageQueue mq : allocateToBefore.keySet()) {
String allocateToOrigin = allocateToBefore.get(mq);
if (allocateToOrigin.equals(removeCID)) {
......@@ -213,14 +211,15 @@ public class AllocateMessageQueueConsitentHashTest {
}
}
private void verifyAfterAdd(Map<MessageQueue, String> allocateBefore, Map<MessageQueue, String> allocateAfter, String newCID) {
private void verifyAfterAdd(Map<MessageQueue, String> allocateBefore, Map<MessageQueue, String> allocateAfter,
String newCID) {
for (MessageQueue mq : allocateAfter.keySet()) {
String allocateToOrigin = allocateBefore.get(mq);
String allocateToAfter = allocateAfter.get(mq);
if (allocateToAfter.equals(newCID)) {
} else {//the rest queue should be the same
Assert.assertTrue("it was allocated to "+allocateToOrigin+". Now, it is to "+allocateAfter.get(mq)+" mq:"+mq,allocateAfter.get(mq).equals(allocateToOrigin));//should be the same
Assert.assertTrue("it was allocated to " + allocateToOrigin + ". Now, it is to " + allocateAfter.get(mq) + " mq:" + mq, allocateAfter.get(mq).equals(allocateToOrigin));//should be the same
}
}
}
......
......@@ -99,7 +99,8 @@ public class RemoteBrokerOffsetStoreTest {
final MessageQueue messageQueue = new MessageQueue(topic, brokerName, 3);
doAnswer(new Answer() {
@Override public Object answer(InvocationOnMock mock) throws Throwable {
@Override
public Object answer(InvocationOnMock mock) throws Throwable {
UpdateConsumerOffsetRequestHeader updateRequestHeader = mock.getArgument(1);
when(mqClientAPI.queryConsumerOffset(anyString(), any(QueryConsumerOffsetRequestHeader.class), anyLong())).thenReturn(updateRequestHeader.getCommitOffset());
return null;
......@@ -123,8 +124,6 @@ public class RemoteBrokerOffsetStoreTest {
assertThat(offsetStore.readOffset(messageQueue, ReadOffsetType.READ_FROM_STORE)).isEqualTo(1025);
}
@Test
public void testRemoveOffset() throws Exception {
OffsetStore offsetStore = new RemoteBrokerOffsetStore(mQClientFactory, group);
......
......@@ -107,7 +107,8 @@ public class MQClientAPIImplTest {
@Test
public void testSendMessageSync_Success() throws InterruptedException, RemotingException, MQBrokerException {
doAnswer(new Answer() {
@Override public Object answer(InvocationOnMock mock) throws Throwable {
@Override
public Object answer(InvocationOnMock mock) throws Throwable {
RemotingCommand request = mock.getArgument(1);
return createSuccessResponse(request);
}
......@@ -127,7 +128,8 @@ public class MQClientAPIImplTest {
@Test
public void testSendMessageSync_WithException() throws InterruptedException, RemotingException, MQBrokerException {
doAnswer(new Answer() {
@Override public Object answer(InvocationOnMock mock) throws Throwable {
@Override
public Object answer(InvocationOnMock mock) throws Throwable {
RemotingCommand request = mock.getArgument(1);
RemotingCommand response = RemotingCommand.createResponseCommand(SendMessageResponseHeader.class);
response.setCode(ResponseCode.SYSTEM_ERROR);
......@@ -156,7 +158,8 @@ public class MQClientAPIImplTest {
assertThat(sendResult).isNull();
doAnswer(new Answer() {
@Override public Object answer(InvocationOnMock mock) throws Throwable {
@Override
public Object answer(InvocationOnMock mock) throws Throwable {
InvokeCallback callback = mock.getArgument(3);
RemotingCommand request = mock.getArgument(1);
ResponseFuture responseFuture = new ResponseFuture(request.getOpaque(), 3 * 1000, null, null);
......@@ -169,14 +172,16 @@ public class MQClientAPIImplTest {
sendMessageContext.setProducer(new DefaultMQProducerImpl(new DefaultMQProducer()));
mqClientAPI.sendMessage(brokerAddr, brokerName, msg, new SendMessageRequestHeader(), 3 * 1000, CommunicationMode.ASYNC,
new SendCallback() {
@Override public void onSuccess(SendResult sendResult) {
@Override
public void onSuccess(SendResult sendResult) {
assertThat(sendResult.getSendStatus()).isEqualTo(SendStatus.SEND_OK);
assertThat(sendResult.getOffsetMsgId()).isEqualTo("123");
assertThat(sendResult.getQueueOffset()).isEqualTo(123L);
assertThat(sendResult.getMessageQueue().getQueueId()).isEqualTo(1);
}
@Override public void onException(Throwable e) {
@Override
public void onException(Throwable e) {
}
},
null, null, 0, sendMessageContext, defaultMQProducerImpl);
......
......@@ -39,7 +39,7 @@ import static org.mockito.Mockito.mock;
@RunWith(MockitoJUnitRunner.class)
public class MQClientInstanceTest {
private MQClientInstance mqClientInstance = MQClientManager.getInstance().getAndCreateMQClientInstance(new ClientConfig());
private MQClientInstance mqClientInstance = MQClientManager.getInstance().getAndCreateMQClientInstance(new ClientConfig());
private String topic = "FooBar";
private String group = "FooBarGroup";
......
......@@ -149,13 +149,16 @@ public class DefaultMQProducerTest {
final Throwable[] assertionErrors = new Throwable[1];
final CountDownLatch countDownLatch = new CountDownLatch(2);
producer.getDefaultMQProducerImpl().registerSendMessageHook(new SendMessageHook() {
@Override public String hookName() {
@Override
public String hookName() {
return "TestHook";
}
@Override public void sendMessageBefore(final SendMessageContext context) {
@Override
public void sendMessageBefore(final SendMessageContext context) {
assertionErrors[0] = assertInOtherThread(new Runnable() {
@Override public void run() {
@Override
public void run() {
assertThat(context.getMessage()).isEqualTo(message);
assertThat(context.getProducer()).isEqualTo(producer);
assertThat(context.getCommunicationMode()).isEqualTo(CommunicationMode.SYNC);
......@@ -165,9 +168,11 @@ public class DefaultMQProducerTest {
countDownLatch.countDown();
}
@Override public void sendMessageAfter(final SendMessageContext context) {
@Override
public void sendMessageAfter(final SendMessageContext context) {
assertionErrors[0] = assertInOtherThread(new Runnable() {
@Override public void run() {
@Override
public void run() {
assertThat(context.getMessage()).isEqualTo(message);
assertThat(context.getProducer()).isEqualTo(producer.getDefaultMQProducerImpl());
assertThat(context.getCommunicationMode()).isEqualTo(CommunicationMode.SYNC);
......@@ -229,7 +234,8 @@ public class DefaultMQProducerTest {
private Throwable assertInOtherThread(final Runnable runnable) {
final Throwable[] assertionErrors = new Throwable[1];
Thread thread = new Thread(new Runnable() {
@Override public void run() {
@Override
public void run() {
try {
runnable.run();
} catch (AssertionError e) {
......
......@@ -54,7 +54,8 @@ public class BrokerConfig {
private String messageStorePlugIn = "";
/**
* thread numbers for send message thread pool, since spin lock will be used by default since 4.0.x, the default value is 1.
* thread numbers for send message thread pool, since spin lock will be used by default since 4.0.x, the default
* value is 1.
*/
private int sendMessageThreadPoolNums = 1; //16 + Runtime.getRuntime().availableProcessors() * 4;
private int pullMessageThreadPoolNums = 16 + Runtime.getRuntime().availableProcessors() * 2;
......
......@@ -65,7 +65,6 @@ public class Configuration {
/**
* register config object
*
* @param configObject
* @return the current Configuration object
*/
public Configuration registerConfig(Object configObject) {
......@@ -91,7 +90,6 @@ public class Configuration {
/**
* register config properties
*
* @param extProperties
* @return the current Configuration object
*/
public Configuration registerConfig(Properties extProperties) {
......@@ -117,8 +115,6 @@ public class Configuration {
/**
* The store path will be gotten from the field of object.
*
* @param object
* @param fieldName
* @throws java.lang.RuntimeException if the field of object is not exist.
*/
public void setStorePathFromConfig(Object object, String fieldName) {
......
......@@ -29,7 +29,8 @@ public class CountDownLatch2 {
/**
* Constructs a {@code CountDownLatch2} initialized with the given count.
*
* @param count the number of times {@link #countDown} must be invoked before threads can pass through {@link #await}
* @param count the number of times {@link #countDown} must be invoked before threads can pass through {@link
* #await}
* @throws IllegalArgumentException if {@code count} is negative
*/
public CountDownLatch2(int count) {
......@@ -104,7 +105,8 @@ public class CountDownLatch2 {
*
* @param timeout the maximum time to wait
* @param unit the time unit of the {@code timeout} argument
* @return {@code true} if the count reached zero and {@code false} if the waiting time elapsed before the count reached zero
* @return {@code true} if the count reached zero and {@code false} if the waiting time elapsed before the count
* reached zero
* @throws InterruptedException if the current thread is interrupted while waiting
*/
public boolean await(long timeout, TimeUnit unit)
......@@ -176,7 +178,7 @@ public class CountDownLatch2 {
protected boolean tryReleaseShared(int releases) {
// Decrement count; signal when transition to zero
for (;;) {
for (; ; ) {
int c = getState();
if (c == 0)
return false;
......
......@@ -74,7 +74,7 @@ public class DataVersion extends RemotingSerializable {
int result = (int) (timestamp ^ (timestamp >>> 32));
if (null != counter) {
long l = counter.get();
result = 31 * result + (int)(l ^ (l >>> 32));
result = 31 * result + (int) (l ^ (l >>> 32));
}
return result;
}
......
......@@ -58,8 +58,8 @@ public class MixAll {
public static final String DEFAULT_NAMESRV_ADDR_LOOKUP = "jmenv.tbsite.net";
public static final String WS_DOMAIN_NAME = System.getProperty("rocketmq.namesrv.domain", DEFAULT_NAMESRV_ADDR_LOOKUP);
public static final String WS_DOMAIN_SUBGROUP = System.getProperty("rocketmq.namesrv.domain.subgroup", "nsaddr");
// // http://jmenv.tbsite.net:8080/rocketmq/nsaddr
// public static final String WS_ADDR = "http://" + WS_DOMAIN_NAME + ":8080/rocketmq/" + WS_DOMAIN_SUBGROUP;
//http://jmenv.tbsite.net:8080/rocketmq/nsaddr
//public static final String WS_ADDR = "http://" + WS_DOMAIN_NAME + ":8080/rocketmq/" + WS_DOMAIN_SUBGROUP;
public static final String DEFAULT_TOPIC = "TBW102";
public static final String BENCHMARK_TOPIC = "BenchmarkTest";
public static final String DEFAULT_PRODUCER_GROUP = "DEFAULT_PRODUCER";
......@@ -169,7 +169,6 @@ public class MixAll {
file.renameTo(new File(fileName));
}
public static void string2FileNotSafe(final String str, final String fileName) throws IOException {
File file = new File(fileName);
File fileParent = file.getParentFile();
......@@ -250,7 +249,8 @@ public class MixAll {
printObjectProperties(logger, object, false);
}
public static void printObjectProperties(final Logger logger, final Object object, final boolean onlyImportantField) {
public static void printObjectProperties(final Logger logger, final Object object,
final boolean onlyImportantField) {
Field[] fields = object.getClass().getDeclaredFields();
for (Field field : fields) {
if (!Modifier.isStatic(field.getModifiers())) {
......
......@@ -65,7 +65,7 @@ public abstract class ServiceThread implements Runnable {
}
long eclipseTime = System.currentTimeMillis() - beginTime;
log.info("join thread " + this.getServiceName() + " eclipse time(ms) " + eclipseTime + " "
+ this.getJointime());
+ this.getJointime());
} catch (InterruptedException e) {
log.error("Interrupted", e);
}
......
......@@ -209,7 +209,6 @@ public class UtilAll {
return -1;
}
public static int crc32(byte[] array) {
if (array != null) {
return crc32(array, 0, array.length);
......@@ -218,7 +217,6 @@ public class UtilAll {
return 0;
}
public static int crc32(byte[] array, int offset, int length) {
CRC32 crc32 = new CRC32();
crc32.update(array, offset, length);
......
......@@ -25,20 +25,18 @@ import java.util.TreeMap;
/**
* To hash Node objects to a hash ring with a certain amount of virtual node.
* Method routeNode will return a Node instance which the object key should be allocated to according to consistent hash algorithm
*
* @param <T>
* Method routeNode will return a Node instance which the object key should be allocated to according to consistent hash
* algorithm
*/
public class ConsistentHashRouter<T extends Node> {
private final SortedMap<Long, VirtualNode<T>> ring = new TreeMap<Long, VirtualNode<T>>();
private final HashFunction hashFunction;
public ConsistentHashRouter(Collection<T> pNodes, int vNodeCount) {
this(pNodes,vNodeCount, new MD5Hash());
this(pNodes, vNodeCount, new MD5Hash());
}
/**
*
* @param pNodes collections of physical nodes
* @param vNodeCount amounts of virtual nodes
* @param hashFunction hash Function to hash Node instances
......@@ -57,11 +55,13 @@ public class ConsistentHashRouter<T extends Node> {
/**
* add physic node to the hash ring with some virtual nodes
*
* @param pNode physical node needs added to hash ring
* @param vNodeCount the number of virtual node of the physical node. Value should be greater than or equals to 0
*/
public void addNode(T pNode, int vNodeCount) {
if (vNodeCount < 0) throw new IllegalArgumentException("illegal virtual node counts :" + vNodeCount);
if (vNodeCount < 0)
throw new IllegalArgumentException("illegal virtual node counts :" + vNodeCount);
int existingReplicas = getExistingReplicas(pNode);
for (int i = 0; i < vNodeCount; i++) {
VirtualNode<T> vNode = new VirtualNode<T>(pNode, i + existingReplicas);
......@@ -71,7 +71,6 @@ public class ConsistentHashRouter<T extends Node> {
/**
* remove the physical node from the hash ring
* @param pNode
*/
public void removeNode(T pNode) {
Iterator<Long> it = ring.keySet().iterator();
......@@ -86,20 +85,19 @@ public class ConsistentHashRouter<T extends Node> {
/**
* with a specified key, route the nearest Node instance in the current hash ring
*
* @param objectKey the object key to find a nearest Node
* @return
*/
public T routeNode(String objectKey) {
if (ring.isEmpty()) {
return null;
}
Long hashVal = hashFunction.hash(objectKey);
SortedMap<Long,VirtualNode<T>> tailMap = ring.tailMap(hashVal);
SortedMap<Long, VirtualNode<T>> tailMap = ring.tailMap(hashVal);
Long nodeHashVal = !tailMap.isEmpty() ? tailMap.firstKey() : ring.firstKey();
return ring.get(nodeHashVal).getPhysicalNode();
}
public int getExistingReplicas(T pNode) {
int replicas = 0;
for (VirtualNode<T> vNode : ring.values()) {
......@@ -110,7 +108,6 @@ public class ConsistentHashRouter<T extends Node> {
return replicas;
}
//default hash function
private static class MD5Hash implements HashFunction {
MessageDigest instance;
......
......@@ -21,7 +21,6 @@ package org.apache.rocketmq.common.consistenthash;
*/
public interface Node {
/**
*
* @return the key which will be used for hash mapping
*/
String getKey();
......
......@@ -16,7 +16,6 @@
*/
package org.apache.rocketmq.common.consistenthash;
public class VirtualNode<T extends Node> implements Node {
final T physicalNode;
final int replicaIndex;
......
......@@ -65,7 +65,7 @@ public class FilterAPI {
}
public static SubscriptionData build(final String topic, final String subString,
final String type) throws Exception {
final String type) throws Exception {
if (ExpressionType.TAG.equals(type) || type == null) {
return buildSubscriptionData(null, topic, subString);
}
......
......@@ -35,7 +35,6 @@ public class PolishExpr {
* Shunting-yard algorithm <br/>
* http://en.wikipedia.org/wiki/Shunting_yard_algorithm
*
* @param tokens
* @return the compute result of Shunting-yard algorithm
*/
public static List<Op> reversePolish(List<Op> tokens) {
......
......@@ -98,7 +98,6 @@ public class MessageDecoder {
* Just decode properties from msg buffer.
*
* @param byteBuffer msg commit log buffer.
* @return
*/
public static Map<String, String> decodeProperties(java.nio.ByteBuffer byteBuffer) {
int topicLengthPosition = BODY_SIZE_POSITION + 4 + byteBuffer.getInt(BODY_SIZE_POSITION);
......@@ -239,8 +238,6 @@ public class MessageDecoder {
return byteBuffer.array();
}
public static MessageExt decode(
java.nio.ByteBuffer byteBuffer, final boolean readBody, final boolean deCompressBody) {
return decode(byteBuffer, readBody, deCompressBody, false);
......@@ -414,7 +411,6 @@ public class MessageDecoder {
return map;
}
public static byte[] encodeMessage(Message message) {
//only need flag, body, properties
byte[] body = message.getBody();
......@@ -488,9 +484,9 @@ public class MessageDecoder {
public static byte[] encodeMessages(List<Message> messages) {
//TO DO refactor, accumulate in one buffer, avoid copies
List<byte[]> encodedMessages = new ArrayList<byte[]>(messages.size());
List<byte[]> encodedMessages = new ArrayList<byte[]>(messages.size());
int allSize = 0;
for (Message message: messages) {
for (Message message : messages) {
byte[] tmp = encodeMessage(message);
encodedMessages.add(tmp);
allSize += tmp.length;
......@@ -504,7 +500,6 @@ public class MessageDecoder {
return allBytes;
}
public static List<Message> decodeMessages(ByteBuffer byteBuffer) throws Exception {
//TO DO add a callback for processing, avoid creating lists
List<Message> msgs = new ArrayList<Message>();
......
......@@ -6,13 +6,13 @@
* (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
* 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.
* 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.common.message;
......@@ -23,13 +23,11 @@ public class MessageExtBatch extends MessageExt {
private static final long serialVersionUID = -2353110995348498537L;
public ByteBuffer wrap() {
assert getBody() != null;
return ByteBuffer.wrap(getBody(), 0, getBody().length);
return ByteBuffer.wrap(getBody(), 0, getBody().length);
}
private ByteBuffer encodedBuff;
public ByteBuffer getEncodedBuff() {
......
......@@ -162,7 +162,6 @@ public class RequestCode {
*/
public static final int GET_NAMESRV_CONFIG = 319;
public static final int SEND_BATCH_MESSAGE = 320;
public static final int QUERY_CONSUME_QUEUE = 321;
......
......@@ -35,7 +35,6 @@ public class SearchOffsetRequestHeader implements CommandCustomHeader {
@Override
public void checkFields() throws RemotingCommandException {
}
public String getTopic() {
......
......@@ -54,7 +54,6 @@ public class SendMessageRequestHeaderV2 implements CommandCustomHeader {
@CFNullable
private boolean m; //batch
public static SendMessageRequestHeader createSendMessageRequestHeaderV1(final SendMessageRequestHeaderV2 v2) {
SendMessageRequestHeader v1 = new SendMessageRequestHeader();
v1.setProducerGroup(v2.a);
......
......@@ -58,6 +58,5 @@ public class UnregisterClientRequestHeader implements CommandCustomHeader {
@Override
public void checkFields() throws RemotingCommandException {
}
}
......@@ -25,7 +25,6 @@ public class UnregisterClientResponseHeader implements CommandCustomHeader {
@Override
public void checkFields() throws RemotingCommandException {
}
}
......@@ -22,7 +22,6 @@ package org.apache.rocketmq.common.protocol.heartbeat;
/**
* Message model
*
*/
public enum MessageModel {
/**
......
......@@ -16,7 +16,6 @@
*/
package org.apache.rocketmq.common.sysflag;
public class TopicSysFlag {
private final static int FLAG_UNIT = 0x1 << 0;
......
......@@ -90,13 +90,7 @@ public class HttpTinyClient {
}
/**
* @param url
* @param headers
* @param paramValues
* @param encoding
* @param readTimeoutMs
* @return the http response of given http post request
* @throws java.io.IOException
*/
static public HttpResult httpPost(String url, List<String> headers, List<String> paramValues,
String encoding, long readTimeoutMs) throws IOException {
......
......@@ -60,7 +60,7 @@ public class IOTinyUtils {
BufferedReader reader = toBufferedReader(input);
List<String> list = new ArrayList<String>();
String line;
for (;;) {
for (; ; ) {
line = reader.readLine();
if (null != line) {
list.add(line);
......@@ -114,7 +114,6 @@ public class IOTinyUtils {
fileOrDir.delete();
}
public static void cleanDirectory(File directory) throws IOException {
if (!directory.exists()) {
String message = directory + " does not exist";
......
......@@ -18,6 +18,7 @@
package org.apache.rocketmq.common;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class MQVersionTest {
......@@ -39,7 +40,6 @@ public class MQVersionTest {
assertThat(MQVersion.value2Version(0)).isEqualTo(MQVersion.Version.V3_0_0_SNAPSHOT);
}
@Test
public void testValue2Version_HigherVersion() throws Exception {
assertThat(MQVersion.value2Version(Integer.MAX_VALUE)).isEqualTo(MQVersion.Version.HIGHER_VERSION);
......
......@@ -25,7 +25,6 @@ import org.junit.Test;
public class MessageBatchTest {
public List<Message> generateMessages() {
List<Message> messages = new ArrayList<Message>();
Message message1 = new Message("topic1", "body".getBytes());
......@@ -37,32 +36,34 @@ public class MessageBatchTest {
}
@Test
public void testGenerate_OK() throws Exception{
public void testGenerate_OK() throws Exception {
List<Message> messages = generateMessages();
MessageBatch.generateFromList(messages);
}
@Test(expected = UnsupportedOperationException.class)
public void testGenerate_DiffTopic() throws Exception{
public void testGenerate_DiffTopic() throws Exception {
List<Message> messages = generateMessages();
messages.get(1).setTopic("topic2");
MessageBatch.generateFromList(messages);
}
@Test(expected = UnsupportedOperationException.class)
public void testGenerate_DiffWaitOK() throws Exception{
public void testGenerate_DiffWaitOK() throws Exception {
List<Message> messages = generateMessages();
messages.get(1).setWaitStoreMsgOK(false);
MessageBatch.generateFromList(messages);
}
@Test(expected = UnsupportedOperationException.class)
public void testGenerate_Delay() throws Exception{
public void testGenerate_Delay() throws Exception {
List<Message> messages = generateMessages();
messages.get(1).setDelayTimeLevel(1);
MessageBatch.generateFromList(messages);
}
@Test(expected = UnsupportedOperationException.class)
public void testGenerate_Retry() throws Exception{
public void testGenerate_Retry() throws Exception {
List<Message> messages = generateMessages();
messages.get(1).setTopic(MixAll.RETRY_GROUP_TOPIC_PREFIX + "topic");
MessageBatch.generateFromList(messages);
......
......@@ -35,7 +35,7 @@ public class FilterAPITest {
FilterAPI.buildSubscriptionData(group, topic, subString);
assertThat(subscriptionData.getTopic()).isEqualTo(topic);
assertThat(subscriptionData.getSubString()).isEqualTo(subString);
String [] tags = subString.split("\\|\\|");
String[] tags = subString.split("\\|\\|");
Set<String> tagSet = new HashSet<String>();
for (String tag : tags) {
tagSet.add(tag.trim());
......
......@@ -16,28 +16,28 @@
-->
<java>
<debug>false</debug>
<debug>false</debug>
<javahome>${JAVA_HOME}</javahome>
<javahome>${JAVA_HOME}</javahome>
<jvmtype>server</jvmtype>
<jvmtype>server</jvmtype>
<mainclass>org.apache.rocketmq.tools.command.MQAdminStartup</mainclass>
<mainclass>org.apache.rocketmq.tools.command.MQAdminStartup</mainclass>
<properties>
<java.ext.dirs>${cpd}/../lib</java.ext.dirs>
<rocketmq.home.dir>${cpd}/..</rocketmq.home.dir>
</properties>
<properties>
<java.ext.dirs>${cpd}/../lib</java.ext.dirs>
<rocketmq.home.dir>${cpd}/..</rocketmq.home.dir>
</properties>
<classpaths>
</classpaths>
<classpaths>
</classpaths>
<options>
<-Xms512m></-Xms512m>
<-Xmx1g></-Xmx1g>
<-XX:NewSize>256M</-XX:NewSize>
<-XX:MaxNewSize>512M</-XX:MaxNewSize>
<-XX:PermSize>128M</-XX:PermSize>
<-XX:MaxPermSize>128M</-XX:MaxPermSize>
</options>
<options>
<-Xms512m></-Xms512m>
<-Xmx1g></-Xmx1g>
<-XX:NewSize>256M</-XX:NewSize>
<-XX:MaxNewSize>512M</-XX:MaxNewSize>
<-XX:PermSize>128M</-XX:PermSize>
<-XX:MaxPermSize>128M</-XX:MaxPermSize>
</options>
</java>
......@@ -16,28 +16,30 @@
-->
<java>
<debug>false</debug>
<debug>false</debug>
<javahome>${JAVA_HOME}</javahome>
<javahome>${JAVA_HOME}</javahome>
<jvmtype>server</jvmtype>
<jvmtype>server</jvmtype>
<mainclass>org.apache.rocketmq.broker.BrokerStartup</mainclass>
<mainclass>org.apache.rocketmq.broker.BrokerStartup</mainclass>
<properties>
<java.ext.dirs>${cpd}/../lib</java.ext.dirs>
<rocketmq.home.dir>${cpd}/..</rocketmq.home.dir>
</properties>
<properties>
<java.ext.dirs>${cpd}/../lib</java.ext.dirs>
<rocketmq.home.dir>${cpd}/..</rocketmq.home.dir>
</properties>
<classpaths>
</classpaths>
<classpaths>
</classpaths>
<options>
<-Xms512m></-Xms512m>
<-Xmx1g></-Xmx1g>
<-XX:NewSize>256M</-XX:NewSize>
<-XX:MaxNewSize>512M</-XX:MaxNewSize>
<-XX:PermSize>128M</-XX:PermSize>
<-XX:MaxPermSize>128M</-XX:MaxPermSize>
</options>
</java>
<options>
<-Xms512m>
</-Xms512m>
<-Xmx1g>
</-Xmx1g>
<-XX:NewSize>256M</-XX:NewSize>
<-XX:MaxNewSize>512M</-XX:MaxNewSize>
<-XX:PermSize>128M</-XX:PermSize>
<-XX:MaxPermSize>128M</-XX:MaxPermSize>
</options>
</java>
......@@ -16,28 +16,30 @@
-->
<java>
<debug>false</debug>
<debug>false</debug>
<javahome>${JAVA_HOME}</javahome>
<javahome>${JAVA_HOME}</javahome>
<jvmtype>server</jvmtype>
<jvmtype>server</jvmtype>
<mainclass>org.apache.rocketmq.filtersrv.FiltersrvStartup</mainclass>
<mainclass>org.apache.rocketmq.filtersrv.FiltersrvStartup</mainclass>
<properties>
<java.ext.dirs>${cpd}/../lib</java.ext.dirs>
<rocketmq.home.dir>${cpd}/..</rocketmq.home.dir>
</properties>
<properties>
<java.ext.dirs>${cpd}/../lib</java.ext.dirs>
<rocketmq.home.dir>${cpd}/..</rocketmq.home.dir>
</properties>
<classpaths>
</classpaths>
<classpaths>
</classpaths>
<options>
<-Xms512m></-Xms512m>
<-Xmx1g></-Xmx1g>
<-XX:NewSize>256M</-XX:NewSize>
<-XX:MaxNewSize>512M</-XX:MaxNewSize>
<-XX:PermSize>128M</-XX:PermSize>
<-XX:MaxPermSize>128M</-XX:MaxPermSize>
</options>
</java>
<options>
<-Xms512m>
</-Xms512m>
<-Xmx1g>
</-Xmx1g>
<-XX:NewSize>256M</-XX:NewSize>
<-XX:MaxNewSize>512M</-XX:MaxNewSize>
<-XX:PermSize>128M</-XX:PermSize>
<-XX:MaxPermSize>128M</-XX:MaxPermSize>
</options>
</java>
......@@ -16,28 +16,30 @@
-->
<java>
<debug>false</debug>
<debug>false</debug>
<javahome>${JAVA_HOME}</javahome>
<javahome>${JAVA_HOME}</javahome>
<jvmtype>server</jvmtype>
<jvmtype>server</jvmtype>
<mainclass>org.apache.rocketmq.namesrv.NamesrvStartup</mainclass>
<mainclass>org.apache.rocketmq.namesrv.NamesrvStartup</mainclass>
<properties>
<java.ext.dirs>${cpd}/../lib</java.ext.dirs>
<rocketmq.home.dir>${cpd}/..</rocketmq.home.dir>
</properties>
<properties>
<java.ext.dirs>${cpd}/../lib</java.ext.dirs>
<rocketmq.home.dir>${cpd}/..</rocketmq.home.dir>
</properties>
<classpaths>
</classpaths>
<classpaths>
</classpaths>
<options>
<-Xms512m></-Xms512m>
<-Xmx1g></-Xmx1g>
<-XX:NewSize>256M</-XX:NewSize>
<-XX:MaxNewSize>512M</-XX:MaxNewSize>
<-XX:PermSize>128M</-XX:PermSize>
<-XX:MaxPermSize>128M</-XX:MaxPermSize>
</options>
</java>
<options>
<-Xms512m>
</-Xms512m>
<-Xmx1g>
</-Xmx1g>
<-XX:NewSize>256M</-XX:NewSize>
<-XX:MaxNewSize>512M</-XX:MaxNewSize>
<-XX:PermSize>128M</-XX:PermSize>
<-XX:MaxPermSize>128M</-XX:MaxPermSize>
</options>
</java>
......@@ -12,7 +12,6 @@
# 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.
brokerClusterName=DefaultCluster
brokerName=broker-a
brokerId=1
......
......@@ -12,7 +12,6 @@
# 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.
brokerClusterName=DefaultCluster
brokerName=broker-a
brokerId=0
......
......@@ -12,7 +12,6 @@
# 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.
brokerClusterName=DefaultCluster
brokerName=broker-b
brokerId=1
......
......@@ -12,7 +12,6 @@
# 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.
brokerClusterName=DefaultCluster
brokerName=broker-b
brokerId=0
......
......@@ -12,7 +12,6 @@
# 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.
brokerClusterName=DefaultCluster
brokerName=broker-a
brokerId=1
......
......@@ -12,7 +12,6 @@
# 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.
brokerClusterName=DefaultCluster
brokerName=broker-a
brokerId=0
......
......@@ -12,7 +12,6 @@
# 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.
brokerClusterName=DefaultCluster
brokerName=broker-b
brokerId=1
......
......@@ -12,7 +12,6 @@
# 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.
brokerClusterName=DefaultCluster
brokerName=broker-b
brokerId=0
......
......@@ -12,7 +12,6 @@
# 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.
brokerClusterName=DefaultCluster
brokerName=broker-a
brokerId=0
......
......@@ -12,7 +12,6 @@
# 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.
brokerClusterName=DefaultCluster
brokerName=broker-b
brokerId=0
......
......@@ -233,7 +233,7 @@
<maxIndex>10</maxIndex>
</rollingPolicy>
<triggeringPolicy
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>100MB</maxFileSize>
</triggeringPolicy>
<encoder>
......@@ -350,8 +350,8 @@
</logger>
<logger name="RocketmqConsole" additivity="false">
<level value="INFO" />
<appender-ref ref="STDOUT" />
<level value="INFO"/>
<appender-ref ref="STDOUT"/>
</logger>
<root>
......
......@@ -24,8 +24,7 @@ import org.apache.rocketmq.common.message.Message;
public class SimpleBatchProducer {
public static void main(String[] args) throws Exception {
public static void main(String[] args) throws Exception {
DefaultMQProducer producer = new DefaultMQProducer("BatchProducerGroupName");
producer.start();
......
......@@ -26,7 +26,7 @@ import org.apache.rocketmq.common.message.Message;
public class SplitBatchProducer {
public static void main(String[] args) throws Exception {
public static void main(String[] args) throws Exception {
DefaultMQProducer producer = new DefaultMQProducer("BatchProducerGroupName");
producer.start();
......@@ -41,25 +41,29 @@ public class SplitBatchProducer {
//split the large batch into small ones:
ListSplitter splitter = new ListSplitter(messages);
while (splitter.hasNext()) {
List<Message> listItem = splitter.next();
List<Message> listItem = splitter.next();
producer.send(listItem);
}
}
}
class ListSplitter implements Iterator<List<Message>> {
private int sizeLimit = 1000 * 1000;
private final List<Message> messages;
private int currIndex;
public ListSplitter(List<Message> messages) {
this.messages = messages;
}
@Override public boolean hasNext() {
@Override
public boolean hasNext() {
return currIndex < messages.size();
}
@Override public List<Message> next() {
@Override
public List<Message> next() {
int nextIndex = currIndex;
int totalSize = 0;
for (; nextIndex < messages.size(); nextIndex++) {
......@@ -91,7 +95,8 @@ class ListSplitter implements Iterator<List<Message>> {
return subList;
}
@Override public void remove() {
@Override
public void remove() {
throw new UnsupportedOperationException("Not allowed to remove");
}
}
......@@ -242,7 +242,7 @@ class StatsBenchmarkProducer {
private final AtomicLong sendMessageMaxRT = new AtomicLong(0L);
public Long[] createSnapshot() {
Long[] snap = new Long[]{
Long[] snap = new Long[] {
System.currentTimeMillis(),
this.sendRequestSuccessCount.get(),
this.sendRequestFailedCount.get(),
......
......@@ -44,7 +44,7 @@ public class SqlConsumer {
@Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
ConsumeConcurrentlyContext context) {
ConsumeConcurrentlyContext context) {
System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n");
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
......
......@@ -25,7 +25,8 @@ import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.common.RemotingHelper;
public class AsyncProducer {
public static void main(String[] args) throws MQClientException, InterruptedException, UnsupportedEncodingException {
public static void main(
String[] args) throws MQClientException, InterruptedException, UnsupportedEncodingException {
DefaultMQProducer producer = new DefaultMQProducer("Jodie_Daily_test");
producer.start();
......
......@@ -35,7 +35,6 @@ public class PushConsumer {
consumer.setConsumeTimestamp("20170422221800");
consumer.registerMessageListener(new MessageListenerConcurrently() {
@Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeConcurrentlyContext context) {
System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n");
......
......@@ -38,8 +38,6 @@ public class FilterFactory {
* <br>
* Note:
* <li>1. Filter registered will be used in broker server, so take care of it's reliability and performance.</li>
*
* @param filterSpi
*/
public void register(FilterSpi filterSpi) {
if (FILTER_SPI_HOLDER.containsKey(filterSpi.ofType())) {
......@@ -51,9 +49,6 @@ public class FilterFactory {
/**
* Un register a filter.
*
* @param type
* @return
*/
public FilterSpi unRegister(String type) {
return FILTER_SPI_HOLDER.remove(type);
......@@ -61,9 +56,6 @@ public class FilterFactory {
/**
* Get a filter registered, null if none exist.
*
* @param type
* @return
*/
public FilterSpi get(String type) {
return FILTER_SPI_HOLDER.get(type);
......
......@@ -27,17 +27,11 @@ public interface FilterSpi {
/**
* Compile.
*
* @param expr
* @return
* @throws org.apache.rocketmq.filter.expression.MQFilterException
*/
Expression compile(final String expr) throws MQFilterException;
/**
* Which type.
*
* @return
*/
String ofType();
}
......@@ -69,8 +69,6 @@ public abstract class BinaryExpression implements Expression {
/**
* Returns the symbol that represents this binary expression. For example, addition is
* represented by "+"
*
* @return
*/
public abstract String getExpressionSymbol();
......
......@@ -30,9 +30,7 @@ package org.apache.rocketmq.filter.expression;
public interface BooleanExpression extends Expression {
/**
* @param context
* @return true if the expression evaluates to Boolean.TRUE.
* @throws Exception
*/
boolean matches(EvaluationContext context) throws Exception;
......
......@@ -203,8 +203,6 @@ public abstract class ComparisonExpression extends BinaryExpression implements B
/**
* Only Numeric expressions can be used in >, >=, < or <= expressions.s
*
* @param expr
*/
public static void checkLessThanOperand(Expression expr) {
if (expr instanceof ConstantExpression) {
......@@ -224,8 +222,6 @@ public abstract class ComparisonExpression extends BinaryExpression implements B
/**
* Validates that the expression can be used in == or <> expression. Cannot
* not be NULL TRUE or FALSE litterals.
*
* @param expr
*/
public static void checkEqualOperand(Expression expr) {
if (expr instanceof ConstantExpression) {
......
......@@ -136,8 +136,6 @@ public class ConstantExpression implements Expression {
/**
* Encodes the value of string so that it looks like it would look like when
* it was provided in a selector.
*
* @return
*/
public static String encodeString(String s) {
StringBuffer b = new StringBuffer();
......
......@@ -28,16 +28,11 @@ public interface EvaluationContext {
/**
* Get value by name from context
*
* @param name
* @return
*/
Object get(String name);
/**
* Context variables.
*
* @return
*/
Map<String, Object> keyValues();
}
......@@ -71,7 +71,7 @@ public abstract class UnaryExpression implements Expression {
}
public static BooleanExpression createInExpression(PropertyExpression right, List<Object> elements,
final boolean not) {
final boolean not) {
// Use a HashSet if there are many elements.
Collection<Object> t;
......@@ -259,8 +259,6 @@ public abstract class UnaryExpression implements Expression {
/**
* Returns the symbol that represents this binary expression. For example,
* addition is represented by "+"
*
* @return
*/
public abstract String getExpressionSymbol();
......
......@@ -31,7 +31,7 @@ abstract public class UnaryInExpression extends UnaryExpression implements Boole
private Collection inList;
public UnaryInExpression(Expression left, UnaryType unaryType,
Collection inList, boolean not) {
Collection inList, boolean not) {
super(left, unaryType);
this.setInList(inList);
this.setNot(not);
......
......@@ -44,8 +44,8 @@ public class ParseException extends Exception {
* "expectedTokenSequences", and "TOKEN_IMAGE" set.
*/
public ParseException(Token currentTokenVal,
int[][] expectedTokenSequencesVal,
String[] tokenImageVal
int[][] expectedTokenSequencesVal,
String[] tokenImageVal
) {
super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal));
currentToken = currentTokenVal;
......@@ -103,8 +103,8 @@ public class ParseException extends Exception {
* gets displayed.
*/
private static String initialise(Token currentToken,
int[][] expectedTokenSequences,
String[] tokenImage) {
int[][] expectedTokenSequences,
String[] tokenImage) {
String eol = System.getProperty("line.separator", "\n");
StringBuffer expected = new StringBuffer();
int maxSize = 0;
......
......@@ -996,12 +996,13 @@ public class SelectorParser implements SelectorParserConstants {
}
private static void jj_la1_init_0() {
jjLa10 = new int[]{0x400, 0x200, 0xc10000, 0xc00000, 0x10000, 0xf001900, 0x20000000, 0x20000000, 0xf000800,
jjLa10 = new int[] {
0x400, 0x200, 0xc10000, 0xc00000, 0x10000, 0xf001900, 0x20000000, 0x20000000, 0xf000800,
0x1000, 0x1036e100, 0x1036e000, 0x16e000};
}
private static void jj_la1_init_1() {
jjLa11 = new int[]{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0};
jjLa11 = new int[] {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0};
}
final private JJCalls[] jj2Rtns = new JJCalls[4];
......@@ -1322,7 +1323,8 @@ public class SelectorParser implements SelectorParserConstants {
}
}
p = p.next;
} while (p != null);
}
while (p != null);
} catch (LookaheadSuccess ls) {
}
}
......
......@@ -385,7 +385,7 @@ public class SelectorParserTokenManager implements SelectorParserConstants {
int i = 1;
jjstateSet[0] = startState;
int kind = 0x7fffffff;
for (;;) {
for (; ; ) {
if (++jjround == 0x7fffffff)
ReInitRounds();
if (curChar < 64) {
......@@ -586,7 +586,8 @@ public class SelectorParserTokenManager implements SelectorParserConstants {
default:
break;
}
} while (i != startsAt);
}
while (i != startsAt);
} else if (curChar < 128) {
long l = 1L << (curChar & 077);
do {
......@@ -631,7 +632,8 @@ public class SelectorParserTokenManager implements SelectorParserConstants {
default:
break;
}
} while (i != startsAt);
}
while (i != startsAt);
} else {
int hiByte = (int) (curChar >> 8);
int i1 = hiByte >> 6;
......@@ -660,7 +662,8 @@ public class SelectorParserTokenManager implements SelectorParserConstants {
default:
break;
}
} while (i != startsAt);
}
while (i != startsAt);
}
if (kind != 0x7fffffff) {
jjmatchedKind = kind;
......@@ -834,7 +837,7 @@ public class SelectorParserTokenManager implements SelectorParserConstants {
int curPos = 0;
EOFLoop:
for (;;) {
for (; ; ) {
try {
curChar = inputStream.BeginToken();
} catch (java.io.IOException e) {
......@@ -902,7 +905,8 @@ public class SelectorParserTokenManager implements SelectorParserConstants {
private void jjAddStates(int start, int end) {
do {
jjstateSet[jjnewStateCnt++] = JJ_NEXT_STATES[start];
} while (start++ != end);
}
while (start++ != end);
}
private void jjCheckNAddTwoStates(int state1, int state2) {
......@@ -913,7 +917,8 @@ public class SelectorParserTokenManager implements SelectorParserConstants {
private void jjCheckNAddStates(int start, int end) {
do {
jjCheckNAdd(JJ_NEXT_STATES[start]);
} while (start++ != end);
}
while (start++ != end);
}
}
......@@ -264,7 +264,7 @@ public class SimpleCharStream {
* Constructor.
*/
public SimpleCharStream(java.io.Reader dstream, int startline,
int startcolumn, int buffersize) {
int startcolumn, int buffersize) {
inputStream = dstream;
line = startline;
column = startcolumn - 1;
......@@ -279,7 +279,7 @@ public class SimpleCharStream {
* Constructor.
*/
public SimpleCharStream(java.io.Reader dstream, int startline,
int startcolumn) {
int startcolumn) {
this(dstream, startline, startcolumn, 4096);
}
......@@ -294,7 +294,7 @@ public class SimpleCharStream {
* Reinitialise.
*/
public void ReInit(java.io.Reader dstream, int startline,
int startcolumn, int buffersize) {
int startcolumn, int buffersize) {
inputStream = dstream;
line = startline;
column = startcolumn - 1;
......@@ -314,7 +314,7 @@ public class SimpleCharStream {
* Reinitialise.
*/
public void ReInit(java.io.Reader dstream, int startline,
int startcolumn) {
int startcolumn) {
ReInit(dstream, startline, startcolumn, 4096);
}
......@@ -329,7 +329,7 @@ public class SimpleCharStream {
* Constructor.
*/
public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline,
int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException {
int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException {
this(encoding == null ?
new java.io.InputStreamReader(dstream) :
new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
......@@ -339,7 +339,7 @@ public class SimpleCharStream {
* Constructor.
*/
public SimpleCharStream(java.io.InputStream dstream, int startline,
int startcolumn, int buffersize) {
int startcolumn, int buffersize) {
this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
}
......@@ -347,7 +347,7 @@ public class SimpleCharStream {
* Constructor.
*/
public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline,
int startcolumn) throws java.io.UnsupportedEncodingException {
int startcolumn) throws java.io.UnsupportedEncodingException {
this(dstream, encoding, startline, startcolumn, 4096);
}
......@@ -355,7 +355,7 @@ public class SimpleCharStream {
* Constructor.
*/
public SimpleCharStream(java.io.InputStream dstream, int startline,
int startcolumn) {
int startcolumn) {
this(dstream, startline, startcolumn, 4096);
}
......@@ -377,7 +377,7 @@ public class SimpleCharStream {
* Reinitialise.
*/
public void ReInit(java.io.InputStream dstream, String encoding, int startline,
int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException {
int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException {
ReInit(encoding == null ?
new java.io.InputStreamReader(dstream) :
new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
......@@ -387,7 +387,7 @@ public class SimpleCharStream {
* Reinitialise.
*/
public void ReInit(java.io.InputStream dstream, int startline,
int startcolumn, int buffersize) {
int startcolumn, int buffersize) {
ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
}
......@@ -409,7 +409,7 @@ public class SimpleCharStream {
* Reinitialise.
*/
public void ReInit(java.io.InputStream dstream, String encoding, int startline,
int startcolumn) throws java.io.UnsupportedEncodingException {
int startcolumn) throws java.io.UnsupportedEncodingException {
ReInit(dstream, encoding, startline, startcolumn, 4096);
}
......@@ -417,7 +417,7 @@ public class SimpleCharStream {
* Reinitialise.
*/
public void ReInit(java.io.InputStream dstream, int startline,
int startcolumn) {
int startcolumn) {
ReInit(dstream, startline, startcolumn, 4096);
}
......
......@@ -122,7 +122,7 @@ public class TokenMgrError extends Error {
* Note: You can customize the lexical error message by modifying this method.
*/
protected static String LexicalError(boolean eofSeen, int lexState, int errorLine, int errorColumn,
String errorAfter, char curChar) {
String errorAfter, char curChar) {
return "Lexical error at line " +
errorLine + ", column " +
errorColumn + ". Encountered: " +
......@@ -167,7 +167,7 @@ public class TokenMgrError extends Error {
* Full Constructor.
*/
public TokenMgrError(boolean eofSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar,
int reason) {
int reason) {
this(LexicalError(eofSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
}
}
......
......@@ -42,7 +42,6 @@ public class BloomFilter {
*
* @param f error rate
* @param n num will mapping to bit
* @return
*/
public static BloomFilter createByFn(int f, int n) {
return new BloomFilter(f, n);
......@@ -87,9 +86,6 @@ public class BloomFilter {
* See "Less Hashing, Same Performance: Building a Better Bloom Filter" by Adam Kirsch and Michael
* Mitzenmacher.
* </p>
*
* @param str
* @return
*/
public int[] calcBitPositions(String str) {
int[] bitPositions = new int[this.k];
......@@ -113,9 +109,6 @@ public class BloomFilter {
/**
* Calculate bit positions of {@code str} to construct {@code BloomFilterData}
*
* @param str
* @return
*/
public BloomFilterData generate(String str) {
int[] bitPositions = calcBitPositions(str);
......@@ -125,9 +118,6 @@ public class BloomFilter {
/**
* Calculate bit positions of {@code str}, then set the related {@code bits} positions to 1.
*
* @param str
* @param bits
*/
public void hashTo(String str, BitsArray bits) {
hashTo(calcBitPositions(str), bits);
......@@ -135,9 +125,6 @@ public class BloomFilter {
/**
* Set the related {@code bits} positions to 1.
*
* @param bitPositions
* @param bits
*/
public void hashTo(int[] bitPositions, BitsArray bits) {
check(bits);
......@@ -153,9 +140,6 @@ public class BloomFilter {
* <p>
* Then set the related {@code bits} positions to 1.
* </p>
*
* @param filterData
* @param bits
*/
public void hashTo(BloomFilterData filterData, BitsArray bits) {
if (!isValid(filterData)) {
......@@ -170,8 +154,6 @@ public class BloomFilter {
/**
* Calculate bit positions of {@code str}, then check all the related {@code bits} positions is 1.
*
* @param str
* @param bits
* @return true: all the related {@code bits} positions is 1
*/
public boolean isHit(String str, BitsArray bits) {
......@@ -181,8 +163,6 @@ public class BloomFilter {
/**
* Check all the related {@code bits} positions is 1.
*
* @param bitPositions
* @param bits
* @return true: all the related {@code bits} positions is 1
*/
public boolean isHit(int[] bitPositions, BitsArray bits) {
......@@ -197,8 +177,6 @@ public class BloomFilter {
/**
* Check all the related {@code bits} positions is 1.
*
* @param filterData
* @param bits
* @return true: all the related {@code bits} positions is 1
*/
public boolean isHit(BloomFilterData filterData, BitsArray bits) {
......@@ -214,8 +192,6 @@ public class BloomFilter {
/**
* Check whether one of {@code bitPositions} has been occupied.
*
* @param bitPositions
* @param bits
* @return true: if all positions have been occupied.
*/
public boolean checkFalseHit(int[] bitPositions, BitsArray bits) {
......@@ -246,9 +222,6 @@ public class BloomFilter {
* <li>2. {@link org.apache.rocketmq.filter.util.BloomFilterData#getBitNum} must be equal to {@code m} </li>
* <li>3. {@link org.apache.rocketmq.filter.util.BloomFilterData#getBitPos} is not null</li>
* <li>4. {@link org.apache.rocketmq.filter.util.BloomFilterData#getBitPos}'s length is equal to {@code k}</li>
*
* @param filterData
* @return
*/
public boolean isValid(BloomFilterData filterData) {
if (filterData == null
......@@ -263,8 +236,6 @@ public class BloomFilter {
/**
* error rate.
*
* @return
*/
public int getF() {
return f;
......@@ -272,8 +243,6 @@ public class BloomFilter {
/**
* expect mapping num.
*
* @return
*/
public int getN() {
return n;
......@@ -281,8 +250,6 @@ public class BloomFilter {
/**
* hash function num.
*
* @return
*/
public int getK() {
return k;
......@@ -290,8 +257,6 @@ public class BloomFilter {
/**
* total bit num.
*
* @return
*/
public int getM() {
return m;
......
......@@ -55,13 +55,17 @@ public class BloomFilterData {
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (!(o instanceof BloomFilterData)) return false;
if (this == o)
return true;
if (!(o instanceof BloomFilterData))
return false;
final BloomFilterData that = (BloomFilterData) o;
if (bitNum != that.bitNum) return false;
if (!Arrays.equals(bitPos, that.bitPos)) return false;
if (bitNum != that.bitNum)
return false;
if (!Arrays.equals(bitPos, that.bitPos))
return false;
return true;
}
......
......@@ -111,8 +111,8 @@ public class BitsArrayTest {
@Test
public void testOr() {
BitsArray b1 = BitsArray.create(new byte[]{(byte) 0xff, 0x00});
BitsArray b2 = BitsArray.create(new byte[]{0x00, (byte) 0xff});
BitsArray b1 = BitsArray.create(new byte[] {(byte) 0xff, 0x00});
BitsArray b2 = BitsArray.create(new byte[] {0x00, (byte) 0xff});
b1.or(b2);
......
......@@ -107,9 +107,9 @@ public class BloomFilterTest {
@Test
public void testBloomFilterData() {
BloomFilterData bloomFilterData = new BloomFilterData(new int[]{1, 2, 3}, 128);
BloomFilterData bloomFilterData1 = new BloomFilterData(new int[]{1, 2, 3}, 128);
BloomFilterData bloomFilterData2 = new BloomFilterData(new int[]{1, 2, 3}, 129);
BloomFilterData bloomFilterData = new BloomFilterData(new int[] {1, 2, 3}, 128);
BloomFilterData bloomFilterData1 = new BloomFilterData(new int[] {1, 2, 3}, 128);
BloomFilterData bloomFilterData2 = new BloomFilterData(new int[] {1, 2, 3}, 129);
assertThat(bloomFilterData).isEqualTo(bloomFilterData1);
assertThat(bloomFilterData2).isNotEqualTo(bloomFilterData);
......@@ -127,7 +127,7 @@ public class BloomFilterTest {
assertThat(bloomFilterData).isEqualTo(bloomFilterData2);
bloomFilterData2.setBitPos(new int[]{1, 2, 3, 4});
bloomFilterData2.setBitPos(new int[] {1, 2, 3, 4});
assertThat(bloomFilterData).isNotEqualTo(bloomFilterData2);
......
......@@ -48,7 +48,6 @@ public class FilterSpiTest {
}
}
@Test
public void testRegister() {
FilterFactory.INSTANCE.register(new NothingFilter());
......
......@@ -83,7 +83,8 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
return false;
}
private RemotingCommand registerMessageFilterClass(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand registerMessageFilterClass(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final RegisterMessageFilterClassRequestHeader requestHeader =
(RegisterMessageFilterClassRequestHeader) request.decodeCommandCustomHeader(RegisterMessageFilterClassRequestHeader.class);
......@@ -108,7 +109,8 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand pullMessageForward(final ChannelHandlerContext ctx, final RemotingCommand request) throws Exception {
private RemotingCommand pullMessageForward(final ChannelHandlerContext ctx,
final RemotingCommand request) throws Exception {
final RemotingCommand response = RemotingCommand.createResponseCommand(PullMessageResponseHeader.class);
final PullMessageResponseHeader responseHeader = (PullMessageResponseHeader) response.readCustomHeader();
final PullMessageRequestHeader requestHeader =
......@@ -215,7 +217,8 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
return null;
}
private void returnResponse(final String group, final String topic, ChannelHandlerContext ctx, final RemotingCommand response,
private void returnResponse(final String group, final String topic, ChannelHandlerContext ctx,
final RemotingCommand response,
final List<MessageExt> msgList) {
if (null != msgList) {
ByteBuffer[] msgBufferList = new ByteBuffer[msgList.size()];
......
......@@ -52,7 +52,6 @@ public class ProducerInstance {
return nameServerAddress + "_" + group;
}
public MQProducer getInstance(String nameServerAddress, String group) throws MQClientException {
if (StringUtils.isBlank(group)) {
group = DEFAULT_GROUP;
......@@ -75,7 +74,6 @@ public class ProducerInstance {
return defaultMQProducer;
}
public void removeAndClose(String nameServerAddress, String group) {
if (group == null) {
group = DEFAULT_GROUP;
......
......@@ -59,7 +59,6 @@ public class RocketmqLog4jAppender extends AppenderSkeleton {
public RocketmqLog4jAppender() {
}
public void activateOptions() {
LogLog.debug("Getting initial context.");
if (!checkEntryConditions()) {
......@@ -72,11 +71,8 @@ public class RocketmqLog4jAppender extends AppenderSkeleton {
}
}
/**
* Info,error,warn,callback method implementation
*
* @param event
*/
public void append(LoggingEvent event) {
if (null == producer) {
......@@ -95,7 +91,7 @@ public class RocketmqLog4jAppender extends AppenderSkeleton {
} catch (Exception e) {
String msg = new String(data);
errorHandler.error("Could not send message in RocketmqLog4jAppender [" + name + "].Message is :" + msg, e,
ErrorCode.GENERIC_FAILURE);
ErrorCode.GENERIC_FAILURE);
}
}
......@@ -145,7 +141,6 @@ public class RocketmqLog4jAppender extends AppenderSkeleton {
return topic;
}
public void setTopic(String topic) {
this.topic = topic;
}
......
......@@ -70,10 +70,9 @@ public class RocketmqLog4j2Appender extends AbstractAppender {
*/
private String topic;
protected RocketmqLog4j2Appender(String name, Filter filter, Layout<? extends Serializable> layout,
boolean ignoreExceptions, String nameServerAddress, String producerGroup,
String topic, String tag) {
boolean ignoreExceptions, String nameServerAddress, String producerGroup,
String topic, String tag) {
super(name, filter, layout, ignoreExceptions);
this.producer = producer;
this.topic = topic;
......@@ -86,15 +85,13 @@ public class RocketmqLog4j2Appender extends AbstractAppender {
ErrorHandler handler = this.getHandler();
if (handler != null) {
handler.error("Starting RocketmqLog4j2Appender [" + this.getName()
+ "] nameServerAddress:" + nameServerAddress + " group:" + producerGroup + " " + e.getMessage());
+ "] nameServerAddress:" + nameServerAddress + " group:" + producerGroup + " " + e.getMessage());
}
}
}
/**
* Info,error,warn,callback method implementation
*
* @param event
*/
public void append(LogEvent event) {
if (null == producer) {
......@@ -119,10 +116,6 @@ public class RocketmqLog4j2Appender extends AbstractAppender {
/**
* When system exit,this method will be called to close resources
*
* @param timeout
* @param timeUnit
* @return
*/
public boolean stop(long timeout, TimeUnit timeUnit) {
this.setStopping();
......@@ -132,7 +125,7 @@ public class RocketmqLog4j2Appender extends AbstractAppender {
ErrorHandler handler = this.getHandler();
if (handler != null) {
handler.error("Closeing RocketmqLog4j2Appender [" + this.getName()
+ "] nameServerAddress:" + nameServerAddress + " group:" + producerGroup + " " + e.getMessage());
+ "] nameServerAddress:" + nameServerAddress + " group:" + producerGroup + " " + e.getMessage());
}
}
......@@ -227,7 +220,7 @@ public class RocketmqLog4j2Appender extends AbstractAppender {
public RocketmqLog4j2Appender build() {
return new RocketmqLog4j2Appender(name, filter, layout, ignoreExceptions,
nameServerAddress, producerGroup, topic, tag);
nameServerAddress, producerGroup, topic, tag);
}
}
}
......@@ -62,8 +62,6 @@ public class RocketmqLogbackAppender extends AppenderBase<ILoggingEvent> {
/**
* Info,error,warn,callback method implementation
*
* @param event
*/
@Override
protected void append(ILoggingEvent event) {
......@@ -100,7 +98,7 @@ public class RocketmqLogbackAppender extends AppenderBase<ILoggingEvent> {
producer = ProducerInstance.getProducerInstance().getInstance(nameServerAddress, producerGroup);
} catch (Exception e) {
addError("Starting RocketmqLogbackAppender [" + this.getName()
+ "] nameServerAddress:" + nameServerAddress + " group:" + producerGroup + " " + e.getMessage());
+ "] nameServerAddress:" + nameServerAddress + " group:" + producerGroup + " " + e.getMessage());
}
if (producer != null) {
super.start();
......@@ -122,7 +120,7 @@ public class RocketmqLogbackAppender extends AppenderBase<ILoggingEvent> {
ProducerInstance.getProducerInstance().removeAndClose(this.nameServerAddress, this.producerGroup);
} catch (Exception e) {
addError("Closeing RocketmqLogbackAppender [" + this.getName()
+ "] nameServerAddress:" + nameServerAddress + " group:" + producerGroup + " " + e.getMessage());
+ "] nameServerAddress:" + nameServerAddress + " group:" + producerGroup + " " + e.getMessage());
}
// Help garbage collection
......@@ -144,7 +142,6 @@ public class RocketmqLogbackAppender extends AppenderBase<ILoggingEvent> {
}
}
public Layout getLayout() {
return this.layout;
}
......@@ -160,7 +157,6 @@ public class RocketmqLogbackAppender extends AppenderBase<ILoggingEvent> {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
......
......@@ -30,7 +30,6 @@ import java.lang.reflect.Field;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Basic test rocketmq broker and name server init
*/
......
......@@ -22,8 +22,7 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
public abstract class Log4jTest extends AbstractTestCase{
public abstract class Log4jTest extends AbstractTestCase {
@Before
public abstract void init();
......@@ -37,8 +36,8 @@ public abstract class Log4jTest extends AbstractTestCase{
for (int i = 0; i < 10; i++) {
logger.info("log4j " + this.getType() + " simple test message " + i);
}
int received = consumeMessages(10, "log4j",10);
Assert.assertTrue(received>5);
int received = consumeMessages(10, "log4j", 10);
Assert.assertTrue(received > 5);
}
}
......@@ -29,7 +29,7 @@ import org.slf4j.LoggerFactory;
import java.io.File;
public class LogbackTest extends AbstractTestCase{
public class LogbackTest extends AbstractTestCase {
@Before
public void init() throws JoranException {
......@@ -41,7 +41,6 @@ public class LogbackTest extends AbstractTestCase{
StatusPrinter.printInCaseOfErrorsOrWarnings(lc);
}
@Test
public void testLogback() throws InterruptedException, MQClientException {
clear();
......@@ -49,7 +48,7 @@ public class LogbackTest extends AbstractTestCase{
for (int i = 0; i < 10; i++) {
logger.info("logback test message " + i);
}
int received = consumeMessages(10, "logback",10);
Assert.assertTrue(received>=5);
int received = consumeMessages(10, "logback", 10);
Assert.assertTrue(received >= 5);
}
}
......@@ -24,14 +24,13 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
public class log4j2Test extends AbstractTestCase{
public class log4j2Test extends AbstractTestCase {
@Before
public void init() {
Configurator.initialize("log4j2", "src/test/resources/log4j2-example.xml");
}
@Test
public void testLog4j2() throws InterruptedException, MQClientException {
clear();
......@@ -39,7 +38,7 @@ public class log4j2Test extends AbstractTestCase{
for (int i = 0; i < 10; i++) {
logger.info("log4j2 log message " + i);
}
int received = consumeMessages(10, "log4j2",10);
Assert.assertTrue(received>5);
int received = consumeMessages(10, "log4j2", 10);
Assert.assertTrue(received > 5);
}
}
......@@ -12,23 +12,18 @@
# 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.
log4j.rootLogger=INFO,stdout
log4j.logger.testLogger=INFO,mq
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %-4r [%t] (%F:%L) %-5p - %m%n
log4j.appender.store=org.apache.log4j.DailyRollingFileAppender
log4j.appender.store.File=${user.home}/logs/rocketmqlogs/appender.log
log4j.appender.store.Append=true
log4j.appender.store.DatePattern ='_'yyyy-MM-dd'.log'
log4j.appender.store.DatePattern='_'yyyy-MM-dd'.log'
log4j.appender.store.layout=org.apache.log4j.PatternLayout
log4j.appender.store.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-4r [%t] (%F:%L) %-5p - %m%n
log4j.appender.mq=org.apache.rocketmq.logappender.log4j.RocketmqLog4jAppender
log4j.appender.mq.Tag=log
log4j.appender.mq.Topic=TopicTest
......
......@@ -19,37 +19,37 @@ limitations under the License.
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender">
<param name="Encoding" value="UTF-8" />
<param name="Target" value="System.out" />
<param name="Encoding" value="UTF-8"/>
<param name="Target" value="System.out"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss},%d %-4r [%t] (%F:%L) %-5p - %m%n" />
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss},%d %-4r [%t] (%F:%L) %-5p - %m%n"/>
</layout>
</appender>
<appender name="mqAppender1" class="org.apache.rocketmq.logappender.log4j.RocketmqLog4jAppender">
<param name="Tag" value="log1" />
<param name="Topic" value="TopicTest" />
<param name="ProducerGroup" value="loggerAppender" />
<param name="Tag" value="log1"/>
<param name="Topic" value="TopicTest"/>
<param name="ProducerGroup" value="loggerAppender"/>
<param name="NameServerAddress" value="127.0.0.1:9876"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss}-%p %t %c - %m%n" />
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss}-%p %t %c - %m%n"/>
</layout>
</appender>
<logger name="testLogger" additivity="false">
<level value="INFO" />
<appender-ref ref="mqAppender1" />
<appender-ref ref="consoleAppender" />
<level value="INFO"/>
<appender-ref ref="mqAppender1"/>
<appender-ref ref="consoleAppender"/>
</logger>
<logger name="consoleLogger" additivity="false">
<level value="INFO" />
<appender-ref ref="consoleAppender" />
<level value="INFO"/>
<appender-ref ref="consoleAppender"/>
</logger>
<root>
<level value="INFO" />
<level value="INFO"/>
<appender-ref ref="consoleAppender"/>
</root>
......
......@@ -17,25 +17,25 @@
-->
<Configuration status="warn" name="Rocketmq">
<Appenders>
<RocketMQ name="rocketmqAppender" producerGroup="loggerAppender" nameServerAddress="127.0.0.1:9876"
topic="TopicTest" tag="log">
<PatternLayout pattern="%d [%p] hahahah %c %m%n"/>
</RocketMQ>
<Appenders>
<RocketMQ name="rocketmqAppender" producerGroup="loggerAppender" nameServerAddress="127.0.0.1:9876"
topic="TopicTest" tag="log">
<PatternLayout pattern="%d [%p] hahahah %c %m%n"/>
</RocketMQ>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Logger name="rocketmqLogger" level="info">
<AppenderRef ref="rocketmqAppender"/>
</Logger>
<Logger name="rocketmqLogger" level="info">
<AppenderRef ref="rocketmqAppender"/>
</Logger>
<Root level="debug">
<AppenderRef ref="Console"/>
<AppenderRef ref="rocketmqAppender"/>
</Root>
</Loggers>
<Root level="debug">
<AppenderRef ref="Console"/>
<AppenderRef ref="rocketmqAppender"/>
</Root>
</Loggers>
</Configuration>
\ No newline at end of file
......@@ -50,7 +50,8 @@ public class ClusterTestRequestProcessor extends DefaultRequestProcessor {
}
@Override
public RemotingCommand getRouteInfoByTopic(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
public RemotingCommand getRouteInfoByTopic(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetRouteInfoRequestHeader requestHeader =
(GetRouteInfoRequestHeader) request.decodeCommandCustomHeader(GetRouteInfoRequestHeader.class);
......
......@@ -63,7 +63,8 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
}
@Override
public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
public RemotingCommand processRequest(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
if (log.isDebugEnabled()) {
log.debug("receive request, {} {} {}",
request.getCode(),
......@@ -124,7 +125,8 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
return false;
}
public RemotingCommand putKVConfig(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
public RemotingCommand putKVConfig(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final PutKVConfigRequestHeader requestHeader =
(PutKVConfigRequestHeader) request.decodeCommandCustomHeader(PutKVConfigRequestHeader.class);
......@@ -140,7 +142,8 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
return response;
}
public RemotingCommand getKVConfig(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
public RemotingCommand getKVConfig(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(GetKVConfigResponseHeader.class);
final GetKVConfigResponseHeader responseHeader = (GetKVConfigResponseHeader) response.readCustomHeader();
final GetKVConfigRequestHeader requestHeader =
......@@ -163,7 +166,8 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
return response;
}
public RemotingCommand deleteKVConfig(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
public RemotingCommand deleteKVConfig(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final DeleteKVConfigRequestHeader requestHeader =
(DeleteKVConfigRequestHeader) request.decodeCommandCustomHeader(DeleteKVConfigRequestHeader.class);
......@@ -215,7 +219,8 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
return response;
}
public RemotingCommand registerBroker(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
public RemotingCommand registerBroker(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(RegisterBrokerResponseHeader.class);
final RegisterBrokerResponseHeader responseHeader = (RegisterBrokerResponseHeader) response.readCustomHeader();
final RegisterBrokerRequestHeader requestHeader =
......@@ -251,7 +256,8 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
return response;
}
public RemotingCommand unregisterBroker(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
public RemotingCommand unregisterBroker(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final UnRegisterBrokerRequestHeader requestHeader =
(UnRegisterBrokerRequestHeader) request.decodeCommandCustomHeader(UnRegisterBrokerRequestHeader.class);
......@@ -267,7 +273,8 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
return response;
}
public RemotingCommand getRouteInfoByTopic(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
public RemotingCommand getRouteInfoByTopic(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetRouteInfoRequestHeader requestHeader =
(GetRouteInfoRequestHeader) request.decodeCommandCustomHeader(GetRouteInfoRequestHeader.class);
......@@ -306,7 +313,8 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand wipeWritePermOfBroker(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand wipeWritePermOfBroker(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(WipeWritePermOfBrokerResponseHeader.class);
final WipeWritePermOfBrokerResponseHeader responseHeader = (WipeWritePermOfBrokerResponseHeader) response.readCustomHeader();
final WipeWritePermOfBrokerRequestHeader requestHeader =
......@@ -336,7 +344,8 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand deleteTopicInNamesrv(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand deleteTopicInNamesrv(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final DeleteTopicInNamesrvRequestHeader requestHeader =
(DeleteTopicInNamesrvRequestHeader) request.decodeCommandCustomHeader(DeleteTopicInNamesrvRequestHeader.class);
......@@ -348,7 +357,8 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand getKVListByNamespace(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand getKVListByNamespace(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetKVListByNamespaceRequestHeader requestHeader =
(GetKVListByNamespaceRequestHeader) request.decodeCommandCustomHeader(GetKVListByNamespaceRequestHeader.class);
......@@ -367,7 +377,8 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand getTopicsByCluster(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand getTopicsByCluster(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetTopicsByClusterRequestHeader requestHeader =
(GetTopicsByClusterRequestHeader) request.decodeCommandCustomHeader(GetTopicsByClusterRequestHeader.class);
......@@ -380,7 +391,8 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand getSystemTopicListFromNs(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand getSystemTopicListFromNs(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
byte[] body = this.namesrvController.getRouteInfoManager().getSystemTopicList();
......@@ -391,7 +403,8 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand getUnitTopicList(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand getUnitTopicList(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
byte[] body = this.namesrvController.getRouteInfoManager().getUnitTopics();
......@@ -402,7 +415,8 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
return response;
}
private RemotingCommand getHasUnitSubTopicList(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
private RemotingCommand getHasUnitSubTopicList(ChannelHandlerContext ctx,
RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
byte[] body = this.namesrvController.getRouteInfoManager().getHasUnitSubTopicList();
......
......@@ -276,8 +276,8 @@ public class RouteInfoManager {
this.lock.writeLock().lockInterruptibly();
BrokerLiveInfo brokerLiveInfo = this.brokerLiveTable.remove(brokerAddr);
log.info("unregisterBroker, remove from brokerLiveTable {}, {}",
brokerLiveInfo != null ? "OK" : "Failed",
brokerAddr
brokerLiveInfo != null ? "OK" : "Failed",
brokerAddr
);
this.filterServerTable.remove(brokerAddr);
......
......@@ -99,7 +99,8 @@ public class ClusterTestRequestProcessorTest {
@Test
public void testGetRouteInfoByTopic() throws RemotingCommandException {
RemotingCommand request = RemotingCommand.createRequestCommand(12, new CommandCustomHeader() {
@Override public void checkFields() throws RemotingCommandException {
@Override
public void checkFields() throws RemotingCommandException {
}
});
......
......@@ -77,7 +77,7 @@ public class DefaultPromise<V> implements Promise<V> {
} else {
long waitTime = timeout - (System.currentTimeMillis() - createTime);
if (waitTime > 0) {
for (;; ) {
for (; ; ) {
try {
lock.wait(waitTime);
} catch (InterruptedException e) {
......
......@@ -75,7 +75,7 @@ public class LocalMessageCacheTest {
@Test
public void testSubmitConsumeRequest() throws Exception {
byte [] body = new byte[]{'1', '2', '3'};
byte[] body = new byte[] {'1', '2', '3'};
MessageExt consumedMsg = new MessageExt();
consumedMsg.setMsgId("NewMsgId");
consumedMsg.setBody(body);
......
......@@ -63,7 +63,7 @@ public abstract class ServiceThread implements Runnable {
this.thread.join(this.getJointime());
long eclipseTime = System.currentTimeMillis() - beginTime;
log.info("join thread " + this.getServiceName() + " eclipse time(ms) " + eclipseTime + " "
+ this.getJointime());
+ this.getJointime());
} catch (InterruptedException e) {
log.error("Interrupted", e);
}
......
......@@ -90,6 +90,7 @@ public abstract class NettyRemotingAbstract {
/**
* Constructor, specifying capacity of one-way and asynchronous semaphores.
*
* @param permitsOneway Number of permits for one-way requests.
* @param permitsAsync Number of permits for asynchronous requests.
*/
......@@ -100,12 +101,14 @@ public abstract class NettyRemotingAbstract {
/**
* Custom channel event listener.
*
* @return custom channel event listener if defined; null otherwise.
*/
public abstract ChannelEventListener getChannelEventListener();
/**
* Put a netty event to the executor.
*
* @param event Netty event instance.
*/
public void putNettyEvent(final NettyEvent event) {
......@@ -116,13 +119,14 @@ public abstract class NettyRemotingAbstract {
* Entry of incoming command processing.
*
* <p>
* <strong>Note:</strong>
* The incoming remoting command may be
* <ul>
* <li>An inquiry request from a remote peer component;</li>
* <li>A response to a previous request issued by this very participant.</li>
* </ul>
* <strong>Note:</strong>
* The incoming remoting command may be
* <ul>
* <li>An inquiry request from a remote peer component;</li>
* <li>A response to a previous request issued by this very participant.</li>
* </ul>
* </p>
*
* @param ctx Channel handler context.
* @param msg incoming remoting command.
* @throws Exception if there were any error while processing the incoming command.
......@@ -145,6 +149,7 @@ public abstract class NettyRemotingAbstract {
/**
* Process incoming request command issued by remote peer.
*
* @param ctx channel handler context.
* @param cmd request command.
*/
......@@ -235,6 +240,7 @@ public abstract class NettyRemotingAbstract {
/**
* Process response from remote peer to the previous issued requests.
*
* @param ctx channel handler context.
* @param cmd response command instance.
*/
......@@ -261,7 +267,6 @@ public abstract class NettyRemotingAbstract {
/**
* Execute callback in callback executor. If callback executor is null, run directly in current thread
* @param responseFuture
*/
private void executeInvokeCallback(final ResponseFuture responseFuture) {
boolean runInThisThread = false;
......@@ -297,12 +302,14 @@ public abstract class NettyRemotingAbstract {
/**
* Custom RPC hook.
*
* @return RPC hook if specified; null otherwise.
*/
public abstract RPCHook getRPCHook();
/**
* This method specifies thread pool to use while invoking callback methods.
*
* @return Dedicated thread pool instance if specified; or null if the callback is supposed to be executed in the
* netty event-loop thread.
*/
......@@ -310,7 +317,7 @@ public abstract class NettyRemotingAbstract {
/**
* <p>
* This method is periodically invoked to scan and expire deprecated request.
* This method is periodically invoked to scan and expire deprecated request.
* </p>
*/
public void scanResponseTable() {
......@@ -337,7 +344,8 @@ public abstract class NettyRemotingAbstract {
}
}
public RemotingCommand invokeSyncImpl(final Channel channel, final RemotingCommand request, final long timeoutMillis)
public RemotingCommand invokeSyncImpl(final Channel channel, final RemotingCommand request,
final long timeoutMillis)
throws InterruptedException, RemotingSendRequestException, RemotingTimeoutException {
final int opaque = request.getOpaque();
......
......@@ -322,7 +322,7 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
if (update) {
Collections.shuffle(addrs);
log.info("name server address updated. NEW : {} , OLD: {}",addrs,old);
log.info("name server address updated. NEW : {} , OLD: {}", addrs, old);
this.namesrvAddrList.set(addrs);
}
}
......
......@@ -78,7 +78,8 @@ public class NettyRemotingServer extends NettyRemotingAbstract implements Remoti
this(nettyServerConfig, null);
}
public NettyRemotingServer(final NettyServerConfig nettyServerConfig, final ChannelEventListener channelEventListener) {
public NettyRemotingServer(final NettyServerConfig nettyServerConfig,
final ChannelEventListener channelEventListener) {
super(nettyServerConfig.getServerOnewaySemaphoreValue(), nettyServerConfig.getServerAsyncSemaphoreValue());
this.serverBootstrap = new ServerBootstrap();
this.nettyServerConfig = nettyServerConfig;
......
......@@ -16,7 +16,6 @@
*/
package org.apache.rocketmq.remoting.netty;
public class NettyServerConfig implements Cloneable {
private int listenPort = 8888;
private int serverWorkerThreads = 8;
......
......@@ -29,7 +29,7 @@ public class RemotingCommandTest {
int source = 261;
SerializeType type = SerializeType.JSON;
byte[] result = RemotingCommand.markProtocolType(source, type);
assertThat(result).isEqualTo(new byte[]{0, 0, 1, 5});
assertThat(result).isEqualTo(new byte[] {0, 0, 1, 5});
}
@Test
......@@ -37,7 +37,7 @@ public class RemotingCommandTest {
int source = 16777215;
SerializeType type = SerializeType.ROCKETMQ;
byte[] result = RemotingCommand.markProtocolType(source, type);
assertThat(result).isEqualTo(new byte[]{1, -1, -1, -1});
assertThat(result).isEqualTo(new byte[] {1, -1, -1, -1});
}
@Test
......@@ -58,7 +58,7 @@ public class RemotingCommandTest {
int code = RemotingSysResponseCode.SUCCESS;
String remark = "Sample remark";
RemotingCommand cmd = RemotingCommand.createResponseCommand(code ,remark, SampleCommandCustomHeader.class);
RemotingCommand cmd = RemotingCommand.createResponseCommand(code, remark, SampleCommandCustomHeader.class);
assertThat(cmd.getCode()).isEqualTo(code);
assertThat(cmd.getVersion()).isEqualTo(2333);
assertThat(cmd.getRemark()).isEqualTo(remark);
......@@ -71,7 +71,7 @@ public class RemotingCommandTest {
int code = RemotingSysResponseCode.SUCCESS;
String remark = "Sample remark";
RemotingCommand cmd = RemotingCommand.createResponseCommand(code ,remark);
RemotingCommand cmd = RemotingCommand.createResponseCommand(code, remark);
assertThat(cmd.getCode()).isEqualTo(code);
assertThat(cmd.getVersion()).isEqualTo(2333);
assertThat(cmd.getRemark()).isEqualTo(remark);
......@@ -84,7 +84,7 @@ public class RemotingCommandTest {
int code = RemotingSysResponseCode.SUCCESS;
String remark = "Sample remark";
RemotingCommand cmd = RemotingCommand.createResponseCommand(code ,remark, CommandCustomHeader.class);
RemotingCommand cmd = RemotingCommand.createResponseCommand(code, remark, CommandCustomHeader.class);
assertThat(cmd).isNull();
}
......@@ -128,7 +128,7 @@ public class RemotingCommandTest {
int code = 103; //org.apache.rocketmq.common.protocol.RequestCode.REGISTER_BROKER
CommandCustomHeader header = new SampleCommandCustomHeader();
RemotingCommand cmd = RemotingCommand.createRequestCommand(code, header);
cmd.setBody(new byte[] { 0, 1, 2, 3, 4});
cmd.setBody(new byte[] {0, 1, 2, 3, 4});
ByteBuffer buffer = cmd.encode();
......@@ -141,7 +141,7 @@ public class RemotingCommandTest {
RemotingCommand decodedCommand = RemotingCommand.decode(buffer);
assertThat(decodedCommand.getSerializeTypeCurrentRPC()).isEqualTo(SerializeType.JSON);
assertThat(decodedCommand.getBody()).isEqualTo(new byte[]{ 0, 1, 2, 3, 4});
assertThat(decodedCommand.getBody()).isEqualTo(new byte[] {0, 1, 2, 3, 4});
}
@Test
......
......@@ -86,7 +86,7 @@ class Sample {
private String stringValue = "string";
private int intValue = 2333;
private Integer integerValue = 666;
private double[] doubleArray = new double[]{0.618, 1.618};
private double[] doubleArray = new double[] {0.618, 1.618};
private List<String> stringList = Arrays.asList("a", "o", "e", "i", "u", "v");
public String getStringValue() {
......@@ -136,7 +136,7 @@ class Sample {
if (o == null || getClass() != o.getClass())
return false;
Sample sample = (Sample)o;
Sample sample = (Sample) o;
if (intValue != sample.intValue)
return false;
......
......@@ -27,23 +27,17 @@ public interface AppendMessageCallback {
/**
* After message serialization, write MapedByteBuffer
*
* @param byteBuffer
* @param maxBlank
* @param msg
* @return How many bytes to write
*/
AppendMessageResult doAppend(final long fileFromOffset, final ByteBuffer byteBuffer,
final int maxBlank, final MessageExtBrokerInner msg);
final int maxBlank, final MessageExtBrokerInner msg);
/**
* After batched message serialization, write MapedByteBuffer
*
* @param byteBuffer
* @param maxBlank
* @param messageExtBatch, backed up by a byte array
*
* @return How many bytes to write
*/
AppendMessageResult doAppend(final long fileFromOffset, final ByteBuffer byteBuffer,
final int maxBlank, final MessageExtBatch messageExtBatch);
final int maxBlank, final MessageExtBatch messageExtBatch);
}
......@@ -62,6 +62,7 @@ public class CommitLog {
private volatile long beginTimeInLock = 0;
private final PutMessageLock putMessageLock;
public CommitLog(final DefaultMessageStore defaultMessageStore) {
this.mappedFileQueue = new MappedFileQueue(defaultMessageStore.getMessageStoreConfig().getStorePathCommitLog(),
defaultMessageStore.getMessageStoreConfig().getMapedFileSizeCommitLog(), defaultMessageStore.getAllocateMappedFileService());
......@@ -77,11 +78,12 @@ public class CommitLog {
this.appendMessageCallback = new DefaultAppendMessageCallback(defaultMessageStore.getMessageStoreConfig().getMaxMessageSize());
batchEncoderThreadLocal = new ThreadLocal<MessageExtBatchEncoder>() {
@Override protected MessageExtBatchEncoder initialValue() {
@Override
protected MessageExtBatchEncoder initialValue() {
return new MessageExtBatchEncoder(defaultMessageStore.getMessageStoreConfig().getMaxMessageSize());
}
};
this.putMessageLock = defaultMessageStore.getMessageStoreConfig().isUseReentrantLockWhenPutMessage() ? new PutMessageReentrantLock() : new PutMessageSpinLock();
this.putMessageLock = defaultMessageStore.getMessageStoreConfig().isUseReentrantLockWhenPutMessage() ? new PutMessageReentrantLock() : new PutMessageSpinLock();
}
......@@ -661,7 +663,7 @@ public class CommitLog {
if (messageExt.isWaitStoreMsgOK()) {
// Determine whether to wait
if (service.isSlaveOK(result.getWroteOffset() + result.getWroteBytes())) {
GroupCommitRequest request = new GroupCommitRequest(result.getWroteOffset() + result.getWroteBytes());
GroupCommitRequest request = new GroupCommitRequest(result.getWroteOffset() + result.getWroteBytes());
service.putRequest(request);
service.getWaitNotifyObject().wakeupAll();
boolean flushOK =
......@@ -758,7 +760,6 @@ public class CommitLog {
putMessageLock.unlock();
}
if (eclipseTimeInLock > 500) {
log.warn("[NOTIFYME]putMessages in lock cost time(ms)={}, bodyLength={} AppendMessageResult={}", eclipseTimeInLock, messageExtBatch.getBody().length, result);
}
......@@ -773,7 +774,6 @@ public class CommitLog {
storeStatsService.getSinglePutMessageTopicTimesTotal(messageExtBatch.getTopic()).addAndGet(result.getMsgNum());
storeStatsService.getSinglePutMessageTopicSizeTotal(messageExtBatch.getTopic()).addAndGet(result.getWroteBytes());
handleDiskFlush(result, putMessageResult, messageExtBatch);
handleHA(result, putMessageResult, messageExtBatch);
......@@ -885,8 +885,6 @@ public class CommitLog {
return diff;
}
abstract class FlushCommitLogService extends ServiceThread {
protected static final int RETRY_TIMES_OVER = 10;
}
......@@ -1030,23 +1028,19 @@ public class CommitLog {
private final CountDownLatch countDownLatch = new CountDownLatch(1);
private volatile boolean flushOK = false;
public GroupCommitRequest(long nextOffset) {
this.nextOffset = nextOffset;
}
public long getNextOffset() {
return nextOffset;
}
public void wakeupCustomer(final boolean flushOK) {
this.flushOK = flushOK;
this.countDownLatch.countDown();
}
public boolean waitForFlush(long timeout) {
try {
this.countDownLatch.await(timeout, TimeUnit.MILLISECONDS);
......@@ -1430,7 +1424,6 @@ public class CommitLog {
this.maxMessageSize = size;
}
public ByteBuffer encode(final MessageExtBatch messageExtBatch) {
msgBatchMemory.clear(); //not thread-safe
int totalMsgLen = 0;
......
......@@ -350,7 +350,7 @@ public class ConsumeQueue {
if (offsetPy >= phyMinOffset) {
this.minLogicOffset = result.getMappedFile().getFileFromOffset() + i;
log.info("Compute logical min offset: {}, topic: {}, queueId: {}",
this.getMinOffsetInQueue(), this.topic, this.queueId);
this.getMinOffsetInQueue(), this.topic, this.queueId);
// This maybe not take effect, when not every consume queue has extend file.
if (isExtAddr(tagsCode)) {
minExtAddr = tagsCode;
......@@ -567,9 +567,6 @@ public class ConsumeQueue {
/**
* Check {@code tagsCode} is address of extend file or tags code.
*
* @param tagsCode
* @return
*/
public boolean isExtAddr(long tagsCode) {
return isExtReadEnable() && this.consumeQueueExt.isExtAddr(tagsCode);
......
......@@ -58,17 +58,17 @@ public class ConsumeQueueExt {
/**
* Constructor.
*
* @param topic topic
* @param queueId id of queue
* @param storePath root dir of files to store.
* @param topic topic
* @param queueId id of queue
* @param storePath root dir of files to store.
* @param mappedFileSize file size
* @param bitMapLength bit map length.
* @param bitMapLength bit map length.
*/
public ConsumeQueueExt(final String topic,
final int queueId,
final String storePath,
final int mappedFileSize,
final int bitMapLength) {
final int queueId,
final String storePath,
final int mappedFileSize,
final int bitMapLength) {
this.storePath = storePath;
this.mappedFileSize = mappedFileSize;
......@@ -94,9 +94,6 @@ public class ConsumeQueueExt {
* <p>
* Just test {@code address} is less than 0.
* </p>
*
* @param address
* @return
*/
public boolean isExtAddr(final long address) {
return address <= MAX_ADDR;
......@@ -108,9 +105,6 @@ public class ConsumeQueueExt {
* if {@code address} is less than 0, return {@code address} - {@link java.lang.Long#MIN_VALUE};
* else, just return {@code address}
* </p>
*
* @param address
* @return
*/
public long unDecorate(final long address) {
if (isExtAddr(address)) {
......@@ -126,7 +120,6 @@ public class ConsumeQueueExt {
* else, just return {@code offset}
* </p>
*
* @param offset
* @return ext address(value is less than 0)
*/
public long decorate(final long offset) {
......@@ -140,7 +133,6 @@ public class ConsumeQueueExt {
* Get data from buffer.
*
* @param address less than 0
* @return
*/
public CqExtUnit get(final long address) {
CqExtUnit cqExtUnit = new CqExtUnit();
......@@ -154,9 +146,7 @@ public class ConsumeQueueExt {
/**
* Get data from buffer, and set to {@code cqExtUnit}
*
* @param address less than 0
* @param cqExtUnit
* @return
* @param address less than 0
*/
public boolean get(final long address, final CqExtUnit cqExtUnit) {
if (!isExtAddr(address)) {
......@@ -194,7 +184,6 @@ public class ConsumeQueueExt {
* Be careful, this method is not thread safe.
* </p>
*
* @param cqExtUnit
* @return success: < 0: fail: >=0
*/
public long put(final CqExtUnit cqExtUnit) {
......@@ -259,8 +248,6 @@ public class ConsumeQueueExt {
/**
* Load data from file when startup.
*
* @return
*/
public boolean load() {
boolean result = this.mappedFileQueue.load();
......@@ -379,9 +366,6 @@ public class ConsumeQueueExt {
/**
* flush buffer to file.
*
* @param flushLeastPages
* @return
*/
public boolean flush(final int flushLeastPages) {
return this.mappedFileQueue.flush(flushLeastPages);
......@@ -400,8 +384,6 @@ public class ConsumeQueueExt {
* <p>
* Be careful: it's an address just when invoking this method.
* </p>
*
* @return
*/
public long getMaxAddress() {
MappedFile mappedFile = this.mappedFileQueue.getLastMappedFile();
......@@ -413,8 +395,6 @@ public class ConsumeQueueExt {
/**
* Minus address saved in file.
*
* @return
*/
public long getMinAddress() {
MappedFile firstFile = this.mappedFileQueue.getFirstMappedFile();
......@@ -435,7 +415,8 @@ public class ConsumeQueueExt {
public static final int MAX_EXT_UNIT_SIZE = Short.MAX_VALUE;
public CqExtUnit() {}
public CqExtUnit() {
}
public CqExtUnit(Long tagsCode, long msgStoreTime, byte[] filterBitMap) {
this.tagsCode = tagsCode == null ? 0 : tagsCode;
......@@ -468,9 +449,6 @@ public class ConsumeQueueExt {
/**
* build unit from buffer from current position.
*
* @param buffer
* @return
*/
private boolean read(final ByteBuffer buffer) {
if (buffer.position() + 2 > buffer.limit()) {
......@@ -507,8 +485,6 @@ public class ConsumeQueueExt {
* <p>
* if size <= 0, nothing to do.
* </p>
*
* @param buffer
*/
private void readBySkip(final ByteBuffer buffer) {
ByteBuffer temp = buffer.slice();
......@@ -527,9 +503,6 @@ public class ConsumeQueueExt {
* <li>1. @{code container} can be null, it will be created if null.</li>
* <li>2. if capacity of @{code container} is less than unit size, it will be created also.</li>
* <li>3. Pls be sure that size of unit is not greater than {@link #MAX_EXT_UNIT_SIZE}</li>
*
* @param container
* @return
*/
private byte[] write(final ByteBuffer container) {
this.bitMapSize = (short) (filterBitMap == null ? 0 : filterBitMap.length);
......@@ -557,8 +530,6 @@ public class ConsumeQueueExt {
/**
* Calculate unit size by current data.
*
* @return
*/
private int calcUnitSize() {
int sizeTemp = MIN_EXT_UNIT_SIZE + (filterBitMap == null ? 0 : filterBitMap.length);
......@@ -600,16 +571,23 @@ public class ConsumeQueueExt {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof CqExtUnit)) return false;
if (this == o)
return true;
if (!(o instanceof CqExtUnit))
return false;
CqExtUnit cqExtUnit = (CqExtUnit) o;
if (bitMapSize != cqExtUnit.bitMapSize) return false;
if (msgStoreTime != cqExtUnit.msgStoreTime) return false;
if (size != cqExtUnit.size) return false;
if (tagsCode != cqExtUnit.tagsCode) return false;
if (!Arrays.equals(filterBitMap, cqExtUnit.filterBitMap)) return false;
if (bitMapSize != cqExtUnit.bitMapSize)
return false;
if (msgStoreTime != cqExtUnit.msgStoreTime)
return false;
if (size != cqExtUnit.size)
return false;
if (tagsCode != cqExtUnit.tagsCode)
return false;
if (!Arrays.equals(filterBitMap, cqExtUnit.filterBitMap))
return false;
return true;
}
......
......@@ -218,7 +218,6 @@ public class DefaultMessageStore implements MessageStore {
this.shutdown = false;
}
public void shutdown() {
if (!this.shutdown) {
this.shutdown = true;
......@@ -577,7 +576,6 @@ public class DefaultMessageStore implements MessageStore {
return getResult;
}
public long getMaxOffsetInQueue(String topic, int queueId) {
ConsumeQueue logic = this.findConsumeQueue(topic, queueId);
if (logic != null) {
......@@ -588,7 +586,6 @@ public class DefaultMessageStore implements MessageStore {
return 0;
}
public long getMinOffsetInQueue(String topic, int queueId) {
ConsumeQueue logic = this.findConsumeQueue(topic, queueId);
if (logic != null) {
......
......@@ -73,7 +73,8 @@ public class MappedFile extends ReferenceResource {
init(fileName, fileSize);
}
public MappedFile(final String fileName, final int fileSize, final TransientStorePool transientStorePool) throws IOException {
public MappedFile(final String fileName, final int fileSize,
final TransientStorePool transientStorePool) throws IOException {
init(fileName, fileSize, transientStorePool);
}
......@@ -142,7 +143,8 @@ public class MappedFile extends ReferenceResource {
return TOTAL_MAPPED_VIRTUAL_MEMORY.get();
}
public void init(final String fileName, final int fileSize, final TransientStorePool transientStorePool) throws IOException {
public void init(final String fileName, final int fileSize,
final TransientStorePool transientStorePool) throws IOException {
init(fileName, fileSize);
this.writeBuffer = transientStorePool.borrowBuffer();
this.transientStorePool = transientStorePool;
......@@ -209,7 +211,7 @@ public class MappedFile extends ReferenceResource {
if (messageExt instanceof MessageExtBrokerInner) {
result = cb.doAppend(this.getFileFromOffset(), byteBuffer, this.fileSize - currentPos, (MessageExtBrokerInner) messageExt);
} else if (messageExt instanceof MessageExtBatch) {
result = cb.doAppend(this.getFileFromOffset(), byteBuffer, this.fileSize - currentPos, (MessageExtBatch)messageExt);
result = cb.doAppend(this.getFileFromOffset(), byteBuffer, this.fileSize - currentPos, (MessageExtBatch) messageExt);
} else {
return new AppendMessageResult(AppendMessageStatus.UNKNOWN_ERROR);
}
......@@ -217,16 +219,14 @@ public class MappedFile extends ReferenceResource {
this.storeTimestamp = result.getStoreTimestamp();
return result;
}
log.error("MappedFile.appendMessage return null, wrotePosition: {} fileSize: {}", currentPos, this.fileSize);
log.error("MappedFile.appendMessage return null, wrotePosition: {} fileSize: {}", currentPos, this.fileSize);
return new AppendMessageResult(AppendMessageStatus.UNKNOWN_ERROR);
}
public long getFileFromOffset() {
return this.fileFromOffset;
}
public boolean appendMessage(final byte[] data) {
int currentPos = this.wrotePosition.get();
......@@ -247,10 +247,8 @@ public class MappedFile extends ReferenceResource {
/**
* Content of data from offset to offset + length will be wrote to file.
*
* @param data
* @param offset The offset of the subarray to be used.
* @param length The length of the subarray to be used.
* @return
*/
public boolean appendMessage(final byte[] data, final int offset, final int length) {
int currentPos = this.wrotePosition.get();
......@@ -270,7 +268,6 @@ public class MappedFile extends ReferenceResource {
}
/**
* @param flushLeastPages
* @return The current flushed position
*/
public int flush(final int flushLeastPages) {
......@@ -404,7 +401,6 @@ public class MappedFile extends ReferenceResource {
return null;
}
public SelectMappedBufferResult selectMappedBuffer(int pos) {
int readPosition = getReadPosition();
if (pos < readPosition && pos >= 0) {
......
......@@ -21,5 +21,5 @@ import java.util.Map;
public interface MessageArrivingListener {
void arriving(String topic, int queueId, long logicOffset, long tagsCode,
long msgStoreTime, byte[] filterBitMap, Map<String, String> properties);
long msgStoreTime, byte[] filterBitMap, Map<String, String> properties);
}
......@@ -24,22 +24,20 @@ public interface MessageFilter {
* match by tags code or filter bit map which is calculated when message received
* and stored in consume queue ext.
*
* @param tagsCode tagsCode
* @param cqExtUnit extend unit of consume queue
* @return
* @param tagsCode tagsCode
* @param cqExtUnit extend unit of consume queue
*/
boolean isMatchedByConsumeQueue(final Long tagsCode,
final ConsumeQueueExt.CqExtUnit cqExtUnit);
final ConsumeQueueExt.CqExtUnit cqExtUnit);
/**
* match by message content which are stored in commit log.
* <br>{@code msgBuffer} and {@code properties} are not all null.If invoked in store,
* {@code properties} is null;If invoked in {@code PullRequestHoldService}, {@code msgBuffer} is null.
*
* @param msgBuffer message buffer in commit log, may be null if not invoked in store.
* @param properties message properties, should decode from buffer if null by yourself.
* @return
* @param msgBuffer message buffer in commit log, may be null if not invoked in store.
* @param properties message properties, should decode from buffer if null by yourself.
*/
boolean isMatchedByCommitLog(final ByteBuffer msgBuffer,
final Map<String, String> properties);
final Map<String, String> properties);
}
......@@ -29,12 +29,14 @@ public interface MessageStore {
/**
* Load previously stored messages.
*
* @return true if success; false otherwise.
*/
boolean load();
/**
* Launch this message store.
*
* @throws Exception if there is any error.
*/
void start() throws Exception;
......@@ -51,6 +53,7 @@ public interface MessageStore {
/**
* Store a message into store.
*
* @param msg Message instance to store
* @return result of store operation.
*/
......@@ -58,6 +61,7 @@ public interface MessageStore {
/**
* Store a batch of messages.
*
* @param messageExtBatch Message batch.
* @return result of storing batch messages.
*/
......@@ -80,6 +84,7 @@ public interface MessageStore {
/**
* Get maximum offset of the topic queue.
*
* @param topic Topic name.
* @param queueId Queue ID.
* @return Maximum offset at present.
......@@ -88,6 +93,7 @@ public interface MessageStore {
/**
* Get the minimum offset of the topic queue.
*
* @param topic Topic name.
* @param queueId Queue ID.
* @return Minimum offset at present.
......@@ -96,6 +102,7 @@ public interface MessageStore {
/**
* Get the offset of the message in the commit log, which is also known as physical offset.
*
* @param topic Topic of the message to lookup.
* @param queueId Queue ID.
* @param consumeQueueOffset offset of consume queue.
......@@ -105,6 +112,7 @@ public interface MessageStore {
/**
* Look up the physical offset of the message whose store timestamp is as specified.
*
* @param topic Topic of the message.
* @param queueId Queue ID.
* @param timestamp Timestamp to look up.
......@@ -114,6 +122,7 @@ public interface MessageStore {
/**
* Look up the message by given commit log offset.
*
* @param commitLogOffset physical offset.
* @return Message whose physical offset is as specified.
*/
......@@ -121,6 +130,7 @@ public interface MessageStore {
/**
* Get one message from the specified commit log offset.
*
* @param commitLogOffset commit log offset.
* @return wrapped result of the message.
*/
......@@ -128,6 +138,7 @@ public interface MessageStore {
/**
* Get one message from the specified commit log offset.
*
* @param commitLogOffset commit log offset.
* @param msgSize message size.
* @return wrapped result of the message.
......@@ -136,30 +147,35 @@ public interface MessageStore {
/**
* Get the running information of this store.
*
* @return message store running info.
*/
String getRunningDataInfo();
/**
* Message store runtime information, which should generally contains various statistical information.
*
* @return runtime information of the message store in format of key-value pairs.
*/
HashMap<String, String> getRuntimeInfo();
/**
* Get the maximum commit log offset.
*
* @return maximum commit log offset.
*/
long getMaxPhyOffset();
/**
* Get the minimum commit log offset.
*
* @return minimum commit log offset.
*/
long getMinPhyOffset();
/**
* Get the store time of the earliest message in the given queue.
*
* @param topic Topic of the messages to query.
* @param queueId Queue ID to find.
* @return store time of the earliest message.
......@@ -168,12 +184,14 @@ public interface MessageStore {
/**
* Get the store time of the earliest message in this store.
*
* @return timestamp of the earliest message in this store.
*/
long getEarliestMessageTime();
/**
* Get the store time of the message specified.
*
* @param topic message topic.
* @param queueId queue ID.
* @param consumeQueueOffset consume queue offset.
......@@ -183,6 +201,7 @@ public interface MessageStore {
/**
* Get the total number of the messages in the specified queue.
*
* @param topic Topic
* @param queueId Queue ID.
* @return total number.
......@@ -191,6 +210,7 @@ public interface MessageStore {
/**
* Get the raw commit log data starting from the given offset, which should used for replication purpose.
*
* @param offset starting offset.
* @return commit log data.
*/
......@@ -198,6 +218,7 @@ public interface MessageStore {
/**
* Append data to commit log.
*
* @param startOffset starting offset.
* @param data data to append.
* @return true if success; false otherwise.
......@@ -211,36 +232,40 @@ public interface MessageStore {
/**
* Query messages by given key.
*
* @param topic topic of the message.
* @param key message key.
* @param maxNum maximum number of the messages possible.
* @param begin begin timestamp.
* @param end end timestamp.
* @return
*/
QueryMessageResult queryMessage(final String topic, final String key, final int maxNum, final long begin,
final long end);
/**
* Update HA master address.
*
* @param newAddr new address.
*/
void updateHaMasterAddress(final String newAddr);
/**
* Return how much the slave falls behind.
*
* @return number of bytes that slave falls behind.
*/
long slaveFallBehindMuch();
/**
* Return the current timestamp of the store.
*
* @return current time in milliseconds since 1970-01-01.
*/
long now();
/**
* Clean unused topics.
*
* @param topics all valid topics.
* @return number of the topics deleted.
*/
......@@ -253,6 +278,7 @@ public interface MessageStore {
/**
* Check if the given message has been swapped out of the memory.
*
* @param topic topic.
* @param queueId queue ID.
* @param consumeOffset consume queue offset.
......@@ -262,18 +288,21 @@ public interface MessageStore {
/**
* Get number of the bytes that have been stored in commit log and not yet dispatched to consume queue.
*
* @return number of the bytes to dispatch.
*/
long dispatchBehindBytes();
/**
* Flush the message store to persist all data.
*
* @return maximum offset flushed to persistent storage device.
*/
long flush();
/**
* Reset written offset.
*
* @param phyOffset new offset.
* @return true if success; false otherwise.
*/
......@@ -281,42 +310,49 @@ public interface MessageStore {
/**
* Get confirm offset.
*
* @return confirm offset.
*/
long getConfirmOffset();
/**
* Set confirm offset.
*
* @param phyOffset confirm offset to set.
*/
void setConfirmOffset(long phyOffset);
/**
* Check if the operation system page cache is busy or not.
*
* @return true if the OS page cache is busy; false otherwise.
*/
boolean isOSPageCacheBusy();
/**
* Get lock time in milliseconds of the store by far.
*
* @return lock time in milliseconds.
*/
long lockTimeMills();
/**
* Check if the transient store pool is deficient.
*
* @return true if the transient store pool is running out; false otherwise.
*/
boolean isTransientStorePoolDeficient();
/**
* Get the dispatcher list.
*
* @return list of the dispatcher.
*/
LinkedList<CommitLogDispatcher> getDispatcherList();
/**
* Get consume queue of the topic/queue.
*
* @param topic Topic.
* @param queueId Queue ID.
* @return Consume queue.
......
......@@ -21,5 +21,6 @@ package org.apache.rocketmq.store;
*/
public interface PutMessageLock {
void lock();
void unlock();
}
......@@ -16,7 +16,6 @@
*/
package org.apache.rocketmq.store;
import java.util.concurrent.locks.ReentrantLock;
/**
......
......@@ -16,12 +16,10 @@
*/
package org.apache.rocketmq.store;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* Spin lock Implementation to put message, suggest using this witb low race conditions
*
*/
public class PutMessageSpinLock implements PutMessageLock {
//true: Can lock, false : in lock.
......
......@@ -28,7 +28,6 @@ public class RunningFlags {
private static final int DISK_FULL_BIT = 1 << 4;
private volatile int flagBits = 0;
public RunningFlags() {
......
......@@ -143,7 +143,6 @@ public class MessageStoreConfig {
private int transientStorePoolSize = 5;
private boolean fastFailIfNoBufferInStorePool = false;
public boolean isDebugLockEnable() {
return debugLockEnable;
}
......@@ -605,7 +604,8 @@ public class MessageStoreConfig {
}
/**
* Enable transient commitLog store poll only if transientStorePoolEnable is true and the FlushDiskType is ASYNC_FLUSH
* Enable transient commitLog store poll only if transientStorePoolEnable is true and the FlushDiskType is
* ASYNC_FLUSH
*
* @return <tt>true</tt> or <tt>false</tt>
*/
......
......@@ -78,7 +78,6 @@ public class HAConnection {
return socketChannel;
}
class ReadSocketService extends ServiceThread {
private static final int READ_MAX_BUFFER_SIZE = 1024 * 1024;
private final Selector selector;
......@@ -191,7 +190,6 @@ public class HAConnection {
}
}
class WriteSocketService extends ServiceThread {
private final Selector selector;
private final SocketChannel socketChannel;
......@@ -327,7 +325,6 @@ public class HAConnection {
HAConnection.log.info(this.getServiceName() + " service end");
}
private boolean transferData() throws Exception {
int writeSizeZeroTimes = 0;
// Write Header
......
......@@ -85,7 +85,6 @@ public class HAService {
return result;
}
public void notifyTransferSome(final long offset) {
for (long value = this.push2SlaveMaxOffset.get(); offset > value; ) {
boolean ok = this.push2SlaveMaxOffset.compareAndSet(value, offset);
......@@ -180,7 +179,9 @@ public class HAService {
this.serverSocketChannel.register(this.selector, SelectionKey.OP_ACCEPT);
}
/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
@Override
public void shutdown(final boolean interrupt) {
super.shutdown(interrupt);
......@@ -192,7 +193,9 @@ public class HAService {
}
}
/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
@Override
public void run() {
log.info(this.getServiceName() + " service started");
......@@ -235,7 +238,9 @@ public class HAService {
log.info(this.getServiceName() + " service end");
}
/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
@Override
public String getServiceName() {
return AcceptSocketService.class.getSimpleName();
......
......@@ -209,7 +209,7 @@ public class IndexFile {
if (slotValue <= invalidIndex || slotValue > this.indexHeader.getIndexCount()
|| this.indexHeader.getIndexCount() <= 1) {
} else {
for (int nextIndexToRead = slotValue;;) {
for (int nextIndexToRead = slotValue; ; ) {
if (phyOffsets.size() >= maxNum) {
break;
}
......
......@@ -20,7 +20,6 @@ import java.nio.ByteBuffer;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
public class IndexHeader {
public static final int INDEX_HEADER_SIZE = 40;
private static int beginTimestampIndex = 0;
......
......@@ -35,7 +35,9 @@ import org.slf4j.LoggerFactory;
public class IndexService {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
/** Maximum times to attempt index file creation. */
/**
* Maximum times to attempt index file creation.
*/
private static final int MAX_TRY_IDX_CREATE = 3;
private final DefaultMessageStore defaultMessageStore;
private final int hashSlotNum;
......
......@@ -38,7 +38,6 @@ public class BrokerStats {
this.defaultMessageStore = defaultMessageStore;
}
public void record() {
this.msgPutTotalYesterdayMorning = this.msgPutTotalTodayMorning;
this.msgGetTotalYesterdayMorning = this.msgGetTotalTodayMorning;
......
......@@ -123,9 +123,11 @@ public class BrokerStatsManager {
public void incTopicPutNums(final String topic) {
this.statsTable.get(TOPIC_PUT_NUMS).addValue(topic, 1, 1);
}
public void incTopicPutNums(final String topic, int num, int times) {
this.statsTable.get(TOPIC_PUT_NUMS).addValue(topic, num, times);
}
public void incTopicPutSize(final String topic, final int size) {
this.statsTable.get(TOPIC_PUT_SIZE).addValue(topic, size, 1);
}
......@@ -156,9 +158,11 @@ public class BrokerStatsManager {
public void incBrokerPutNums() {
this.statsTable.get(BROKER_PUT_NUMS).getAndCreateStatsItem(this.clusterName).getValue().incrementAndGet();
}
public void incBrokerPutNums(final int incValue) {
this.statsTable.get(BROKER_PUT_NUMS).getAndCreateStatsItem(this.clusterName).getValue().addAndGet(incValue);
}
public void incBrokerGetNums(final int incValue) {
this.statsTable.get(BROKER_GET_NUMS).getAndCreateStatsItem(this.clusterName).getValue().addAndGet(incValue);
}
......@@ -173,12 +177,14 @@ public class BrokerStatsManager {
return this.statsTable.get(GROUP_GET_NUMS).getStatsDataInMinute(statsKey).getTps();
}
public void recordDiskFallBehindTime(final String group, final String topic, final int queueId, final long fallBehind) {
public void recordDiskFallBehindTime(final String group, final String topic, final int queueId,
final long fallBehind) {
final String statsKey = String.format("%d@%s@%s", queueId, topic, group);
this.momentStatsItemSetFallTime.getAndCreateStatsItem(statsKey).getValue().set(fallBehind);
}
public void recordDiskFallBehindSize(final String group, final String topic, final int queueId, final long fallBehind) {
public void recordDiskFallBehindSize(final String group, final String topic, final int queueId,
final long fallBehind) {
final String statsKey = String.format("%d@%s@%s", queueId, topic, group);
this.momentStatsItemSetFallSize.getAndCreateStatsItem(statsKey).getValue().set(fallBehind);
}
......
......@@ -6,18 +6,17 @@
* (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
* 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.
* 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;
import java.io.File;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
......@@ -39,7 +38,6 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class AppendCallbackTest {
AppendMessageCallback callback;
......@@ -47,7 +45,7 @@ public class AppendCallbackTest {
CommitLog.MessageExtBatchEncoder batchEncoder = new CommitLog.MessageExtBatchEncoder(10 * 1024 * 1024);
@Before
public void init() throws Exception{
public void init() throws Exception {
MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
messageStoreConfig.setMapedFileSizeCommitLog(1024 * 8);
messageStoreConfig.setMapedFileSizeConsumeQueue(1024 * 4);
......@@ -62,16 +60,15 @@ public class AppendCallbackTest {
}
@After
public void destroy(){
public void destroy() {
UtilAll.deleteFile(new File(System.getProperty("user.home") + File.separator + "unitteststore"));
}
@Test
public void testAppendMessageBatchEndOfFile() throws Exception{
List<Message> messages = new ArrayList<>();
public void testAppendMessageBatchEndOfFile() throws Exception {
List<Message> messages = new ArrayList<>();
String topic = "test-topic";
int queue= 0;
int queue = 0;
for (int i = 0; i < 10; i++) {
Message msg = new Message();
msg.setBody("body".getBytes());
......@@ -83,8 +80,8 @@ public class AppendCallbackTest {
messageExtBatch.setTopic(topic);
messageExtBatch.setQueueId(queue);
messageExtBatch.setBornTimestamp(System.currentTimeMillis());
messageExtBatch.setBornHost(new InetSocketAddress("127.0.0.1",123));
messageExtBatch.setStoreHost(new InetSocketAddress("127.0.0.1",124));
messageExtBatch.setBornHost(new InetSocketAddress("127.0.0.1", 123));
messageExtBatch.setStoreHost(new InetSocketAddress("127.0.0.1", 124));
messageExtBatch.setBody(MessageDecoder.encodeMessages(messages));
messageExtBatch.setEncodedBuff(batchEncoder.encode(messageExtBatch));
......@@ -99,11 +96,12 @@ public class AppendCallbackTest {
assertTrue(result.getMsgId().length() > 0); //should have already constructed some message ids
}
@Test
public void testAppendMessageBatchSucc() throws Exception {
List<Message> messages = new ArrayList<>();
List<Message> messages = new ArrayList<>();
String topic = "test-topic";
int queue= 0;
int queue = 0;
for (int i = 0; i < 10; i++) {
Message msg = new Message();
msg.setBody("body".getBytes());
......@@ -115,8 +113,8 @@ public class AppendCallbackTest {
messageExtBatch.setTopic(topic);
messageExtBatch.setQueueId(queue);
messageExtBatch.setBornTimestamp(System.currentTimeMillis());
messageExtBatch.setBornHost(new InetSocketAddress("127.0.0.1",123));
messageExtBatch.setStoreHost(new InetSocketAddress("127.0.0.1",124));
messageExtBatch.setBornHost(new InetSocketAddress("127.0.0.1", 123));
messageExtBatch.setStoreHost(new InetSocketAddress("127.0.0.1", 124));
messageExtBatch.setBody(MessageDecoder.encodeMessages(messages));
messageExtBatch.setEncodedBuff(batchEncoder.encode(messageExtBatch));
......@@ -131,7 +129,7 @@ public class AppendCallbackTest {
assertEquals(messages.size(), allresult.getMsgNum());
Set<String> msgIds = new HashSet<>();
for (String msgId: allresult.getMsgId().split(",")) {
for (String msgId : allresult.getMsgId().split(",")) {
assertEquals(32, msgId.length());
msgIds.add(msgId);
}
......
......@@ -36,7 +36,6 @@ public class ConsumeQueueExtTest {
private static final int cqExtFileSize = 10 * unitSizeWithBitMap;
private static final int unitCount = 20;
protected ConsumeQueueExt genExt() {
return new ConsumeQueueExt(
topic, queueId, storePath, cqExtFileSize, bitMapLength
......@@ -65,7 +64,7 @@ public class ConsumeQueueExtTest {
}
protected void putSth(ConsumeQueueExt consumeQueueExt, boolean getAfterPut,
boolean unitSameSize, int unitCount) {
boolean unitSameSize, int unitCount) {
for (int i = 0; i < unitCount; i++) {
ConsumeQueueExt.CqExtUnit putUnit =
unitSameSize ? genUnit(true) : genUnit(i % 2 == 0);
......@@ -236,7 +235,7 @@ public class ConsumeQueueExtTest {
}
@After
public void destroy(){
public void destroy() {
UtilAll.deleteFile(new File(storePath));
}
}
......@@ -83,9 +83,8 @@ public class ConsumeQueueTest {
return msg;
}
public MessageStoreConfig buildStoreConfig(int commitLogFileSize, int cqFileSize,
boolean enableCqExt, int cqExtFileSize) {
boolean enableCqExt, int cqExtFileSize) {
MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
messageStoreConfig.setMapedFileSizeCommitLog(commitLogFileSize);
messageStoreConfig.setMapedFileSizeConsumeQueue(cqFileSize);
......@@ -112,7 +111,7 @@ public class ConsumeQueueTest {
new MessageArrivingListener() {
@Override
public void arriving(String topic, int queueId, long logicOffset, long tagsCode,
long msgStoreTime, byte[] filterBitMap, Map<String, String> properties) {
long msgStoreTime, byte[] filterBitMap, Map<String, String> properties) {
}
}
, brokerConfig);
......
......@@ -56,7 +56,7 @@ public class DefaultMessageStoreTest {
File file = new File(messageStoreConfig.getStorePathRootDir());
UtilAll.deleteFile(file);
}
public MessageStore buildMessageStore() throws Exception {
MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
messageStoreConfig.setMapedFileSizeCommitLog(1024 * 1024 * 10);
......@@ -149,7 +149,6 @@ public class DefaultMessageStoreTest {
GetMessageResult getMessageResult32 = messageStore.getMessage(group, topic, 0, 0, 32, null);
assertThat(getMessageResult32.getMessageBufferList().size()).isEqualTo(32);
GetMessageResult getMessageResult20 = messageStore.getMessage(group, topic, 0, 0, 20, null);
assertThat(getMessageResult20.getMessageBufferList().size()).isEqualTo(20);
......
......@@ -24,6 +24,7 @@ import org.apache.rocketmq.test.listener.AbstractListener;
public class RMQSqlConsumer extends RMQNormalConsumer {
private static Logger logger = Logger.getLogger(RMQSqlConsumer.class);
private MessageSelector selector;
public RMQSqlConsumer(String nsAddr, String topic, MessageSelector selector,
String consumerGroup, AbstractListener listener) {
super(nsAddr, topic, "*", consumerGroup, listener);
......
......@@ -55,7 +55,8 @@ public class IntegrationTestBase {
static {
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override public void run() {
@Override
public void run() {
try {
for (BrokerController brokerController : BROKER_CONTROLLERS) {
if (brokerController != null) {
......@@ -78,7 +79,7 @@ public class IntegrationTestBase {
for (File file : TMPE_FILES) {
UtilAll.deleteFile(file);
}
} catch (Exception e){
} catch (Exception e) {
logger.error("Shutdown error", e);
}
}
......@@ -149,7 +150,7 @@ public class IntegrationTestBase {
return brokerController;
}
public static boolean initTopic(String topic, String nsAddr, String clusterName,int queueNumbers){
public static boolean initTopic(String topic, String nsAddr, String clusterName, int queueNumbers) {
long startTime = System.currentTimeMillis();
boolean createResult;
......@@ -159,7 +160,7 @@ public class IntegrationTestBase {
break;
} else if (System.currentTimeMillis() - startTime > topicCreateTime) {
Assert.fail(String.format("topic[%s] is created failed after:%d ms", topic,
System.currentTimeMillis() - startTime));
System.currentTimeMillis() - startTime));
break;
} else {
TestUtils.waitForMoment(500);
......@@ -171,7 +172,7 @@ public class IntegrationTestBase {
}
public static boolean initTopic(String topic, String nsAddr, String clusterName) {
return initTopic(topic, nsAddr, clusterName,8);
return initTopic(topic, nsAddr, clusterName, 8);
}
public static void deleteFile(File file) {
......@@ -188,5 +189,5 @@ public class IntegrationTestBase {
file.delete();
}
}
}
......@@ -62,7 +62,6 @@ public class OrderMsgBroadCastIT extends BaseBroadCastIT {
consumer1.getConsumerGroup(), topic, "*", new RMQOrderListener());
TestUtils.waitForSeconds(waitTime);
List<MessageQueue> mqs = producer.getMessageQueue();
MessageQueueMsg mqMsgs = new MessageQueueMsg(mqs, msgSize);
producer.send(mqMsgs.getMsgsWithMQ());
......
......@@ -67,7 +67,7 @@ public class SqlFilterIT extends BaseConf {
consumer.getListener().waitForMessageConsume(msgSize * 2, consumeTime);
assertThat(producer.getAllMsgBody())
.containsAllIn(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
consumer.getListener().getAllMsgBody()));
consumer.getListener().getAllMsgBody()));
assertThat(consumer.getListener().getAllMsgBody().size()).isEqualTo(msgSize * 2);
}
......
......@@ -77,7 +77,6 @@ public class BatchSendIT extends BaseConf {
}
}
@Test
public void testBatchSend_CheckProperties() throws Exception {
List<Message> messageList = new ArrayList<>();
......@@ -91,7 +90,6 @@ public class BatchSendIT extends BaseConf {
message.setBody("body".getBytes());
messageList.add(message);
DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr);
SendResult sendResult = producer.send(messageList);
Assert.assertEquals(SendStatus.SEND_OK, sendResult.getSendStatus());
......
......@@ -119,12 +119,14 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
}
@Override
public MessageExt viewMessage(String offsetMsgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
public MessageExt viewMessage(
String offsetMsgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
return defaultMQAdminExtImpl.viewMessage(offsetMsgId);
}
@Override
public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end) throws MQClientException,
public QueryResult queryMessage(String topic, String key, int maxNum, long begin,
long end) throws MQClientException,
InterruptedException {
return defaultMQAdminExtImpl.queryMessage(topic, key, maxNum, begin, end);
}
......@@ -140,7 +142,8 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
}
@Override
public void updateBrokerConfig(String brokerAddr, Properties properties) throws RemotingConnectException, RemotingSendRequestException,
public void updateBrokerConfig(String brokerAddr,
Properties properties) throws RemotingConnectException, RemotingSendRequestException,
RemotingTimeoutException, UnsupportedEncodingException, InterruptedException, MQBrokerException {
defaultMQAdminExtImpl.updateBrokerConfig(brokerAddr, properties);
}
......@@ -158,7 +161,8 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
}
@Override
public void createAndUpdateSubscriptionGroupConfig(String addr, SubscriptionGroupConfig config) throws RemotingException,
public void createAndUpdateSubscriptionGroupConfig(String addr,
SubscriptionGroupConfig config) throws RemotingException,
MQBrokerException, InterruptedException, MQClientException {
defaultMQAdminExtImpl.createAndUpdateSubscriptionGroupConfig(addr, config);
}
......@@ -174,7 +178,8 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
}
@Override
public TopicStatsTable examineTopicStats(String topic) throws RemotingException, MQClientException, InterruptedException,
public TopicStatsTable examineTopicStats(
String topic) throws RemotingException, MQClientException, InterruptedException,
MQBrokerException {
return defaultMQAdminExtImpl.examineTopicStats(topic);
}
......@@ -185,24 +190,28 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
}
@Override
public TopicList fetchTopicsByCLuster(String clusterName) throws RemotingException, MQClientException, InterruptedException {
public TopicList fetchTopicsByCLuster(
String clusterName) throws RemotingException, MQClientException, InterruptedException {
return this.defaultMQAdminExtImpl.fetchTopicsByCLuster(clusterName);
}
@Override
public KVTable fetchBrokerRuntimeStats(final String brokerAddr) throws RemotingConnectException, RemotingSendRequestException,
public KVTable fetchBrokerRuntimeStats(
final String brokerAddr) throws RemotingConnectException, RemotingSendRequestException,
RemotingTimeoutException, InterruptedException, MQBrokerException {
return this.defaultMQAdminExtImpl.fetchBrokerRuntimeStats(brokerAddr);
}
@Override
public ConsumeStats examineConsumeStats(String consumerGroup) throws RemotingException, MQClientException, InterruptedException,
public ConsumeStats examineConsumeStats(
String consumerGroup) throws RemotingException, MQClientException, InterruptedException,
MQBrokerException {
return examineConsumeStats(consumerGroup, null);
}
@Override
public ConsumeStats examineConsumeStats(String consumerGroup, String topic) throws RemotingException, MQClientException,
public ConsumeStats examineConsumeStats(String consumerGroup,
String topic) throws RemotingException, MQClientException,
InterruptedException, MQBrokerException {
return defaultMQAdminExtImpl.examineConsumeStats(consumerGroup, topic);
}
......@@ -214,18 +223,21 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
}
@Override
public TopicRouteData examineTopicRouteInfo(String topic) throws RemotingException, MQClientException, InterruptedException {
public TopicRouteData examineTopicRouteInfo(
String topic) throws RemotingException, MQClientException, InterruptedException {
return defaultMQAdminExtImpl.examineTopicRouteInfo(topic);
}
@Override
public ConsumerConnection examineConsumerConnectionInfo(String consumerGroup) throws InterruptedException, MQBrokerException,
public ConsumerConnection examineConsumerConnectionInfo(
String consumerGroup) throws InterruptedException, MQBrokerException,
RemotingException, MQClientException {
return defaultMQAdminExtImpl.examineConsumerConnectionInfo(consumerGroup);
}
@Override
public ProducerConnection examineProducerConnectionInfo(String producerGroup, final String topic) throws RemotingException,
public ProducerConnection examineProducerConnectionInfo(String producerGroup,
final String topic) throws RemotingException,
MQClientException, InterruptedException, MQBrokerException {
return defaultMQAdminExtImpl.examineProducerConnectionInfo(producerGroup, topic);
}
......@@ -247,46 +259,54 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
}
@Override
public String getKVConfig(String namespace, String key) throws RemotingException, MQClientException, InterruptedException {
public String getKVConfig(String namespace,
String key) throws RemotingException, MQClientException, InterruptedException {
return defaultMQAdminExtImpl.getKVConfig(namespace, key);
}
@Override
public KVTable getKVListByNamespace(String namespace) throws RemotingException, MQClientException, InterruptedException {
public KVTable getKVListByNamespace(
String namespace) throws RemotingException, MQClientException, InterruptedException {
return defaultMQAdminExtImpl.getKVListByNamespace(namespace);
}
@Override
public void deleteTopicInBroker(Set<String> addrs, String topic) throws RemotingException, MQBrokerException, InterruptedException,
public void deleteTopicInBroker(Set<String> addrs,
String topic) throws RemotingException, MQBrokerException, InterruptedException,
MQClientException {
defaultMQAdminExtImpl.deleteTopicInBroker(addrs, topic);
}
@Override
public void deleteTopicInNameServer(Set<String> addrs, String topic) throws RemotingException, MQBrokerException, InterruptedException,
public void deleteTopicInNameServer(Set<String> addrs,
String topic) throws RemotingException, MQBrokerException, InterruptedException,
MQClientException {
defaultMQAdminExtImpl.deleteTopicInNameServer(addrs, topic);
}
@Override
public void deleteSubscriptionGroup(String addr, String groupName) throws RemotingException, MQBrokerException, InterruptedException,
public void deleteSubscriptionGroup(String addr,
String groupName) throws RemotingException, MQBrokerException, InterruptedException,
MQClientException {
defaultMQAdminExtImpl.deleteSubscriptionGroup(addr, groupName);
}
@Override
public void createAndUpdateKvConfig(String namespace, String key, String value) throws RemotingException, MQBrokerException,
public void createAndUpdateKvConfig(String namespace, String key,
String value) throws RemotingException, MQBrokerException,
InterruptedException, MQClientException {
defaultMQAdminExtImpl.createAndUpdateKvConfig(namespace, key, value);
}
@Override
public void deleteKvConfig(String namespace, String key) throws RemotingException, MQBrokerException, InterruptedException,
public void deleteKvConfig(String namespace,
String key) throws RemotingException, MQBrokerException, InterruptedException,
MQClientException {
defaultMQAdminExtImpl.deleteKvConfig(namespace, key);
}
public List<RollbackStats> resetOffsetByTimestampOld(String consumerGroup, String topic, long timestamp, boolean force)
public List<RollbackStats> resetOffsetByTimestampOld(String consumerGroup, String topic, long timestamp,
boolean force)
throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
return defaultMQAdminExtImpl.resetOffsetByTimestampOld(consumerGroup, topic, timestamp, force);
}
......@@ -297,49 +317,57 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
return resetOffsetByTimestamp(topic, group, timestamp, isForce, false);
}
public Map<MessageQueue, Long> resetOffsetByTimestamp(String topic, String group, long timestamp, boolean isForce, boolean isC)
public Map<MessageQueue, Long> resetOffsetByTimestamp(String topic, String group, long timestamp, boolean isForce,
boolean isC)
throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
return defaultMQAdminExtImpl.resetOffsetByTimestamp(topic, group, timestamp, isForce, isC);
}
@Override
public void resetOffsetNew(String consumerGroup, String topic, long timestamp) throws RemotingException, MQBrokerException,
public void resetOffsetNew(String consumerGroup, String topic,
long timestamp) throws RemotingException, MQBrokerException,
InterruptedException, MQClientException {
this.defaultMQAdminExtImpl.resetOffsetNew(consumerGroup, topic, timestamp);
}
@Override
public Map<String, Map<MessageQueue, Long>> getConsumeStatus(String topic, String group, String clientAddr) throws RemotingException,
public Map<String, Map<MessageQueue, Long>> getConsumeStatus(String topic, String group,
String clientAddr) throws RemotingException,
MQBrokerException, InterruptedException, MQClientException {
return defaultMQAdminExtImpl.getConsumeStatus(topic, group, clientAddr);
}
@Override
public void createOrUpdateOrderConf(String key, String value, boolean isCluster) throws RemotingException, MQBrokerException,
public void createOrUpdateOrderConf(String key, String value,
boolean isCluster) throws RemotingException, MQBrokerException,
InterruptedException, MQClientException {
defaultMQAdminExtImpl.createOrUpdateOrderConf(key, value, isCluster);
}
@Override
public GroupList queryTopicConsumeByWho(String topic) throws InterruptedException, MQBrokerException, RemotingException,
public GroupList queryTopicConsumeByWho(
String topic) throws InterruptedException, MQBrokerException, RemotingException,
MQClientException {
return this.defaultMQAdminExtImpl.queryTopicConsumeByWho(topic);
}
@Override
public List<QueueTimeSpan> queryConsumeTimeSpan(final String topic, final String group) throws InterruptedException, MQBrokerException,
public List<QueueTimeSpan> queryConsumeTimeSpan(final String topic,
final String group) throws InterruptedException, MQBrokerException,
RemotingException, MQClientException {
return this.defaultMQAdminExtImpl.queryConsumeTimeSpan(topic, group);
}
@Override
public boolean cleanExpiredConsumerQueue(String cluster) throws RemotingConnectException, RemotingSendRequestException,
public boolean cleanExpiredConsumerQueue(
String cluster) throws RemotingConnectException, RemotingSendRequestException,
RemotingTimeoutException, MQClientException, InterruptedException {
return defaultMQAdminExtImpl.cleanExpiredConsumerQueue(cluster);
}
@Override
public boolean cleanExpiredConsumerQueueByAddr(String addr) throws RemotingConnectException, RemotingSendRequestException,
public boolean cleanExpiredConsumerQueueByAddr(
String addr) throws RemotingConnectException, RemotingSendRequestException,
RemotingTimeoutException, MQClientException, InterruptedException {
return defaultMQAdminExtImpl.cleanExpiredConsumerQueueByAddr(addr);
}
......@@ -357,7 +385,8 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
}
@Override
public ConsumerRunningInfo getConsumerRunningInfo(String consumerGroup, String clientId, boolean jstack) throws RemotingException,
public ConsumerRunningInfo getConsumerRunningInfo(String consumerGroup, String clientId,
boolean jstack) throws RemotingException,
MQClientException, InterruptedException {
return defaultMQAdminExtImpl.getConsumerRunningInfo(consumerGroup, clientId, jstack);
}
......@@ -369,25 +398,29 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
}
@Override
public ConsumeMessageDirectlyResult consumeMessageDirectly(final String consumerGroup, final String clientId, final String topic,
public ConsumeMessageDirectlyResult consumeMessageDirectly(final String consumerGroup, final String clientId,
final String topic,
final String msgId) throws RemotingException, MQClientException, InterruptedException, MQBrokerException {
return defaultMQAdminExtImpl.consumeMessageDirectly(consumerGroup, clientId, topic, msgId);
}
@Override
public List<MessageTrack> messageTrackDetail(MessageExt msg) throws RemotingException, MQClientException, InterruptedException,
public List<MessageTrack> messageTrackDetail(
MessageExt msg) throws RemotingException, MQClientException, InterruptedException,
MQBrokerException {
return this.defaultMQAdminExtImpl.messageTrackDetail(msg);
}
@Override
public void cloneGroupOffset(String srcGroup, String destGroup, String topic, boolean isOffline) throws RemotingException,
public void cloneGroupOffset(String srcGroup, String destGroup, String topic,
boolean isOffline) throws RemotingException,
MQClientException, InterruptedException, MQBrokerException {
this.defaultMQAdminExtImpl.cloneGroupOffset(srcGroup, destGroup, topic, isOffline);
}
@Override
public BrokerStatsData viewBrokerStatsData(String brokerAddr, String statsName, String statsKey) throws RemotingConnectException,
public BrokerStatsData viewBrokerStatsData(String brokerAddr, String statsName,
String statsKey) throws RemotingConnectException,
RemotingSendRequestException, RemotingTimeoutException, MQClientException, InterruptedException {
return this.defaultMQAdminExtImpl.viewBrokerStatsData(brokerAddr, statsName, statsKey);
}
......@@ -406,7 +439,8 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
}
@Override
public Set<String> getTopicClusterList(final String topic) throws InterruptedException, MQBrokerException, MQClientException, RemotingException {
public Set<String> getTopicClusterList(
final String topic) throws InterruptedException, MQBrokerException, MQClientException, RemotingException {
return this.defaultMQAdminExtImpl.getTopicClusterList(topic);
}
......@@ -472,7 +506,8 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
}
@Override
public QueryConsumeQueueResponseBody queryConsumeQueue(String brokerAddr, String topic, int queueId, long index, int count, String consumerGroup)
public QueryConsumeQueueResponseBody queryConsumeQueue(String brokerAddr, String topic, int queueId, long index,
int count, String consumerGroup)
throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException {
return this.defaultMQAdminExtImpl.queryConsumeQueue(
brokerAddr, topic, queueId, index, count, consumerGroup
......
......@@ -160,7 +160,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public void updateBrokerConfig(String brokerAddr, Properties properties) throws RemotingConnectException, RemotingSendRequestException,
public void updateBrokerConfig(String brokerAddr,
Properties properties) throws RemotingConnectException, RemotingSendRequestException,
RemotingTimeoutException, UnsupportedEncodingException, InterruptedException, MQBrokerException {
this.mqClientInstance.getMQClientAPIImpl().updateBrokerConfig(brokerAddr, properties, timeoutMillis);
}
......@@ -178,7 +179,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public void createAndUpdateSubscriptionGroupConfig(String addr, SubscriptionGroupConfig config) throws RemotingException,
public void createAndUpdateSubscriptionGroupConfig(String addr,
SubscriptionGroupConfig config) throws RemotingException,
MQBrokerException, InterruptedException, MQClientException {
this.mqClientInstance.getMQClientAPIImpl().createSubscriptionGroup(addr, config, timeoutMillis);
}
......@@ -194,7 +196,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public TopicStatsTable examineTopicStats(String topic) throws RemotingException, MQClientException, InterruptedException,
public TopicStatsTable examineTopicStats(
String topic) throws RemotingException, MQClientException, InterruptedException,
MQBrokerException {
TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic);
TopicStatsTable topicStatsTable = new TopicStatsTable();
......@@ -220,24 +223,28 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public TopicList fetchTopicsByCLuster(String clusterName) throws RemotingException, MQClientException, InterruptedException {
public TopicList fetchTopicsByCLuster(
String clusterName) throws RemotingException, MQClientException, InterruptedException {
return this.mqClientInstance.getMQClientAPIImpl().getTopicsByCluster(clusterName, timeoutMillis);
}
@Override
public KVTable fetchBrokerRuntimeStats(final String brokerAddr) throws RemotingConnectException, RemotingSendRequestException,
public KVTable fetchBrokerRuntimeStats(
final String brokerAddr) throws RemotingConnectException, RemotingSendRequestException,
RemotingTimeoutException, InterruptedException, MQBrokerException {
return this.mqClientInstance.getMQClientAPIImpl().getBrokerRuntimeInfo(brokerAddr, timeoutMillis);
}
@Override
public ConsumeStats examineConsumeStats(String consumerGroup) throws RemotingException, MQClientException, InterruptedException,
public ConsumeStats examineConsumeStats(
String consumerGroup) throws RemotingException, MQClientException, InterruptedException,
MQBrokerException {
return examineConsumeStats(consumerGroup, null);
}
@Override
public ConsumeStats examineConsumeStats(String consumerGroup, String topic) throws RemotingException, MQClientException,
public ConsumeStats examineConsumeStats(String consumerGroup,
String topic) throws RemotingException, MQClientException,
InterruptedException, MQBrokerException {
String retryTopic = MixAll.getRetryTopic(consumerGroup);
TopicRouteData topicRouteData = this.examineTopicRouteInfo(retryTopic);
......@@ -269,12 +276,14 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public TopicRouteData examineTopicRouteInfo(String topic) throws RemotingException, MQClientException, InterruptedException {
public TopicRouteData examineTopicRouteInfo(
String topic) throws RemotingException, MQClientException, InterruptedException {
return this.mqClientInstance.getMQClientAPIImpl().getTopicRouteInfoFromNameServer(topic, timeoutMillis);
}
@Override
public MessageExt viewMessage(String topic, String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
public MessageExt viewMessage(String topic,
String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
try {
MessageDecoder.decodeMessageId(msgId);
return this.viewMessage(msgId);
......@@ -285,7 +294,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public ConsumerConnection examineConsumerConnectionInfo(String consumerGroup) throws InterruptedException, MQBrokerException,
public ConsumerConnection examineConsumerConnectionInfo(
String consumerGroup) throws InterruptedException, MQBrokerException,
RemotingException, MQClientException {
ConsumerConnection result = new ConsumerConnection();
String topic = MixAll.getRetryTopic(consumerGroup);
......@@ -308,7 +318,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public ProducerConnection examineProducerConnectionInfo(String producerGroup, final String topic) throws RemotingException,
public ProducerConnection examineProducerConnectionInfo(String producerGroup,
final String topic) throws RemotingException,
MQClientException, InterruptedException, MQBrokerException {
ProducerConnection result = new ProducerConnection();
List<BrokerData> brokers = this.examineTopicRouteInfo(topic).getBrokerDatas();
......@@ -345,17 +356,20 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public String getKVConfig(String namespace, String key) throws RemotingException, MQClientException, InterruptedException {
public String getKVConfig(String namespace,
String key) throws RemotingException, MQClientException, InterruptedException {
return this.mqClientInstance.getMQClientAPIImpl().getKVConfigValue(namespace, key, timeoutMillis);
}
@Override
public KVTable getKVListByNamespace(String namespace) throws RemotingException, MQClientException, InterruptedException {
public KVTable getKVListByNamespace(
String namespace) throws RemotingException, MQClientException, InterruptedException {
return this.mqClientInstance.getMQClientAPIImpl().getKVListByNamespace(namespace, timeoutMillis);
}
@Override
public void deleteTopicInBroker(Set<String> addrs, String topic) throws RemotingException, MQBrokerException, InterruptedException,
public void deleteTopicInBroker(Set<String> addrs,
String topic) throws RemotingException, MQBrokerException, InterruptedException,
MQClientException {
for (String addr : addrs) {
this.mqClientInstance.getMQClientAPIImpl().deleteTopicInBroker(addr, topic, timeoutMillis);
......@@ -363,7 +377,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public void deleteTopicInNameServer(Set<String> addrs, String topic) throws RemotingException, MQBrokerException, InterruptedException,
public void deleteTopicInNameServer(Set<String> addrs,
String topic) throws RemotingException, MQBrokerException, InterruptedException,
MQClientException {
if (addrs == null) {
String ns = this.mqClientInstance.getMQClientAPIImpl().fetchNameServerAddr();
......@@ -375,25 +390,29 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public void deleteSubscriptionGroup(String addr, String groupName) throws RemotingException, MQBrokerException, InterruptedException,
public void deleteSubscriptionGroup(String addr,
String groupName) throws RemotingException, MQBrokerException, InterruptedException,
MQClientException {
this.mqClientInstance.getMQClientAPIImpl().deleteSubscriptionGroup(addr, groupName, timeoutMillis);
}
@Override
public void createAndUpdateKvConfig(String namespace, String key, String value) throws RemotingException, MQBrokerException,
public void createAndUpdateKvConfig(String namespace, String key,
String value) throws RemotingException, MQBrokerException,
InterruptedException, MQClientException {
this.mqClientInstance.getMQClientAPIImpl().putKVConfigValue(namespace, key, value, timeoutMillis);
}
@Override
public void deleteKvConfig(String namespace, String key) throws RemotingException, MQBrokerException, InterruptedException,
public void deleteKvConfig(String namespace,
String key) throws RemotingException, MQBrokerException, InterruptedException,
MQClientException {
this.mqClientInstance.getMQClientAPIImpl().deleteKVConfigValue(namespace, key, timeoutMillis);
}
@Override
public List<RollbackStats> resetOffsetByTimestampOld(String consumerGroup, String topic, long timestamp, boolean force)
public List<RollbackStats> resetOffsetByTimestampOld(String consumerGroup, String topic, long timestamp,
boolean force)
throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic);
List<RollbackStats> rollbackStatsList = new ArrayList<RollbackStats>();
......@@ -444,7 +463,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public void resetOffsetNew(String consumerGroup, String topic, long timestamp) throws RemotingException, MQBrokerException,
public void resetOffsetNew(String consumerGroup, String topic,
long timestamp) throws RemotingException, MQBrokerException,
InterruptedException, MQClientException {
try {
this.resetOffsetByTimestamp(topic, consumerGroup, timestamp, true);
......@@ -457,7 +477,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
}
public Map<MessageQueue, Long> resetOffsetByTimestamp(String topic, String group, long timestamp, boolean isForce, boolean isC)
public Map<MessageQueue, Long> resetOffsetByTimestamp(String topic, String group, long timestamp, boolean isForce,
boolean isC)
throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic);
List<BrokerData> brokerDatas = topicRouteData.getBrokerDatas();
......@@ -478,7 +499,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
return allOffsetTable;
}
private RollbackStats resetOffsetConsumeOffset(String brokerAddr, String consumeGroup, MessageQueue queue, OffsetWrapper offsetWrapper,
private RollbackStats resetOffsetConsumeOffset(String brokerAddr, String consumeGroup, MessageQueue queue,
OffsetWrapper offsetWrapper,
long timestamp, boolean force) throws RemotingException, InterruptedException, MQBrokerException {
long resetOffset;
if (timestamp == -1) {
......@@ -511,7 +533,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public Map<String, Map<MessageQueue, Long>> getConsumeStatus(String topic, String group, String clientAddr) throws RemotingException,
public Map<String, Map<MessageQueue, Long>> getConsumeStatus(String topic, String group,
String clientAddr) throws RemotingException,
MQBrokerException, InterruptedException, MQClientException {
TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic);
List<BrokerData> brokerDatas = topicRouteData.getBrokerDatas();
......@@ -525,7 +548,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
return Collections.EMPTY_MAP;
}
public void createOrUpdateOrderConf(String key, String value, boolean isCluster) throws RemotingException, MQBrokerException,
public void createOrUpdateOrderConf(String key, String value,
boolean isCluster) throws RemotingException, MQBrokerException,
InterruptedException, MQClientException {
if (isCluster) {
......@@ -564,7 +588,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public GroupList queryTopicConsumeByWho(String topic) throws InterruptedException, MQBrokerException, RemotingException,
public GroupList queryTopicConsumeByWho(
String topic) throws InterruptedException, MQBrokerException, RemotingException,
MQClientException {
TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic);
......@@ -581,7 +606,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public List<QueueTimeSpan> queryConsumeTimeSpan(final String topic, final String group) throws InterruptedException, MQBrokerException,
public List<QueueTimeSpan> queryConsumeTimeSpan(final String topic,
final String group) throws InterruptedException, MQBrokerException,
RemotingException, MQClientException {
List<QueueTimeSpan> spanSet = new ArrayList<QueueTimeSpan>();
TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic);
......@@ -595,7 +621,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public boolean cleanExpiredConsumerQueue(String cluster) throws RemotingConnectException, RemotingSendRequestException,
public boolean cleanExpiredConsumerQueue(
String cluster) throws RemotingConnectException, RemotingSendRequestException,
RemotingTimeoutException, MQClientException, InterruptedException {
boolean result = false;
try {
......@@ -614,7 +641,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
return result;
}
public boolean cleanExpiredConsumerQueueByCluster(ClusterInfo clusterInfo, String cluster) throws RemotingConnectException,
public boolean cleanExpiredConsumerQueueByCluster(ClusterInfo clusterInfo,
String cluster) throws RemotingConnectException,
RemotingSendRequestException, RemotingTimeoutException, MQClientException, InterruptedException {
boolean result = false;
String[] addrs = clusterInfo.retrieveAllAddrByCluster(cluster);
......@@ -625,7 +653,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public boolean cleanExpiredConsumerQueueByAddr(String addr) throws RemotingConnectException, RemotingSendRequestException,
public boolean cleanExpiredConsumerQueueByAddr(
String addr) throws RemotingConnectException, RemotingSendRequestException,
RemotingTimeoutException, MQClientException, InterruptedException {
boolean result = mqClientInstance.getMQClientAPIImpl().cleanExpiredConsumeQueue(addr, timeoutMillis);
log.warn("clean expired ConsumeQueue on target " + addr + " broker " + result);
......@@ -671,7 +700,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public ConsumerRunningInfo getConsumerRunningInfo(String consumerGroup, String clientId, boolean jstack) throws RemotingException,
public ConsumerRunningInfo getConsumerRunningInfo(String consumerGroup, String clientId,
boolean jstack) throws RemotingException,
MQClientException, InterruptedException {
String topic = MixAll.RETRY_GROUP_TOPIC_PREFIX + consumerGroup;
TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic);
......@@ -698,7 +728,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public ConsumeMessageDirectlyResult consumeMessageDirectly(final String consumerGroup, final String clientId, final String topic,
public ConsumeMessageDirectlyResult consumeMessageDirectly(final String consumerGroup, final String clientId,
final String topic,
final String msgId) throws RemotingException, MQClientException, InterruptedException, MQBrokerException {
MessageExt msg = this.viewMessage(topic, msgId);
if (msg.getProperty(MessageConst.PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX) == null) {
......@@ -712,7 +743,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public List<MessageTrack> messageTrackDetail(MessageExt msg) throws RemotingException, MQClientException, InterruptedException,
public List<MessageTrack> messageTrackDetail(
MessageExt msg) throws RemotingException, MQClientException, InterruptedException,
MQBrokerException {
List<MessageTrack> result = new ArrayList<MessageTrack>();
......@@ -794,7 +826,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
return result;
}
public boolean consumed(final MessageExt msg, final String group) throws RemotingException, MQClientException, InterruptedException,
public boolean consumed(final MessageExt msg,
final String group) throws RemotingException, MQClientException, InterruptedException,
MQBrokerException {
ConsumeStats cstats = this.examineConsumeStats(group);
......@@ -822,7 +855,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public void cloneGroupOffset(String srcGroup, String destGroup, String topic, boolean isOffline) throws RemotingException,
public void cloneGroupOffset(String srcGroup, String destGroup, String topic,
boolean isOffline) throws RemotingException,
MQClientException, InterruptedException, MQBrokerException {
String retryTopic = MixAll.getRetryTopic(srcGroup);
TopicRouteData topicRouteData = this.examineTopicRouteInfo(retryTopic);
......@@ -836,7 +870,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public BrokerStatsData viewBrokerStatsData(String brokerAddr, String statsName, String statsKey) throws RemotingConnectException,
public BrokerStatsData viewBrokerStatsData(String brokerAddr, String statsName,
String statsKey) throws RemotingConnectException,
RemotingSendRequestException, RemotingTimeoutException, MQClientException, InterruptedException {
return this.mqClientInstance.getMQClientAPIImpl().viewBrokerStatsData(brokerAddr, statsName, statsKey, timeoutMillis);
}
......@@ -855,7 +890,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public Set<String> getTopicClusterList(final String topic) throws InterruptedException, MQBrokerException, MQClientException,
public Set<String> getTopicClusterList(
final String topic) throws InterruptedException, MQBrokerException, MQClientException,
RemotingException {
Set<String> clusterSet = new HashSet<String>();
ClusterInfo clusterInfo = examineBrokerClusterInfo();
......@@ -873,13 +909,15 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public SubscriptionGroupWrapper getAllSubscriptionGroup(final String brokerAddr, long timeoutMillis) throws InterruptedException,
public SubscriptionGroupWrapper getAllSubscriptionGroup(final String brokerAddr,
long timeoutMillis) throws InterruptedException,
RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
return this.mqClientInstance.getMQClientAPIImpl().getAllSubscriptionGroup(brokerAddr, timeoutMillis);
}
@Override
public TopicConfigSerializeWrapper getAllTopicGroup(final String brokerAddr, long timeoutMillis) throws InterruptedException,
public TopicConfigSerializeWrapper getAllTopicGroup(final String brokerAddr,
long timeoutMillis) throws InterruptedException,
RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
return this.mqClientInstance.getMQClientAPIImpl().getAllTopicConfig(brokerAddr, timeoutMillis);
}
......@@ -915,12 +953,14 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public MessageExt viewMessage(String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
public MessageExt viewMessage(
String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
return this.mqClientInstance.getMQAdminImpl().viewMessage(msgId);
}
@Override
public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end) throws MQClientException,
public QueryResult queryMessage(String topic, String key, int maxNum, long begin,
long end) throws MQClientException,
InterruptedException {
return this.mqClientInstance.getMQAdminImpl().queryMessage(topic, key, maxNum, begin, end);
}
......@@ -953,7 +993,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public QueryConsumeQueueResponseBody queryConsumeQueue(String brokerAddr, String topic, int queueId, long index, int count, String consumerGroup)
public QueryConsumeQueueResponseBody queryConsumeQueue(String brokerAddr, String topic, int queueId, long index,
int count, String consumerGroup)
throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException {
return this.mqClientInstance.getMQClientAPIImpl().queryConsumeQueue(
brokerAddr, topic, queueId, index, count, consumerGroup, timeoutMillis
......
......@@ -64,42 +64,51 @@ public interface MQAdminExt extends MQAdmin {
Properties getBrokerConfig(final String brokerAddr) throws RemotingConnectException,
RemotingSendRequestException, RemotingTimeoutException, UnsupportedEncodingException, InterruptedException, MQBrokerException;
void createAndUpdateTopicConfig(final String addr, final TopicConfig config) throws RemotingException, MQBrokerException,
void createAndUpdateTopicConfig(final String addr,
final TopicConfig config) throws RemotingException, MQBrokerException,
InterruptedException, MQClientException;
void createAndUpdateSubscriptionGroupConfig(final String addr, final SubscriptionGroupConfig config) throws RemotingException,
void createAndUpdateSubscriptionGroupConfig(final String addr,
final SubscriptionGroupConfig config) throws RemotingException,
MQBrokerException, InterruptedException, MQClientException;
SubscriptionGroupConfig examineSubscriptionGroupConfig(final String addr, final String group);
TopicConfig examineTopicConfig(final String addr, final String topic);
TopicStatsTable examineTopicStats(final String topic) throws RemotingException, MQClientException, InterruptedException,
TopicStatsTable examineTopicStats(
final String topic) throws RemotingException, MQClientException, InterruptedException,
MQBrokerException;
TopicList fetchAllTopicList() throws RemotingException, MQClientException, InterruptedException;
TopicList fetchTopicsByCLuster(String clusterName) throws RemotingException, MQClientException, InterruptedException;
TopicList fetchTopicsByCLuster(
String clusterName) throws RemotingException, MQClientException, InterruptedException;
KVTable fetchBrokerRuntimeStats(final String brokerAddr) throws RemotingConnectException, RemotingSendRequestException,
KVTable fetchBrokerRuntimeStats(
final String brokerAddr) throws RemotingConnectException, RemotingSendRequestException,
RemotingTimeoutException, InterruptedException, MQBrokerException;
ConsumeStats examineConsumeStats(final String consumerGroup) throws RemotingException, MQClientException, InterruptedException,
ConsumeStats examineConsumeStats(
final String consumerGroup) throws RemotingException, MQClientException, InterruptedException,
MQBrokerException;
ConsumeStats examineConsumeStats(final String consumerGroup, final String topic) throws RemotingException, MQClientException,
ConsumeStats examineConsumeStats(final String consumerGroup,
final String topic) throws RemotingException, MQClientException,
InterruptedException, MQBrokerException;
ClusterInfo examineBrokerClusterInfo() throws InterruptedException, MQBrokerException, RemotingTimeoutException,
RemotingSendRequestException, RemotingConnectException;
TopicRouteData examineTopicRouteInfo(final String topic) throws RemotingException, MQClientException, InterruptedException;
TopicRouteData examineTopicRouteInfo(
final String topic) throws RemotingException, MQClientException, InterruptedException;
ConsumerConnection examineConsumerConnectionInfo(final String consumerGroup) throws RemotingConnectException,
RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException, RemotingException,
MQClientException;
ProducerConnection examineProducerConnectionInfo(final String producerGroup, final String topic) throws RemotingException,
ProducerConnection examineProducerConnectionInfo(final String producerGroup,
final String topic) throws RemotingException,
MQClientException, InterruptedException, MQBrokerException;
List<String> getNameServerAddressList();
......@@ -109,20 +118,24 @@ public interface MQAdminExt extends MQAdmin {
void putKVConfig(final String namespace, final String key, final String value);
String getKVConfig(final String namespace, final String key) throws RemotingException, MQClientException, InterruptedException;
String getKVConfig(final String namespace,
final String key) throws RemotingException, MQClientException, InterruptedException;
KVTable getKVListByNamespace(final String namespace) throws RemotingException, MQClientException, InterruptedException;
KVTable getKVListByNamespace(
final String namespace) throws RemotingException, MQClientException, InterruptedException;
void deleteTopicInBroker(final Set<String> addrs, final String topic) throws RemotingException, MQBrokerException,
InterruptedException, MQClientException;
void deleteTopicInNameServer(final Set<String> addrs, final String topic) throws RemotingException, MQBrokerException,
void deleteTopicInNameServer(final Set<String> addrs,
final String topic) throws RemotingException, MQBrokerException,
InterruptedException, MQClientException;
void deleteSubscriptionGroup(final String addr, String groupName) throws RemotingException, MQBrokerException,
InterruptedException, MQClientException;
void createAndUpdateKvConfig(String namespace, String key, String value) throws RemotingException, MQBrokerException,
void createAndUpdateKvConfig(String namespace, String key,
String value) throws RemotingException, MQBrokerException,
InterruptedException, MQClientException;
void deleteKvConfig(String namespace, String key) throws RemotingException, MQBrokerException, InterruptedException,
......@@ -137,16 +150,19 @@ public interface MQAdminExt extends MQAdmin {
void resetOffsetNew(String consumerGroup, String topic, long timestamp) throws RemotingException, MQBrokerException,
InterruptedException, MQClientException;
Map<String, Map<MessageQueue, Long>> getConsumeStatus(String topic, String group, String clientAddr) throws RemotingException,
Map<String, Map<MessageQueue, Long>> getConsumeStatus(String topic, String group,
String clientAddr) throws RemotingException,
MQBrokerException, InterruptedException, MQClientException;
void createOrUpdateOrderConf(String key, String value, boolean isCluster) throws RemotingException, MQBrokerException,
void createOrUpdateOrderConf(String key, String value,
boolean isCluster) throws RemotingException, MQBrokerException,
InterruptedException, MQClientException;
GroupList queryTopicConsumeByWho(final String topic) throws RemotingConnectException, RemotingSendRequestException,
RemotingTimeoutException, InterruptedException, MQBrokerException, RemotingException, MQClientException;
List<QueueTimeSpan> queryConsumeTimeSpan(final String topic, final String group) throws InterruptedException, MQBrokerException,
List<QueueTimeSpan> queryConsumeTimeSpan(final String topic,
final String group) throws InterruptedException, MQBrokerException,
RemotingException, MQClientException;
boolean cleanExpiredConsumerQueue(String cluster) throws RemotingConnectException, RemotingSendRequestException,
......@@ -173,7 +189,8 @@ public interface MQAdminExt extends MQAdmin {
String topic,
String msgId) throws RemotingException, MQClientException, InterruptedException, MQBrokerException;
List<MessageTrack> messageTrackDetail(MessageExt msg) throws RemotingException, MQClientException, InterruptedException,
List<MessageTrack> messageTrackDetail(
MessageExt msg) throws RemotingException, MQClientException, InterruptedException,
MQBrokerException;
void cloneGroupOffset(String srcGroup, String destGroup, String topic, boolean isOffline) throws RemotingException,
......@@ -190,7 +207,8 @@ public interface MQAdminExt extends MQAdmin {
long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException,
RemotingTimeoutException, MQClientException, InterruptedException;
Set<String> getTopicClusterList(final String topic) throws InterruptedException, MQBrokerException, MQClientException, RemotingException;
Set<String> getTopicClusterList(
final String topic) throws InterruptedException, MQBrokerException, MQClientException, RemotingException;
SubscriptionGroupWrapper getAllSubscriptionGroup(final String brokerAddr,
long timeoutMillis) throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException,
......@@ -209,18 +227,9 @@ public interface MQAdminExt extends MQAdmin {
* Command Code : RequestCode.UPDATE_NAMESRV_CONFIG
*
* <br> If param(nameServers) is null or empty, will use name servers from ns!
*
* @param properties
* @param nameServers
* @throws InterruptedException
* @throws RemotingConnectException
* @throws UnsupportedEncodingException
* @throws RemotingSendRequestException
* @throws RemotingTimeoutException
* @throws MQClientException
* @throws MQBrokerException
*/
void updateNameServerConfig(final Properties properties, final List<String> nameServers) throws InterruptedException, RemotingConnectException,
void updateNameServerConfig(final Properties properties,
final List<String> nameServers) throws InterruptedException, RemotingConnectException,
UnsupportedEncodingException, RemotingSendRequestException, RemotingTimeoutException,
MQClientException, MQBrokerException;
......@@ -230,14 +239,7 @@ public interface MQAdminExt extends MQAdmin {
* Command Code : RequestCode.GET_NAMESRV_CONFIG
* <br> If param(nameServers) is null or empty, will use name servers from ns!
*
* @param nameServers
* @return The fetched name server config
* @throws InterruptedException
* @throws RemotingTimeoutException
* @throws RemotingSendRequestException
* @throws RemotingConnectException
* @throws MQClientException
* @throws UnsupportedEncodingException
*/
Map<String, Properties> getNameServerConfig(final List<String> nameServers) throws InterruptedException,
RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException,
......@@ -252,15 +254,9 @@ public interface MQAdminExt extends MQAdmin {
* @param index start offset
* @param count how many
* @param consumerGroup group
* @return
* @throws InterruptedException
* @throws RemotingTimeoutException
* @throws RemotingSendRequestException
* @throws RemotingConnectException
* @throws MQClientException
*/
QueryConsumeQueueResponseBody queryConsumeQueue(final String brokerAddr,
final String topic, final int queueId,
final long index, final int count, final String consumerGroup)
final String topic, final int queueId,
final long index, final int count, final String consumerGroup)
throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException;
}
......@@ -60,7 +60,8 @@ public class GetBrokerConfigCommand implements SubCommand {
}
@Override
public void execute(final CommandLine commandLine, final Options options, final RPCHook rpcHook) throws SubCommandException {
public void execute(final CommandLine commandLine, final Options options,
final RPCHook rpcHook) throws SubCommandException {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
......
......@@ -61,7 +61,8 @@ public class ClusterListSubCommand implements SubCommand {
}
@Override
public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) throws SubCommandException {
public void execute(final CommandLine commandLine, final Options options,
RPCHook rpcHook) throws SubCommandException {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
......@@ -164,7 +165,8 @@ public class ClusterListSubCommand implements SubCommand {
}
}
private void printClusterBaseInfo(final DefaultMQAdminExt defaultMQAdminExt) throws RemotingConnectException, RemotingTimeoutException,
private void printClusterBaseInfo(
final DefaultMQAdminExt defaultMQAdminExt) throws RemotingConnectException, RemotingTimeoutException,
RemotingSendRequestException, InterruptedException, MQBrokerException {
ClusterInfo clusterInfoSerializeWrapper = defaultMQAdminExt.examineBrokerClusterInfo();
......@@ -253,16 +255,16 @@ public class ClusterListSubCommand implements SubCommand {
}
System.out.printf("%-16s %-22s %-4s %-22s %-16s %19s %19s %10s %5s %6s%n",
clusterName,
brokerName,
next1.getKey(),
next1.getValue(),
version,
String.format("%9.2f(%s,%sms)", in, sendThreadPoolQueueSize, sendThreadPoolQueueHeadWaitTimeMills),
String.format("%9.2f(%s,%sms)", out, pullThreadPoolQueueSize, pullThreadPoolQueueHeadWaitTimeMills),
pageCacheLockTimeMills,
String.format("%2.2f", hour),
String.format("%.4f", space)
clusterName,
brokerName,
next1.getKey(),
next1.getValue(),
version,
String.format("%9.2f(%s,%sms)", in, sendThreadPoolQueueSize, sendThreadPoolQueueHeadWaitTimeMills),
String.format("%9.2f(%s,%sms)", out, pullThreadPoolQueueSize, pullThreadPoolQueueHeadWaitTimeMills),
pageCacheLockTimeMills,
String.format("%2.2f", hour),
String.format("%.4f", space)
);
}
}
......
......@@ -90,7 +90,8 @@ public class UpdateSubGroupSubCommand implements SubCommand {
}
@Override
public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) throws SubCommandException {
public void execute(final CommandLine commandLine, final Options options,
RPCHook rpcHook) throws SubCommandException {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
......
......@@ -45,7 +45,8 @@ public class DecodeMessageIdCommond implements SubCommand {
}
@Override
public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) throws SubCommandException {
public void execute(final CommandLine commandLine, final Options options,
RPCHook rpcHook) throws SubCommandException {
String messageId = commandLine.getOptionValue('i').trim();
try {
......
......@@ -52,7 +52,8 @@ public class PrintMessageByQueueCommand implements SubCommand {
return timestamp;
}
private static void calculateByTag(final List<MessageExt> msgs, final Map<String, AtomicLong> tagCalmap, final boolean calByTag) {
private static void calculateByTag(final List<MessageExt> msgs, final Map<String, AtomicLong> tagCalmap,
final boolean calByTag) {
if (!calByTag)
return;
......@@ -85,7 +86,8 @@ public class PrintMessageByQueueCommand implements SubCommand {
}
}
public static void printMessage(final List<MessageExt> msgs, final String charsetName, boolean printMsg, boolean printBody) {
public static void printMessage(final List<MessageExt> msgs, final String charsetName, boolean printMsg,
boolean printBody) {
if (!printMsg)
return;
......@@ -162,11 +164,11 @@ public class PrintMessageByQueueCommand implements SubCommand {
String charsetName =
!commandLine.hasOption('c') ? "UTF-8" : commandLine.getOptionValue('c').trim();
boolean printMsg =
commandLine.hasOption('p') && Boolean.parseBoolean(commandLine.getOptionValue('p').trim());
commandLine.hasOption('p') && Boolean.parseBoolean(commandLine.getOptionValue('p').trim());
boolean printBody =
commandLine.hasOption('d') && Boolean.parseBoolean(commandLine.getOptionValue('d').trim());
commandLine.hasOption('d') && Boolean.parseBoolean(commandLine.getOptionValue('d').trim());
boolean calByTag =
commandLine.hasOption('f') && Boolean.parseBoolean(commandLine.getOptionValue('f').trim());
commandLine.hasOption('f') && Boolean.parseBoolean(commandLine.getOptionValue('f').trim());
String subExpression =
!commandLine.hasOption('s') ? "*" : commandLine.getOptionValue('s').trim();
......
......@@ -262,7 +262,8 @@ public class QueryMsgByIdSubCommand implements SubCommand {
}
}
private void pushMsg(final DefaultMQAdminExt defaultMQAdminExt, final String consumerGroup, final String clientId, final String msgId) {
private void pushMsg(final DefaultMQAdminExt defaultMQAdminExt, final String consumerGroup, final String clientId,
final String msgId) {
try {
ConsumeMessageDirectlyResult result =
defaultMQAdminExt.consumeMessageDirectly(consumerGroup, clientId, msgId);
......
......@@ -39,7 +39,8 @@ import org.apache.rocketmq.tools.command.SubCommandException;
public class QueryMsgByUniqueKeySubCommand implements SubCommand {
public static void queryById(final DefaultMQAdminExt admin, final String topic, final String msgId) throws MQClientException,
public static void queryById(final DefaultMQAdminExt admin, final String topic,
final String msgId) throws MQClientException,
RemotingException, MQBrokerException, InterruptedException, IOException {
MessageExt msg = admin.viewMessage(topic, msgId);
......
......@@ -46,7 +46,8 @@ public class GetNamesrvConfigCommand implements SubCommand {
}
@Override
public void execute(final CommandLine commandLine, final Options options, final RPCHook rpcHook) throws SubCommandException {
public void execute(final CommandLine commandLine, final Options options,
final RPCHook rpcHook) throws SubCommandException {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
try {
......
......@@ -53,7 +53,8 @@ public class UpdateNamesrvConfigCommand implements SubCommand {
}
@Override
public void execute(final CommandLine commandLine, final Options options, final RPCHook rpcHook) throws SubCommandException {
public void execute(final CommandLine commandLine, final Options options,
final RPCHook rpcHook) throws SubCommandException {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
try {
......
......@@ -36,7 +36,7 @@ public class QueryConsumeQueueCommand implements SubCommand {
QueryConsumeQueueCommand cmd = new QueryConsumeQueueCommand();
Options options = ServerUtil.buildCommandlineOptions(new Options());
String[] subargs = new String[]{"-t TopicTest", "-q 0", "-i 6447", "-b 100.81.165.119:10911"};
String[] subargs = new String[] {"-t TopicTest", "-q 0", "-i 6447", "-b 100.81.165.119:10911"};
final CommandLine commandLine =
ServerUtil.parseCmdLine("mqadmin " + cmd.commandName(), subargs, cmd.buildCommandlineOptions(options),
new PosixParser());
......
......@@ -46,7 +46,8 @@ public class TopicClusterSubCommand implements SubCommand {
}
@Override
public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) throws SubCommandException {
public void execute(final CommandLine commandLine, final Options options,
RPCHook rpcHook) throws SubCommandException {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
String topic = commandLine.getOptionValue('t').trim();
......
......@@ -57,7 +57,8 @@ public class TopicListSubCommand implements SubCommand {
}
@Override
public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) throws SubCommandException {
public void execute(final CommandLine commandLine, final Options options,
RPCHook rpcHook) throws SubCommandException {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
......
......@@ -47,7 +47,8 @@ public class TopicRouteSubCommand implements SubCommand {
}
@Override
public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) throws SubCommandException {
public void execute(final CommandLine commandLine, final Options options,
RPCHook rpcHook) throws SubCommandException {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
......
......@@ -52,7 +52,8 @@ public class TopicStatusSubCommand implements SubCommand {
}
@Override
public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) throws SubCommandException {
public void execute(final CommandLine commandLine, final Options options,
RPCHook rpcHook) throws SubCommandException {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
......
......@@ -57,7 +57,8 @@ public class UpdateOrderConfCommand implements SubCommand {
}
@Override
public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) throws SubCommandException {
public void execute(final CommandLine commandLine, final Options options,
RPCHook rpcHook) throws SubCommandException {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
......
......@@ -65,7 +65,8 @@ public class UpdateTopicPermSubCommand implements SubCommand {
}
@Override
public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) throws SubCommandException {
public void execute(final CommandLine commandLine, final Options options,
RPCHook rpcHook) throws SubCommandException {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
try {
......
......@@ -83,7 +83,8 @@ public class UpdateTopicSubCommand implements SubCommand {
}
@Override
public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) throws SubCommandException {
public void execute(final CommandLine commandLine, final Options options,
RPCHook rpcHook) throws SubCommandException {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
......
......@@ -81,7 +81,7 @@ public class GetNamesrvConfigCommandTest {
defaultMQAdminExt.shutdown();
}
// @Ignore
// @Ignore
@Test
public void testExecute() throws SubCommandException {
GetNamesrvConfigCommand cmd = new GetNamesrvConfigCommand();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册