├── .gitignore ├── README.md ├── broker ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── apache │ │ │ └── rocketmq │ │ │ └── broker │ │ │ ├── BrokerController.java │ │ │ ├── BrokerPathConfigHelper.java │ │ │ ├── BrokerStartup.java │ │ │ ├── client │ │ │ ├── ClientChannelInfo.java │ │ │ ├── ClientHousekeepingService.java │ │ │ ├── ConsumerGroupEvent.java │ │ │ ├── ConsumerGroupInfo.java │ │ │ ├── ConsumerIdsChangeListener.java │ │ │ ├── ConsumerManager.java │ │ │ ├── DefaultConsumerIdsChangeListener.java │ │ │ ├── ProducerManager.java │ │ │ ├── net │ │ │ │ └── Broker2Client.java │ │ │ └── rebalance │ │ │ │ └── RebalanceLockManager.java │ │ │ ├── filter │ │ │ ├── CommitLogDispatcherCalcBitMap.java │ │ │ ├── ConsumerFilterData.java │ │ │ ├── ConsumerFilterManager.java │ │ │ ├── ExpressionForRetryMessageFilter.java │ │ │ ├── ExpressionMessageFilter.java │ │ │ └── MessageEvaluationContext.java │ │ │ ├── filtersrv │ │ │ ├── FilterServerManager.java │ │ │ └── FilterServerUtil.java │ │ │ ├── latency │ │ │ ├── BrokerFastFailure.java │ │ │ ├── BrokerFixedThreadPoolExecutor.java │ │ │ └── FutureTaskExt.java │ │ │ ├── longpolling │ │ │ ├── ManyPullRequest.java │ │ │ ├── NotifyMessageArrivingListener.java │ │ │ ├── PullRequest.java │ │ │ └── PullRequestHoldService.java │ │ │ ├── mqtrace │ │ │ ├── ConsumeMessageContext.java │ │ │ ├── ConsumeMessageHook.java │ │ │ ├── SendMessageContext.java │ │ │ └── SendMessageHook.java │ │ │ ├── offset │ │ │ └── ConsumerOffsetManager.java │ │ │ ├── out │ │ │ └── BrokerOuterAPI.java │ │ │ ├── pagecache │ │ │ ├── ManyMessageTransfer.java │ │ │ ├── OneMessageTransfer.java │ │ │ └── QueryMessageTransfer.java │ │ │ ├── plugin │ │ │ ├── AbstractPluginMessageStore.java │ │ │ ├── MessageStoreFactory.java │ │ │ └── MessageStorePluginContext.java │ │ │ ├── processor │ │ │ ├── AbstractSendMessageProcessor.java │ │ │ ├── AdminBrokerProcessor.java │ │ │ ├── ClientManageProcessor.java │ │ │ ├── ConsumerManageProcessor.java │ │ │ ├── EndTransactionProcessor.java │ │ │ ├── ForwardRequestProcessor.java │ │ │ ├── PullMessageProcessor.java │ │ │ ├── QueryMessageProcessor.java │ │ │ └── SendMessageProcessor.java │ │ │ ├── slave │ │ │ └── SlaveSynchronize.java │ │ │ ├── subscription │ │ │ └── SubscriptionGroupManager.java │ │ │ ├── topic │ │ │ └── TopicConfigManager.java │ │ │ ├── transaction │ │ │ ├── AbstractTransactionalMessageCheckListener.java │ │ │ ├── OperationResult.java │ │ │ ├── TransactionRecord.java │ │ │ ├── TransactionStore.java │ │ │ ├── TransactionalMessageCheckService.java │ │ │ ├── TransactionalMessageService.java │ │ │ ├── jdbc │ │ │ │ ├── JDBCTransactionStore.java │ │ │ │ └── JDBCTransactionStoreConfig.java │ │ │ └── queue │ │ │ │ ├── DefaultTransactionalMessageCheckListener.java │ │ │ │ ├── GetResult.java │ │ │ │ ├── TransactionalMessageBridge.java │ │ │ │ ├── TransactionalMessageServiceImpl.java │ │ │ │ └── TransactionalMessageUtil.java │ │ │ └── util │ │ │ ├── PositiveAtomicCounter.java │ │ │ └── ServiceProvider.java │ └── resources │ │ └── transaction.sql │ └── test │ ├── java │ └── org │ │ └── apache │ │ └── rocketmq │ │ └── broker │ │ ├── BrokerControllerTest.java │ │ ├── BrokerOuterAPITest.java │ │ ├── BrokerStartupTest.java │ │ ├── client │ │ └── ProducerManagerTest.java │ │ ├── filter │ │ ├── CommitLogDispatcherCalcBitMapTest.java │ │ ├── ConsumerFilterManagerTest.java │ │ └── MessageStoreWithFilterTest.java │ │ ├── latency │ │ └── BrokerFastFailureTest.java │ │ ├── processor │ │ ├── ClientManageProcessorTest.java │ │ ├── EndTransactionProcessorTest.java │ │ ├── PullMessageProcessorTest.java │ │ └── SendMessageProcessorTest.java │ │ ├── transaction │ │ └── queue │ │ │ ├── DefaultTransactionalMessageCheckListenerTest.java │ │ │ ├── TransactionalMessageBridgeTest.java │ │ │ └── TransactionalMessageServiceImplTest.java │ │ └── util │ │ ├── LogTransactionalMessageCheckListener.java │ │ ├── ServiceProviderTest.java │ │ └── TransactionalMessageServiceImpl.java │ └── resources │ ├── META-INF │ └── service │ │ ├── org.apache.rocketmq.broker.transaction.AbstractTransactionalMessageCheckListener │ │ └── org.apache.rocketmq.broker.transaction.TransactionalMessageService │ └── logback-test.xml ├── client ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── apache │ │ └── rocketmq │ │ └── client │ │ ├── ClientConfig.java │ │ ├── MQAdmin.java │ │ ├── MQHelper.java │ │ ├── QueryResult.java │ │ ├── Validators.java │ │ ├── admin │ │ └── MQAdminExtInner.java │ │ ├── common │ │ ├── ClientErrorCode.java │ │ └── ThreadLocalIndex.java │ │ ├── consumer │ │ ├── AllocateMessageQueueStrategy.java │ │ ├── DefaultMQPullConsumer.java │ │ ├── DefaultMQPushConsumer.java │ │ ├── MQConsumer.java │ │ ├── MQPullConsumer.java │ │ ├── MQPullConsumerScheduleService.java │ │ ├── MQPushConsumer.java │ │ ├── MessageQueueListener.java │ │ ├── MessageSelector.java │ │ ├── PullCallback.java │ │ ├── PullResult.java │ │ ├── PullStatus.java │ │ ├── PullTaskCallback.java │ │ ├── PullTaskContext.java │ │ ├── listener │ │ │ ├── ConsumeConcurrentlyContext.java │ │ │ ├── ConsumeConcurrentlyStatus.java │ │ │ ├── ConsumeOrderlyContext.java │ │ │ ├── ConsumeOrderlyStatus.java │ │ │ ├── ConsumeReturnType.java │ │ │ ├── MessageListener.java │ │ │ ├── MessageListenerConcurrently.java │ │ │ └── MessageListenerOrderly.java │ │ ├── rebalance │ │ │ ├── AllocateMachineRoomNearby.java │ │ │ ├── AllocateMessageQueueAveragely.java │ │ │ ├── AllocateMessageQueueAveragelyByCircle.java │ │ │ ├── AllocateMessageQueueByConfig.java │ │ │ ├── AllocateMessageQueueByMachineRoom.java │ │ │ └── AllocateMessageQueueConsistentHash.java │ │ └── store │ │ │ ├── LocalFileOffsetStore.java │ │ │ ├── OffsetSerializeWrapper.java │ │ │ ├── OffsetStore.java │ │ │ ├── ReadOffsetType.java │ │ │ └── RemoteBrokerOffsetStore.java │ │ ├── exception │ │ ├── MQBrokerException.java │ │ └── MQClientException.java │ │ ├── hook │ │ ├── CheckForbiddenContext.java │ │ ├── CheckForbiddenHook.java │ │ ├── ConsumeMessageContext.java │ │ ├── ConsumeMessageHook.java │ │ ├── FilterMessageContext.java │ │ ├── FilterMessageHook.java │ │ ├── SendMessageContext.java │ │ └── SendMessageHook.java │ │ ├── impl │ │ ├── ClientRemotingProcessor.java │ │ ├── CommunicationMode.java │ │ ├── FindBrokerResult.java │ │ ├── MQAdminImpl.java │ │ ├── MQClientAPIImpl.java │ │ ├── MQClientManager.java │ │ ├── consumer │ │ │ ├── ConsumeMessageConcurrentlyService.java │ │ │ ├── ConsumeMessageOrderlyService.java │ │ │ ├── ConsumeMessageService.java │ │ │ ├── DefaultMQPullConsumerImpl.java │ │ │ ├── DefaultMQPushConsumerImpl.java │ │ │ ├── MQConsumerInner.java │ │ │ ├── MessageQueueLock.java │ │ │ ├── ProcessQueue.java │ │ │ ├── PullAPIWrapper.java │ │ │ ├── PullMessageService.java │ │ │ ├── PullRequest.java │ │ │ ├── PullResultExt.java │ │ │ ├── RebalanceImpl.java │ │ │ ├── RebalancePullImpl.java │ │ │ ├── RebalancePushImpl.java │ │ │ └── RebalanceService.java │ │ ├── factory │ │ │ └── MQClientInstance.java │ │ └── producer │ │ │ ├── DefaultMQProducerImpl.java │ │ │ ├── MQProducerInner.java │ │ │ └── TopicPublishInfo.java │ │ ├── latency │ │ ├── LatencyFaultTolerance.java │ │ ├── LatencyFaultToleranceImpl.java │ │ └── MQFaultStrategy.java │ │ ├── log │ │ └── ClientLogger.java │ │ ├── producer │ │ ├── DefaultMQProducer.java │ │ ├── LocalTransactionExecuter.java │ │ ├── LocalTransactionState.java │ │ ├── MQProducer.java │ │ ├── MessageQueueSelector.java │ │ ├── SendCallback.java │ │ ├── SendResult.java │ │ ├── SendStatus.java │ │ ├── TransactionCheckListener.java │ │ ├── TransactionListener.java │ │ ├── TransactionMQProducer.java │ │ ├── TransactionSendResult.java │ │ └── selector │ │ │ ├── SelectMessageQueueByHash.java │ │ │ ├── SelectMessageQueueByMachineRoom.java │ │ │ └── SelectMessageQueueByRandom.java │ │ └── stat │ │ └── ConsumerStatsManager.java │ └── test │ └── java │ └── org │ └── apache │ └── rocketmq │ └── client │ ├── ValidatorsTest.java │ ├── common │ └── ThreadLocalIndexTest.java │ ├── consumer │ ├── DefaultMQPullConsumerTest.java │ ├── DefaultMQPushConsumerTest.java │ ├── rebalance │ │ ├── AllocateMachineRoomNearByTest.java │ │ └── AllocateMessageQueueConsitentHashTest.java │ └── store │ │ ├── LocalFileOffsetStoreTest.java │ │ └── RemoteBrokerOffsetStoreTest.java │ ├── impl │ ├── MQClientAPIImplTest.java │ ├── consumer │ │ ├── DefaultMQPushConsumerImplTest.java │ │ ├── ProcessQueueTest.java │ │ └── RebalancePushImplTest.java │ └── factory │ │ └── MQClientInstanceTest.java │ ├── latency │ └── LatencyFaultToleranceImplTest.java │ └── producer │ ├── DefaultMQProducerTest.java │ └── selector │ └── SelectMessageQueueByHashTest.java ├── common ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── apache │ │ └── rocketmq │ │ └── common │ │ ├── BrokerConfig.java │ │ ├── BrokerConfigSingleton.java │ │ ├── ConfigManager.java │ │ ├── Configuration.java │ │ ├── CountDownLatch2.java │ │ ├── DataVersion.java │ │ ├── MQVersion.java │ │ ├── MixAll.java │ │ ├── Pair.java │ │ ├── ServiceState.java │ │ ├── ServiceThread.java │ │ ├── SystemClock.java │ │ ├── ThreadFactoryImpl.java │ │ ├── TopicConfig.java │ │ ├── TopicFilterType.java │ │ ├── UtilAll.java │ │ ├── admin │ │ ├── ConsumeStats.java │ │ ├── OffsetWrapper.java │ │ ├── RollbackStats.java │ │ ├── TopicOffset.java │ │ └── TopicStatsTable.java │ │ ├── annotation │ │ └── ImportantField.java │ │ ├── consistenthash │ │ ├── ConsistentHashRouter.java │ │ ├── HashFunction.java │ │ ├── Node.java │ │ └── VirtualNode.java │ │ ├── constant │ │ ├── DBMsgConstants.java │ │ ├── LoggerName.java │ │ └── PermName.java │ │ ├── consumer │ │ └── ConsumeFromWhere.java │ │ ├── filter │ │ ├── ExpressionType.java │ │ ├── FilterAPI.java │ │ ├── FilterContext.java │ │ ├── MessageFilter.java │ │ └── impl │ │ │ ├── Op.java │ │ │ ├── Operand.java │ │ │ ├── Operator.java │ │ │ ├── PolishExpr.java │ │ │ └── Type.java │ │ ├── help │ │ └── FAQUrl.java │ │ ├── hook │ │ └── FilterCheckHook.java │ │ ├── message │ │ ├── Message.java │ │ ├── MessageAccessor.java │ │ ├── MessageBatch.java │ │ ├── MessageClientExt.java │ │ ├── MessageClientIDSetter.java │ │ ├── MessageConst.java │ │ ├── MessageDecoder.java │ │ ├── MessageExt.java │ │ ├── MessageExtBatch.java │ │ ├── MessageId.java │ │ ├── MessageQueue.java │ │ ├── MessageQueueForC.java │ │ └── MessageType.java │ │ ├── namesrv │ │ ├── NamesrvConfig.java │ │ ├── NamesrvUtil.java │ │ ├── RegisterBrokerResult.java │ │ └── TopAddressing.java │ │ ├── protocol │ │ ├── MQProtosHelper.java │ │ ├── RequestCode.java │ │ ├── ResponseCode.java │ │ ├── body │ │ │ ├── BrokerStatsData.java │ │ │ ├── BrokerStatsItem.java │ │ │ ├── CMResult.java │ │ │ ├── CheckClientRequestBody.java │ │ │ ├── ClusterInfo.java │ │ │ ├── Connection.java │ │ │ ├── ConsumeByWho.java │ │ │ ├── ConsumeMessageDirectlyResult.java │ │ │ ├── ConsumeQueueData.java │ │ │ ├── ConsumeStatsList.java │ │ │ ├── ConsumeStatus.java │ │ │ ├── ConsumerConnection.java │ │ │ ├── ConsumerOffsetSerializeWrapper.java │ │ │ ├── ConsumerRunningInfo.java │ │ │ ├── GetConsumerStatusBody.java │ │ │ ├── GroupList.java │ │ │ ├── KVTable.java │ │ │ ├── LockBatchRequestBody.java │ │ │ ├── LockBatchResponseBody.java │ │ │ ├── ProcessQueueInfo.java │ │ │ ├── ProducerConnection.java │ │ │ ├── QueryConsumeQueueResponseBody.java │ │ │ ├── QueryConsumeTimeSpanBody.java │ │ │ ├── QueryCorrectionOffsetBody.java │ │ │ ├── QueueTimeSpan.java │ │ │ ├── RegisterBrokerBody.java │ │ │ ├── ResetOffsetBody.java │ │ │ ├── ResetOffsetBodyForC.java │ │ │ ├── SubscriptionGroupWrapper.java │ │ │ ├── TopicConfigSerializeWrapper.java │ │ │ ├── TopicList.java │ │ │ └── UnlockBatchRequestBody.java │ │ ├── header │ │ │ ├── CheckTransactionStateRequestHeader.java │ │ │ ├── CheckTransactionStateResponseHeader.java │ │ │ ├── CloneGroupOffsetRequestHeader.java │ │ │ ├── ConsumeMessageDirectlyResultRequestHeader.java │ │ │ ├── ConsumerSendMsgBackRequestHeader.java │ │ │ ├── CreateTopicRequestHeader.java │ │ │ ├── DeleteSubscriptionGroupRequestHeader.java │ │ │ ├── DeleteTopicRequestHeader.java │ │ │ ├── EndTransactionRequestHeader.java │ │ │ ├── EndTransactionResponseHeader.java │ │ │ ├── GetAllTopicConfigResponseHeader.java │ │ │ ├── GetBrokerConfigResponseHeader.java │ │ │ ├── GetConsumeStatsInBrokerHeader.java │ │ │ ├── GetConsumeStatsRequestHeader.java │ │ │ ├── GetConsumerConnectionListRequestHeader.java │ │ │ ├── GetConsumerListByGroupRequestHeader.java │ │ │ ├── GetConsumerListByGroupResponseBody.java │ │ │ ├── GetConsumerListByGroupResponseHeader.java │ │ │ ├── GetConsumerRunningInfoRequestHeader.java │ │ │ ├── GetConsumerStatusRequestHeader.java │ │ │ ├── GetEarliestMsgStoretimeRequestHeader.java │ │ │ ├── GetEarliestMsgStoretimeResponseHeader.java │ │ │ ├── GetMaxOffsetRequestHeader.java │ │ │ ├── GetMaxOffsetResponseHeader.java │ │ │ ├── GetMinOffsetRequestHeader.java │ │ │ ├── GetMinOffsetResponseHeader.java │ │ │ ├── GetProducerConnectionListRequestHeader.java │ │ │ ├── GetTopicStatsInfoRequestHeader.java │ │ │ ├── GetTopicsByClusterRequestHeader.java │ │ │ ├── NotifyConsumerIdsChangedRequestHeader.java │ │ │ ├── PullMessageRequestHeader.java │ │ │ ├── PullMessageResponseHeader.java │ │ │ ├── QueryConsumeQueueRequestHeader.java │ │ │ ├── QueryConsumeTimeSpanRequestHeader.java │ │ │ ├── QueryConsumerOffsetRequestHeader.java │ │ │ ├── QueryConsumerOffsetResponseHeader.java │ │ │ ├── QueryCorrectionOffsetHeader.java │ │ │ ├── QueryMessageRequestHeader.java │ │ │ ├── QueryMessageResponseHeader.java │ │ │ ├── QueryTopicConsumeByWhoRequestHeader.java │ │ │ ├── ResetOffsetRequestHeader.java │ │ │ ├── SearchOffsetRequestHeader.java │ │ │ ├── SearchOffsetResponseHeader.java │ │ │ ├── SendMessageRequestHeader.java │ │ │ ├── SendMessageRequestHeaderV2.java │ │ │ ├── SendMessageResponseHeader.java │ │ │ ├── UnregisterClientRequestHeader.java │ │ │ ├── UnregisterClientResponseHeader.java │ │ │ ├── UpdateConsumerOffsetRequestHeader.java │ │ │ ├── UpdateConsumerOffsetResponseHeader.java │ │ │ ├── ViewBrokerStatsDataRequestHeader.java │ │ │ ├── ViewMessageRequestHeader.java │ │ │ ├── ViewMessageResponseHeader.java │ │ │ ├── filtersrv │ │ │ │ ├── RegisterFilterServerRequestHeader.java │ │ │ │ ├── RegisterFilterServerResponseHeader.java │ │ │ │ └── RegisterMessageFilterClassRequestHeader.java │ │ │ └── namesrv │ │ │ │ ├── DeleteKVConfigRequestHeader.java │ │ │ │ ├── DeleteTopicInNamesrvRequestHeader.java │ │ │ │ ├── GetKVConfigRequestHeader.java │ │ │ │ ├── GetKVConfigResponseHeader.java │ │ │ │ ├── GetKVListByNamespaceRequestHeader.java │ │ │ │ ├── GetRouteInfoRequestHeader.java │ │ │ │ ├── PutKVConfigRequestHeader.java │ │ │ │ ├── QueryDataVersionRequestHeader.java │ │ │ │ ├── QueryDataVersionResponseHeader.java │ │ │ │ ├── RegisterBrokerRequestHeader.java │ │ │ │ ├── RegisterBrokerResponseHeader.java │ │ │ │ ├── RegisterOrderTopicRequestHeader.java │ │ │ │ ├── UnRegisterBrokerRequestHeader.java │ │ │ │ ├── WipeWritePermOfBrokerRequestHeader.java │ │ │ │ └── WipeWritePermOfBrokerResponseHeader.java │ │ ├── heartbeat │ │ │ ├── ConsumeType.java │ │ │ ├── ConsumerData.java │ │ │ ├── HeartbeatData.java │ │ │ ├── MessageModel.java │ │ │ ├── ProducerData.java │ │ │ └── SubscriptionData.java │ │ ├── route │ │ │ ├── BrokerData.java │ │ │ ├── QueueData.java │ │ │ └── TopicRouteData.java │ │ └── topic │ │ │ └── OffsetMovedEvent.java │ │ ├── queue │ │ ├── ConcurrentTreeMap.java │ │ └── RoundQueue.java │ │ ├── running │ │ └── RunningStats.java │ │ ├── stats │ │ ├── MomentStatsItem.java │ │ ├── MomentStatsItemSet.java │ │ ├── StatsItem.java │ │ ├── StatsItemSet.java │ │ └── StatsSnapshot.java │ │ ├── subscription │ │ └── SubscriptionGroupConfig.java │ │ ├── sysflag │ │ ├── MessageSysFlag.java │ │ ├── PullSysFlag.java │ │ ├── SubscriptionSysFlag.java │ │ └── TopicSysFlag.java │ │ └── utils │ │ ├── ChannelUtil.java │ │ ├── HttpTinyClient.java │ │ ├── IOTinyUtils.java │ │ └── ThreadUtils.java │ └── test │ └── java │ └── org │ └── apache │ └── rocketmq │ └── common │ ├── BrokerConfigTest.java │ ├── DataVersionTest.java │ ├── MQVersionTest.java │ ├── MessageBatchTest.java │ ├── MessageEncodeDecodeTest.java │ ├── MixAllTest.java │ ├── RegisterBrokerBodyTest.java │ ├── RemotingUtilTest.java │ ├── UtilAllTest.java │ ├── filter │ └── FilterAPITest.java │ ├── message │ ├── MessageDecoderTest.java │ └── MessageTest.java │ └── protocol │ └── ConsumeStatusTest.java ├── distribution ├── LICENSE-BIN ├── NOTICE-BIN ├── benchmark │ ├── consumer.sh │ ├── producer.sh │ ├── runclass.sh │ └── tproducer.sh ├── bin │ ├── README.md │ ├── cachedog.sh │ ├── cleancache.sh │ ├── cleancache.v1.sh │ ├── mqadmin │ ├── mqadmin.cmd │ ├── mqadmin.xml │ ├── mqbroker │ ├── mqbroker.cmd │ ├── mqbroker.numanode0 │ ├── mqbroker.numanode1 │ ├── mqbroker.numanode2 │ ├── mqbroker.numanode3 │ ├── mqbroker.xml │ ├── mqnamesrv │ ├── mqnamesrv.cmd │ ├── mqnamesrv.xml │ ├── mqshutdown │ ├── mqshutdown.cmd │ ├── os.sh │ ├── play.cmd │ ├── play.sh │ ├── runbroker.cmd │ ├── runbroker.sh │ ├── runserver.cmd │ ├── runserver.sh │ ├── setcache.sh │ ├── startfsrv.sh │ ├── tools.cmd │ └── tools.sh ├── conf │ ├── 2m-2s-async │ │ ├── broker-a-s.properties │ │ ├── broker-a.properties │ │ ├── broker-b-s.properties │ │ └── broker-b.properties │ ├── 2m-2s-sync │ │ ├── broker-a-s.properties │ │ ├── broker-a.properties │ │ ├── broker-b-s.properties │ │ └── broker-b.properties │ ├── 2m-noslave │ │ ├── broker-a.properties │ │ └── broker-b.properties │ ├── broker.conf │ ├── logback_broker.xml │ ├── logback_namesrv.xml │ └── logback_tools.xml ├── pom.xml ├── release-client.xml └── release.xml ├── example ├── pom.xml └── src │ └── main │ ├── java │ └── org │ │ └── apache │ │ └── rocketmq │ │ └── example │ │ ├── batch │ │ ├── SimpleBatchProducer.java │ │ └── SplitBatchProducer.java │ │ ├── benchmark │ │ ├── Consumer.java │ │ ├── Producer.java │ │ └── TransactionProducer.java │ │ ├── broadcast │ │ └── PushConsumer.java │ │ ├── filter │ │ ├── Consumer.java │ │ ├── Producer.java │ │ ├── SqlConsumer.java │ │ └── SqlProducer.java │ │ ├── openmessaging │ │ ├── SimpleProducer.java │ │ ├── SimplePullConsumer.java │ │ └── SimplePushConsumer.java │ │ ├── operation │ │ ├── Consumer.java │ │ └── Producer.java │ │ ├── ordermessage │ │ ├── Consumer.java │ │ └── Producer.java │ │ ├── quickstart │ │ ├── Consumer.java │ │ └── Producer.java │ │ ├── simple │ │ ├── AsyncProducer.java │ │ ├── CachedQueue.java │ │ ├── Producer.java │ │ ├── PullConsumer.java │ │ ├── PullConsumerTest.java │ │ ├── PullScheduleService.java │ │ ├── PushConsumer.java │ │ ├── RandomAsyncCommit.java │ │ └── TestProducer.java │ │ └── transaction │ │ ├── TransactionListenerImpl.java │ │ └── TransactionProducer.java │ └── resources │ └── MessageFilterImpl.java ├── filter ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── apache │ │ └── rocketmq │ │ └── filter │ │ ├── FilterFactory.java │ │ ├── FilterSpi.java │ │ ├── SqlFilter.java │ │ ├── constant │ │ └── UnaryType.java │ │ ├── expression │ │ ├── BinaryExpression.java │ │ ├── BooleanExpression.java │ │ ├── ComparisonExpression.java │ │ ├── ConstantExpression.java │ │ ├── EmptyEvaluationContext.java │ │ ├── EvaluationContext.java │ │ ├── Expression.java │ │ ├── LogicExpression.java │ │ ├── MQFilterException.java │ │ ├── NowExpression.java │ │ ├── PropertyExpression.java │ │ ├── UnaryExpression.java │ │ └── UnaryInExpression.java │ │ ├── parser │ │ ├── ParseException.java │ │ ├── SelectorParser.java │ │ ├── SelectorParser.jj │ │ ├── SelectorParserConstants.java │ │ ├── SelectorParserTokenManager.java │ │ ├── SimpleCharStream.java │ │ ├── Token.java │ │ └── TokenMgrError.java │ │ └── util │ │ ├── BitsArray.java │ │ ├── BloomFilter.java │ │ └── BloomFilterData.java │ └── test │ └── java │ └── org │ └── apache │ └── rocketmq │ └── filter │ ├── BitsArrayTest.java │ ├── BloomFilterTest.java │ ├── ExpressionTest.java │ ├── FilterSpiTest.java │ └── ParserTest.java ├── logappender ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── apache │ │ └── rocketmq │ │ └── logappender │ │ ├── common │ │ └── ProducerInstance.java │ │ ├── log4j │ │ └── RocketmqLog4jAppender.java │ │ ├── log4j2 │ │ └── RocketmqLog4j2Appender.java │ │ └── logback │ │ └── RocketmqLogbackAppender.java │ └── test │ ├── java │ └── org │ │ └── apache │ │ └── rocketmq │ │ └── logappender │ │ ├── AbstractTestCase.java │ │ ├── Log4jPropertiesTest.java │ │ ├── Log4jTest.java │ │ ├── Log4jXmlTest.java │ │ ├── LogbackTest.java │ │ └── log4j2Test.java │ └── resources │ ├── log4j-example.properties │ ├── log4j-example.xml │ ├── log4j2-example.xml │ └── logback-example.xml ├── logging ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── apache │ │ └── rocketmq │ │ └── logging │ │ ├── InnerLoggerFactory.java │ │ ├── InternalLogger.java │ │ ├── InternalLoggerFactory.java │ │ ├── Slf4jLoggerFactory.java │ │ ├── inner │ │ ├── Appender.java │ │ ├── Layout.java │ │ ├── Level.java │ │ ├── Logger.java │ │ ├── LoggingBuilder.java │ │ ├── LoggingEvent.java │ │ └── SysLogger.java │ │ └── package-info.java │ └── test │ ├── java │ └── org │ │ └── apache │ │ └── rocketmq │ │ └── logging │ │ ├── BasicLoggerTest.java │ │ ├── InnerLoggerFactoryTest.java │ │ ├── InternalLoggerTest.java │ │ ├── Slf4jLoggerFactoryTest.java │ │ └── inner │ │ ├── AppenderTest.java │ │ ├── LayoutTest.java │ │ ├── LevelTest.java │ │ ├── LoggerRepositoryTest.java │ │ ├── LoggerTest.java │ │ ├── LoggingBuilderTest.java │ │ └── MessageFormatterTest.java │ └── resources │ └── logback_test.xml ├── namesrv ├── pom.xml └── src │ ├── main │ └── java │ │ ├── NameServer架构设计图.png │ │ └── org │ │ └── apache │ │ └── rocketmq │ │ └── namesrv │ │ ├── NamesrvController.java │ │ ├── NamesrvStartup.java │ │ ├── kvconfig │ │ ├── KVConfigManager.java │ │ └── KVConfigSerializeWrapper.java │ │ ├── processor │ │ ├── ClusterTestRequestProcessor.java │ │ └── DefaultRequestProcessor.java │ │ └── routeinfo │ │ ├── BrokerHousekeepingService.java │ │ └── RouteInfoManager.java │ └── test │ └── java │ └── org │ └── apache │ └── rocketmq │ └── namesrv │ ├── NameServerInstanceTest.java │ ├── kvconfig │ ├── KVConfigManagerTest.java │ └── KVConfigSerializeWrapperTest.java │ ├── processor │ ├── ClusterTestRequestProcessorTest.java │ └── DefaultRequestProcessorTest.java │ └── routeinfo │ ├── BrokerHousekeepingServiceTest.java │ └── RouteInfoManagerTest.java ├── openmessaging ├── pom.xml └── src │ ├── main │ └── java │ │ └── io │ │ └── openmessaging │ │ └── rocketmq │ │ ├── MessagingAccessPointImpl.java │ │ ├── config │ │ └── ClientConfig.java │ │ ├── consumer │ │ ├── LocalMessageCache.java │ │ ├── PullConsumerImpl.java │ │ └── PushConsumerImpl.java │ │ ├── domain │ │ ├── BytesMessageImpl.java │ │ ├── ConsumeRequest.java │ │ ├── NonStandardKeys.java │ │ ├── RocketMQConstants.java │ │ └── SendResultImpl.java │ │ ├── producer │ │ ├── AbstractOMSProducer.java │ │ └── ProducerImpl.java │ │ ├── promise │ │ ├── DefaultPromise.java │ │ └── FutureState.java │ │ └── utils │ │ ├── BeanUtils.java │ │ └── OMSUtil.java │ └── test │ └── java │ └── io │ └── openmessaging │ └── rocketmq │ ├── consumer │ ├── LocalMessageCacheTest.java │ ├── PullConsumerImplTest.java │ └── PushConsumerImplTest.java │ ├── producer │ └── ProducerImplTest.java │ ├── promise │ └── DefaultPromiseTest.java │ └── utils │ └── BeanUtilsTest.java ├── pom.xml ├── remoting ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── apache │ │ └── rocketmq │ │ └── remoting │ │ ├── ChannelEventListener.java │ │ ├── CommandCustomHeader.java │ │ ├── InvokeCallback.java │ │ ├── RPCHook.java │ │ ├── RemotingClient.java │ │ ├── RemotingServer.java │ │ ├── RemotingService.java │ │ ├── annotation │ │ ├── CFNotNull.java │ │ └── CFNullable.java │ │ ├── common │ │ ├── Pair.java │ │ ├── RemotingHelper.java │ │ ├── RemotingUtil.java │ │ ├── SemaphoreReleaseOnlyOnce.java │ │ ├── ServiceThread.java │ │ └── TlsMode.java │ │ ├── exception │ │ ├── RemotingCommandException.java │ │ ├── RemotingConnectException.java │ │ ├── RemotingException.java │ │ ├── RemotingSendRequestException.java │ │ ├── RemotingTimeoutException.java │ │ └── RemotingTooMuchRequestException.java │ │ ├── netty │ │ ├── FileRegionEncoder.java │ │ ├── NettyClientConfig.java │ │ ├── NettyDecoder.java │ │ ├── NettyEncoder.java │ │ ├── NettyEvent.java │ │ ├── NettyEventType.java │ │ ├── NettyLogger.java │ │ ├── NettyRemotingAbstract.java │ │ ├── NettyRemotingClient.java │ │ ├── NettyRemotingServer.java │ │ ├── NettyRequestProcessor.java │ │ ├── NettyServerConfig.java │ │ ├── NettySystemConfig.java │ │ ├── RequestTask.java │ │ ├── ResponseFuture.java │ │ ├── TlsHelper.java │ │ └── TlsSystemConfig.java │ │ └── protocol │ │ ├── LanguageCode.java │ │ ├── RemotingCommand.java │ │ ├── RemotingCommandType.java │ │ ├── RemotingSerializable.java │ │ ├── RemotingSysResponseCode.java │ │ ├── RocketMQSerializable.java │ │ └── SerializeType.java │ └── test │ ├── java │ └── org │ │ └── apache │ │ └── rocketmq │ │ └── remoting │ │ ├── RemotingServerTest.java │ │ ├── TlsTest.java │ │ ├── netty │ │ ├── FileRegionEncoderTest.java │ │ ├── NettyRemotingAbstractTest.java │ │ └── NettyRemotingClientTest.java │ │ └── protocol │ │ ├── RemotingCommandTest.java │ │ ├── RemotingSerializableTest.java │ │ └── RocketMQSerializableTest.java │ └── resources │ └── certs │ ├── badClient.key │ ├── badClient.pem │ ├── badServer.key │ ├── badServer.pem │ ├── ca.pem │ ├── client.key │ ├── client.pem │ ├── privkey.pem │ ├── server.key │ └── server.pem ├── srvutil ├── pom.xml └── src │ └── main │ ├── java │ └── org │ │ └── apache │ │ └── rocketmq │ │ └── srvutil │ │ ├── FileWatchService.java │ │ ├── ServerUtil.java │ │ └── ShutdownHookThread.java │ └── test │ └── org │ └── apache │ └── rocketmq │ └── srvutil │ └── FileWatchServiceTest.java ├── store ├── pom.xml └── src │ ├── main │ └── java │ │ ├── Java NIO内存映射模型图.png │ │ ├── Java NIO内存映射模型图说明.txt │ │ ├── RocketMQ同步&&异步刷盘两种方式.png │ │ ├── RocketMQ同步&&异步刷盘两种方式说明.txt │ │ ├── RokcetMQ文件存储PageCache机制.png │ │ ├── RokcetMQ文件存储PageCache机制说明.txt │ │ ├── org │ │ └── apache │ │ │ └── rocketmq │ │ │ └── store │ │ │ ├── AllocateMappedFileService.java │ │ │ ├── AppendMessageCallback.java │ │ │ ├── AppendMessageResult.java │ │ │ ├── AppendMessageStatus.java │ │ │ ├── CommitLog.java │ │ │ ├── CommitLogDispatcher.java │ │ │ ├── ConsumeQueue.java │ │ │ ├── ConsumeQueueExt.java │ │ │ ├── DefaultMessageFilter.java │ │ │ ├── DefaultMessageStore.java │ │ │ ├── DispatchRequest.java │ │ │ ├── GetMessageResult.java │ │ │ ├── GetMessageStatus.java │ │ │ ├── MappedFile.java │ │ │ ├── MappedFileQueue.java │ │ │ ├── MessageArrivingListener.java │ │ │ ├── MessageExtBrokerInner.java │ │ │ ├── MessageFilter.java │ │ │ ├── MessageStore.java │ │ │ ├── PutMessageLock.java │ │ │ ├── PutMessageReentrantLock.java │ │ │ ├── PutMessageResult.java │ │ │ ├── PutMessageSpinLock.java │ │ │ ├── PutMessageStatus.java │ │ │ ├── QueryMessageResult.java │ │ │ ├── ReferenceResource.java │ │ │ ├── RunningFlags.java │ │ │ ├── SelectMappedBufferResult.java │ │ │ ├── StoreCheckpoint.java │ │ │ ├── StoreStatsService.java │ │ │ ├── StoreUtil.java │ │ │ ├── TransientStorePool.java │ │ │ ├── config │ │ │ ├── BrokerRole.java │ │ │ ├── FlushDiskType.java │ │ │ ├── MessageStoreConfig.java │ │ │ └── StorePathConfigHelper.java │ │ │ ├── ha │ │ │ ├── HAConnection.java │ │ │ ├── HAService.java │ │ │ └── WaitNotifyObject.java │ │ │ ├── index │ │ │ ├── IndexFile.java │ │ │ ├── IndexHeader.java │ │ │ ├── IndexService.java │ │ │ └── QueryOffsetResult.java │ │ │ ├── schedule │ │ │ ├── DelayOffsetSerializeWrapper.java │ │ │ └── ScheduleMessageService.java │ │ │ ├── stats │ │ │ ├── BrokerStats.java │ │ │ └── BrokerStatsManager.java │ │ │ └── util │ │ │ └── LibC.java │ │ ├── store代码架构图.png │ │ ├── store设计架构图.png │ │ ├── store设计架构图说明.txt │ │ ├── 预分配MappedFile的主要过程.png │ │ └── 预分配MappedFile的主要过程说明.txt │ └── test │ ├── java │ └── org │ │ └── apache │ │ └── rocketmq │ │ └── store │ │ ├── AppendCallbackTest.java │ │ ├── ConsumeQueueExtTest.java │ │ ├── ConsumeQueueTest.java │ │ ├── DefaultMessageStoreShutDownTest.java │ │ ├── DefaultMessageStoreTest.java │ │ ├── MappedFileQueueTest.java │ │ ├── MappedFileTest.java │ │ ├── StoreCheckpointTest.java │ │ ├── StoreStatsServiceTest.java │ │ ├── ha │ │ └── WaitNotifyObjectTest.java │ │ └── index │ │ └── IndexFileTest.java │ └── resources │ └── logback-test.xml ├── style ├── copyright │ ├── Apache.xml │ └── profiles_settings.xml ├── rmq_checkstyle.xml └── rmq_codeStyle.xml ├── test ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── apache │ │ └── rocketmq │ │ └── test │ │ ├── client │ │ ├── mq │ │ │ └── MQAsyncProducer.java │ │ └── rmq │ │ │ ├── RMQAsyncSendProducer.java │ │ │ ├── RMQBroadCastConsumer.java │ │ │ ├── RMQNormalConsumer.java │ │ │ ├── RMQNormalProducer.java │ │ │ └── RMQSqlConsumer.java │ │ ├── clientinterface │ │ ├── AbstractMQConsumer.java │ │ ├── AbstractMQProducer.java │ │ ├── MQCollector.java │ │ ├── MQConsumer.java │ │ └── MQProducer.java │ │ ├── factory │ │ ├── ConsumerFactory.java │ │ ├── MQMessageFactory.java │ │ ├── MessageFactory.java │ │ ├── ProducerFactory.java │ │ ├── SendCallBackFactory.java │ │ └── TagMessage.java │ │ ├── listener │ │ ├── AbstractListener.java │ │ └── rmq │ │ │ ├── concurrent │ │ │ ├── RMQDelayListner.java │ │ │ └── RMQNormalListener.java │ │ │ └── order │ │ │ └── RMQOrderListener.java │ │ ├── message │ │ └── MessageQueueMsg.java │ │ ├── sendresult │ │ └── ResultWrapper.java │ │ └── util │ │ ├── Condition.java │ │ ├── DuplicateMessageInfo.java │ │ ├── FileUtil.java │ │ ├── MQAdmin.java │ │ ├── MQRandomUtils.java │ │ ├── MQWait.java │ │ ├── RandomUtil.java │ │ ├── RandomUtils.java │ │ ├── TestUtil.java │ │ ├── TestUtils.java │ │ ├── VerifyUtils.java │ │ ├── data │ │ └── collect │ │ │ ├── DataCollector.java │ │ │ ├── DataCollectorManager.java │ │ │ ├── DataFilter.java │ │ │ └── impl │ │ │ ├── ListDataCollectorImpl.java │ │ │ └── MapDataCollectorImpl.java │ │ └── parallel │ │ ├── ParallelTask.java │ │ ├── ParallelTaskExecutor.java │ │ └── Task4Test.java │ └── test │ ├── java │ └── org │ │ └── apache │ │ └── rocketmq │ │ └── test │ │ ├── base │ │ ├── BaseConf.java │ │ └── IntegrationTestBase.java │ │ ├── client │ │ ├── consumer │ │ │ ├── balance │ │ │ │ ├── NormalMsgDynamicBalanceIT.java │ │ │ │ └── NormalMsgStaticBalanceIT.java │ │ │ ├── broadcast │ │ │ │ ├── BaseBroadCastIT.java │ │ │ │ ├── normal │ │ │ │ │ ├── BroadCastNormalMsgNotRecvIT.java │ │ │ │ │ ├── BroadCastNormalMsgRecvCrashIT.java │ │ │ │ │ ├── BroadCastNormalMsgRecvFailIT.java │ │ │ │ │ ├── BroadCastNormalMsgRecvStartLaterIT.java │ │ │ │ │ ├── BroadCastNormalMsgTwoDiffGroupRecvIT.java │ │ │ │ │ └── NormalMsgTwoSameGroupConsumerIT.java │ │ │ │ ├── order │ │ │ │ │ └── OrderMsgBroadCastIT.java │ │ │ │ └── tag │ │ │ │ │ ├── BroadCastTwoConsumerFilterIT.java │ │ │ │ │ ├── BroadCastTwoConsumerSubDiffTagIT.java │ │ │ │ │ └── BroadCastTwoConsumerSubTagIT.java │ │ │ ├── cluster │ │ │ │ ├── DynamicAddAndCrashIT.java │ │ │ │ ├── DynamicAddConsumerIT.java │ │ │ │ └── DynamicCrashConsumerIT.java │ │ │ ├── filter │ │ │ │ └── SqlFilterIT.java │ │ │ ├── tag │ │ │ │ ├── MulTagSubIT.java │ │ │ │ ├── TagMessageWith1ConsumerIT.java │ │ │ │ ├── TagMessageWithMulConsumerIT.java │ │ │ │ └── TagMessageWithSameGroupConsumerIT.java │ │ │ └── topic │ │ │ │ ├── MulConsumerMulTopicIT.java │ │ │ │ └── OneConsumerMulTopicIT.java │ │ └── producer │ │ │ ├── async │ │ │ ├── AsyncSendExceptionIT.java │ │ │ ├── AsyncSendWithMessageQueueIT.java │ │ │ ├── AsyncSendWithMessageQueueSelectorIT.java │ │ │ └── AsyncSendWithOnlySendCallBackIT.java │ │ │ ├── batch │ │ │ └── BatchSendIT.java │ │ │ ├── exception │ │ │ ├── msg │ │ │ │ ├── ChinaPropIT.java │ │ │ │ ├── MessageExceptionIT.java │ │ │ │ └── MessageUserPropIT.java │ │ │ └── producer │ │ │ │ └── ProducerGroupAndInstanceNameValidityIT.java │ │ │ ├── oneway │ │ │ ├── OneWaySendExceptionIT.java │ │ │ ├── OneWaySendIT.java │ │ │ ├── OneWaySendWithMQIT.java │ │ │ └── OneWaySendWithSelectorIT.java │ │ │ ├── order │ │ │ ├── OrderMsgDynamicRebalanceIT.java │ │ │ ├── OrderMsgIT.java │ │ │ ├── OrderMsgRebalanceIT.java │ │ │ └── OrderMsgWithTagIT.java │ │ │ └── querymsg │ │ │ ├── QueryMsgByIdExceptionIT.java │ │ │ ├── QueryMsgByIdIT.java │ │ │ └── QueryMsgByKeyIT.java │ │ ├── delay │ │ ├── DelayConf.java │ │ └── NormalMsgDelayIT.java │ │ ├── smoke │ │ └── NormalMessageSendAndRecvIT.java │ │ └── tls │ │ ├── TLS_IT.java │ │ ├── TLS_Mix2_IT.java │ │ └── TLS_Mix_IT.java │ └── resources │ ├── log4j.xml │ └── logback-test.xml └── tools ├── pom.xml └── src ├── main └── java │ └── org │ └── apache │ └── rocketmq │ └── tools │ ├── admin │ ├── DefaultMQAdminExt.java │ ├── DefaultMQAdminExtImpl.java │ ├── MQAdminExt.java │ └── api │ │ ├── MessageTrack.java │ │ └── TrackType.java │ ├── command │ ├── CommandUtil.java │ ├── MQAdminStartup.java │ ├── SubCommand.java │ ├── SubCommandException.java │ ├── broker │ │ ├── BrokerConsumeStatsSubCommad.java │ │ ├── BrokerStatusSubCommand.java │ │ ├── CleanExpiredCQSubCommand.java │ │ ├── CleanUnusedTopicCommand.java │ │ ├── GetBrokerConfigCommand.java │ │ ├── SendMsgStatusCommand.java │ │ └── UpdateBrokerConfigSubCommand.java │ ├── cluster │ │ ├── CLusterSendMsgRTCommand.java │ │ └── ClusterListSubCommand.java │ ├── connection │ │ ├── ConsumerConnectionSubCommand.java │ │ └── ProducerConnectionSubCommand.java │ ├── consumer │ │ ├── ConsumerProgressSubCommand.java │ │ ├── ConsumerStatusSubCommand.java │ │ ├── ConsumerSubCommand.java │ │ ├── DeleteSubscriptionGroupCommand.java │ │ ├── StartMonitoringSubCommand.java │ │ └── UpdateSubGroupSubCommand.java │ ├── message │ │ ├── CheckMsgSendRTCommand.java │ │ ├── ConsumeMessageCommand.java │ │ ├── DecodeMessageIdCommond.java │ │ ├── PrintMessageByQueueCommand.java │ │ ├── PrintMessageSubCommand.java │ │ ├── QueryMsgByIdSubCommand.java │ │ ├── QueryMsgByKeySubCommand.java │ │ ├── QueryMsgByOffsetSubCommand.java │ │ ├── QueryMsgByUniqueKeySubCommand.java │ │ └── SendMessageCommand.java │ ├── namesrv │ │ ├── DeleteKvConfigCommand.java │ │ ├── GetNamesrvConfigCommand.java │ │ ├── UpdateKvConfigCommand.java │ │ ├── UpdateNamesrvConfigCommand.java │ │ └── WipeWritePermSubCommand.java │ ├── offset │ │ ├── CloneGroupOffsetCommand.java │ │ ├── GetConsumerStatusCommand.java │ │ ├── ResetOffsetByTimeCommand.java │ │ └── ResetOffsetByTimeOldCommand.java │ ├── queue │ │ └── QueryConsumeQueueCommand.java │ ├── stats │ │ └── StatsAllSubCommand.java │ └── topic │ │ ├── AllocateMQSubCommand.java │ │ ├── DeleteTopicSubCommand.java │ │ ├── RebalanceResult.java │ │ ├── TopicClusterSubCommand.java │ │ ├── TopicListSubCommand.java │ │ ├── TopicRouteSubCommand.java │ │ ├── TopicStatusSubCommand.java │ │ ├── UpdateOrderConfCommand.java │ │ ├── UpdateTopicPermSubCommand.java │ │ └── UpdateTopicSubCommand.java │ └── monitor │ ├── DefaultMonitorListener.java │ ├── DeleteMsgsEvent.java │ ├── FailedMsgs.java │ ├── MonitorConfig.java │ ├── MonitorListener.java │ ├── MonitorService.java │ └── UndoneMsgs.java └── test └── java └── org └── apache └── rocketmq └── tools ├── admin └── DefaultMQAdminExtTest.java ├── command ├── CommandUtilTest.java ├── broker │ ├── BrokerConsumeStatsSubCommadTest.java │ ├── BrokerStatusSubCommandTest.java │ ├── CleanExpiredCQSubCommandTest.java │ ├── CleanUnusedTopicCommandTest.java │ ├── GetBrokerConfigCommandTest.java │ ├── SendMsgStatusCommandTest.java │ └── UpdateBrokerConfigSubCommandTest.java ├── connection │ ├── ConsumerConnectionSubCommandTest.java │ └── ProducerConnectionSubCommandTest.java ├── consumer │ ├── ConsumerProgressSubCommandTest.java │ └── ConsumerStatusSubCommandTest.java ├── message │ ├── ConsumeMessageCommandTest.java │ └── SendMessageCommandTest.java ├── namesrv │ ├── GetNamesrvConfigCommandTest.java │ └── WipeWritePermSubCommandTest.java ├── offset │ ├── GetConsumerStatusCommandTest.java │ ├── ResetOffsetByTimeCommandTest.java │ └── ResetOffsetByTimeOldCommandTest.java └── topic │ ├── AllocateMQSubCommandTest.java │ ├── DeleteTopicSubCommandTest.java │ ├── TopicClusterSubCommandTest.java │ ├── TopicRouteSubCommandTest.java │ ├── TopicStatusSubCommandTest.java │ ├── UpdateOrderConfCommandTest.java │ ├── UpdateTopicPermSubCommandTest.java │ └── UpdateTopicSubCommandTest.java └── monitor ├── DefaultMonitorListenerTest.java └── MonitorServiceTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | *dependency-reduced-pom.xml 2 | .classpath 3 | .project 4 | .settings/ 5 | target/ 6 | devenv 7 | *.log* 8 | *.iml 9 | .idea/ 10 | *.versionsBackup 11 | !NOTICE-BIN 12 | !LICENSE-BIN 13 | .DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Apache RocketMQ 源代码学习 2 | 3 | 添加注解说明,原理图等等 -------------------------------------------------------------------------------- /broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerGroupEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.broker.client; 18 | 19 | public enum ConsumerGroupEvent { 20 | 21 | /** 22 | * Some consumers in the group are changed. 23 | */ 24 | CHANGE, 25 | /** 26 | * The group of consumer is unregistered. 27 | */ 28 | UNREGISTER, 29 | /** 30 | * The group of consumer is registered. 31 | */ 32 | REGISTER 33 | } 34 | -------------------------------------------------------------------------------- /broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerIdsChangeListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.broker.client; 18 | 19 | public interface ConsumerIdsChangeListener { 20 | 21 | void handle(ConsumerGroupEvent event, String group, Object... args); 22 | } 23 | -------------------------------------------------------------------------------- /broker/src/main/java/org/apache/rocketmq/broker/latency/FutureTaskExt.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.broker.latency; 19 | 20 | import java.util.concurrent.Callable; 21 | import java.util.concurrent.FutureTask; 22 | 23 | public class FutureTaskExt extends FutureTask { 24 | private final Runnable runnable; 25 | 26 | public FutureTaskExt(final Callable callable) { 27 | super(callable); 28 | this.runnable = null; 29 | } 30 | 31 | public FutureTaskExt(final Runnable runnable, final V result) { 32 | super(runnable, result); 33 | this.runnable = runnable; 34 | } 35 | 36 | public Runnable getRunnable() { 37 | return runnable; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /broker/src/main/java/org/apache/rocketmq/broker/mqtrace/ConsumeMessageHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.broker.mqtrace; 18 | 19 | public interface ConsumeMessageHook { 20 | String hookName(); 21 | 22 | void consumeMessageBefore(final ConsumeMessageContext context); 23 | 24 | void consumeMessageAfter(final ConsumeMessageContext context); 25 | } 26 | -------------------------------------------------------------------------------- /broker/src/main/java/org/apache/rocketmq/broker/mqtrace/SendMessageHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.broker.mqtrace; 18 | 19 | public interface SendMessageHook { 20 | public String hookName(); 21 | 22 | public void sendMessageBefore(final SendMessageContext context); 23 | 24 | public void sendMessageAfter(final SendMessageContext context); 25 | } 26 | -------------------------------------------------------------------------------- /broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionStore.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.broker.transaction; 19 | 20 | import java.util.List; 21 | 22 | /** 23 | * This class will be removed in ther version 4.4.0, and {@link TransactionalMessageService} class is recommended. 24 | */ 25 | @Deprecated 26 | public interface TransactionStore { 27 | boolean open(); 28 | 29 | void close(); 30 | 31 | boolean put(final List trs); 32 | 33 | void remove(final List pks); 34 | 35 | List traverse(final long pk, final int nums); 36 | 37 | long totalRecords(); 38 | 39 | long minPK(); 40 | 41 | long maxPK(); 42 | } 43 | -------------------------------------------------------------------------------- /broker/src/main/java/org/apache/rocketmq/broker/util/PositiveAtomicCounter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.broker.util; 18 | 19 | import java.util.concurrent.atomic.AtomicInteger; 20 | 21 | public class PositiveAtomicCounter { 22 | private static final int MASK = 0x7FFFFFFF; 23 | private final AtomicInteger atom; 24 | 25 | 26 | public PositiveAtomicCounter() { 27 | atom = new AtomicInteger(0); 28 | } 29 | 30 | 31 | public final int incrementAndGet() { 32 | final int rt = atom.incrementAndGet(); 33 | return rt & MASK; 34 | } 35 | 36 | 37 | public int intValue() { 38 | return atom.intValue(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /broker/src/main/resources/transaction.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- Licensed to the Apache Software Foundation (ASF) under one 3 | -- or more contributor license agreements. See the NOTICE file 4 | -- distributed with this work for additional information 5 | -- regarding copyright ownership. The ASF licenses this file 6 | -- to you under the Apache License, Version 2.0 (the 7 | -- "License"); you may not use this file except in compliance 8 | -- with the License. You may obtain a copy of the License at 9 | -- 10 | -- http://www.apache.org/licenses/LICENSE-2.0 11 | -- 12 | -- Unless required by applicable law or agreed to in writing, 13 | -- software distributed under the License is distributed on an 14 | -- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | -- KIND, either express or implied. See the License for the 16 | -- specific language governing permissions and limitations 17 | -- under the License. 18 | -- 19 | CREATE TABLE t_transaction( 20 | offset NUMERIC(20) PRIMARY KEY, 21 | producerGroup VARCHAR(64) 22 | ) 23 | -------------------------------------------------------------------------------- /broker/src/test/java/org/apache/rocketmq/broker/util/LogTransactionalMessageCheckListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.broker.util; 18 | 19 | import org.apache.rocketmq.broker.transaction.AbstractTransactionalMessageCheckListener; 20 | import org.apache.rocketmq.common.message.MessageExt; 21 | 22 | public class LogTransactionalMessageCheckListener extends AbstractTransactionalMessageCheckListener { 23 | 24 | @Override 25 | public void resolveDiscardMsg(MessageExt msgExt) { 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /broker/src/test/resources/META-INF/service/org.apache.rocketmq.broker.transaction.AbstractTransactionalMessageCheckListener: -------------------------------------------------------------------------------- 1 | org.apache.rocketmq.broker.util.LogTransactionalMessageCheckListener -------------------------------------------------------------------------------- /broker/src/test/resources/META-INF/service/org.apache.rocketmq.broker.transaction.TransactionalMessageService: -------------------------------------------------------------------------------- 1 | org.apache.rocketmq.broker.util.TransactionalMessageServiceImpl -------------------------------------------------------------------------------- /broker/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | %d{yyy-MM-dd HH\:mm\:ss,GMT+8} %p %t - %m%n 24 | UTF-8 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/rocketmq/client/admin/MQAdminExtInner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.client.admin; 18 | 19 | public interface MQAdminExtInner { 20 | 21 | } 22 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/rocketmq/client/common/ClientErrorCode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.client.common; 19 | 20 | public class ClientErrorCode { 21 | public static final int CONNECT_BROKER_EXCEPTION = 10001; 22 | public static final int ACCESS_BROKER_TIMEOUT = 10002; 23 | public static final int BROKER_NOT_EXIST_EXCEPTION = 10003; 24 | public static final int NO_NAME_SERVER_EXCEPTION = 10004; 25 | public static final int NOT_FOUND_TOPIC_EXCEPTION = 10005; 26 | } -------------------------------------------------------------------------------- /client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.client.consumer; 18 | 19 | /** 20 | * Async message pulling interface 21 | */ 22 | public interface PullCallback { 23 | void onSuccess(final PullResult pullResult); 24 | 25 | void onException(final Throwable e); 26 | } 27 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/rocketmq/client/consumer/PullStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.client.consumer; 18 | 19 | public enum PullStatus { 20 | /** 21 | * Founded 22 | */ 23 | FOUND, 24 | /** 25 | * No new message can be pull 26 | */ 27 | NO_NEW_MSG, 28 | /** 29 | * Filtering results can not match 30 | */ 31 | NO_MATCHED_MSG, 32 | /** 33 | * Illegal offset,may be too big or too small 34 | */ 35 | OFFSET_ILLEGAL 36 | } 37 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/rocketmq/client/consumer/PullTaskCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.client.consumer; 18 | 19 | import org.apache.rocketmq.common.message.MessageQueue; 20 | 21 | public interface PullTaskCallback { 22 | void doPullTask(final MessageQueue mq, final PullTaskContext context); 23 | } 24 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.client.consumer.listener; 18 | 19 | public enum ConsumeConcurrentlyStatus { 20 | /** 21 | * Success consumption 22 | */ 23 | CONSUME_SUCCESS, 24 | /** 25 | * Failure consumption,later try to consume 26 | */ 27 | RECONSUME_LATER; 28 | } 29 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.client.consumer.listener; 18 | 19 | public enum ConsumeOrderlyStatus { 20 | /** 21 | * Success consumption 22 | */ 23 | SUCCESS, 24 | /** 25 | * Rollback consumption(only for binlog consumption) 26 | */ 27 | @Deprecated 28 | ROLLBACK, 29 | /** 30 | * Commit offset(only for binlog consumption) 31 | */ 32 | @Deprecated 33 | COMMIT, 34 | /** 35 | * Suspend current queue a moment 36 | */ 37 | SUSPEND_CURRENT_QUEUE_A_MOMENT; 38 | } 39 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeReturnType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.client.consumer.listener; 19 | 20 | public enum ConsumeReturnType { 21 | /** 22 | * consume return success 23 | */ 24 | SUCCESS, 25 | /** 26 | * consume timeout ,even if success 27 | */ 28 | TIME_OUT, 29 | /** 30 | * consume throw exception 31 | */ 32 | EXCEPTION, 33 | /** 34 | * consume return null 35 | */ 36 | RETURNNULL, 37 | /** 38 | * consume return failed 39 | */ 40 | FAILED 41 | } 42 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.client.consumer.listener; 18 | 19 | /** 20 | * A MessageListener object is used to receive asynchronously delivered messages. 21 | */ 22 | public interface MessageListener { 23 | } 24 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/rocketmq/client/consumer/store/ReadOffsetType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.client.consumer.store; 18 | 19 | public enum ReadOffsetType { 20 | /** 21 | * From memory 22 | */ 23 | READ_FROM_MEMORY, 24 | /** 25 | * From storage 26 | */ 27 | READ_FROM_STORE, 28 | /** 29 | * From memory,then from storage 30 | */ 31 | MEMORY_FIRST_THEN_STORE; 32 | } 33 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.client.hook; 19 | 20 | import org.apache.rocketmq.client.exception.MQClientException; 21 | 22 | public interface CheckForbiddenHook { 23 | String hookName(); 24 | 25 | void checkForbidden(final CheckForbiddenContext context) throws MQClientException; 26 | } 27 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/rocketmq/client/hook/ConsumeMessageHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.client.hook; 18 | 19 | public interface ConsumeMessageHook { 20 | String hookName(); 21 | 22 | void consumeMessageBefore(final ConsumeMessageContext context); 23 | 24 | void consumeMessageAfter(final ConsumeMessageContext context); 25 | } 26 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.client.hook; 18 | 19 | public interface FilterMessageHook { 20 | String hookName(); 21 | 22 | void filterMessage(final FilterMessageContext context); 23 | } 24 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/rocketmq/client/hook/SendMessageHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.client.hook; 18 | 19 | public interface SendMessageHook { 20 | String hookName(); 21 | 22 | void sendMessageBefore(final SendMessageContext context); 23 | 24 | void sendMessageAfter(final SendMessageContext context); 25 | } 26 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/rocketmq/client/impl/CommunicationMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.client.impl; 18 | 19 | public enum CommunicationMode { 20 | SYNC, 21 | ASYNC, 22 | ONEWAY, 23 | } 24 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionExecuter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.client.producer; 18 | 19 | import org.apache.rocketmq.common.message.Message; 20 | 21 | /** 22 | * This interface will be removed in the version 5.0.0, interface {@link TransactionListener} is recommended. 23 | */ 24 | @Deprecated 25 | public interface LocalTransactionExecuter { 26 | LocalTransactionState executeLocalTransactionBranch(final Message msg, final Object arg); 27 | } 28 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.client.producer; 18 | 19 | public enum LocalTransactionState { 20 | COMMIT_MESSAGE, 21 | ROLLBACK_MESSAGE, 22 | UNKNOW, 23 | } 24 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/rocketmq/client/producer/MessageQueueSelector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.client.producer; 18 | 19 | import java.util.List; 20 | import org.apache.rocketmq.common.message.Message; 21 | import org.apache.rocketmq.common.message.MessageQueue; 22 | 23 | public interface MessageQueueSelector { 24 | MessageQueue select(final List mqs, final Message msg, final Object arg); 25 | } 26 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/rocketmq/client/producer/SendCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.client.producer; 18 | 19 | public interface SendCallback { 20 | void onSuccess(final SendResult sendResult); 21 | 22 | void onException(final Throwable e); 23 | } 24 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/rocketmq/client/producer/SendStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.client.producer; 18 | 19 | public enum SendStatus { 20 | SEND_OK, 21 | FLUSH_DISK_TIMEOUT, 22 | FLUSH_SLAVE_TIMEOUT, 23 | SLAVE_NOT_AVAILABLE, 24 | } 25 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/rocketmq/client/producer/TransactionCheckListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.client.producer; 18 | 19 | import org.apache.rocketmq.common.message.MessageExt; 20 | /** 21 | * This interface will be removed in the version 5.0.0, interface {@link TransactionListener} is recommended. 22 | */ 23 | @Deprecated 24 | public interface TransactionCheckListener { 25 | LocalTransactionState checkLocalTransactionState(final MessageExt msg); 26 | } 27 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/rocketmq/client/producer/TransactionSendResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.client.producer; 18 | 19 | public class TransactionSendResult extends SendResult { 20 | private LocalTransactionState localTransactionState; 21 | 22 | public TransactionSendResult() { 23 | } 24 | 25 | public LocalTransactionState getLocalTransactionState() { 26 | return localTransactionState; 27 | } 28 | 29 | public void setLocalTransactionState(LocalTransactionState localTransactionState) { 30 | this.localTransactionState = localTransactionState; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /client/src/test/java/org/apache/rocketmq/client/common/ThreadLocalIndexTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.client.common; 18 | 19 | import org.junit.Test; 20 | 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | 23 | public class ThreadLocalIndexTest { 24 | @Test 25 | public void testGetAndIncrement() throws Exception { 26 | ThreadLocalIndex localIndex = new ThreadLocalIndex(); 27 | int initialVal = localIndex.getAndIncrement(); 28 | 29 | assertThat(localIndex.getAndIncrement()).isEqualTo(initialVal + 1); 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/Pair.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.common; 18 | 19 | public class Pair { 20 | private T1 object1; 21 | private T2 object2; 22 | 23 | public Pair(T1 object1, T2 object2) { 24 | this.object1 = object1; 25 | this.object2 = object2; 26 | } 27 | 28 | public T1 getObject1() { 29 | return object1; 30 | } 31 | 32 | public void setObject1(T1 object1) { 33 | this.object1 = object1; 34 | } 35 | 36 | public T2 getObject2() { 37 | return object2; 38 | } 39 | 40 | public void setObject2(T2 object2) { 41 | this.object2 = object2; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/ServiceState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.common; 18 | 19 | public enum ServiceState { 20 | /** 21 | * Service just created,not start 22 | */ 23 | CREATE_JUST, 24 | /** 25 | * Service Running 26 | */ 27 | RUNNING, 28 | /** 29 | * Service shutdown 30 | */ 31 | SHUTDOWN_ALREADY, 32 | /** 33 | * Service Start failure 34 | */ 35 | START_FAILED; 36 | } 37 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/SystemClock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.common; 18 | 19 | public class SystemClock { 20 | public long now() { 21 | return System.currentTimeMillis(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/TopicFilterType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.common; 18 | 19 | public enum TopicFilterType { 20 | SINGLE_TAG, 21 | MULTI_TAG 22 | 23 | } 24 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/annotation/ImportantField.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.common.annotation; 18 | 19 | import java.lang.annotation.Documented; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | @Documented 26 | @Retention(RetentionPolicy.RUNTIME) 27 | @Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE}) 28 | public @interface ImportantField { 29 | } 30 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/consistenthash/HashFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.common.consistenthash; 18 | 19 | /** 20 | * Hash String to long value 21 | */ 22 | public interface HashFunction { 23 | long hash(String key); 24 | } 25 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/consistenthash/Node.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.common.consistenthash; 18 | 19 | /** 20 | * Represent a node which should be mapped to a hash ring 21 | */ 22 | public interface Node { 23 | /** 24 | * @return the key which will be used for hash mapping 25 | */ 26 | String getKey(); 27 | } 28 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/constant/DBMsgConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.common.constant; 19 | 20 | public class DBMsgConstants { 21 | public static final int MAX_BODY_SIZE = 64 * 1024 * 1204; //64KB 22 | } 23 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/consumer/ConsumeFromWhere.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.common.consumer; 18 | 19 | public enum ConsumeFromWhere { 20 | CONSUME_FROM_LAST_OFFSET, 21 | 22 | @Deprecated 23 | CONSUME_FROM_LAST_OFFSET_AND_FROM_MIN_WHEN_BOOT_FIRST, 24 | @Deprecated 25 | CONSUME_FROM_MIN_OFFSET, 26 | @Deprecated 27 | CONSUME_FROM_MAX_OFFSET, 28 | CONSUME_FROM_FIRST_OFFSET, 29 | CONSUME_FROM_TIMESTAMP, 30 | } 31 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/filter/FilterContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.common.filter; 19 | 20 | public class FilterContext { 21 | private String consumerGroup; 22 | 23 | public String getConsumerGroup() { 24 | return consumerGroup; 25 | } 26 | 27 | public void setConsumerGroup(String consumerGroup) { 28 | this.consumerGroup = consumerGroup; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/filter/MessageFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.common.filter; 19 | 20 | import org.apache.rocketmq.common.message.MessageExt; 21 | 22 | public interface MessageFilter { 23 | boolean match(final MessageExt msg, final FilterContext context); 24 | } 25 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/filter/impl/Op.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.common.filter.impl; 19 | 20 | public abstract class Op { 21 | 22 | private String symbol; 23 | 24 | protected Op(String symbol) { 25 | this.symbol = symbol; 26 | } 27 | 28 | public String getSymbol() { 29 | return symbol; 30 | } 31 | 32 | public String toString() { 33 | return symbol; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/filter/impl/Operand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.common.filter.impl; 19 | 20 | public class Operand extends Op { 21 | 22 | public Operand(String symbol) { 23 | super(symbol); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/filter/impl/Type.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.common.filter.impl; 19 | 20 | public enum Type { 21 | NULL, 22 | OPERAND, 23 | OPERATOR, 24 | PARENTHESIS, 25 | SEPAERATOR; 26 | } 27 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/hook/FilterCheckHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.common.hook; 19 | 20 | import java.nio.ByteBuffer; 21 | 22 | public interface FilterCheckHook { 23 | public String hookName(); 24 | 25 | public boolean isFilterMatched(final boolean isUnitMode, final ByteBuffer byteBuffer); 26 | } 27 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/message/MessageType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.common.message; 19 | 20 | public enum MessageType { 21 | Normal_Msg, 22 | Trans_Msg_Half, 23 | Trans_msg_Commit, 24 | Delay_Msg, 25 | } 26 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.common.namesrv; 19 | 20 | public class NamesrvUtil { 21 | public static final String NAMESPACE_ORDER_TOPIC_CONFIG = "ORDER_TOPIC_CONFIG"; 22 | } 23 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/protocol/body/CMResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.common.protocol.body; 19 | 20 | public enum CMResult { 21 | CR_SUCCESS, 22 | CR_LATER, 23 | CR_ROLLBACK, 24 | CR_COMMIT, 25 | CR_THROW_EXCEPTION, 26 | CR_RETURN_NULL, 27 | } 28 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/protocol/body/GroupList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.common.protocol.body; 18 | 19 | import java.util.HashSet; 20 | import org.apache.rocketmq.remoting.protocol.RemotingSerializable; 21 | 22 | public class GroupList extends RemotingSerializable { 23 | private HashSet groupList = new HashSet(); 24 | 25 | public HashSet getGroupList() { 26 | return groupList; 27 | } 28 | 29 | public void setGroupList(HashSet groupList) { 30 | this.groupList = groupList; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/protocol/body/KVTable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.common.protocol.body; 18 | 19 | import java.util.HashMap; 20 | import org.apache.rocketmq.remoting.protocol.RemotingSerializable; 21 | 22 | public class KVTable extends RemotingSerializable { 23 | private HashMap table = new HashMap(); 24 | 25 | public HashMap getTable() { 26 | return table; 27 | } 28 | 29 | public void setTable(HashMap table) { 30 | this.table = table; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/protocol/body/ProducerConnection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.common.protocol.body; 19 | 20 | import java.util.HashSet; 21 | import org.apache.rocketmq.remoting.protocol.RemotingSerializable; 22 | 23 | public class ProducerConnection extends RemotingSerializable { 24 | private HashSet connectionSet = new HashSet(); 25 | 26 | public HashSet getConnectionSet() { 27 | return connectionSet; 28 | } 29 | 30 | public void setConnectionSet(HashSet connectionSet) { 31 | this.connectionSet = connectionSet; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryCorrectionOffsetBody.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.common.protocol.body; 18 | 19 | import java.util.HashMap; 20 | import java.util.Map; 21 | import org.apache.rocketmq.remoting.protocol.RemotingSerializable; 22 | 23 | public class QueryCorrectionOffsetBody extends RemotingSerializable { 24 | private Map correctionOffsets = new HashMap(); 25 | 26 | public Map getCorrectionOffsets() { 27 | return correctionOffsets; 28 | } 29 | 30 | public void setCorrectionOffsets(Map correctionOffsets) { 31 | this.correctionOffsets = correctionOffsets; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/protocol/body/ResetOffsetBody.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.common.protocol.body; 19 | 20 | import java.util.Map; 21 | import org.apache.rocketmq.common.message.MessageQueue; 22 | import org.apache.rocketmq.remoting.protocol.RemotingSerializable; 23 | 24 | public class ResetOffsetBody extends RemotingSerializable { 25 | private Map offsetTable; 26 | 27 | public Map getOffsetTable() { 28 | return offsetTable; 29 | } 30 | 31 | public void setOffsetTable(Map offsetTable) { 32 | this.offsetTable = offsetTable; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/protocol/body/ResetOffsetBodyForC.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.common.protocol.body; 19 | 20 | import java.util.List; 21 | import org.apache.rocketmq.common.message.MessageQueueForC; 22 | import org.apache.rocketmq.remoting.protocol.RemotingSerializable; 23 | 24 | public class ResetOffsetBodyForC extends RemotingSerializable { 25 | 26 | private List offsetTable; 27 | 28 | public List getOffsetTable() { 29 | return offsetTable; 30 | } 31 | 32 | public void setOffsetTable(List offsetTable) { 33 | this.offsetTable = offsetTable; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionResponseHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * $Id: EndTransactionResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $ 20 | */ 21 | package org.apache.rocketmq.common.protocol.header; 22 | 23 | import org.apache.rocketmq.remoting.CommandCustomHeader; 24 | import org.apache.rocketmq.remoting.exception.RemotingCommandException; 25 | 26 | public class EndTransactionResponseHeader implements CommandCustomHeader { 27 | 28 | @Override 29 | public void checkFields() throws RemotingCommandException { 30 | 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * $Id: GetAllTopicConfigResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $ 20 | */ 21 | package org.apache.rocketmq.common.protocol.header; 22 | 23 | import org.apache.rocketmq.remoting.CommandCustomHeader; 24 | import org.apache.rocketmq.remoting.exception.RemotingCommandException; 25 | 26 | public class GetAllTopicConfigResponseHeader implements CommandCustomHeader { 27 | 28 | @Override 29 | public void checkFields() throws RemotingCommandException { 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseBody.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.common.protocol.header; 19 | 20 | import java.util.List; 21 | import org.apache.rocketmq.remoting.protocol.RemotingSerializable; 22 | 23 | public class GetConsumerListByGroupResponseBody extends RemotingSerializable { 24 | private List consumerIdList; 25 | 26 | public List getConsumerIdList() { 27 | return consumerIdList; 28 | } 29 | 30 | public void setConsumerIdList(List consumerIdList) { 31 | this.consumerIdList = consumerIdList; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.common.protocol.header; 19 | 20 | import org.apache.rocketmq.remoting.CommandCustomHeader; 21 | import org.apache.rocketmq.remoting.exception.RemotingCommandException; 22 | 23 | public class GetConsumerListByGroupResponseHeader implements CommandCustomHeader { 24 | 25 | @Override 26 | public void checkFields() throws RemotingCommandException { 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.common.protocol.header; 19 | 20 | import org.apache.rocketmq.remoting.CommandCustomHeader; 21 | import org.apache.rocketmq.remoting.exception.RemotingCommandException; 22 | 23 | public class UnregisterClientResponseHeader implements CommandCustomHeader { 24 | 25 | @Override 26 | public void checkFields() throws RemotingCommandException { 27 | 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * $Id: UpdateConsumerOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $ 20 | */ 21 | package org.apache.rocketmq.common.protocol.header; 22 | 23 | import org.apache.rocketmq.remoting.CommandCustomHeader; 24 | import org.apache.rocketmq.remoting.exception.RemotingCommandException; 25 | 26 | public class UpdateConsumerOffsetResponseHeader implements CommandCustomHeader { 27 | @Override 28 | public void checkFields() throws RemotingCommandException { 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageResponseHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * $Id: ViewMessageResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $ 20 | */ 21 | package org.apache.rocketmq.common.protocol.header; 22 | 23 | import org.apache.rocketmq.remoting.CommandCustomHeader; 24 | import org.apache.rocketmq.remoting.exception.RemotingCommandException; 25 | 26 | public class ViewMessageResponseHeader implements CommandCustomHeader { 27 | 28 | @Override 29 | public void checkFields() throws RemotingCommandException { 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumeType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * $Id: ConsumeType.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $ 20 | */ 21 | package org.apache.rocketmq.common.protocol.heartbeat; 22 | 23 | public enum ConsumeType { 24 | 25 | CONSUME_ACTIVELY("PULL"), 26 | 27 | CONSUME_PASSIVELY("PUSH"); 28 | 29 | private String typeCN; 30 | 31 | ConsumeType(String typeCN) { 32 | this.typeCN = typeCN; 33 | } 34 | 35 | public String getTypeCN() { 36 | return typeCN; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MessageModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * $Id: MessageModel.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $ 20 | */ 21 | package org.apache.rocketmq.common.protocol.heartbeat; 22 | 23 | /** 24 | * Message model 25 | */ 26 | public enum MessageModel { 27 | /** 28 | * broadcast 29 | */ 30 | BROADCASTING("BROADCASTING"), 31 | /** 32 | * clustering 33 | */ 34 | CLUSTERING("CLUSTERING"); 35 | 36 | private String modeCN; 37 | 38 | MessageModel(String modeCN) { 39 | this.modeCN = modeCN; 40 | } 41 | 42 | public String getModeCN() { 43 | return modeCN; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ProducerData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * $Id: ProducerData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $ 20 | */ 21 | package org.apache.rocketmq.common.protocol.heartbeat; 22 | 23 | public class ProducerData { 24 | private String groupName; 25 | 26 | public String getGroupName() { 27 | return groupName; 28 | } 29 | 30 | public void setGroupName(String groupName) { 31 | this.groupName = groupName; 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return "ProducerData [groupName=" + groupName + "]"; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/running/RunningStats.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.common.running; 18 | 19 | public enum RunningStats { 20 | commitLogMaxOffset, 21 | commitLogMinOffset, 22 | commitLogDiskRatio, 23 | consumeQueueDiskRatio, 24 | scheduleMessageOffset, 25 | } 26 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/rocketmq/common/utils/ChannelUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.common.utils; 19 | 20 | import io.netty.channel.Channel; 21 | import java.net.InetAddress; 22 | import java.net.InetSocketAddress; 23 | 24 | public class ChannelUtil { 25 | public static String getRemoteIp(Channel channel) { 26 | InetSocketAddress inetSocketAddress = (InetSocketAddress) channel.remoteAddress(); 27 | if (inetSocketAddress == null) { 28 | return ""; 29 | } 30 | final InetAddress inetAddr = inetSocketAddress.getAddress(); 31 | return inetAddr != null ? inetAddr.getHostAddress() : inetSocketAddress.getHostName(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /common/src/test/java/org/apache/rocketmq/common/BrokerConfigTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.common; 18 | 19 | import org.junit.Test; 20 | 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | 23 | public class BrokerConfigTest { 24 | 25 | @Test 26 | public void testConsumerFallBehindThresholdOverflow() { 27 | long expect = 1024L * 1024 * 1024 * 16; 28 | assertThat(new BrokerConfig().getConsumerFallbehindThreshold()).isEqualTo(expect); 29 | } 30 | } -------------------------------------------------------------------------------- /common/src/test/java/org/apache/rocketmq/common/RemotingUtilTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.common; 18 | 19 | import org.apache.rocketmq.remoting.common.RemotingUtil; 20 | import org.junit.Test; 21 | 22 | import static org.assertj.core.api.Assertions.assertThat; 23 | 24 | public class RemotingUtilTest { 25 | @Test 26 | public void testGetLocalAddress() throws Exception { 27 | String localAddress = RemotingUtil.getLocalAddress(); 28 | assertThat(localAddress).isNotNull(); 29 | assertThat(localAddress.length()).isGreaterThan(0); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /distribution/NOTICE-BIN: -------------------------------------------------------------------------------- 1 | Apache RocketMQ 2 | Copyright 2016-2017 The Apache Software Foundation 3 | 4 | This product includes software developed at 5 | The Apache Software Foundation (http://www.apache.org/). 6 | 7 | ------ 8 | This product has a bundle netty: 9 | The Netty Project 10 | ================= 11 | 12 | Please visit the Netty web site for more information: 13 | 14 | * http://netty.io/ 15 | 16 | Copyright 2014 The Netty Project 17 | 18 | The Netty Project licenses this file to you under the Apache License, 19 | version 2.0 (the "License"); you may not use this file except in compliance 20 | with the License. You may obtain a copy of the License at: 21 | 22 | http://www.apache.org/licenses/LICENSE-2.0 23 | 24 | Unless required by applicable law or agreed to in writing, software 25 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 26 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 27 | License for the specific language governing permissions and limitations 28 | under the License. 29 | 30 | Also, please refer to each LICENSE..txt file, which is located in 31 | the 'license' directory of the distribution file, for the license terms of the 32 | components that this product depends on. 33 | 34 | ------ 35 | This product has a bundle commons-lang, which includes software from the Spring Framework, 36 | under the Apache License 2.0 (see: StringUtils.containsWhitespace()) -------------------------------------------------------------------------------- /distribution/benchmark/consumer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Licensed to the Apache Software Foundation (ASF) under one or more 4 | # contributor license agreements. See the NOTICE file distributed with 5 | # this work for additional information regarding copyright ownership. 6 | # The ASF licenses this file to You under the Apache License, Version 2.0 7 | # (the "License"); you may not use this file except in compliance with 8 | # the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | 18 | sh ./runclass.sh org.apache.rocketmq.example.benchmark.Consumer $@ & 19 | -------------------------------------------------------------------------------- /distribution/benchmark/producer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Licensed to the Apache Software Foundation (ASF) under one or more 4 | # contributor license agreements. See the NOTICE file distributed with 5 | # this work for additional information regarding copyright ownership. 6 | # The ASF licenses this file to You under the Apache License, Version 2.0 7 | # (the "License"); you may not use this file except in compliance with 8 | # the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | 18 | sh ./runclass.sh -Dorg.apache.rocketmq.client.sendSmartMsg=true org.apache.rocketmq.example.benchmark.Producer $@ & 19 | -------------------------------------------------------------------------------- /distribution/benchmark/tproducer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Licensed to the Apache Software Foundation (ASF) under one or more 4 | # contributor license agreements. See the NOTICE file distributed with 5 | # this work for additional information regarding copyright ownership. 6 | # The ASF licenses this file to You under the Apache License, Version 2.0 7 | # (the "License"); you may not use this file except in compliance with 8 | # the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | 18 | sh ./runclass.sh org.apache.rocketmq.example.benchmark.TransactionProducer $@ 19 | -------------------------------------------------------------------------------- /distribution/bin/README.md: -------------------------------------------------------------------------------- 1 | ### Operating system tuning 2 | Before deploying broker servers, it's highly recommended to run **os.sh**, which is to optimize your operating system for better performance. 3 | 4 | ## Notice 5 | ### os.sh should be executed only once with root permission. 6 | ### os.sh parameter settings are for reference purpose only. You can tune them according to your target host configurations. 7 | 8 | 9 | ### Start broker 10 | * Unix platform 11 | 12 | `nohup sh mqbroker &` 13 | 14 | ### Shutdown broker 15 | sh mqshutdown broker 16 | 17 | ### Start Nameserver 18 | * Unix platform 19 | 20 | `nohup sh mqnamesrv &` 21 | 22 | ### Shutdown Nameserver 23 | sh mqshutdown namesrv 24 | 25 | ### Update or create Topic 26 | sh mqadmin updateTopic -b 127.0.0.1:10911 -t TopicA 27 | 28 | ### Update or create subscription group 29 | sh mqadmin updateSubGroup -b 127.0.0.1:10911 -g SubGroupA -------------------------------------------------------------------------------- /distribution/bin/cleancache.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Licensed to the Apache Software Foundation (ASF) under one or more 4 | # contributor license agreements. See the NOTICE file distributed with 5 | # this work for additional information regarding copyright ownership. 6 | # The ASF licenses this file to You under the Apache License, Version 2.0 7 | # (the "License"); you may not use this file except in compliance with 8 | # the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | 18 | export PATH=$PATH:/sbin 19 | 20 | sysctl -w vm.drop_caches=3 21 | -------------------------------------------------------------------------------- /distribution/bin/cleancache.v1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Licensed to the Apache Software Foundation (ASF) under one or more 4 | # contributor license agreements. See the NOTICE file distributed with 5 | # this work for additional information regarding copyright ownership. 6 | # The ASF licenses this file to You under the Apache License, Version 2.0 7 | # (the "License"); you may not use this file except in compliance with 8 | # the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | 18 | export PATH=$PATH:/sbin 19 | 20 | # 21 | # GB 22 | # 23 | function changeFreeCache() 24 | { 25 | EXTRA=$1 26 | MIN=$2 27 | sysctl -w vm.extra_free_kbytes=${EXTRA}000000 28 | sysctl -w vm.min_free_kbytes=${MIN}000000 29 | } 30 | 31 | 32 | if [ $# -ne 1 ] 33 | then 34 | echo "Usage: $0 freecache(GB)" 35 | echo "Example: $0 15" 36 | exit 37 | fi 38 | 39 | changeFreeCache 3 $1 40 | changeFreeCache 3 1 41 | -------------------------------------------------------------------------------- /distribution/bin/mqadmin.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem Licensed to the Apache Software Foundation (ASF) under one or more 3 | rem contributor license agreements. See the NOTICE file distributed with 4 | rem this work for additional information regarding copyright ownership. 5 | rem The ASF licenses this file to You under the Apache License, Version 2.0 6 | rem (the "License"); you may not use this file except in compliance with 7 | rem the License. You may obtain a copy of the License at 8 | rem 9 | rem http://www.apache.org/licenses/LICENSE-2.0 10 | rem 11 | rem Unless required by applicable law or agreed to in writing, software 12 | rem distributed under the License is distributed on an "AS IS" BASIS, 13 | rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | rem See the License for the specific language governing permissions and 15 | rem limitations under the License. 16 | 17 | if not exist "%ROCKETMQ_HOME%\bin\tools.cmd" echo Please set the ROCKETMQ_HOME variable in your environment! & EXIT /B 1 18 | call "%ROCKETMQ_HOME%\bin\tools.cmd" org.apache.rocketmq.tools.command.MQAdminStartup %* -------------------------------------------------------------------------------- /distribution/bin/mqbroker.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem Licensed to the Apache Software Foundation (ASF) under one or more 3 | rem contributor license agreements. See the NOTICE file distributed with 4 | rem this work for additional information regarding copyright ownership. 5 | rem The ASF licenses this file to You under the Apache License, Version 2.0 6 | rem (the "License"); you may not use this file except in compliance with 7 | rem the License. You may obtain a copy of the License at 8 | rem 9 | rem http://www.apache.org/licenses/LICENSE-2.0 10 | rem 11 | rem Unless required by applicable law or agreed to in writing, software 12 | rem distributed under the License is distributed on an "AS IS" BASIS, 13 | rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | rem See the License for the specific language governing permissions and 15 | rem limitations under the License. 16 | 17 | if not exist "%ROCKETMQ_HOME%\bin\runbroker.cmd" echo Please set the ROCKETMQ_HOME variable in your environment! & EXIT /B 1 18 | 19 | call "%ROCKETMQ_HOME%\bin\runbroker.cmd" org.apache.rocketmq.broker.BrokerStartup %* 20 | 21 | IF %ERRORLEVEL% EQU 0 ( 22 | ECHO "Broker starts OK" 23 | ) -------------------------------------------------------------------------------- /distribution/bin/mqnamesrv.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem Licensed to the Apache Software Foundation (ASF) under one or more 3 | rem contributor license agreements. See the NOTICE file distributed with 4 | rem this work for additional information regarding copyright ownership. 5 | rem The ASF licenses this file to You under the Apache License, Version 2.0 6 | rem (the "License"); you may not use this file except in compliance with 7 | rem the License. You may obtain a copy of the License at 8 | rem 9 | rem http://www.apache.org/licenses/LICENSE-2.0 10 | rem 11 | rem Unless required by applicable law or agreed to in writing, software 12 | rem distributed under the License is distributed on an "AS IS" BASIS, 13 | rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | rem See the License for the specific language governing permissions and 15 | rem limitations under the License. 16 | 17 | if not exist "%ROCKETMQ_HOME%\bin\runserver.cmd" echo Please set the ROCKETMQ_HOME variable in your environment! & EXIT /B 1 18 | 19 | call "%ROCKETMQ_HOME%\bin\runserver.cmd" org.apache.rocketmq.namesrv.NamesrvStartup %* 20 | 21 | IF %ERRORLEVEL% EQU 0 ( 22 | ECHO "Namesrv starts OK" 23 | ) -------------------------------------------------------------------------------- /distribution/bin/mqshutdown.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem Licensed to the Apache Software Foundation (ASF) under one or more 3 | rem contributor license agreements. See the NOTICE file distributed with 4 | rem this work for additional information regarding copyright ownership. 5 | rem The ASF licenses this file to You under the Apache License, Version 2.0 6 | rem (the "License"); you may not use this file except in compliance with 7 | rem the License. You may obtain a copy of the License at 8 | rem 9 | rem http://www.apache.org/licenses/LICENSE-2.0 10 | rem 11 | rem Unless required by applicable law or agreed to in writing, software 12 | rem distributed under the License is distributed on an "AS IS" BASIS, 13 | rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | rem See the License for the specific language governing permissions and 15 | rem limitations under the License. 16 | 17 | if not exist "%JAVA_HOME%\bin\jps.exe" echo Please set the JAVA_HOME variable in your environment, We need java(x64)! & EXIT /B 1 18 | 19 | setlocal 20 | 21 | set "PATH=%JAVA_HOME%\bin;%PATH%" 22 | 23 | if /I "%1" == "broker" ( 24 | echo killing broker 25 | for /f "tokens=1" %%i in ('jps -m ^| find "BrokerStartup"') do ( taskkill /F /PID %%i ) 26 | echo Done! 27 | ) else if /I "%1" == "namesrv" ( 28 | echo killing name server 29 | 30 | for /f "tokens=1" %%i in ('jps -m ^| find "NamesrvStartup"') do ( taskkill /F /PID %%i ) 31 | 32 | echo Done! 33 | ) else ( 34 | echo Unknown role to kill, please specify broker or namesrv 35 | ) -------------------------------------------------------------------------------- /distribution/bin/play.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem Licensed to the Apache Software Foundation (ASF) under one or more 3 | rem contributor license agreements. See the NOTICE file distributed with 4 | rem this work for additional information regarding copyright ownership. 5 | rem The ASF licenses this file to You under the Apache License, Version 2.0 6 | rem (the "License"); you may not use this file except in compliance with 7 | rem the License. You may obtain a copy of the License at 8 | rem 9 | rem http://www.apache.org/licenses/LICENSE-2.0 10 | rem 11 | rem Unless required by applicable law or agreed to in writing, software 12 | rem distributed under the License is distributed on an "AS IS" BASIS, 13 | rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | rem See the License for the specific language governing permissions and 15 | rem limitations under the License. 16 | 17 | START /B mqnamesrv > ns.log 2>&1 18 | IF %ERRORLEVEL% NEQ 0 ( 19 | echo "Failed to start name server. Please check ns.log" 20 | EXIT /B 1 21 | ) 22 | 23 | START /B mqbroker -n localhost:9876 > bk.log 2>&1 24 | 25 | IF %ERRORLEVEL% NEQ 0 ( 26 | ECHO "Failed to start broker. Please check bk.log" 27 | EXIT /B 1 28 | ) 29 | 30 | echo "Start Name Server and Broker Successfully." -------------------------------------------------------------------------------- /distribution/bin/play.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Licensed to the Apache Software Foundation (ASF) under one or more 4 | # contributor license agreements. See the NOTICE file distributed with 5 | # this work for additional information regarding copyright ownership. 6 | # The ASF licenses this file to You under the Apache License, Version 2.0 7 | # (the "License"); you may not use this file except in compliance with 8 | # the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | 18 | # 19 | # Name Server 20 | # 21 | nohup sh mqnamesrv > ns.log 2>&1 & 22 | 23 | # 24 | # Service Addr 25 | # 26 | ADDR=`hostname -i`:9876 27 | 28 | # 29 | # Broker 30 | # 31 | nohup sh mqbroker -n ${ADDR} > bk.log 2>&1 & 32 | 33 | echo "Start Name Server and Broker Successfully, ${ADDR}" 34 | -------------------------------------------------------------------------------- /distribution/bin/setcache.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Licensed to the Apache Software Foundation (ASF) under one or more 4 | # contributor license agreements. See the NOTICE file distributed with 5 | # this work for additional information regarding copyright ownership. 6 | # The ASF licenses this file to You under the Apache License, Version 2.0 7 | # (the "License"); you may not use this file except in compliance with 8 | # the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | 18 | export PATH=$PATH:/sbin 19 | 20 | # 21 | # GB 22 | # 23 | function changeFreeCache() 24 | { 25 | EXTRA=$1 26 | MIN=$2 27 | sysctl -w vm.extra_free_kbytes=${EXTRA}000000 28 | sysctl -w vm.min_free_kbytes=${MIN}000000 29 | sysctl -w vm.swappiness=0 30 | } 31 | 32 | 33 | if [ $# -ne 2 ] 34 | then 35 | echo "Usage: $0 extra_free_kbytes(GB) min_free_kbytes(GB)" 36 | echo "Example: $0 3 1" 37 | exit 38 | fi 39 | 40 | changeFreeCache $1 $2 41 | -------------------------------------------------------------------------------- /distribution/conf/2m-2s-async/broker-a-s.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | brokerClusterName=DefaultCluster 16 | brokerName=broker-a 17 | brokerId=1 18 | deleteWhen=04 19 | fileReservedTime=48 20 | brokerRole=SLAVE 21 | flushDiskType=ASYNC_FLUSH 22 | -------------------------------------------------------------------------------- /distribution/conf/2m-2s-async/broker-a.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | brokerClusterName=DefaultCluster 16 | brokerName=broker-a 17 | brokerId=0 18 | deleteWhen=04 19 | fileReservedTime=48 20 | brokerRole=ASYNC_MASTER 21 | flushDiskType=ASYNC_FLUSH 22 | -------------------------------------------------------------------------------- /distribution/conf/2m-2s-async/broker-b-s.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | brokerClusterName=DefaultCluster 16 | brokerName=broker-b 17 | brokerId=1 18 | deleteWhen=04 19 | fileReservedTime=48 20 | brokerRole=SLAVE 21 | flushDiskType=ASYNC_FLUSH 22 | -------------------------------------------------------------------------------- /distribution/conf/2m-2s-async/broker-b.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | brokerClusterName=DefaultCluster 16 | brokerName=broker-b 17 | brokerId=0 18 | deleteWhen=04 19 | fileReservedTime=48 20 | brokerRole=ASYNC_MASTER 21 | flushDiskType=ASYNC_FLUSH 22 | -------------------------------------------------------------------------------- /distribution/conf/2m-2s-sync/broker-a-s.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | brokerClusterName=DefaultCluster 16 | brokerName=broker-a 17 | brokerId=1 18 | deleteWhen=04 19 | fileReservedTime=48 20 | brokerRole=SLAVE 21 | flushDiskType=ASYNC_FLUSH 22 | -------------------------------------------------------------------------------- /distribution/conf/2m-2s-sync/broker-a.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | brokerClusterName=DefaultCluster 16 | brokerName=broker-a 17 | brokerId=0 18 | deleteWhen=04 19 | fileReservedTime=48 20 | brokerRole=SYNC_MASTER 21 | flushDiskType=ASYNC_FLUSH 22 | -------------------------------------------------------------------------------- /distribution/conf/2m-2s-sync/broker-b-s.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | brokerClusterName=DefaultCluster 16 | brokerName=broker-b 17 | brokerId=1 18 | deleteWhen=04 19 | fileReservedTime=48 20 | brokerRole=SLAVE 21 | flushDiskType=ASYNC_FLUSH 22 | -------------------------------------------------------------------------------- /distribution/conf/2m-2s-sync/broker-b.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | brokerClusterName=DefaultCluster 16 | brokerName=broker-b 17 | brokerId=0 18 | deleteWhen=04 19 | fileReservedTime=48 20 | brokerRole=SYNC_MASTER 21 | flushDiskType=ASYNC_FLUSH 22 | -------------------------------------------------------------------------------- /distribution/conf/2m-noslave/broker-a.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | brokerClusterName=DefaultCluster 16 | brokerName=broker-a 17 | brokerId=0 18 | deleteWhen=04 19 | fileReservedTime=48 20 | brokerRole=ASYNC_MASTER 21 | flushDiskType=ASYNC_FLUSH 22 | -------------------------------------------------------------------------------- /distribution/conf/2m-noslave/broker-b.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | brokerClusterName=DefaultCluster 16 | brokerName=broker-b 17 | brokerId=0 18 | deleteWhen=04 19 | fileReservedTime=48 20 | brokerRole=ASYNC_MASTER 21 | flushDiskType=ASYNC_FLUSH 22 | -------------------------------------------------------------------------------- /distribution/conf/broker.conf: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | brokerClusterName = DefaultCluster 17 | brokerName = broker-a 18 | brokerId = 0 19 | deleteWhen = 04 20 | fileReservedTime = 48 21 | brokerRole = ASYNC_MASTER 22 | flushDiskType = ASYNC_FLUSH 23 | -------------------------------------------------------------------------------- /example/src/main/java/org/apache/rocketmq/example/simple/CachedQueue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.example.simple; 19 | 20 | import java.util.TreeMap; 21 | import org.apache.rocketmq.common.message.MessageExt; 22 | 23 | public class CachedQueue { 24 | private final TreeMap msgCachedTable = new TreeMap(); 25 | 26 | public TreeMap getMsgCachedTable() { 27 | return msgCachedTable; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /filter/src/main/java/org/apache/rocketmq/filter/FilterSpi.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.filter; 19 | 20 | import org.apache.rocketmq.filter.expression.Expression; 21 | import org.apache.rocketmq.filter.expression.MQFilterException; 22 | 23 | /** 24 | * Filter spi interface. 25 | */ 26 | public interface FilterSpi { 27 | 28 | /** 29 | * Compile. 30 | */ 31 | Expression compile(final String expr) throws MQFilterException; 32 | 33 | /** 34 | * Which type. 35 | */ 36 | String ofType(); 37 | } 38 | -------------------------------------------------------------------------------- /filter/src/main/java/org/apache/rocketmq/filter/constant/UnaryType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.filter.constant; 19 | 20 | public enum UnaryType { 21 | NEGATE, 22 | IN, 23 | NOT, 24 | BOOLEANCAST, 25 | LIKE 26 | } 27 | -------------------------------------------------------------------------------- /filter/src/main/java/org/apache/rocketmq/filter/expression/EmptyEvaluationContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.filter.expression; 19 | 20 | import java.util.Map; 21 | 22 | /** 23 | * Empty context. 24 | */ 25 | public class EmptyEvaluationContext implements EvaluationContext { 26 | @Override 27 | public Object get(String name) { 28 | return null; 29 | } 30 | 31 | @Override 32 | public Map keyValues() { 33 | return null; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /filter/src/main/java/org/apache/rocketmq/filter/expression/EvaluationContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.filter.expression; 19 | 20 | import java.util.Map; 21 | 22 | /** 23 | * Context of evaluate expression. 24 | * 25 | * Compare to org.apache.activemq.filter.MessageEvaluationContext, this is just an interface. 26 | */ 27 | public interface EvaluationContext { 28 | 29 | /** 30 | * Get value by name from context 31 | */ 32 | Object get(String name); 33 | 34 | /** 35 | * Context variables. 36 | */ 37 | Map keyValues(); 38 | } 39 | -------------------------------------------------------------------------------- /filter/src/main/java/org/apache/rocketmq/filter/expression/Expression.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.filter.expression; 19 | 20 | /** 21 | * Interface of expression. 22 | *

23 | * This class was taken from ActiveMQ org.apache.activemq.filter.Expression, 24 | * but the parameter is changed to an interface. 25 | *

26 | * 27 | * @see org.apache.rocketmq.filter.expression.EvaluationContext 28 | */ 29 | public interface Expression { 30 | 31 | /** 32 | * Calculate express result with context. 33 | * 34 | * @param context context of evaluation 35 | * @return the value of this expression 36 | */ 37 | Object evaluate(EvaluationContext context) throws Exception; 38 | } 39 | -------------------------------------------------------------------------------- /filter/src/main/java/org/apache/rocketmq/filter/expression/NowExpression.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.filter.expression; 19 | 20 | /** 21 | * Current time expression.Just for test. 22 | */ 23 | public class NowExpression extends ConstantExpression { 24 | public NowExpression() { 25 | super("now"); 26 | } 27 | 28 | @Override 29 | public Object evaluate(EvaluationContext context) throws Exception { 30 | return new Long(System.currentTimeMillis()); 31 | } 32 | 33 | public Object getValue() { 34 | return new Long(System.currentTimeMillis()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /logappender/src/test/java/org/apache/rocketmq/logappender/Log4jPropertiesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.logappender; 18 | 19 | import org.apache.log4j.PropertyConfigurator; 20 | 21 | public class Log4jPropertiesTest extends Log4jTest { 22 | 23 | @Override 24 | public void init() { 25 | PropertyConfigurator.configure("src/test/resources/log4j-example.properties"); 26 | } 27 | 28 | @Override 29 | public String getType() { 30 | return "properties"; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /logappender/src/test/java/org/apache/rocketmq/logappender/Log4jXmlTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.logappender; 18 | 19 | import org.apache.log4j.xml.DOMConfigurator; 20 | 21 | public class Log4jXmlTest extends Log4jTest { 22 | 23 | @Override 24 | public void init() { 25 | DOMConfigurator.configure("src/test/resources/log4j-example.xml"); 26 | } 27 | 28 | @Override 29 | public String getType() { 30 | return "xml"; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /logging/src/main/java/org/apache/rocketmq/logging/inner/Layout.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.logging.inner; 19 | 20 | public abstract class Layout { 21 | 22 | public abstract String format(LoggingEvent event); 23 | 24 | public String getContentType() { 25 | return "text/plain"; 26 | } 27 | 28 | public String getHeader() { 29 | return null; 30 | } 31 | 32 | public String getFooter() { 33 | return null; 34 | } 35 | 36 | 37 | abstract public boolean ignoresThrowable(); 38 | 39 | } -------------------------------------------------------------------------------- /logging/src/main/java/org/apache/rocketmq/logging/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.logging; 19 | 20 | /* 21 | This package is a minimal logger on the basis of Apache Log4j without 22 | file configuration and pattern layout configuration. Main forked files are 23 | followed as below: 24 | 1. LoggingEvent 25 | 2. Logger 26 | 3. Layout 27 | 4. Level 28 | 5. AsyncAppender 29 | 6. FileAppender 30 | 7. RollingFileAppender 31 | 8. DailyRollingFileAppender 32 | 9. ConsoleAppender 33 | 34 | For more information about Apache Log4j, please go to https://github.com/apache/log4j. 35 | */ -------------------------------------------------------------------------------- /logging/src/test/java/org/apache/rocketmq/logging/inner/LevelTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.logging.inner; 19 | 20 | import org.junit.Assert; 21 | import org.junit.Test; 22 | 23 | public class LevelTest { 24 | 25 | @Test 26 | public void levelTest() { 27 | Level info = Level.toLevel("info"); 28 | Level error = Level.toLevel(3); 29 | Assert.assertTrue(error != null && info != null); 30 | } 31 | 32 | @Test 33 | public void loggerLevel(){ 34 | Level level = Logger.getRootLogger().getLevel(); 35 | Assert.assertTrue(level!=null); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /namesrv/src/main/java/NameServer架构设计图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrChiu/RocketMQ-Study/f1e1256bc7f4038c898cfd8bc58934859ee70d15/namesrv/src/main/java/NameServer架构设计图.png -------------------------------------------------------------------------------- /namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigSerializeWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.namesrv.kvconfig; 18 | 19 | import java.util.HashMap; 20 | import org.apache.rocketmq.remoting.protocol.RemotingSerializable; 21 | 22 | public class KVConfigSerializeWrapper extends RemotingSerializable { 23 | private HashMap> configTable; 24 | 25 | public HashMap> getConfigTable() { 26 | return configTable; 27 | } 28 | 29 | public void setConfigTable(HashMap> configTable) { 30 | this.configTable = configTable; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /openmessaging/src/main/java/io/openmessaging/rocketmq/domain/RocketMQConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package io.openmessaging.rocketmq.domain; 18 | 19 | public interface RocketMQConstants { 20 | 21 | /** 22 | * Key of scheduled message delivery time 23 | */ 24 | String START_DELIVER_TIME = "__STARTDELIVERTIME"; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /remoting/src/main/java/org/apache/rocketmq/remoting/ChannelEventListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.remoting; 18 | 19 | import io.netty.channel.Channel; 20 | 21 | /** 22 | * 通道事件监听 23 | */ 24 | public interface ChannelEventListener { 25 | //通道建立连接时 26 | void onChannelConnect(final String remoteAddr, final Channel channel); 27 | //通道关闭时 28 | void onChannelClose(final String remoteAddr, final Channel channel); 29 | //通道异常时 30 | void onChannelException(final String remoteAddr, final Channel channel); 31 | //通道空闲时 32 | void onChannelIdle(final String remoteAddr, final Channel channel); 33 | } 34 | -------------------------------------------------------------------------------- /remoting/src/main/java/org/apache/rocketmq/remoting/CommandCustomHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.remoting; 18 | 19 | import org.apache.rocketmq.remoting.exception.RemotingCommandException; 20 | 21 | public interface CommandCustomHeader { 22 | void checkFields() throws RemotingCommandException; 23 | } 24 | -------------------------------------------------------------------------------- /remoting/src/main/java/org/apache/rocketmq/remoting/InvokeCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.remoting; 18 | 19 | import org.apache.rocketmq.remoting.netty.ResponseFuture; 20 | 21 | public interface InvokeCallback { 22 | void operationComplete(final ResponseFuture responseFuture); 23 | } 24 | -------------------------------------------------------------------------------- /remoting/src/main/java/org/apache/rocketmq/remoting/RPCHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.remoting; 19 | 20 | import org.apache.rocketmq.remoting.protocol.RemotingCommand; 21 | 22 | public interface RPCHook { 23 | void doBeforeRequest(final String remoteAddr, final RemotingCommand request); 24 | 25 | void doAfterResponse(final String remoteAddr, final RemotingCommand request, 26 | final RemotingCommand response); 27 | } 28 | -------------------------------------------------------------------------------- /remoting/src/main/java/org/apache/rocketmq/remoting/RemotingService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.remoting; 19 | 20 | /** 21 | * 远程通信服务 22 | */ 23 | public interface RemotingService { 24 | //启动 25 | void start(); 26 | 27 | //关闭 28 | void shutdown(); 29 | 30 | //注册RPC钩子 31 | void registerRPCHook(RPCHook rpcHook); 32 | } 33 | -------------------------------------------------------------------------------- /remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNotNull.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.remoting.annotation; 18 | 19 | import java.lang.annotation.Documented; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | @Documented 26 | @Retention(RetentionPolicy.RUNTIME) 27 | @Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE}) 28 | public @interface CFNotNull { 29 | } 30 | -------------------------------------------------------------------------------- /remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNullable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.remoting.annotation; 18 | 19 | import java.lang.annotation.Documented; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | @Documented 26 | @Retention(RetentionPolicy.RUNTIME) 27 | @Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE}) 28 | public @interface CFNullable { 29 | } 30 | -------------------------------------------------------------------------------- /remoting/src/main/java/org/apache/rocketmq/remoting/common/Pair.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.remoting.common; 18 | 19 | public class Pair { 20 | private T1 object1; 21 | private T2 object2; 22 | 23 | public Pair(T1 object1, T2 object2) { 24 | this.object1 = object1; 25 | this.object2 = object2; 26 | } 27 | 28 | public T1 getObject1() { 29 | return object1; 30 | } 31 | 32 | public void setObject1(T1 object1) { 33 | this.object1 = object1; 34 | } 35 | 36 | public T2 getObject2() { 37 | return object2; 38 | } 39 | 40 | public void setObject2(T2 object2) { 41 | this.object2 = object2; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingCommandException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.remoting.exception; 18 | 19 | public class RemotingCommandException extends RemotingException { 20 | private static final long serialVersionUID = -6061365915274953096L; 21 | 22 | public RemotingCommandException(String message) { 23 | super(message, null); 24 | } 25 | 26 | public RemotingCommandException(String message, Throwable cause) { 27 | super(message, cause); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingConnectException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.remoting.exception; 18 | 19 | public class RemotingConnectException extends RemotingException { 20 | private static final long serialVersionUID = -5565366231695911316L; 21 | 22 | public RemotingConnectException(String addr) { 23 | this(addr, null); 24 | } 25 | 26 | public RemotingConnectException(String addr, Throwable cause) { 27 | super("connect to <" + addr + "> failed", cause); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.remoting.exception; 18 | 19 | public class RemotingException extends Exception { 20 | private static final long serialVersionUID = -5690687334570505110L; 21 | 22 | public RemotingException(String message) { 23 | super(message); 24 | } 25 | 26 | public RemotingException(String message, Throwable cause) { 27 | super(message, cause); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingSendRequestException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.remoting.exception; 18 | 19 | public class RemotingSendRequestException extends RemotingException { 20 | private static final long serialVersionUID = 5391285827332471674L; 21 | 22 | public RemotingSendRequestException(String addr) { 23 | this(addr, null); 24 | } 25 | 26 | public RemotingSendRequestException(String addr, Throwable cause) { 27 | super("send request to <" + addr + "> failed", cause); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTooMuchRequestException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.remoting.exception; 18 | 19 | public class RemotingTooMuchRequestException extends RemotingException { 20 | private static final long serialVersionUID = 4326919581254519654L; 21 | 22 | public RemotingTooMuchRequestException(String message) { 23 | super(message); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEventType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.remoting.netty; 18 | 19 | public enum NettyEventType { 20 | CONNECT, 21 | CLOSE, 22 | IDLE, 23 | EXCEPTION 24 | } 25 | -------------------------------------------------------------------------------- /remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRequestProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.remoting.netty; 18 | 19 | import io.netty.channel.ChannelHandlerContext; 20 | import org.apache.rocketmq.remoting.protocol.RemotingCommand; 21 | 22 | /** 23 | * 通用远程处理器 24 | * Common remoting command processor 25 | */ 26 | public interface NettyRequestProcessor { 27 | RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) 28 | throws Exception; 29 | 30 | boolean rejectRequest(); 31 | } 32 | -------------------------------------------------------------------------------- /remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommandType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.remoting.protocol; 18 | 19 | public enum RemotingCommandType { 20 | REQUEST_COMMAND, 21 | RESPONSE_COMMAND; 22 | } 23 | -------------------------------------------------------------------------------- /remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSysResponseCode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.remoting.protocol; 19 | 20 | public class RemotingSysResponseCode { 21 | 22 | public static final int SUCCESS = 0; 23 | 24 | public static final int SYSTEM_ERROR = 1; 25 | 26 | public static final int SYSTEM_BUSY = 2; 27 | 28 | public static final int REQUEST_CODE_NOT_SUPPORTED = 3; 29 | 30 | public static final int TRANSACTION_FAILED = 4; 31 | } 32 | -------------------------------------------------------------------------------- /remoting/src/test/resources/certs/badClient.key: -------------------------------------------------------------------------------- 1 | -----BEGIN ENCRYPTED PRIVATE KEY----- 2 | MIICoTAbBgkqhkiG9w0BBQMwDgQIc2h7vaLYK6gCAggABIICgNrkvD1Xxez79Jgk 3 | WhRJg06CG8UthncfeuymR4hgp9HIneUzUHOoaf64mpxUbDWe3YOzA29REcBQsjF0 4 | Rpv+Uyg3cyDG14TmeRoSufOxB3MWLcIenoPPyNNtxe3XXmdkJTXX2YR0j7EOzH2v 5 | qlmuxmN4A7UonV5RdGxCz0sm7bU7EyZKdLO/DwBNxlX7ukcVLxAAqsc7ondclYj0 6 | SFJKk1nzfysCsk/Pq+q3PAVVpG6x5RFaLVS7Zt+gU6IEp+0S0eeYukkTjGh9PMPl 7 | wjCOcRiR3O+g4b3DevmW8TcoBqAZ2cFaf4lGhYlNBfa9PaQ3spJLL8l8xBbRIs8T 8 | 3UnaFIa49r9DO/ZpCwpDeUE+URCx/SpcO6lchWQhdEuFt+DnFKOPYDSCHtHJSWHf 9 | 9Z2bltjcYYPy/8nkPeqsO9vn4/r6jo+l7MYWKyWolLCW+7RYbpx5R2s4SBGtBP6w 10 | bwQOtOASbpG+mqTf7+ARpffHaZm9cKoKwobXigjDojPeaBCg5DgRuLIS1tO46Pjg 11 | USJ8sZilXifUwc6qRZ/2KiTSiJYCPMJD2ZTvK2Inkv2qzg6X3kw7CYCaW+iDL9zN 12 | e3ES7bps1wZ6D8cGq80WUQgrtpaGAXLzIv4FvM5yDoqrre/dh/XDO9l2hYfUmRVv 13 | rynKdSxjhhyHaK2ei8cX4LGEIlRNiu9ZIxSYeUAy37IJ0rVC7vtBWTh30JTeMRop 14 | iIPmygBMX2FEhQ2l/eS2lRhiybR0QXA4kCeJkVQas3aMMBGp2ThPNahLpzP82B7V 15 | f9137okQC95/KXRz/ZLYFsJtY/53206mG7gU/+dYsYI4slLAlnSe8k2sS0D9qkWJ 16 | VV9F7PM= 17 | -----END ENCRYPTED PRIVATE KEY----- 18 | -------------------------------------------------------------------------------- /remoting/src/test/resources/certs/badClient.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIC8zCCAdsCAQIwDQYJKoZIhvcNAQEFBQAwfDELMAkGA1UEBhMCemgxCzAJBgNV 3 | BAgMAnpqMQswCQYDVQQHDAJoejEPMA0GA1UECgwGYXBhY2hlMREwDwYDVQQLDAhy 4 | b2NrZXRtcTEOMAwGA1UEAwwFeXVrb24xHzAdBgkqhkiG9w0BCQEWEHl1a29uQGFw 5 | YWNoZS5vcmcwHhcNMTcxMjExMDk0NDExWhcNMTgwMTEwMDk0NDExWjCBhjELMAkG 6 | A1UEBhMCemgxCzAJBgNVBAgMAnpqMQswCQYDVQQHDAJoejEPMA0GA1UECgwGYXBh 7 | Y2hlMREwDwYDVQQLDAhyb2NrZXRtcTEWMBQGA1UEAwwNZm9vYmFyLmNsaWVudDEh 8 | MB8GCSqGSIb3DQEJARYSZm9vQGJhci5jbGllbnQuY29tMIGfMA0GCSqGSIb3DQEB 9 | AQUAA4GNADCBiQKBgQC+3bvrKGF1Y9/kN5UBtf8bXRtxn6L1W6mCRrX6aHBb+vQp 10 | BEYk3Pwu/OLd7TkOC5zwjCIPIlwV4FaYnWh0KooqpmvXuKJLAQBFa8yGWERYys73 11 | 9a/U31cu6lndnG2lZfb47NTy+KdzDYsqB4GfnASqA7PbxJHDU4Fu7wp7gN3HRQID 12 | AQABMA0GCSqGSIb3DQEBBQUAA4IBAQBsFroSKr3MbCq1HjWpCLDEz2uS4LQV6L1G 13 | smNfGNY17ELOcY9uweBBXOsfKVOEizYJJqatbJlz6FmPkIbfsGW2Wospkp1gvYMy 14 | NGL27vX3rB5vOo5vdFITaaV9/dEu53A0iWdsn3wH/FJnMsqBmynb+/3FY+Lff9d1 15 | XBaXLr+DeBx4lrE8rWTvhWh8gqDkuNLBTygdH0+g8/xkqhQhLqjIlMCSnrG2cTfj 16 | LewizVcX/VZ6DNC2M2vjEFbCShclZHocG80N7udl5KNsLEU2jyO1F61Q0yo+VYGS 17 | 7n8dRYgbOKyCjMdu69fAfZvp4aoy1SXqtjMphDh5R7y7mhP60e0A 18 | -----END CERTIFICATE----- 19 | -------------------------------------------------------------------------------- /remoting/src/test/resources/certs/badServer.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBALBvxESq2VvSpJl1 3 | skv8SzyPYKgU8bZx37hEOCmoeYvd9gWNfeYZuITng2/5mpWX+zuAgKsgPU66YG0v 4 | ++dT5GBQPr0Imb25IMl3xOY2eEiLeMokYiWbnA1C+pw1a27zMqk6pgbcRaMfLdh5 5 | npusWtqBzZIxqo1TpaOGEmyQTNRlAgMBAAECgYBSigbUZOTIWxObov7lI0MDMsPx 6 | /dJSGpWhe3CWtHUgJJdKY7XpJlE3A6Nuh+N0ZiQm4ufOpodnxDMGAXOj9ZAZY16Y 7 | i7I0ayXepcpTqYqo0o0+ze2x7SECAXe26bqvLRuKG2hpUyM59vAmll9gmQM5n8z4 8 | ZzoAzqRqkRHdo5bTxQJBAOF6SwSSfb8KEtTjWpJ48W1PO/NmKbW3QsNCWuk/w5p7 9 | E8L2g3nwakJiFmVNCga74rUbcgbCkw7y/lLeM8yC74MCQQDIUgCN/vuHm+eT85xk 10 | QoVKhDljXzLoog6wTUf5SMtrmUFTbQqyvw5xjHYdp3TWJM/Px8IyLxOr97sSnnft 11 | l7/3AkEAukYLv6U+GRs7X4DMDIG6AjIZNwXJo4PYtfMVo+i3seHH+6MoDw8c2eaq 12 | 1dmFVPbXXgNkek04rHr2vIMxi90H/QJAAMOfUOtaFkhX986EGDXQwFoExgZE8XI8 13 | 0BtbXO4UKJLrFuBhnBDygyhgAvjyjyaQzGAcs4hOcOd/BTEpj/R2PQJBANUKa9T9 14 | qWYhDhWN1Uj7qXhC1j2z/vTAzcYuwhpPRjt3RaVl27itI7cqiGquFhwfKZZFaOh5 15 | pnnWHv63YbGQ2Qc= 16 | -----END PRIVATE KEY----- 17 | -------------------------------------------------------------------------------- /remoting/src/test/resources/certs/badServer.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIC5DCCAcwCAQEwDQYJKoZIhvcNAQEFBQAwfDELMAkGA1UEBhMCemgxCzAJBgNV 3 | BAgMAnpqMQswCQYDVQQHDAJoejEPMA0GA1UECgwGYXBhY2hlMREwDwYDVQQLDAhy 4 | b2NrZXRtcTEOMAwGA1UEAwwFeXVrb24xHzAdBgkqhkiG9w0BCQEWEHl1a29uQGFw 5 | YWNoZS5vcmcwHhcNMTcxMjExMDk0MzE3WhcNMTgwMTEwMDk0MzE3WjB4MQswCQYD 6 | VQQGEwJ6aDELMAkGA1UECAwCemoxCzAJBgNVBAcMAmh6MQ8wDQYDVQQKDAZhcGFj 7 | aGUxETAPBgNVBAsMCHJvY2tldG1xMQ8wDQYDVQQDDAZmb29iYXIxGjAYBgkqhkiG 8 | 9w0BCQEWC2Zvb0BiYXIuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCw 9 | b8REqtlb0qSZdbJL/Es8j2CoFPG2cd+4RDgpqHmL3fYFjX3mGbiE54Nv+ZqVl/s7 10 | gICrID1OumBtL/vnU+RgUD69CJm9uSDJd8TmNnhIi3jKJGIlm5wNQvqcNWtu8zKp 11 | OqYG3EWjHy3YeZ6brFragc2SMaqNU6WjhhJskEzUZQIDAQABMA0GCSqGSIb3DQEB 12 | BQUAA4IBAQAx+0Se3yIvUOe23oQp6UecaHtfXJCZmi1p5WbwJi7jUcYz78JB8oBj 13 | tVsa+1jftJG+cJJxqgxo2IeIAVbcEteO19xm7dc8tgfH/Bl0rxQz4WEYKb2oF/EQ 14 | eRgcvj4uZ0d9WuprAvJgA4r0Slu2ZZ0cVkzi06NevTweTBYIKFzHaPShqUWEw8ki 15 | 42V5jAtRve7sT0c4TH/01dd2fs3V4Ul3E2U3LOP6VizIfKckdht0Bh6B6/5L8wvH 16 | 4l1f4ni7w34vXGANpmTP2FGjQQ3kYjKL7GzgMphh3Kozhil6g1GLMhxvp6ccCA9W 17 | m5g0cPa3RZnjI/FoD0lZ5S1Q5s9qXbLm 18 | -----END CERTIFICATE----- 19 | -------------------------------------------------------------------------------- /remoting/src/test/resources/certs/ca.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDyzCCArOgAwIBAgIJAKzXC2VLdPclMA0GCSqGSIb3DQEBBQUAMHwxCzAJBgNV 3 | BAYTAnpoMQswCQYDVQQIDAJ6ajELMAkGA1UEBwwCaHoxDzANBgNVBAoMBmFwYWNo 4 | ZTERMA8GA1UECwwIcm9ja2V0bXExDjAMBgNVBAMMBXl1a29uMR8wHQYJKoZIhvcN 5 | AQkBFhB5dWtvbkBhcGFjaGUub3JnMB4XDTE3MTIxMTA5MjUxNFoXDTE4MDExMDA5 6 | MjUxNFowfDELMAkGA1UEBhMCemgxCzAJBgNVBAgMAnpqMQswCQYDVQQHDAJoejEP 7 | MA0GA1UECgwGYXBhY2hlMREwDwYDVQQLDAhyb2NrZXRtcTEOMAwGA1UEAwwFeXVr 8 | b24xHzAdBgkqhkiG9w0BCQEWEHl1a29uQGFwYWNoZS5vcmcwggEiMA0GCSqGSIb3 9 | DQEBAQUAA4IBDwAwggEKAoIBAQDLUZi/zPj+7sYbfTng/gJeHpvvrWZkiudNwh1t 10 | 5kxAusrJyGBkGm+xmRPJeQPZzbhfwfrz/UiQSbjlyV4K+SEZuNIHBSU80aTnXFWg 11 | wIgIAKvu3ZwYkcTjSDBvZv1DgbRkuqAB5ExsJ4vovoNqZcsLFLKsqT1G7lTAwRKU 12 | /FTKgD4g/zvhEoolonzKuk7CPivfKWFzcTpe8zRQlI0O9+j9Pq38F+5yxP7atK/b 13 | uYw36Efgt8nbkjusWIyXibpDMbAUroJNNYlFnunb+XKLpslkrIrfLGiMUq2Ru940 14 | ooQaANYWzogRQeIofsMN6H9CCRXtVIzcgJJU3wWXGXPRuNr7AgMBAAGjUDBOMB0G 15 | A1UdDgQWBBTd3bmAcazOY2/TI/h4zaGhni+nJzAfBgNVHSMEGDAWgBTd3bmAcazO 16 | Y2/TI/h4zaGhni+nJzAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4IBAQBp 17 | KRcnYsVtFZJejyt02+7SaMudTNRgh5SexFWsl1O7qWUc+fMVgMHHDzGRbkdevcdZ 18 | 9uKDwUoa6M1wlOeosTTfQlH9b/AwW6QT7KqdpcpMXlmoV/PNCAVt2QeVclmplvqo 19 | Rx8qUHNckvvzNZt1W6AkBG93P0BLK/3FMJDyYmxkstwnpBPf/3A+t5k2INUI7yQf 20 | B3Tqzs/4iQ3idCLqz2WhTNUYpZOREtpJMcFaOdMsGNnIF+LvkKGij0MPVd/mwJtL 21 | UvQXwbOWpCS7A73sWFqPnrSzpi4VwcvAsi8lUYXsc0H064oagb58zvYz3kXqybcb 22 | KQntj5dP4C3lLHUTTcAV 23 | -----END CERTIFICATE----- 24 | -------------------------------------------------------------------------------- /remoting/src/test/resources/certs/client.key: -------------------------------------------------------------------------------- 1 | -----BEGIN ENCRYPTED PRIVATE KEY----- 2 | MIICoTAbBgkqhkiG9w0BBQMwDgQI1vtPpDhOYRcCAggABIICgMHwgw0p9fx95R/+ 3 | cWnNdEq8I3ZOOy2wDjammFvPrYXcCJzS3Xg/0GDJ8pdJRKrI7253e4u3mxf5oMuY 4 | RrvpB3KfdelU1k/5QKqOxL/N0gQafQLViN53f6JelyBEAmO1UxQtKZtkTrdZg8ZP 5 | 0u1cPPWxmgNdn1Xx3taMw+Wo05ysHjnHJhOEDQ2WT3VXigiRmFSX3H567yjYMRD+ 6 | zmvBq+qqR9JPbH9Cn7X1oRXX6c8VsZHWF/Ds0I4i+5zJxsSIuNZxjZw9XXNgXtFv 7 | 7FEFC0HDgDQQUY/FNPUbmjQUp1y0YxoOBjlyIqBIx5FWxu95p2xITS0OimQPFT0o 8 | IngaSb+EKRDhqpLxxIVEbDdkQrdRqcmmLGJioAysExTBDsDwkaEJGOp44bLDM4QW 9 | SIA9SB01omuCXgn7RjUyVXb5g0Lz+Nvsfp1YXUkPDO9hILfz3eMHDSW7/FzbB81M 10 | r8URaTagQxBZnvIoCoWszLDXn3JwEjpZEA6y55Naptps3mMRf7+XMt42lX0e4y9a 11 | ogNu5Zw/RZD9YcaTjC2z5XeKiMCs1Ymhy9iuzbo+eRGESqzvUE4VirtsiEwxJRci 12 | JHAvuAl3X4XnpTty4ahOU+DihM9lALxdU68CN9++7mx581pYuvjzrV+Z5+PuptZX 13 | AjCZmkZLDh8TCHSzWRqvP/Hcvo9BjW8l1Lq6tOa222PefSNCc6gs6Hq+jUghbabZ 14 | /ux4WuFc0Zd6bfQWAZohSvd78/ixsdJPNGm2OP+LUIrEDKIkLuH1PM0uq4wzJZNu 15 | Bo7oJ5iFWF67u3MC8oq+BqOVKDNWaCMi7iiSrN2XW8FBo/rpx4Lf/VYREL+Y0mP6 16 | vzJrZqw= 17 | -----END ENCRYPTED PRIVATE KEY----- 18 | -------------------------------------------------------------------------------- /remoting/src/test/resources/certs/client.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDATCCAekCAQIwDQYJKoZIhvcNAQEFBQAwfDELMAkGA1UEBhMCemgxCzAJBgNV 3 | BAgMAnpqMQswCQYDVQQHDAJoejEPMA0GA1UECgwGYXBhY2hlMREwDwYDVQQLDAhy 4 | b2NrZXRtcTEOMAwGA1UEAwwFeXVrb24xHzAdBgkqhkiG9w0BCQEWEHl1a29uQGFw 5 | YWNoZS5vcmcwIBcNMTgwMTE2MDYxNjQ0WhgPMjExNzEyMjMwNjE2NDRaMIGSMQsw 6 | CQYDVQQGEwJDTjERMA8GA1UECAwIWmhlamlhbmcxETAPBgNVBAcMCEhhbmd6aG91 7 | MQ8wDQYDVQQKDAZhcGFjaGUxETAPBgNVBAsMCHJvY2tldG1xMRgwFgYDVQQDDA9h 8 | cGFjaGUgcm9ja2V0bXExHzAdBgkqhkiG9w0BCQEWEHl1a29uQGFwYWNoZS5vcmcw 9 | gZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAOjPlSjZk37XLBJBc5G/qQNsNdVD 10 | vZnEGntrqW0UuHjF2T/LPtsGOavLP5wCHvn2zwMR2eCXZwKdKIzSvk0L3XOjH/XY 11 | OLgRa3cg90lV7Wzn9UMGq3nOjFtjIODPjtz3lwYAuAt1MH+K0E+ChuCFBgFqdY9U 12 | E0suW3DX0Mt/WB3pAgMBAAEwDQYJKoZIhvcNAQEFBQADggEBAFGPaZKyCZzQihKj 13 | n/7I1J0wKl1HrU7N4sOie8E+ntcpKeX9zKYAou/4Iy0qwgxgRsnucB1rDous560a 14 | +8DFDU8+FnikK9cQtKfQqu4F266IkkXolviZMSfkmB+NIsByIl95eMJlQHVlAvnX 15 | vnpGdhD/Jhs+acE1VHhO6K+8omKLA6Og8MmYGRwmnBLcxIvqoSNDlEShfQyjaECg 16 | I4bEi4ZhH3lSHE46FybJdoxDbj9IjHWqpOnjM23EOyfd1zcwOZJA7a54kfOpiTjz 17 | wrtes5yoQznun5WtGcLM8ZmyaQ+Jr3j6NyZhOwULzK1+A8YUsW6Ww39xTxQoIHEQ 18 | 7eirb54= 19 | -----END CERTIFICATE----- 20 | -------------------------------------------------------------------------------- /remoting/src/test/resources/certs/server.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAOsmp4YtrIRsBdBQ 3 | LyPImafCRynTJls3NNF4g6nZr9e0efBY830gw9kBebcm603sdZNl95fzRr2+srXi 4 | 5FJbG7Fmq1+F0xLNK/kKWirGtNMT2DubmhVdKyXYJSvInoGRkrQzbOG0MdAyzE6Q 5 | O6OjjNN+xGkmadWyCyNF6S8YqMJTAgMBAAECgYEAj0OlnOIG0Ube4+N2VN7KfqKm 6 | qJy0Ka6gx14dGUY/E7Qo9n27GujzaSq09RkJExiVKZBeIH1fBAtC5f2uDV7kpy0l 7 | uNpTpQkbw0g2EQLxDsVwaUEYbu+t9qVeXoDd1vFeoXHBuRwvI9UW1BrxVtvKODia 8 | 5StU8Lw4yjcm2lQalwECQQD/sKj56thIsIY7D9qBHk7fnFLd8aYzhnP2GsbZX4V/ 9 | T1KHRxr/8MqdNQX53DE5qcyM/Mqu95FIpTAniUtvcBujAkEA62+fAMYFTAEWj4Z4 10 | vCmcoPqfVPWhBKFR/wo3L8uUARiIzlbYNU3LIqC2s16QO50+bLUd41oVHNw9Y+uM 11 | fxQpkQJACg/WpncSadHghmR6UchyjCQnsqo2wyJQX+fv2VAD/d2OPtqSem3sW0Fh 12 | 6dI7cax36zhrdXUyl2xAt92URV9hBwJALX93sdWSxnpbWsc449wCydVFH00MnfFz 13 | AB+ARLtJ0eBk58M+qyZqgDmgtQ8sPmkH3EgwC3SoKdiiAIJPt2s1EQJBAKnISZZr 14 | qB2F2PfAW2JJbQlrPyVzkxhv9XYdiVNOErmuxLFae3AI7nECgGuFBtvmeqzm2yRj 15 | 7RBMCmzyWG7MF3o= 16 | -----END PRIVATE KEY----- 17 | -------------------------------------------------------------------------------- /remoting/src/test/resources/certs/server.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDATCCAekCAQIwDQYJKoZIhvcNAQEFBQAwfDELMAkGA1UEBhMCemgxCzAJBgNV 3 | BAgMAnpqMQswCQYDVQQHDAJoejEPMA0GA1UECgwGYXBhY2hlMREwDwYDVQQLDAhy 4 | b2NrZXRtcTEOMAwGA1UEAwwFeXVrb24xHzAdBgkqhkiG9w0BCQEWEHl1a29uQGFw 5 | YWNoZS5vcmcwIBcNMTgwMTE2MDYxMzQ5WhgPMjExNzEyMjMwNjEzNDlaMIGSMQsw 6 | CQYDVQQGEwJDTjERMA8GA1UECAwIWmhlamlhbmcxETAPBgNVBAcMCEhhbmd6aG91 7 | MQ8wDQYDVQQKDAZhcGFjaGUxETAPBgNVBAsMCHJvY2tldG1xMRgwFgYDVQQDDA9h 8 | cGFjaGUgcm9ja2V0bXExHzAdBgkqhkiG9w0BCQEWEHl1a29uQGFwYWNoZS5vcmcw 9 | gZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAOsmp4YtrIRsBdBQLyPImafCRynT 10 | Jls3NNF4g6nZr9e0efBY830gw9kBebcm603sdZNl95fzRr2+srXi5FJbG7Fmq1+F 11 | 0xLNK/kKWirGtNMT2DubmhVdKyXYJSvInoGRkrQzbOG0MdAyzE6QO6OjjNN+xGkm 12 | adWyCyNF6S8YqMJTAgMBAAEwDQYJKoZIhvcNAQEFBQADggEBAAzbwXyAULmXitiU 13 | +8/2vbUZQlzB/nXY52OIq7qu3F55hE5qlHkcVxG2JZjO3p5UETwOyNUpU4dpu3uT 14 | 7WSdygH4Iagl87ILpGsob9pAf0joAbaXAY4sGDhg+WjR5JInAxbmT+QWZ+4NTuLQ 15 | fSudUSJrv+HmUlmcVOvLiNStgt9rbtcgJAvpVwY+iCv0HQziFuQxmOkDv09ZLzu/ 16 | lxCMqnbgkEFYkwdntN6MVk38K3MovszedGO/n19hNOFss7nn5XDEeEnc6BqKGdck 17 | YDoy6amohY0Ds0o0gJ2rq0Y8Gjl9spQ3oeXpoNUoz84OF4KIBRTzSMv8CrmqPdFY 18 | Zd2MGjw= 19 | -----END CERTIFICATE----- 20 | -------------------------------------------------------------------------------- /store/src/main/java/Java NIO内存映射模型图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrChiu/RocketMQ-Study/f1e1256bc7f4038c898cfd8bc58934859ee70d15/store/src/main/java/Java NIO内存映射模型图.png -------------------------------------------------------------------------------- /store/src/main/java/Java NIO内存映射模型图说明.txt: -------------------------------------------------------------------------------- 1 | (1)Mmap内存映射技术的特点 2 | Mmap内存映射和普通标准IO操作的本质区别在于它并不需要将文件中的数据先拷贝至OS的内核IO缓冲区, 3 | 而是可以直接将用户进程私有地址空间中的一块区域与文件对象建立映射关系,这样程序就好像可以直接从内存中完成对文件读/写操作一样。 4 | 只有当缺页中断发生时,直接将文件从磁盘拷贝至用户态的进程空间内,只进行了一次数据拷贝。 5 | 对于容量较大的文件来说(文件大小一般需要限制在1.5~2G以下),采用Mmap的方式其读/写的效率和性能都非常高。 6 | (2)JDK NIO的MappedByteBuffer简要分析 7 | 从JDK的源码来看,MappedByteBuffer继承自ByteBuffer,其内部维护了一个逻辑地址变量—address。在建立映射关系时, 8 | MappedByteBuffer利用了JDK NIO的FileChannel类提供的map()方法把文件对象映射到虚拟内存。仔细看源码中map()方法的实现, 9 | 可以发现最终其通过调用native方法map0()完成文件对象的映射工作,同时使用Util.newMappedByteBuffer()方法初始化MappedByteBuffer 10 | 实例,但最终返回的是DirectByteBuffer的实例。在Java程序中使用MappedByteBuffer的get()方法来获取内存数据是最终通过 11 | DirectByteBuffer.get()方法实现(底层通过unsafe.getByte()方法,以“地址 + 偏移量”的方式获取指定映射至内存中的数据)。 12 | (3)使用Mmap的限制 13 | a.Mmap映射的内存空间释放的问题;由于映射的内存空间本身就不属于JVM的堆内存区(Java Heap), 14 | 因此其不受JVM GC的控制,卸载这部分内存空间需要通过系统调用 unmap()方法来实现。 15 | 然而unmap()方法是FileChannelImpl类里实现的私有方法,无法直接显示调用。RocketMQ中的做法是, 16 | 通过Java反射的方式调用“sun.misc”包下的Cleaner类的clean()方法来释放映射占用的内存空间; 17 | b.MappedByteBuffer内存映射大小限制;因为其占用的是虚拟内存(非JVM的堆内存),大小不受JVM的-Xmx参数限制, 18 | 但其大小也受到OS虚拟内存大小的限制。一般来说,一次只能映射1.5~2G 的文件至用户态的虚拟内存空间, 19 | 这也是为何RocketMQ默认设置单个CommitLog日志数据文件为1G的原因了; 20 | c.使用MappedByteBuffe的其他问题;会存在内存占用率较高和文件关闭不确定性的问题; -------------------------------------------------------------------------------- /store/src/main/java/RocketMQ同步&&异步刷盘两种方式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrChiu/RocketMQ-Study/f1e1256bc7f4038c898cfd8bc58934859ee70d15/store/src/main/java/RocketMQ同步&&异步刷盘两种方式.png -------------------------------------------------------------------------------- /store/src/main/java/RocketMQ同步&&异步刷盘两种方式说明.txt: -------------------------------------------------------------------------------- 1 | (1)同步刷盘:如上图所示,只有在消息真正持久化至磁盘后,RocketMQ的Broker端才会真正地返回给Producer端一个成功的ACK响应。 2 | 同步刷盘对MQ消息可靠性来说是一种不错的保障,但是性能上会有较大影响,一般适用于金融业务应用领域。 3 | RocketMQ同步刷盘的大致做法是,基于生产者消费者模型,主线程创建刷盘请求实例—GroupCommitRequest并在放入刷盘写队列后唤 4 | 醒同步刷盘线程—GroupCommitService,来执行刷盘动作(其中用了CAS变量和CountDownLatch来保证线程间的同步)。 5 | 这里,RocketMQ源码中用读写双缓存队列(requestsWrite/requestsRead)来实现读写分离,其带来的好处在于内部消费生成的同步 6 | 刷盘请求可以不用加锁,提高并发度。 7 | 8 | (2)异步刷盘:能够充分利用OS的PageCache的优势,只要消息写入PageCache即可将成功的ACK返回给Producer端。 9 | 消息刷盘采用后台异步线程提交的方式进行,降低了读写延迟,提高了MQ的性能和吞吐量。异步和同步刷盘的区别在于,异步刷盘时, 10 | 主线程并不会阻塞,在将刷盘线程wakeup后,就会继续执行。 11 | -------------------------------------------------------------------------------- /store/src/main/java/RokcetMQ文件存储PageCache机制.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrChiu/RocketMQ-Study/f1e1256bc7f4038c898cfd8bc58934859ee70d15/store/src/main/java/RokcetMQ文件存储PageCache机制.png -------------------------------------------------------------------------------- /store/src/main/java/RokcetMQ文件存储PageCache机制说明.txt: -------------------------------------------------------------------------------- 1 | PageCache是OS对文件的缓存,用于加速对文件的读写。一般来说,程序对文件进行顺序读写的速度几乎接近于内存的读写访问, 2 | 这里的主要原因就是在于OS使用PageCache机制对读写访问操作进行了性能优化,将一部分的内存用作PageCache。 3 | 4 | (1)对于数据文件的读取,如果一次读取文件时出现未命中PageCache的情况,OS从物理磁盘上访问读取文件的同时, 5 | 会顺序对其他相邻块的数据文件进行预读取(ps:顺序读入紧随其后的少数几个页面)。这样, 6 | 只要下次访问的文件已经被加载至PageCache时,读取操作的速度基本等于访问内存。 7 | (2)对于数据文件的写入,OS会先写入至Cache内,随后通过异步的方式由pdflush内核线程将Cache内的数据刷盘至物理磁盘上。 8 | 9 | 对于文件的顺序读写操作来说,读和写的区域都在OS的PageCache内,此时读写性能接近于内存。RocketMQ的大致做法是, 10 | 将数据文件映射到OS的虚拟内存中(通过JDK NIO的MappedByteBuffer),写消息的时候首先写入PageCache, 11 | 并通过异步刷盘的方式将消息批量的做持久化(同时也支持同步刷盘);订阅消费消息时(对CommitLog操作是随机读取), 12 | 由于PageCache的局部性热点原理且整体情况下还是从旧到新的有序读,因此大部分情况下消息还是可以直接从Page Cache中读取, 13 | 不会产生太多的缺页(Page Fault)中断而从磁盘读取。 14 | 15 | PageCache机制也不是完全无缺点的,当遇到OS进行脏页回写,内存回收,内存swap等情况时,就会引起较大的消息读写延迟。 16 | 对于这些情况,RocketMQ采用了多种优化技术,比如内存预分配,文件预热,mlock系统调用等, 17 | 来保证在最大可能地发挥PageCache机制优点的同时,尽可能地减少其缺点带来的消息读写延迟。 18 | -------------------------------------------------------------------------------- /store/src/main/java/org/apache/rocketmq/store/AppendMessageStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.store; 18 | 19 | /** 20 | * When write a message to the commit log, returns code 21 | */ 22 | public enum AppendMessageStatus { 23 | PUT_OK, //追加成功 24 | END_OF_FILE, //超过文件大小 25 | MESSAGE_SIZE_EXCEEDED, //消息长度超过最大允许长度 26 | PROPERTIES_SIZE_EXCEEDED, //消息属性超过最大允许长度 27 | UNKNOWN_ERROR, //未知异常 28 | } 29 | -------------------------------------------------------------------------------- /store/src/main/java/org/apache/rocketmq/store/CommitLogDispatcher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.store; 19 | 20 | /** 21 | * Dispatcher of commit log. 22 | */ 23 | public interface CommitLogDispatcher { 24 | 25 | void dispatch(final DispatchRequest request); 26 | } 27 | -------------------------------------------------------------------------------- /store/src/main/java/org/apache/rocketmq/store/GetMessageStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.store; 18 | 19 | public enum GetMessageStatus { 20 | 21 | FOUND, 22 | 23 | NO_MATCHED_MESSAGE, 24 | 25 | MESSAGE_WAS_REMOVING, 26 | 27 | OFFSET_FOUND_NULL, 28 | 29 | OFFSET_OVERFLOW_BADLY, 30 | 31 | OFFSET_OVERFLOW_ONE, 32 | 33 | OFFSET_TOO_SMALL, 34 | 35 | NO_MATCHED_LOGIC_QUEUE, 36 | 37 | NO_MESSAGE_IN_QUEUE, 38 | } 39 | -------------------------------------------------------------------------------- /store/src/main/java/org/apache/rocketmq/store/MessageArrivingListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.store; 19 | 20 | import java.util.Map; 21 | 22 | public interface MessageArrivingListener { 23 | void arriving(String topic, int queueId, long logicOffset, long tagsCode, 24 | long msgStoreTime, byte[] filterBitMap, Map properties); 25 | } 26 | -------------------------------------------------------------------------------- /store/src/main/java/org/apache/rocketmq/store/PutMessageLock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.store; 18 | 19 | /** 20 | * Used when trying to put message 21 | */ 22 | public interface PutMessageLock { 23 | void lock(); 24 | 25 | void unlock(); 26 | } 27 | -------------------------------------------------------------------------------- /store/src/main/java/org/apache/rocketmq/store/PutMessageReentrantLock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.store; 18 | 19 | import java.util.concurrent.locks.ReentrantLock; 20 | 21 | /** 22 | * 可重入锁 23 | * Exclusive lock implementation to put message 24 | */ 25 | public class PutMessageReentrantLock implements PutMessageLock { 26 | private ReentrantLock putMessageNormalLock = new ReentrantLock(); // NonfairSync 27 | 28 | @Override 29 | public void lock() { 30 | putMessageNormalLock.lock(); 31 | } 32 | 33 | @Override 34 | public void unlock() { 35 | putMessageNormalLock.unlock(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /store/src/main/java/org/apache/rocketmq/store/PutMessageStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.store; 18 | 19 | public enum PutMessageStatus { 20 | PUT_OK, 21 | FLUSH_DISK_TIMEOUT, 22 | FLUSH_SLAVE_TIMEOUT, 23 | SLAVE_NOT_AVAILABLE, 24 | SERVICE_NOT_AVAILABLE, 25 | CREATE_MAPEDFILE_FAILED, 26 | MESSAGE_ILLEGAL, 27 | PROPERTIES_SIZE_EXCEEDED, 28 | OS_PAGECACHE_BUSY, 29 | UNKNOWN_ERROR, 30 | } 31 | -------------------------------------------------------------------------------- /store/src/main/java/org/apache/rocketmq/store/config/BrokerRole.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.store.config; 18 | 19 | public enum BrokerRole { 20 | ASYNC_MASTER, 21 | SYNC_MASTER, 22 | SLAVE; 23 | } 24 | -------------------------------------------------------------------------------- /store/src/main/java/org/apache/rocketmq/store/config/FlushDiskType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.store.config; 18 | 19 | public enum FlushDiskType { 20 | SYNC_FLUSH, 21 | ASYNC_FLUSH 22 | } 23 | -------------------------------------------------------------------------------- /store/src/main/java/store代码架构图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrChiu/RocketMQ-Study/f1e1256bc7f4038c898cfd8bc58934859ee70d15/store/src/main/java/store代码架构图.png -------------------------------------------------------------------------------- /store/src/main/java/store设计架构图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrChiu/RocketMQ-Study/f1e1256bc7f4038c898cfd8bc58934859ee70d15/store/src/main/java/store设计架构图.png -------------------------------------------------------------------------------- /store/src/main/java/store设计架构图说明.txt: -------------------------------------------------------------------------------- 1 | 从架构图中可以总结出如下几个关键点: 2 | (1)消息生产与消息消费相互分离,Producer端发送消息最终写入的是CommitLog(消息存储的日志数据文件), 3 | Consumer端先从ConsumeQueue(消息逻辑队列)读取持久化消息的起始物理位置偏移量offset、大小size和消息Tag的HashCode值, 4 | 随后再从CommitLog中进行读取待拉取消费消息的真正实体内容部分; 5 | (2)RocketMQ的CommitLog文件采用混合型存储(所有的Topic下的消息队列共用同一个CommitLog的日志数据文件), 6 | 并通过建立类似索引文件—ConsumeQueue的方式来区分不同Topic下面的不同MessageQueue的消息,同时为消费消息起到一定的缓冲作用 7 | (只有ReputMessageService异步服务线程通过doDispatch异步生成了ConsumeQueue队列的元素后,Consumer端才能进行消费)。 8 | 这样,只要消息写入并刷盘至CommitLog文件后,消息就不会丢失,即使ConsumeQueue中的数据丢失,也可以通过CommitLog来恢复。 9 | (3)RocketMQ每次读写文件的时候真的是完全顺序读写么?这里,发送消息时,生产者端的消息确实是顺序写入CommitLog; 10 | 订阅消息时,消费者端也是顺序读取ConsumeQueue,然而根据其中的起始物理位置偏移量offset读取消息真实内容却是随机读取CommitLog。 11 | 在RocketMQ集群整体的吞吐量、并发量非常高的情况下,随机读取文件带来的性能开销影响还是比较大的, 12 | 那么这里如何去优化和避免这个问题呢?后面的章节将会逐步来解答这个问题。 13 | 这里,同样也可以总结下RocketMQ存储架构的优缺点: 14 | (1)优点: 15 | a、ConsumeQueue消息逻辑队列较为轻量级; 16 | b、对磁盘的访问串行化,避免磁盘竟争,不会因为队列增加导致IOWAIT增高; 17 | (2)缺点: 18 | a、对于CommitLog来说写入消息虽然是顺序写,但是读却变成了完全的随机读; 19 | b、Consumer端订阅消费一条消息,需要先读ConsumeQueue,再读Commit Log,一定程度上增加了开销。 -------------------------------------------------------------------------------- /store/src/main/java/预分配MappedFile的主要过程.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrChiu/RocketMQ-Study/f1e1256bc7f4038c898cfd8bc58934859ee70d15/store/src/main/java/预分配MappedFile的主要过程.png -------------------------------------------------------------------------------- /store/src/main/java/预分配MappedFile的主要过程说明.txt: -------------------------------------------------------------------------------- 1 | 在消息写入过程中(调用CommitLog的putMessage()方法),CommitLog会先从MappedFileQueue队列中获取一个 MappedFile, 2 | 如果没有就新建一个。 3 | 4 | 这里,MappedFile的创建过程是将构建好的一个AllocateRequest请求(具体做法是,将下一个文件的路径、下下个文件的路径、 5 | 文件大小为参数封装为AllocateRequest对象)添加至队列中,后台运行的AllocateMappedFileService服务线程(在Broker启动时, 6 | 该线程就会创建并运行),会不停地run,只要请求队列里存在请求,就会去执行MappedFile映射文件的创建和预分配工作, 7 | 分配的时候有两种策略,一种是使用Mmap的方式来构建MappedFile实例,另外一种是从TransientStorePool堆外内存池中获取 8 | 相应的DirectByteBuffer来构建MappedFile(ps:具体采用哪种策略,也与刷盘的方式有关)。并且,在创建分配完下个MappedFile后, 9 | 还会将下下个MappedFile预先创建并保存至请求队列中等待下次获取时直接返回。RocketMQ中预分配MappedFile的设计非常巧妙, 10 | 下次获取时候直接返回就可以不用等待MappedFile创建分配所产生的时间延迟。 11 | -------------------------------------------------------------------------------- /store/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n 23 | UTF-8 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /test/src/main/java/org/apache/rocketmq/test/clientinterface/MQConsumer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.test.clientinterface; 19 | 20 | public interface MQConsumer { 21 | void create(); 22 | 23 | void create(boolean useTLS); 24 | 25 | void start(); 26 | 27 | void shutdown(); 28 | } 29 | -------------------------------------------------------------------------------- /test/src/main/java/org/apache/rocketmq/test/clientinterface/MQProducer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.test.clientinterface; 19 | 20 | import org.apache.rocketmq.test.sendresult.ResultWrapper; 21 | 22 | public interface MQProducer { 23 | ResultWrapper send(Object msg, Object arg); 24 | 25 | void setDebug(); 26 | 27 | void setRun(); 28 | 29 | void shutdown(); 30 | } 31 | -------------------------------------------------------------------------------- /test/src/main/java/org/apache/rocketmq/test/factory/SendCallBackFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.test.factory; 19 | 20 | import org.apache.rocketmq.client.producer.SendCallback; 21 | import org.apache.rocketmq.client.producer.SendResult; 22 | 23 | public class SendCallBackFactory { 24 | public static SendCallback getSendCallBack() { 25 | return new SendCallback() { 26 | @Override 27 | public void onSuccess(SendResult sendResult) { 28 | } 29 | 30 | @Override 31 | public void onException(Throwable throwable) { 32 | } 33 | }; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /test/src/main/java/org/apache/rocketmq/test/util/Condition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.test.util; 19 | 20 | public interface Condition { 21 | boolean meetCondition(); 22 | } 23 | 24 | -------------------------------------------------------------------------------- /test/src/main/java/org/apache/rocketmq/test/util/MQRandomUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.test.util; 19 | 20 | public class MQRandomUtils { 21 | public static String getRandomTopic() { 22 | return RandomUtils.getStringByUUID(); 23 | } 24 | 25 | public static String getRandomConsumerGroup() { 26 | return RandomUtils.getStringByUUID(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /test/src/main/java/org/apache/rocketmq/test/util/data/collect/DataFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.test.util.data.collect; 19 | 20 | public interface DataFilter { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /test/src/main/java/org/apache/rocketmq/test/util/parallel/ParallelTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.test.util.parallel; 19 | 20 | import java.util.concurrent.CountDownLatch; 21 | 22 | public abstract class ParallelTask extends Thread { 23 | private CountDownLatch latch = null; 24 | 25 | public CountDownLatch getLatch() { 26 | return latch; 27 | } 28 | 29 | public void setLatch(CountDownLatch latch) { 30 | this.latch = latch; 31 | } 32 | 33 | public abstract void execute(); 34 | 35 | @Override 36 | public void run() { 37 | this.execute(); 38 | 39 | if (latch != null) { 40 | latch.countDown(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /test/src/main/java/org/apache/rocketmq/test/util/parallel/Task4Test.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.test.util.parallel; 19 | 20 | public class Task4Test extends ParallelTask { 21 | private String name = ""; 22 | 23 | public Task4Test(String name) { 24 | this.name = name; 25 | } 26 | 27 | @Override 28 | public void execute() { 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/src/test/java/org/apache/rocketmq/test/delay/DelayConf.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.test.delay; 19 | 20 | import org.apache.rocketmq.test.base.BaseConf; 21 | 22 | public class DelayConf extends BaseConf { 23 | protected static final int[] DELAY_LEVEL = { 24 | 1, 5, 10, 30, 1 * 60, 5 * 60, 10 * 60, 25 | 30 * 60, 1 * 3600, 2 * 3600, 6 * 3600, 12 * 3600, 1 * 24 * 3600}; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /test/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | true 23 | 24 | %d{yyy-MM-dd HH\:mm\:ss,GMT+8} %p %t - %m%n 25 | UTF-8 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /tools/src/main/java/org/apache/rocketmq/tools/admin/api/TrackType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.tools.admin.api; 19 | 20 | public enum TrackType { 21 | CONSUMED, 22 | CONSUMED_BUT_FILTERED, 23 | PULL, 24 | NOT_CONSUME_YET, 25 | NOT_ONLINE, 26 | UNKNOWN 27 | } 28 | -------------------------------------------------------------------------------- /tools/src/main/java/org/apache/rocketmq/tools/command/SubCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.tools.command; 18 | 19 | import org.apache.commons.cli.CommandLine; 20 | import org.apache.commons.cli.Options; 21 | import org.apache.rocketmq.remoting.RPCHook; 22 | 23 | public interface SubCommand { 24 | String commandName(); 25 | 26 | String commandDesc(); 27 | 28 | Options buildCommandlineOptions(final Options options); 29 | 30 | void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) throws SubCommandException; 31 | } 32 | -------------------------------------------------------------------------------- /tools/src/main/java/org/apache/rocketmq/tools/command/SubCommandException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.rocketmq.tools.command; 18 | 19 | public class SubCommandException extends Exception { 20 | private static final long serialVersionUID = 0L; 21 | 22 | /** 23 | * @param msg Message. 24 | */ 25 | public SubCommandException(String msg) { 26 | super(msg); 27 | } 28 | 29 | /** 30 | * @param msg Message. 31 | * @param cause Cause. 32 | */ 33 | public SubCommandException(String msg, Throwable cause) { 34 | super(msg, cause); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tools/src/main/java/org/apache/rocketmq/tools/command/topic/RebalanceResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.tools.command.topic; 19 | 20 | import java.util.HashMap; 21 | import java.util.List; 22 | import java.util.Map; 23 | import org.apache.rocketmq.common.message.MessageQueue; 24 | 25 | public class RebalanceResult { 26 | private Map> result = new HashMap>(); 27 | 28 | public Map> getResult() { 29 | return result; 30 | } 31 | 32 | public void setResult(final Map> result) { 33 | this.result = result; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /tools/src/main/java/org/apache/rocketmq/tools/monitor/MonitorListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.rocketmq.tools.monitor; 19 | 20 | import java.util.TreeMap; 21 | import org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo; 22 | 23 | public interface MonitorListener { 24 | void beginRound(); 25 | 26 | void reportUndoneMsgs(UndoneMsgs undoneMsgs); 27 | 28 | void reportFailedMsgs(FailedMsgs failedMsgs); 29 | 30 | void reportDeleteMsgsEvent(DeleteMsgsEvent deleteMsgsEvent); 31 | 32 | void reportConsumerRunningInfo(TreeMap criTable); 33 | 34 | void endRound(); 35 | } 36 | --------------------------------------------------------------------------------