Skip to content

Commit

Permalink
fix typo: contant -> constant (#443)
Browse files Browse the repository at this point in the history
  • Loading branch information
BeautyYuYanli authored Oct 25, 2022
1 parent 874d66a commit 04ab685
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 66 deletions.
4 changes: 2 additions & 2 deletions src/common/NameSpaceUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include "NameSpaceUtil.h"
#include "Logging.h"
#include "TraceContant.h"
#include "TraceConstant.h"

namespace rocketmq {

Expand Down Expand Up @@ -93,7 +93,7 @@ string NameSpaceUtil::withNameSpace(const string& source, const string& ns) {
}

bool NameSpaceUtil::hasNameSpace(const string& source, const string& ns) {
if (source.find(TraceContant::TRACE_TOPIC) != string::npos) {
if (source.find(TraceConstant::TRACE_TOPIC) != string::npos) {
LOG_DEBUG("Find Trace Topic [%s]", source.c_str());
return true;
}
Expand Down
8 changes: 4 additions & 4 deletions src/consumer/ConsumeMessageHookImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "Logging.h"
#include "MQClientException.h"
#include "NameSpaceUtil.h"
#include "TraceContant.h"
#include "TraceConstant.h"
#include "TraceContext.h"
#include "TraceTransferBean.h"
#include "TraceUtil.h"
Expand Down Expand Up @@ -66,14 +66,14 @@ void ConsumeMessageHookImpl::executeHookBefore(ConsumeMessageContext* context) {
bean.setRetryTimes((*it).getReconsumeTimes());
std::string regionId = (*it).getProperty(MQMessage::PROPERTY_MSG_REGION);
if (regionId.empty()) {
regionId = TraceContant::DEFAULT_REDION;
regionId = TraceConstant::DEFAULT_REDION;
}
traceContext->setRegionId(regionId);
traceContext->setTraceBean(bean);
}
traceContext->setTimeStamp(UtilAll::currentTimeMillis());

std::string topic = TraceContant::TRACE_TOPIC + traceContext->getRegionId();
std::string topic = TraceConstant::TRACE_TOPIC + traceContext->getRegionId();

TraceTransferBean ben = TraceUtil::CovertTraceContextToTransferBean(traceContext);
MQMessage message(topic, ben.getTransData());
Expand Down Expand Up @@ -102,7 +102,7 @@ void ConsumeMessageHookImpl::executeHookAfter(ConsumeMessageContext* context) {
TraceBean bean = subBeforeContext->getTraceBeans()[subAfterContext.getTraceBeanIndex()];
subAfterContext.setTraceBean(bean);

std::string topic = TraceContant::TRACE_TOPIC + subAfterContext.getRegionId();
std::string topic = TraceConstant::TRACE_TOPIC + subAfterContext.getRegionId();
TraceTransferBean ben = TraceUtil::CovertTraceContextToTransferBean(&subAfterContext);
MQMessage message(topic, ben.getTransData());
message.setKeys(ben.getTransKey());
Expand Down
4 changes: 2 additions & 2 deletions src/producer/DefaultMQProducerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "SendMessageHookImpl.h"
#include "StringIdMaker.h"
#include "TopicPublishInfo.h"
#include "TraceContant.h"
#include "TraceConstant.h"
#include "Validators.h"

namespace rocketmq {
Expand Down Expand Up @@ -707,7 +707,7 @@ bool DefaultMQProducerImpl::dealWithMessageTrace() {
return true;
}
bool DefaultMQProducerImpl::isMessageTraceTopic(const string& source) {
return source.find(TraceContant::TRACE_TOPIC) != string::npos;
return source.find(TraceConstant::TRACE_TOPIC) != string::npos;
}
bool DefaultMQProducerImpl::hasSendMessageHook() {
return !m_sendMessageHookList.empty();
Expand Down
8 changes: 4 additions & 4 deletions src/producer/SendMessageHookImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "Logging.h"
#include "MQClientException.h"
#include "SendMessageContext.h"
#include "TraceContant.h"
#include "TraceConstant.h"
#include "TraceTransferBean.h"
#include "TraceUtil.h"
#include "UtilAll.h"
Expand All @@ -46,7 +46,7 @@ void SendMessageHookImpl::executeHookBefore(SendMessageContext* context) {
if (context != NULL) {
string topic = context->getMessage()->getTopic();
// Check if contains TraceConstants::TRACE_TOPIC
if (topic.find(TraceContant::TRACE_TOPIC) != string::npos) {
if (topic.find(TraceConstant::TRACE_TOPIC) != string::npos) {
// trace message itself
return;
}
Expand All @@ -62,7 +62,7 @@ void SendMessageHookImpl::executeHookAfter(SendMessageContext* context) {
}
string topic = context->getMessage()->getTopic();
// Check if contains TraceConstants::TRACE_TOPIC
if (topic.find(TraceContant::TRACE_TOPIC) != string::npos) {
if (topic.find(TraceConstant::TRACE_TOPIC) != string::npos) {
// trace message itself
return;
}
Expand Down Expand Up @@ -96,7 +96,7 @@ void SendMessageHookImpl::executeHookAfter(SendMessageContext* context) {

traceContext->setTraceBean(traceBean);

topic = TraceContant::TRACE_TOPIC + traceContext->getRegionId();
topic = TraceConstant::TRACE_TOPIC + traceContext->getRegionId();
TraceTransferBean ben = TraceUtil::CovertTraceContextToTransferBean(traceContext.get());
// encode data
MQMessage message(topic, ben.getTransData());
Expand Down
2 changes: 1 addition & 1 deletion src/trace/ConsumeMessageContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "MQMessageExt.h"
#include "MQMessageQueue.h"
#include "TraceBean.h"
#include "TraceContant.h"
#include "TraceConstant.h"
#include "TraceContext.h"

namespace rocketmq {
Expand Down
2 changes: 1 addition & 1 deletion src/trace/SendMessageContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "MQMessageQueue.h"
#include "SendResult.h"
#include "TraceBean.h"
#include "TraceContant.h"
#include "TraceConstant.h"
#include "TraceContext.h"

namespace rocketmq {
Expand Down
2 changes: 1 addition & 1 deletion src/trace/TraceBean.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include <string>
#include <vector>
#include "TraceContant.h"
#include "TraceConstant.h"

namespace rocketmq {
class TraceBean {
Expand Down
18 changes: 9 additions & 9 deletions src/trace/TraceContant.cpp → src/trace/TraceConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
* limitations under the License.
*/

#include "TraceContant.h"
#include "TraceConstant.h"
#include <string>

namespace rocketmq {
std::string TraceContant::GROUP_NAME = "_INNER_TRACE_PRODUCER";
std::string TraceContant::TRACE_TOPIC = "rmq_sys_TRACE_DATA_";
std::string TraceContant::DEFAULT_REDION = "DEFAULT_REGION";
char TraceContant::CONTENT_SPLITOR = 1;
char TraceContant::FIELD_SPLITOR = 2;
std::string TraceContant::TRACE_TYPE_PUB = "Pub";
std::string TraceContant::TRACE_TYPE_BEFORE = "SubBefore";
std::string TraceContant::TRACE_TYPE_AFTER = "SubAfter";
std::string TraceConstant::GROUP_NAME = "_INNER_TRACE_PRODUCER";
std::string TraceConstant::TRACE_TOPIC = "rmq_sys_TRACE_DATA_";
std::string TraceConstant::DEFAULT_REDION = "DEFAULT_REGION";
char TraceConstant::CONTENT_SPLITOR = 1;
char TraceConstant::FIELD_SPLITOR = 2;
std::string TraceConstant::TRACE_TYPE_PUB = "Pub";
std::string TraceConstant::TRACE_TYPE_BEFORE = "SubBefore";
std::string TraceConstant::TRACE_TYPE_AFTER = "SubAfter";
} // namespace rocketmq
2 changes: 1 addition & 1 deletion src/trace/TraceContant.h → src/trace/TraceConstant.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <string>

namespace rocketmq {
class TraceContant {
class TraceConstant {
public:
static std::string GROUP_NAME;
static std::string TRACE_TOPIC;
Expand Down
2 changes: 1 addition & 1 deletion src/trace/TraceContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <string>
#include <vector>
#include "TraceBean.h"
#include "TraceContant.h"
#include "TraceConstant.h"

namespace rocketmq {
class TraceContext {
Expand Down
66 changes: 33 additions & 33 deletions src/trace/TraceUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
#include "TraceUtil.h"
#include <sstream>
#include <string>
#include "TraceContant.h"
#include "TraceConstant.h"

namespace rocketmq {
std::string TraceUtil::CovertTraceTypeToString(TraceType type) {
switch (type) {
case Pub:
return TraceContant::TRACE_TYPE_PUB;
return TraceConstant::TRACE_TYPE_PUB;
case SubBefore:
return TraceContant::TRACE_TYPE_BEFORE;
return TraceConstant::TRACE_TYPE_BEFORE;
case SubAfter:
return TraceContant::TRACE_TYPE_AFTER;
return TraceConstant::TRACE_TYPE_AFTER;
default:
return TraceContant::TRACE_TYPE_PUB;
return TraceConstant::TRACE_TYPE_PUB;
}
}

Expand All @@ -40,54 +40,54 @@ TraceTransferBean TraceUtil::CovertTraceContextToTransferBean(TraceContext* ctx)
switch (ctx->getTraceType()) {
case Pub: {
std::vector<TraceBean>::iterator it = beans.begin();
ss << TraceUtil::CovertTraceTypeToString(ctx->getTraceType()) << TraceContant::CONTENT_SPLITOR;
ss << ctx->getTimeStamp() << TraceContant::CONTENT_SPLITOR;
ss << ctx->getRegionId() << TraceContant::CONTENT_SPLITOR;
ss << ctx->getGroupName() << TraceContant::CONTENT_SPLITOR;
ss << it->getTopic() << TraceContant::CONTENT_SPLITOR;
ss << it->getMsgId() << TraceContant::CONTENT_SPLITOR;
ss << it->getTags() << TraceContant::CONTENT_SPLITOR;
ss << it->getKeys() << TraceContant::CONTENT_SPLITOR;
ss << it->getStoreHost() << TraceContant::CONTENT_SPLITOR;
ss << it->getBodyLength() << TraceContant::CONTENT_SPLITOR;
ss << ctx->getCostTime() << TraceContant::CONTENT_SPLITOR;
ss << it->getMsgType() << TraceContant::CONTENT_SPLITOR;
ss << it->getOffsetMsgId() << TraceContant::CONTENT_SPLITOR;
ss << (ctx->getStatus() ? "true" : "false") << TraceContant::FIELD_SPLITOR;
ss << TraceUtil::CovertTraceTypeToString(ctx->getTraceType()) << TraceConstant::CONTENT_SPLITOR;
ss << ctx->getTimeStamp() << TraceConstant::CONTENT_SPLITOR;
ss << ctx->getRegionId() << TraceConstant::CONTENT_SPLITOR;
ss << ctx->getGroupName() << TraceConstant::CONTENT_SPLITOR;
ss << it->getTopic() << TraceConstant::CONTENT_SPLITOR;
ss << it->getMsgId() << TraceConstant::CONTENT_SPLITOR;
ss << it->getTags() << TraceConstant::CONTENT_SPLITOR;
ss << it->getKeys() << TraceConstant::CONTENT_SPLITOR;
ss << it->getStoreHost() << TraceConstant::CONTENT_SPLITOR;
ss << it->getBodyLength() << TraceConstant::CONTENT_SPLITOR;
ss << ctx->getCostTime() << TraceConstant::CONTENT_SPLITOR;
ss << it->getMsgType() << TraceConstant::CONTENT_SPLITOR;
ss << it->getOffsetMsgId() << TraceConstant::CONTENT_SPLITOR;
ss << (ctx->getStatus() ? "true" : "false") << TraceConstant::FIELD_SPLITOR;
} break;

case SubBefore: {
std::vector<TraceBean>::iterator it = beans.begin();
for (; it != beans.end(); ++it) {
ss << TraceUtil::CovertTraceTypeToString(ctx->getTraceType()) << TraceContant::CONTENT_SPLITOR;
ss << ctx->getTimeStamp() << TraceContant::CONTENT_SPLITOR;
ss << ctx->getRegionId() << TraceContant::CONTENT_SPLITOR;
ss << ctx->getGroupName() << TraceContant::CONTENT_SPLITOR;
ss << ctx->getRequestId() << TraceContant::CONTENT_SPLITOR;
ss << it->getMsgId() << TraceContant::CONTENT_SPLITOR;
ss << it->getRetryTimes() << TraceContant::CONTENT_SPLITOR;
ss << TraceUtil::CovertTraceTypeToString(ctx->getTraceType()) << TraceConstant::CONTENT_SPLITOR;
ss << ctx->getTimeStamp() << TraceConstant::CONTENT_SPLITOR;
ss << ctx->getRegionId() << TraceConstant::CONTENT_SPLITOR;
ss << ctx->getGroupName() << TraceConstant::CONTENT_SPLITOR;
ss << ctx->getRequestId() << TraceConstant::CONTENT_SPLITOR;
ss << it->getMsgId() << TraceConstant::CONTENT_SPLITOR;
ss << it->getRetryTimes() << TraceConstant::CONTENT_SPLITOR;
// this is a bug caused by broker.
std::string defaultKey = "dKey";
if (!it->getKeys().empty()) {
defaultKey = it->getKeys();
}
ss << defaultKey << TraceContant::FIELD_SPLITOR;
ss << defaultKey << TraceConstant::FIELD_SPLITOR;
}
} break;

case SubAfter: {
std::vector<TraceBean>::iterator it = beans.begin();
ss << TraceUtil::CovertTraceTypeToString(ctx->getTraceType()) << TraceContant::CONTENT_SPLITOR;
ss << ctx->getRequestId() << TraceContant::CONTENT_SPLITOR;
ss << it->getMsgId() << TraceContant::CONTENT_SPLITOR;
ss << ctx->getCostTime() << TraceContant::CONTENT_SPLITOR;
ss << (ctx->getStatus() ? "true" : "false") << TraceContant::CONTENT_SPLITOR;
ss << TraceUtil::CovertTraceTypeToString(ctx->getTraceType()) << TraceConstant::CONTENT_SPLITOR;
ss << ctx->getRequestId() << TraceConstant::CONTENT_SPLITOR;
ss << it->getMsgId() << TraceConstant::CONTENT_SPLITOR;
ss << ctx->getCostTime() << TraceConstant::CONTENT_SPLITOR;
ss << (ctx->getStatus() ? "true" : "false") << TraceConstant::CONTENT_SPLITOR;
// this is a bug caused by broker.
std::string defaultKey = "dKey";
if (!it->getKeys().empty()) {
defaultKey = it->getKeys();
}
ss << defaultKey << TraceContant::FIELD_SPLITOR;
ss << defaultKey << TraceConstant::FIELD_SPLITOR;
} break;

default:
Expand Down
2 changes: 1 addition & 1 deletion src/trace/TraceUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define __ROCKETMQ_TRACE_UTIL_H_

#include <string>
#include "TraceContant.h"
#include "TraceConstant.h"
#include "TraceContext.h"
#include "TraceTransferBean.h"

Expand Down
12 changes: 6 additions & 6 deletions test/src/trace/TraceUtilTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"

#include "TraceContant.h"
#include "TraceConstant.h"
#include "TraceUtil.h"

using std::string;
Expand All @@ -30,18 +30,18 @@ using ::testing::InitGoogleTest;
using testing::Return;

using rocketmq::TraceBean;
using rocketmq::TraceContant;
using rocketmq::TraceConstant;
using rocketmq::TraceContext;
using rocketmq::TraceMessageType;
using rocketmq::TraceTransferBean;
using rocketmq::TraceType;
using rocketmq::TraceUtil;

TEST(TraceUtil, CovertTraceTypeToString) {
EXPECT_EQ(TraceUtil::CovertTraceTypeToString(TraceType::Pub), TraceContant::TRACE_TYPE_PUB);
EXPECT_EQ(TraceUtil::CovertTraceTypeToString(TraceType::SubBefore), TraceContant::TRACE_TYPE_BEFORE);
EXPECT_EQ(TraceUtil::CovertTraceTypeToString(TraceType::SubAfter), TraceContant::TRACE_TYPE_AFTER);
EXPECT_EQ(TraceUtil::CovertTraceTypeToString((TraceType)5), TraceContant::TRACE_TYPE_PUB);
EXPECT_EQ(TraceUtil::CovertTraceTypeToString(TraceType::Pub), TraceConstant::TRACE_TYPE_PUB);
EXPECT_EQ(TraceUtil::CovertTraceTypeToString(TraceType::SubBefore), TraceConstant::TRACE_TYPE_BEFORE);
EXPECT_EQ(TraceUtil::CovertTraceTypeToString(TraceType::SubAfter), TraceConstant::TRACE_TYPE_AFTER);
EXPECT_EQ(TraceUtil::CovertTraceTypeToString((TraceType)5), TraceConstant::TRACE_TYPE_PUB);
}
TEST(TraceUtil, CovertTraceContextToTransferBean) {
TraceContext context;
Expand Down

0 comments on commit 04ab685

Please sign in to comment.