You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by go...@apache.org on 2021/05/28 12:20:58 UTC
[incubator-inlong] 01/05: [INLONG-618] Add unit tests for
metastore.dao.entity.*
This is an automated email from the ASF dual-hosted git repository.
gosonzhang pushed a commit to branch TUBEMQ-570
in repository https://gitbox.apache.org/repos/asf/incubator-inlong.git
commit f9f1c273d2d53bf2a63f8136ac75b657dd2a6e46
Author: gosonzhang <go...@tencent.com>
AuthorDate: Wed May 26 12:27:22 2021 +0800
[INLONG-618] Add unit tests for metastore.dao.entity.*
---
.../tubemq/corebase/utils/SettingValidUtils.java | 13 ++
.../{CuPolType.java => CleanPolType.java} | 10 +-
.../server/common/statusdef/EnableStatus.java | 2 +-
.../server/master/metamanage/MetaDataManager.java | 59 -------
.../metastore/dao/entity/BaseEntity.java | 45 +----
.../metastore/dao/entity/BrokerConfEntity.java | 26 ---
.../metastore/dao/entity/ClusterSettingEntity.java | 22 ++-
.../dao/entity/GroupConsumeCtrlEntity.java | 24 +--
.../metastore/dao/entity/GroupResCtrlEntity.java | 29 +---
.../metastore/dao/entity/TopicCtrlEntity.java | 45 ++---
.../metastore/dao/entity/TopicDeployEntity.java | 15 --
.../metastore/dao/entity/TopicPropGroup.java | 24 +--
.../metastore/dao/entity/BaseEntityTest.java | 156 +++++++++++++++++
.../metastore/dao/entity/BrokerConfEntityTest.java | 120 +++++++++++++
.../dao/entity/ClusterSettingEntityTest.java | 185 +++++++++++++++++++++
.../dao/entity/GroupConsumeCtrlEntityTest.java | 90 ++++++++++
.../dao/entity/GroupResCtrlEntityTest.java | 129 ++++++++++++++
.../metastore/dao/entity/TopicCtrlEntityTest.java | 119 +++++++++++++
.../metastore/dao/entity/TopicPropGroupTest.java | 156 +++++++++++++++++
19 files changed, 1036 insertions(+), 233 deletions(-)
diff --git a/tubemq-core/src/main/java/org/apache/tubemq/corebase/utils/SettingValidUtils.java b/tubemq-core/src/main/java/org/apache/tubemq/corebase/utils/SettingValidUtils.java
index e748ba4..18a5d2b 100644
--- a/tubemq-core/src/main/java/org/apache/tubemq/corebase/utils/SettingValidUtils.java
+++ b/tubemq-core/src/main/java/org/apache/tubemq/corebase/utils/SettingValidUtils.java
@@ -23,6 +23,19 @@ import org.apache.tubemq.corebase.TBaseConstants;
public class SettingValidUtils {
+ public static int validAndGetMsgSizeInMB(int inMaxMsgSizeInMB) {
+ return MixedUtils.mid(inMaxMsgSizeInMB,
+ TBaseConstants.META_MIN_ALLOWED_MESSAGE_SIZE_MB,
+ TBaseConstants.META_MAX_ALLOWED_MESSAGE_SIZE_MB);
+ }
+
+ public static int validAndGetMsgSizeBtoMB(int inMaxMsgSizeInB) {
+ return MixedUtils.mid(inMaxMsgSizeInB,
+ TBaseConstants.META_MAX_MESSAGE_DATA_SIZE,
+ TBaseConstants.META_MAX_MESSAGE_DATA_SIZE_UPPER_LIMIT)
+ / TBaseConstants.META_MB_UNIT_SIZE;
+ }
+
public static int validAndXfeMaxMsgSizeFromMBtoB(int inMaxMsgSizeInMB) {
return MixedUtils.mid(inMaxMsgSizeInMB,
TBaseConstants.META_MIN_ALLOWED_MESSAGE_SIZE_MB,
diff --git a/tubemq-server/src/main/java/org/apache/tubemq/server/common/statusdef/CuPolType.java b/tubemq-server/src/main/java/org/apache/tubemq/server/common/statusdef/CleanPolType.java
similarity index 82%
rename from tubemq-server/src/main/java/org/apache/tubemq/server/common/statusdef/CuPolType.java
rename to tubemq-server/src/main/java/org/apache/tubemq/server/common/statusdef/CleanPolType.java
index b6ab79f..8f9a6e4 100644
--- a/tubemq-server/src/main/java/org/apache/tubemq/server/common/statusdef/CuPolType.java
+++ b/tubemq-server/src/main/java/org/apache/tubemq/server/common/statusdef/CleanPolType.java
@@ -18,14 +18,14 @@
package org.apache.tubemq.server.common.statusdef;
-public enum CuPolType {
- CU_POL_DELETE(0, "Delete");
+public enum CleanPolType {
+ CLEAN_POL_DELETE(0, "Delete");
private int code;
private String description;
- CuPolType(int code, String description) {
+ CleanPolType(int code, String description) {
this.code = code;
this.description = description;
}
@@ -35,8 +35,8 @@ public enum CuPolType {
}
- public static CuPolType valueOf(int code) {
- for (CuPolType status : CuPolType.values()) {
+ public static CleanPolType valueOf(int code) {
+ for (CleanPolType status : CleanPolType.values()) {
if (status.getCode() == code) {
return status;
}
diff --git a/tubemq-server/src/main/java/org/apache/tubemq/server/common/statusdef/EnableStatus.java b/tubemq-server/src/main/java/org/apache/tubemq/server/common/statusdef/EnableStatus.java
index b158572..7ef6bc3 100644
--- a/tubemq-server/src/main/java/org/apache/tubemq/server/common/statusdef/EnableStatus.java
+++ b/tubemq-server/src/main/java/org/apache/tubemq/server/common/statusdef/EnableStatus.java
@@ -21,7 +21,7 @@ package org.apache.tubemq.server.common.statusdef;
public enum EnableStatus {
STATUS_UNDEFINE(-2, "Undefined."),
STATUS_DISABLE(0, "Disable."),
- STATUS_ENABLE(1, "Enable.");
+ STATUS_ENABLE(2, "Enable.");
private int code;
private String description;
diff --git a/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/MetaDataManager.java b/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/MetaDataManager.java
index 9d9ed13..e6ee213 100644
--- a/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/MetaDataManager.java
+++ b/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/MetaDataManager.java
@@ -1453,65 +1453,6 @@ public class MetaDataManager implements Server {
return result.isSuccess();
}
-
- /**
- * Add if absent topic control configure info
- *
- * @param deployEntity the topic deploy info will be add
- * @param strBuffer the print info string buffer
- * @param result the process result return
- * @return true if success otherwise false
- */
- public void addIfAbsentTopicCtrlConf(TopicDeployEntity deployEntity,
- StringBuilder strBuffer,
- ProcessResult result) {
- TopicCtrlEntity curEntity =
- metaStoreService.getTopicCtrlConf(deployEntity.getTopicName());
- if (curEntity != null) {
- return;
- }
- int maxMsgSizeInMB = TBaseConstants.META_MIN_ALLOWED_MESSAGE_SIZE_MB;
- ClusterSettingEntity defSetting = metaStoreService.getClusterConfig();
- if (defSetting != null) {
- maxMsgSizeInMB = defSetting.getMaxMsgSizeInMB();
- }
- curEntity = new TopicCtrlEntity(deployEntity.getTopicName(),
- deployEntity.getTopicId(), maxMsgSizeInMB, deployEntity.getCreateUser());
- metaStoreService.addTopicCtrlConf(curEntity, strBuffer, result);
- return;
- }
-
- /**
- * Add if absent topic control configure info
- *
- * @param topicNameSet the topic name will be add
- * @param operator the topic name id will be add
- * @param operator operator
- * @param sBuffer the print info string buffer
- */
- public boolean addIfAbsentTopicCtrlConf(Set<String> topicNameSet, String operator,
- StringBuilder sBuffer, ProcessResult result) {
- TopicCtrlEntity curEntity;
- int maxMsgSizeInMB = TBaseConstants.META_MIN_ALLOWED_MESSAGE_SIZE_MB;
- ClusterSettingEntity defSetting = metaStoreService.getClusterConfig();
- if (defSetting != null) {
- maxMsgSizeInMB = defSetting.getMaxMsgSizeInMB();
- }
- for (String topicName : topicNameSet) {
- curEntity = metaStoreService.getTopicCtrlConf(topicName);
- if (curEntity != null) {
- continue;
- }
- curEntity = new TopicCtrlEntity(topicName,
- TBaseConstants.META_VALUE_UNDEFINED, maxMsgSizeInMB, operator);
- if (!metaStoreService.addTopicCtrlConf(curEntity, sBuffer, result)) {
- return result.isSuccess();
- }
- }
- result.setSuccResult(null);
- return result.isSuccess();
- }
-
/**
* Add if absent topic control configure info
*
diff --git a/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/BaseEntity.java b/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/BaseEntity.java
index 6ee733a..9cf1853 100644
--- a/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/BaseEntity.java
+++ b/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/BaseEntity.java
@@ -46,10 +46,6 @@ public class BaseEntity implements Serializable, Cloneable {
}
- public BaseEntity(long dataVersionId) {
- this.dataVersionId = dataVersionId;
- }
-
public BaseEntity(String createUser, Date createDate) {
this(TServerConstants.DEFAULT_DATA_VERSION,
createUser, createDate, createUser, createDate);
@@ -61,6 +57,8 @@ public class BaseEntity implements Serializable, Cloneable {
this.setCreateDate(other.createDate);
this.modifyUser = other.modifyUser;
this.setModifyDate(other.modifyDate);
+ this.serialId = other.serialId;
+ this.attributes = other.attributes;
}
public BaseEntity(long dataVersionId, String createUser, Date createDate) {
@@ -81,6 +79,7 @@ public class BaseEntity implements Serializable, Cloneable {
this.setCreateDate(createDate);
this.modifyUser = modifyUser;
this.setModifyDate(modifyDate);
+ updSerialId();
}
public boolean updBaseModifyInfo(BaseEntity opInfoEntity) {
@@ -126,44 +125,6 @@ public class BaseEntity implements Serializable, Cloneable {
return changed;
}
- public boolean updBaseModifyInfo(long newDataVerId, String newCreateUser,
- Date newCreateDate, String newModifyUser,
- Date newModifyDate, String newAttributes) {
- boolean changed = false;
- // check and set dataVersionId field
- if (newDataVerId != TBaseConstants.META_VALUE_UNDEFINED
- && this.dataVersionId != newDataVerId) {
- changed = true;
- this.dataVersionId = newDataVerId;
- }
- if (TStringUtils.isNotBlank(newCreateUser)
- && !Objects.equals(createUser, newCreateUser)) {
- changed = true;
- this.createUser = newCreateUser;
- }
- if (newCreateDate != null
- && !Objects.equals(createDate, newCreateDate)) {
- changed = true;
- this.setCreateDate(newCreateDate);
- }
- if (TStringUtils.isNotBlank(newModifyUser)
- && !Objects.equals(modifyUser, newModifyUser)) {
- changed = true;
- this.modifyUser = newModifyUser;
- }
- if (newModifyDate != null
- && !Objects.equals(modifyDate, newModifyDate)) {
- changed = true;
- this.setModifyDate(newModifyDate);
- }
- if (TStringUtils.isNotBlank(newAttributes)
- && !Objects.equals(attributes, newAttributes)) {
- changed = true;
- this.attributes = newAttributes;
- }
- return changed;
- }
-
public void setDataVersionId(long dataVersionId) {
this.dataVersionId = dataVersionId;
}
diff --git a/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/BrokerConfEntity.java b/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/BrokerConfEntity.java
index 5dfa7f0..05216b1 100644
--- a/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/BrokerConfEntity.java
+++ b/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/BrokerConfEntity.java
@@ -17,7 +17,6 @@
package org.apache.tubemq.server.master.metamanage.metastore.dao.entity;
-import java.util.Date;
import java.util.Objects;
import org.apache.tubemq.corebase.TBaseConstants;
import org.apache.tubemq.corebase.TokenConstants;
@@ -63,20 +62,6 @@ public class BrokerConfEntity extends BaseEntity implements Cloneable {
this.brokerIp = brokerIp;
}
- public BrokerConfEntity(int brokerId, String brokerIp, int brokerPort,
- int brokerTLSPort, int brokerWebPort, ManageStatus manageStatus,
- int regionId, int groupId, TopicPropGroup defTopicProps,
- long dataVersionId, String createUser,
- Date createDate, String modifyUser, Date modifyDate) {
- super(dataVersionId, createUser, createDate, modifyUser, modifyDate);
- setBrokerIpAndAllPort(brokerId, brokerIp, brokerPort, brokerTLSPort);
- this.regionId = regionId;
- this.groupId = groupId;
- this.brokerWebPort = brokerWebPort;
- this.topicProps = defTopicProps;
- this.manageStatus = manageStatus;
- }
-
public BrokerConfEntity(BdbBrokerConfEntity bdbEntity) {
super(bdbEntity.getDataVerId(), bdbEntity.getRecordCreateUser(),
bdbEntity.getRecordCreateDate(), bdbEntity.getRecordModifyUser(),
@@ -129,11 +114,6 @@ public class BrokerConfEntity extends BaseEntity implements Cloneable {
this.brokerId = brokerId;
}
- public void setBrokerIdAndIp(int brokerId, String brokerIp) {
- this.brokerId = brokerId;
- this.brokerIp = brokerIp;
- }
-
public ManageStatus getManageStatus() {
return manageStatus;
}
@@ -146,12 +126,6 @@ public class BrokerConfEntity extends BaseEntity implements Cloneable {
this.manageStatus = manageStatus;
}
- public void setBrokerIpAndPort(String brokerIp, int brokerPort) {
- this.brokerPort = brokerPort;
- this.brokerIp = brokerIp;
- this.buildStrInfo();
- }
-
public String getBrokerAddress() {
return brokerAddress;
}
diff --git a/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/ClusterSettingEntity.java b/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/ClusterSettingEntity.java
index fb70bb0..151ff7e 100644
--- a/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/ClusterSettingEntity.java
+++ b/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/ClusterSettingEntity.java
@@ -96,11 +96,15 @@ public class ClusterSettingEntity extends BaseEntity implements Cloneable {
clsDefTopicProps.isAcceptSubscribe(), clsDefTopicProps.getDeletePolicy(),
this.qryPriorityId, this.maxMsgSizeInB, getAttributes(),
getModifyUser(), getModifyDate());
- bdbEntity.setDefDataPath(clsDefTopicProps.getDataPath());
+ if (TStringUtils.isNotBlank(clsDefTopicProps.getDataPath())) {
+ bdbEntity.setDefDataPath(clsDefTopicProps.getDataPath());
+ }
bdbEntity.setDefDataType(clsDefTopicProps.getDataStoreType());
bdbEntity.setEnableGloFlowCtrl(enableFlowCtrl());
bdbEntity.setGloFlowCtrlCnt(gloFlowCtrlRuleCnt);
- bdbEntity.setGloFlowCtrlInfo(gloFlowCtrlRuleInfo);
+ if (TStringUtils.isNotBlank(gloFlowCtrlRuleInfo)) {
+ bdbEntity.setGloFlowCtrlInfo(gloFlowCtrlRuleInfo);
+ }
return bdbEntity;
}
@@ -158,12 +162,13 @@ public class ClusterSettingEntity extends BaseEntity implements Cloneable {
}
// check and set modified field
if (maxMsgSizeMB != TBaseConstants.META_VALUE_UNDEFINED) {
- int newMaxMsgSizeB =
- SettingValidUtils.validAndXfeMaxMsgSizeFromMBtoB(maxMsgSizeMB);
- if (this.maxMsgSizeInB != newMaxMsgSizeB) {
+ int tmpMaxMsgSizeInMB =
+ SettingValidUtils.validAndGetMsgSizeInMB(maxMsgSizeMB);
+ if (this.maxMsgSizeInMB != tmpMaxMsgSizeInMB) {
changed = true;
- this.maxMsgSizeInB = newMaxMsgSizeB;
- this.maxMsgSizeInMB = maxMsgSizeMB;
+ this.maxMsgSizeInMB = tmpMaxMsgSizeInMB;
+ this.maxMsgSizeInB =
+ SettingValidUtils.validAndXfeMaxMsgSizeFromMBtoB(tmpMaxMsgSizeInMB);
}
}
// check and set qry priority id
@@ -174,7 +179,8 @@ public class ClusterSettingEntity extends BaseEntity implements Cloneable {
}
// check and set flowCtrl info
if (flowCtrlEnable != null
- && this.gloFlowCtrlStatus.isEnable() != flowCtrlEnable) {
+ && (this.gloFlowCtrlStatus == EnableStatus.STATUS_UNDEFINE
+ || this.gloFlowCtrlStatus.isEnable() != flowCtrlEnable)) {
changed = true;
setEnableFlowCtrl(flowCtrlEnable);
}
diff --git a/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/GroupConsumeCtrlEntity.java b/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/GroupConsumeCtrlEntity.java
index 1e7a3b9..b125257 100644
--- a/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/GroupConsumeCtrlEntity.java
+++ b/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/GroupConsumeCtrlEntity.java
@@ -17,9 +17,7 @@
package org.apache.tubemq.server.master.metamanage.metastore.dao.entity;
-import java.util.Date;
import java.util.Objects;
-
import org.apache.tubemq.corebase.TBaseConstants;
import org.apache.tubemq.corebase.utils.KeyBuilderUtils;
import org.apache.tubemq.corebase.utils.TStringUtils;
@@ -54,20 +52,6 @@ public class GroupConsumeCtrlEntity extends BaseEntity implements Cloneable {
this.topicName = topicName;
}
- public GroupConsumeCtrlEntity(String groupName, String topicName,
- EnableStatus consumeEnable,
- String disableReason,
- EnableStatus filterEnable,
- String filterCondStr, String createUser,
- Date createDate) {
- super(createUser, createDate);
- this.setGroupAndTopic(groupName, topicName);
- this.consumeEnable = consumeEnable;
- this.disableReason = disableReason;
- this.filterEnable = filterEnable;
- this.filterCondStr = filterCondStr;
- }
-
public GroupConsumeCtrlEntity(BdbGroupFilterCondEntity bdbEntity) {
super(bdbEntity.getDataVerId(),
bdbEntity.getCreateUser(), bdbEntity.getCreateDate());
@@ -89,7 +73,7 @@ public class GroupConsumeCtrlEntity extends BaseEntity implements Cloneable {
BdbGroupFilterCondEntity bdbEntity =
new BdbGroupFilterCondEntity(topicName, groupName,
filterEnable.getCode(), filterCondStr,
- getAttributes(), getCreateUser(), getCreateDate());
+ getAttributes(), getModifyUser(), getModifyDate());
bdbEntity.setDataVerId(getDataVerId());
bdbEntity.setConsumeEnable(consumeEnable);
bdbEntity.setDisableConsumeReason(disableReason);
@@ -187,7 +171,8 @@ public class GroupConsumeCtrlEntity extends BaseEntity implements Cloneable {
}
// check and set consumeEnable info
if (consumeEnable != null
- && this.consumeEnable.isEnable() != consumeEnable) {
+ && (this.consumeEnable == EnableStatus.STATUS_UNDEFINE
+ || this.consumeEnable.isEnable() != consumeEnable)) {
changed = true;
setConsumeEnable(consumeEnable);
}
@@ -199,7 +184,8 @@ public class GroupConsumeCtrlEntity extends BaseEntity implements Cloneable {
}
// check and set consumeEnable info
if (filterEnable != null
- && this.filterEnable.isEnable() != filterEnable) {
+ && (this.filterEnable == EnableStatus.STATUS_UNDEFINE
+ || this.filterEnable.isEnable() != filterEnable)) {
changed = true;
setFilterEnable(filterEnable);
}
diff --git a/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/GroupResCtrlEntity.java b/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/GroupResCtrlEntity.java
index 35f9b96..69c280c 100644
--- a/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/GroupResCtrlEntity.java
+++ b/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/GroupResCtrlEntity.java
@@ -17,7 +17,6 @@
package org.apache.tubemq.server.master.metamanage.metastore.dao.entity;
-import java.util.Date;
import java.util.Objects;
import org.apache.tubemq.corebase.TBaseConstants;
import org.apache.tubemq.corebase.utils.TStringUtils;
@@ -43,6 +42,7 @@ public class GroupResCtrlEntity extends BaseEntity implements Cloneable {
private String flowCtrlInfo = ""; // flow control info
+ // only for query
public GroupResCtrlEntity() {
super();
}
@@ -52,22 +52,6 @@ public class GroupResCtrlEntity extends BaseEntity implements Cloneable {
this.groupName = groupName;
}
- public GroupResCtrlEntity(String groupName, int qryPriorityId,
- boolean enableFlowCtrl, int ruleCnt,
- String flowCtrlInfo, String createUser,
- Date createDate) {
- super(createUser, createDate);
- this.groupName = groupName;
- if (enableFlowCtrl) {
- this.flowCtrlStatus = EnableStatus.STATUS_ENABLE;
- } else {
- this.flowCtrlStatus = EnableStatus.STATUS_DISABLE;
- }
- this.qryPriorityId = qryPriorityId;
- this.ruleCnt = ruleCnt;
- this.flowCtrlInfo = flowCtrlInfo;
- }
-
public GroupResCtrlEntity(BdbGroupFlowCtrlEntity bdbEntity) {
super(bdbEntity.getSerialId(),
bdbEntity.getCreateUser(), bdbEntity.getCreateDate());
@@ -80,6 +64,8 @@ public class GroupResCtrlEntity extends BaseEntity implements Cloneable {
} else {
this.flowCtrlStatus = EnableStatus.STATUS_DISABLE;
}
+ this.resCheckStatus = bdbEntity.getResCheckStatus();
+ this.allowedBrokerClientRate = bdbEntity.getAllowedBrokerClientRate();
setAttributes(bdbEntity.getAttributes());
}
@@ -89,7 +75,7 @@ public class GroupResCtrlEntity extends BaseEntity implements Cloneable {
BdbGroupFlowCtrlEntity bdbEntity =
new BdbGroupFlowCtrlEntity(getDataVerId(), this.groupName,
this.flowCtrlInfo, statusId, this.ruleCnt, this.qryPriorityId,
- getAttributes(), getCreateUser(), getCreateDate());
+ getAttributes(), getModifyUser(), getModifyDate());
bdbEntity.setResCheckStatus(resCheckStatus);
bdbEntity.setAllowedBrokerClientRate(allowedBrokerClientRate);
return bdbEntity;
@@ -105,6 +91,7 @@ public class GroupResCtrlEntity extends BaseEntity implements Cloneable {
this.allowedBrokerClientRate = 0;
this.qryPriorityId = TServerConstants.QRY_PRIORITY_DEF_VALUE;
this.flowCtrlStatus = EnableStatus.STATUS_DISABLE;
+ this.ruleCnt = 0;
this.flowCtrlInfo = TServerConstants.BLANK_FLOWCTRL_RULES;
return this;
}
@@ -205,7 +192,8 @@ public class GroupResCtrlEntity extends BaseEntity implements Cloneable {
}
// check and set resCheckStatus info
if (resChkEnable != null
- && this.resCheckStatus.isEnable() != resChkEnable) {
+ && (this.resCheckStatus == EnableStatus.STATUS_UNDEFINE
+ || this.resCheckStatus.isEnable() != resChkEnable)) {
changed = true;
setResCheckStatus(resChkEnable);
}
@@ -223,7 +211,8 @@ public class GroupResCtrlEntity extends BaseEntity implements Cloneable {
}
// check and set flowCtrl info
if (flowCtrlEnable != null
- && this.flowCtrlStatus.isEnable() != flowCtrlEnable) {
+ && (this.flowCtrlStatus == EnableStatus.STATUS_UNDEFINE
+ || this.flowCtrlStatus.isEnable() != flowCtrlEnable)) {
changed = true;
setFlowCtrlStatus(flowCtrlEnable);
}
diff --git a/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/TopicCtrlEntity.java b/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/TopicCtrlEntity.java
index 61e148b..0ea8559 100644
--- a/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/TopicCtrlEntity.java
+++ b/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/TopicCtrlEntity.java
@@ -61,27 +61,12 @@ public class TopicCtrlEntity extends BaseEntity implements Cloneable {
this.topicName = topicName;
}
- public TopicCtrlEntity(String topicName, int topicNameId,
- boolean enableAuth, int maxMsgSizeInB,
- long dataVersionId, String createUser,
- Date createDate, String modifyUser, Date modifyDate) {
- super(dataVersionId, createUser, createDate, modifyUser, modifyDate);
- this.topicName = topicName;
- this.topicNameId = topicNameId;
- this.fillMaxMsgSize(maxMsgSizeInB);
- if (enableAuth) {
- this.authCtrlStatus = EnableStatus.STATUS_ENABLE;
- } else {
- this.authCtrlStatus = EnableStatus.STATUS_DISABLE;
- }
- }
-
public TopicCtrlEntity(BdbTopicAuthControlEntity bdbEntity) {
super(bdbEntity.getDataVerId(),
bdbEntity.getCreateUser(), bdbEntity.getCreateDate());
this.topicName = bdbEntity.getTopicName();
this.topicNameId = bdbEntity.getTopicId();
- this.fillMaxMsgSize(maxMsgSizeInB);
+ this.fillMaxMsgSizeInB(bdbEntity.getMaxMsgSize());
if (bdbEntity.isEnableAuthControl()) {
this.authCtrlStatus = EnableStatus.STATUS_ENABLE;
} else {
@@ -93,7 +78,7 @@ public class TopicCtrlEntity extends BaseEntity implements Cloneable {
public BdbTopicAuthControlEntity buildBdbTopicAuthControlEntity() {
BdbTopicAuthControlEntity bdbEntity =
new BdbTopicAuthControlEntity(topicName, isAuthCtrlEnable(),
- getAttributes(), getCreateUser(), getCreateDate());
+ getAttributes(), getModifyUser(), getModifyDate());
bdbEntity.setTopicId(topicNameId);
bdbEntity.setDataVerId(getDataVerId());
bdbEntity.setMaxMsgSize(maxMsgSizeInB);
@@ -166,17 +151,19 @@ public class TopicCtrlEntity extends BaseEntity implements Cloneable {
}
// check and set modified field
if (newMaxMsgSizeMB != TBaseConstants.META_VALUE_UNDEFINED) {
- int newMaxMsgSizeB =
- SettingValidUtils.validAndXfeMaxMsgSizeFromMBtoB(newMaxMsgSizeMB);
- if (this.maxMsgSizeInB != newMaxMsgSizeB) {
+ int tmpMaxMsgSizeInMB =
+ SettingValidUtils.validAndGetMsgSizeInMB(newMaxMsgSizeMB);
+ if (this.maxMsgSizeInMB != tmpMaxMsgSizeInMB) {
changed = true;
- this.maxMsgSizeInB = newMaxMsgSizeB;
- this.maxMsgSizeInMB = newMaxMsgSizeMB;
+ this.maxMsgSizeInMB = tmpMaxMsgSizeInMB;
+ this.maxMsgSizeInB =
+ SettingValidUtils.validAndXfeMaxMsgSizeFromMBtoB(tmpMaxMsgSizeInMB);
}
}
// check and set authCtrlStatus info
if (enableTopicAuth != null
- && this.authCtrlStatus.isEnable() != enableTopicAuth) {
+ && (this.authCtrlStatus == EnableStatus.STATUS_UNDEFINE
+ || this.authCtrlStatus.isEnable() != enableTopicAuth)) {
setEnableAuthCtrl(enableTopicAuth);
changed = true;
}
@@ -241,10 +228,14 @@ public class TopicCtrlEntity extends BaseEntity implements Cloneable {
return sBuilder;
}
- private void fillMaxMsgSize(int maxMsgSizeInB) {
- this.maxMsgSizeInB = maxMsgSizeInB;
- this.maxMsgSizeInMB =
- maxMsgSizeInB / TBaseConstants.META_MB_UNIT_SIZE;
+ private void fillMaxMsgSizeInB(int maxMsgSizeInB) {
+ int tmpMaxMsgSizeInMB = TBaseConstants.META_MIN_ALLOWED_MESSAGE_SIZE_MB;
+ if (maxMsgSizeInB > TBaseConstants.META_MB_UNIT_SIZE) {
+ tmpMaxMsgSizeInMB = SettingValidUtils.validAndGetMsgSizeBtoMB(maxMsgSizeInB);
+ }
+ this.maxMsgSizeInMB = tmpMaxMsgSizeInMB;
+ this.maxMsgSizeInB =
+ SettingValidUtils.validAndXfeMaxMsgSizeFromMBtoB(this.maxMsgSizeInMB);
}
/**
diff --git a/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/TopicDeployEntity.java b/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/TopicDeployEntity.java
index 9c1a678..8f79fc8 100644
--- a/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/TopicDeployEntity.java
+++ b/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/TopicDeployEntity.java
@@ -17,7 +17,6 @@
package org.apache.tubemq.server.master.metamanage.metastore.dao.entity;
-import java.util.Date;
import java.util.Objects;
import org.apache.tubemq.corebase.TBaseConstants;
import org.apache.tubemq.corebase.utils.KeyBuilderUtils;
@@ -54,20 +53,6 @@ public class TopicDeployEntity extends BaseEntity implements Cloneable {
this.recordKey = KeyBuilderUtils.buildTopicConfRecKey(brokerId, topicName);
}
- public TopicDeployEntity(String topicName, int topicId, int brokerId,
- String brokerIp, int brokerPort,
- TopicPropGroup topicProps, TopicStatus deployStatus,
- long dataVersionId, String createUser,
- Date createDate, String modifyUser, Date modifyDate) {
- super(dataVersionId, createUser, createDate, modifyUser, modifyDate);
- setTopicDeployInfo(brokerId, brokerIp, brokerPort, topicName);
- this.topicNameId = topicId;
- this.deployStatus = deployStatus;
- this.topicProps = topicProps;
- this.brokerAddress = KeyBuilderUtils.buildAddressInfo(brokerIp, brokerPort);
-
- }
-
public TopicDeployEntity(BdbTopicConfEntity bdbEntity) {
super(bdbEntity.getDataVerId(),
bdbEntity.getCreateUser(), bdbEntity.getCreateDate(),
diff --git a/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/TopicPropGroup.java b/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/TopicPropGroup.java
index 63c7eaa..27db4f9 100644
--- a/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/TopicPropGroup.java
+++ b/tubemq-server/src/main/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/TopicPropGroup.java
@@ -24,7 +24,7 @@ import org.apache.tubemq.corebase.TBaseConstants;
import org.apache.tubemq.corebase.utils.TStringUtils;
import org.apache.tubemq.corebase.utils.Tuple2;
import org.apache.tubemq.server.common.TServerConstants;
-import org.apache.tubemq.server.common.statusdef.CuPolType;
+import org.apache.tubemq.server.common.statusdef.CleanPolType;
/*
@@ -47,7 +47,7 @@ public class TopicPropGroup implements Serializable, Cloneable {
private String dataPath = ""; //data path
private String deletePolicy = ""; // delete policy
// Retention period, unit ms
- private CuPolType fileCuPolicyType = CuPolType.CU_POL_DELETE;
+ private CleanPolType cleanPolicyType = CleanPolType.CLEAN_POL_DELETE;
private long retPeriodInMs = TBaseConstants.META_VALUE_UNDEFINED;
public TopicPropGroup() {
@@ -72,7 +72,9 @@ public class TopicPropGroup implements Serializable, Cloneable {
this.acceptSubscribe = acceptSubscribe;
setDeletePolicy(deletePolicy);
this.dataStoreType = dataStoreType;
- this.dataPath = dataPath;
+ if (dataPath != null) {
+ this.dataPath = dataPath;
+ }
}
public int getNumTopicStores() {
@@ -165,8 +167,8 @@ public class TopicPropGroup implements Serializable, Cloneable {
public void setDeletePolicy(String deletePolicy) {
if (TStringUtils.isNotBlank(deletePolicy)) {
this.deletePolicy = deletePolicy;
- Tuple2<CuPolType, Long> parsedRet = parseDelPolicy(deletePolicy);
- this.fileCuPolicyType = parsedRet.getF0();
+ Tuple2<CleanPolType, Long> parsedRet = parseDelPolicy(deletePolicy);
+ this.cleanPolicyType = parsedRet.getF0();
this.retPeriodInMs = parsedRet.getF1();
}
}
@@ -179,8 +181,8 @@ public class TopicPropGroup implements Serializable, Cloneable {
return retPeriodInMs;
}
- public CuPolType getFileCuPolicyType() {
- return fileCuPolicyType;
+ public CleanPolType getCleanPolicyType() {
+ return cleanPolicyType;
}
public void setDataStoreInfo(int dataStoreType, String dataPath) {
@@ -327,7 +329,7 @@ public class TopicPropGroup implements Serializable, Cloneable {
&& Objects.equals(acceptSubscribe, other.acceptSubscribe)
&& Objects.equals(dataPath, other.dataPath)
&& Objects.equals(deletePolicy, other.deletePolicy)
- && fileCuPolicyType == other.fileCuPolicyType;
+ && cleanPolicyType == other.cleanPolicyType;
}
/**
@@ -436,7 +438,7 @@ public class TopicPropGroup implements Serializable, Cloneable {
return Objects.hash(numTopicStores, numPartitions, unflushThreshold,
unflushInterval, unflushDataHold, memCacheMsgSizeInMB, memCacheMsgCntInK,
memCacheFlushIntvl, acceptPublish, acceptSubscribe, dataStoreType,
- dataPath, deletePolicy, fileCuPolicyType, retPeriodInMs);
+ dataPath, deletePolicy, cleanPolicyType, retPeriodInMs);
}
@Override
@@ -454,7 +456,7 @@ public class TopicPropGroup implements Serializable, Cloneable {
}
- private Tuple2<CuPolType, Long> parseDelPolicy(String delPolicy) {
+ private Tuple2<CleanPolType, Long> parseDelPolicy(String delPolicy) {
long validDuration = 0;
String[] tmpStrs = delPolicy.split(",");
String validValStr = tmpStrs[1];
@@ -468,7 +470,7 @@ public class TopicPropGroup implements Serializable, Cloneable {
} else {
validDuration = Long.parseLong(validValStr) * 3600000;
}
- return new Tuple2<>(CuPolType.CU_POL_DELETE, validDuration);
+ return new Tuple2<>(CleanPolType.CLEAN_POL_DELETE, validDuration);
}
}
diff --git a/tubemq-server/src/test/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/BaseEntityTest.java b/tubemq-server/src/test/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/BaseEntityTest.java
new file mode 100644
index 0000000..74ee410
--- /dev/null
+++ b/tubemq-server/src/test/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/BaseEntityTest.java
@@ -0,0 +1,156 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tubemq.server.master.metamanage.metastore.dao.entity;
+
+import java.util.Date;
+import org.apache.tubemq.corebase.TBaseConstants;
+import org.apache.tubemq.server.common.TServerConstants;
+import org.apache.tubemq.server.common.utils.WebParameterUtils;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+
+public class BaseEntityTest {
+
+ @Test
+ public void baseEntityTest() {
+ // case 1
+ BaseEntity baseEntity1 = new BaseEntity();
+ Assert.assertEquals(baseEntity1.getDataVerId(), TBaseConstants.META_VALUE_UNDEFINED);
+ Assert.assertEquals(baseEntity1.getSerialId(), TBaseConstants.META_VALUE_UNDEFINED);
+ Assert.assertEquals(baseEntity1.getCreateUser(), "");
+ Assert.assertNull(baseEntity1.getCreateDate());
+ Assert.assertEquals(baseEntity1.getModifyUser(), "");
+ Assert.assertNull(baseEntity1.getModifyDate());
+ Assert.assertEquals(baseEntity1.getAttributes(), "");
+ Assert.assertEquals(baseEntity1.getCreateDateStr(), "");
+ Assert.assertEquals(baseEntity1.getModifyDateStr(), "");
+ // case 2
+ String createUser = "test";
+ Date createDate = new Date();
+ String createDataStr = WebParameterUtils.date2yyyyMMddHHmmss(createDate);
+ BaseEntity baseEntity2 = new BaseEntity(createUser, createDate);
+ Assert.assertEquals(baseEntity2.getDataVerId(), TServerConstants.DEFAULT_DATA_VERSION);
+ Assert.assertNotEquals(baseEntity2.getSerialId(), TBaseConstants.META_VALUE_UNDEFINED);
+ Assert.assertEquals(baseEntity2.getCreateUser(), createUser);
+ Assert.assertEquals(baseEntity2.getCreateDate(), createDate);
+ Assert.assertEquals(baseEntity2.getModifyUser(), createUser);
+ Assert.assertEquals(baseEntity2.getModifyDate(), createDate);
+ Assert.assertEquals(baseEntity2.getAttributes(), "");
+ Assert.assertEquals(baseEntity2.getCreateDateStr(), createDataStr);
+ Assert.assertEquals(baseEntity2.getModifyDateStr(), createDataStr);
+ // case 3
+ long dataVersionId = 5;
+ BaseEntity baseEntity3 = new BaseEntity(dataVersionId, createUser, createDate);
+ Assert.assertEquals(baseEntity3.getDataVerId(), dataVersionId);
+ Assert.assertNotEquals(baseEntity3.getSerialId(), TBaseConstants.META_VALUE_UNDEFINED);
+ Assert.assertEquals(baseEntity3.getCreateUser(), createUser);
+ Assert.assertEquals(baseEntity3.getCreateDate(), createDate);
+ Assert.assertEquals(baseEntity3.getModifyUser(), createUser);
+ Assert.assertEquals(baseEntity3.getModifyDate(), createDate);
+ Assert.assertEquals(baseEntity3.getAttributes(), "");
+ Assert.assertEquals(baseEntity3.getCreateDateStr(), createDataStr);
+ Assert.assertEquals(baseEntity3.getModifyDateStr(), createDataStr);
+ // case 4
+ String modifyUser = "modifyUser";
+ Date modifyDate = new Date();
+ String modifyDateStr = WebParameterUtils.date2yyyyMMddHHmmss(modifyDate);
+ BaseEntity baseEntity4 =
+ new BaseEntity(createUser, createDate, modifyUser, modifyDate);
+ Assert.assertEquals(baseEntity4.getDataVerId(), TServerConstants.DEFAULT_DATA_VERSION);
+ Assert.assertNotEquals(baseEntity4.getSerialId(), TBaseConstants.META_VALUE_UNDEFINED);
+ Assert.assertEquals(baseEntity4.getCreateUser(), createUser);
+ Assert.assertEquals(baseEntity4.getCreateDate(), createDate);
+ Assert.assertEquals(baseEntity4.getModifyUser(), modifyUser);
+ Assert.assertEquals(baseEntity4.getModifyDate(), modifyDate);
+ Assert.assertEquals(baseEntity4.getAttributes(), "");
+ Assert.assertEquals(baseEntity4.getCreateDateStr(), createDataStr);
+ Assert.assertEquals(baseEntity4.getModifyDateStr(), modifyDateStr);
+ // case 5
+ dataVersionId = 10;
+ BaseEntity baseEntity5 = new BaseEntity(dataVersionId,
+ createUser, createDate, modifyUser, modifyDate);
+ Assert.assertEquals(baseEntity5.getDataVerId(), dataVersionId);
+ Assert.assertNotEquals(baseEntity5.getSerialId(), TBaseConstants.META_VALUE_UNDEFINED);
+ Assert.assertEquals(baseEntity5.getCreateUser(), createUser);
+ Assert.assertEquals(baseEntity5.getCreateDate(), createDate);
+ Assert.assertEquals(baseEntity5.getModifyUser(), modifyUser);
+ Assert.assertEquals(baseEntity5.getModifyDate(), modifyDate);
+ Assert.assertEquals(baseEntity5.getAttributes(), "");
+ Assert.assertEquals(baseEntity5.getCreateDateStr(), createDataStr);
+ Assert.assertEquals(baseEntity5.getModifyDateStr(), modifyDateStr);
+ // case 6
+ baseEntity5.setKeyAndVal("aaa", "bbb");
+ BaseEntity baseEntity6 = new BaseEntity(baseEntity5);
+ Assert.assertEquals(baseEntity6.getDataVerId(), baseEntity5.getDataVerId());
+ Assert.assertEquals(baseEntity6.getSerialId(), baseEntity5.getSerialId());
+ Assert.assertEquals(baseEntity6.getCreateUser(), baseEntity5.getCreateUser());
+ Assert.assertEquals(baseEntity6.getCreateDate(), baseEntity5.getCreateDate());
+ Assert.assertEquals(baseEntity6.getModifyUser(), baseEntity5.getModifyUser());
+ Assert.assertEquals(baseEntity6.getModifyDate(), baseEntity5.getModifyDate());
+ Assert.assertEquals(baseEntity6.getAttributes(), baseEntity5.getAttributes());
+ Assert.assertEquals(baseEntity6.getCreateDateStr(), baseEntity5.getCreateDateStr());
+ Assert.assertEquals(baseEntity6.getModifyDateStr(), baseEntity5.getModifyDateStr());
+ // case 7
+ BaseEntity baseEntity7 = new BaseEntity();
+ baseEntity7.updBaseModifyInfo(baseEntity6);
+ Assert.assertNotEquals(baseEntity6.getDataVerId(), baseEntity7.getDataVerId());
+ Assert.assertNotEquals(baseEntity6.getSerialId(), baseEntity7.getSerialId());
+ Assert.assertNotEquals(baseEntity6.getCreateUser(), baseEntity7.getCreateUser());
+ Assert.assertNotEquals(baseEntity6.getCreateDate(), baseEntity7.getCreateDate());
+ Assert.assertNotEquals(baseEntity6.getCreateDateStr(), baseEntity7.getCreateDateStr());
+ Assert.assertEquals(baseEntity6.getModifyUser(), baseEntity7.getModifyUser());
+ Assert.assertEquals(baseEntity6.getModifyDate(), baseEntity7.getModifyDate());
+ Assert.assertEquals(baseEntity6.getAttributes(), baseEntity7.getAttributes());
+ Assert.assertEquals(baseEntity6.getModifyDateStr(), baseEntity7.getModifyDateStr());
+ // case 8
+ long newDataVerId = 999;
+ String newCreateUser = "queryCreate";
+ String newModifyUser = "queryModify";
+ BaseEntity baseEntity8 = new BaseEntity();
+ baseEntity8.updQueryKeyInfo(newDataVerId, newCreateUser, newModifyUser);
+ Assert.assertEquals(baseEntity8.getDataVerId(), newDataVerId);
+ Assert.assertEquals(baseEntity8.getSerialId(), TBaseConstants.META_VALUE_UNDEFINED);
+ Assert.assertEquals(baseEntity8.getCreateUser(), newCreateUser);
+ Assert.assertNull(baseEntity8.getCreateDate());
+ Assert.assertEquals(baseEntity8.getModifyUser(), newModifyUser);
+ Assert.assertNull(baseEntity8.getModifyDate());
+ Assert.assertEquals(baseEntity8.getAttributes(), "");
+ Assert.assertEquals(baseEntity8.getCreateDateStr(), "");
+ Assert.assertEquals(baseEntity8.getModifyDateStr(), "");
+ // case 9
+ BaseEntity baseEntity9 = (BaseEntity) baseEntity6.clone();
+ Assert.assertEquals(baseEntity9, baseEntity6);
+ baseEntity9.setAttributes("aaaaabbbbccccddd");
+ baseEntity9.updSerialId();
+ baseEntity9.updQueryKeyInfo(newDataVerId, newCreateUser, newModifyUser);
+ Assert.assertNotEquals(baseEntity6.getDataVerId(), baseEntity9.getDataVerId());
+ Assert.assertNotEquals(baseEntity6.getSerialId(), baseEntity9.getSerialId());
+ Assert.assertNotEquals(baseEntity6.getCreateUser(), baseEntity9.getCreateUser());
+ Assert.assertEquals(baseEntity6.getCreateDate(), baseEntity9.getCreateDate());
+ Assert.assertNotEquals(baseEntity6.getModifyUser(), baseEntity9.getModifyUser());
+ Assert.assertEquals(baseEntity6.getModifyDate(), baseEntity9.getModifyDate());
+ Assert.assertNotEquals(baseEntity6.getAttributes(), baseEntity9.getAttributes());
+ Assert.assertEquals(baseEntity6.getCreateDateStr(), baseEntity9.getCreateDateStr());
+ Assert.assertEquals(baseEntity6.getModifyDateStr(), baseEntity9.getModifyDateStr());
+ // case 10
+ Assert.assertTrue(baseEntity8.isMatched(baseEntity9));
+ }
+
+}
diff --git a/tubemq-server/src/test/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/BrokerConfEntityTest.java b/tubemq-server/src/test/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/BrokerConfEntityTest.java
new file mode 100644
index 0000000..b6b81f4
--- /dev/null
+++ b/tubemq-server/src/test/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/BrokerConfEntityTest.java
@@ -0,0 +1,120 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tubemq.server.master.metamanage.metastore.dao.entity;
+
+import java.util.Date;
+import org.apache.tubemq.corebase.TBaseConstants;
+import org.apache.tubemq.corebase.utils.SettingValidUtils;
+import org.apache.tubemq.server.common.statusdef.EnableStatus;
+import org.apache.tubemq.server.master.bdbstore.bdbentitys.BdbTopicAuthControlEntity;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+
+
+public class BrokerConfEntityTest {
+
+ @Test
+ public void trokerConfEntityTest() {
+ // case 1
+ String topicName = "test_1";
+ boolean enableAuthControl = false;
+ String attributes = "";
+ String createUser = "creater";
+ Date createDate = new Date();
+ int maxMsgSizeInB = 12222;
+ BdbTopicAuthControlEntity bdbEntity1 =
+ new BdbTopicAuthControlEntity(topicName,
+ enableAuthControl, attributes, createUser, createDate);
+ TopicCtrlEntity ctrlEntity1 = new TopicCtrlEntity(bdbEntity1);
+ // check bdbEntity1
+ Assert.assertEquals(bdbEntity1.getTopicName(), topicName);
+ Assert.assertEquals(bdbEntity1.getTopicId(), TBaseConstants.META_VALUE_UNDEFINED);
+ Assert.assertEquals(bdbEntity1.isEnableAuthControl(), enableAuthControl);
+ Assert.assertEquals(bdbEntity1.getMaxMsgSize(), TBaseConstants.META_VALUE_UNDEFINED);
+ Assert.assertEquals(bdbEntity1.getCreateUser(), createUser);
+ Assert.assertEquals(bdbEntity1.getCreateDate(), createDate);
+ Assert.assertEquals(bdbEntity1.getDataVerId(), TBaseConstants.META_VALUE_UNDEFINED);
+ bdbEntity1.setMaxMsgSize(maxMsgSizeInB);
+ Assert.assertEquals(bdbEntity1.getMaxMsgSize(), maxMsgSizeInB);
+ // check ctrlEntity1
+ Assert.assertEquals(ctrlEntity1.getTopicName(), topicName);
+ Assert.assertEquals(ctrlEntity1.getTopicId(), TBaseConstants.META_VALUE_UNDEFINED);
+ Assert.assertEquals(ctrlEntity1.getAuthCtrlStatus(), EnableStatus.STATUS_DISABLE);
+ Assert.assertEquals(ctrlEntity1.getMaxMsgSizeInB(),
+ TBaseConstants.META_MAX_MESSAGE_DATA_SIZE);
+ Assert.assertEquals(ctrlEntity1.getMaxMsgSizeInMB(),
+ TBaseConstants.META_MIN_ALLOWED_MESSAGE_SIZE_MB);
+ Assert.assertEquals(ctrlEntity1.getCreateUser(), createUser);
+ Assert.assertEquals(ctrlEntity1.getCreateDate(), createDate);
+ Assert.assertEquals(ctrlEntity1.getDataVerId(), TBaseConstants.META_VALUE_UNDEFINED);
+ // case 2
+ long dataVerId2 = 555;
+ int topicId2 = 222;
+ String topicName2 = "test_1";
+ boolean enableAuthControl2 = true;
+ String attributes2 = "";
+ String createUser2 = "creater2";
+ Date createDate2 = new Date();
+ int maxMsgSizeInB2 = 14;
+ TopicCtrlEntity ctrlEntity2 = ctrlEntity1.clone();
+ Assert.assertTrue(ctrlEntity2.isDataEquals(ctrlEntity1));
+ BaseEntity opInfoEntry = new BaseEntity(dataVerId2, createUser2, createDate2);
+ Assert.assertTrue(ctrlEntity2.updBaseModifyInfo(opInfoEntry));
+ Assert.assertTrue(ctrlEntity2.updModifyInfo(opInfoEntry.getDataVerId(),
+ topicId2, maxMsgSizeInB2, enableAuthControl2));
+ Assert.assertFalse(ctrlEntity2.isDataEquals(ctrlEntity1));
+ Assert.assertFalse(ctrlEntity2.isMatched(ctrlEntity1));
+ // check ctrlEntity2
+ Assert.assertEquals(ctrlEntity2.getTopicName(), topicName);
+ Assert.assertEquals(ctrlEntity2.getTopicId(), topicId2);
+ Assert.assertEquals(ctrlEntity2.getAuthCtrlStatus(), EnableStatus.STATUS_ENABLE);
+ Assert.assertEquals(ctrlEntity2.getMaxMsgSizeInB(),
+ SettingValidUtils.validAndXfeMaxMsgSizeFromMBtoB(maxMsgSizeInB2));
+ Assert.assertEquals(ctrlEntity2.getMaxMsgSizeInMB(), maxMsgSizeInB2);
+ Assert.assertEquals(ctrlEntity2.getCreateUser(), createUser);
+ Assert.assertEquals(ctrlEntity2.getCreateDate(), createDate);
+ Assert.assertEquals(ctrlEntity2.getModifyUser(), createUser2);
+ Assert.assertEquals(ctrlEntity2.getModifyDate(), createDate2);
+ Assert.assertEquals(ctrlEntity2.getDataVerId(), dataVerId2);
+ // case 3
+ BdbTopicAuthControlEntity bdbEntity3 =
+ ctrlEntity2.buildBdbTopicAuthControlEntity();
+ Assert.assertEquals(bdbEntity3.getTopicName(), ctrlEntity2.getTopicName());
+ Assert.assertEquals(bdbEntity3.getTopicId(), ctrlEntity2.getTopicId());
+ Assert.assertEquals(bdbEntity3.isEnableAuthControl(),
+ ctrlEntity2.getAuthCtrlStatus().isEnable());
+ Assert.assertEquals(bdbEntity3.getMaxMsgSize(), ctrlEntity2.getMaxMsgSizeInB());
+ Assert.assertEquals(bdbEntity3.getCreateUser(), ctrlEntity2.getModifyUser());
+ Assert.assertEquals(bdbEntity3.getCreateDate(), ctrlEntity2.getModifyDate());
+ Assert.assertEquals(bdbEntity3.getDataVerId(), ctrlEntity2.getDataVerId());
+ // case 4
+ TopicCtrlEntity ctrlEntity4 = new TopicCtrlEntity(bdbEntity3);
+ // check ctrlEntity4
+ Assert.assertTrue(ctrlEntity4.isDataEquals(ctrlEntity2));
+ Assert.assertEquals(ctrlEntity4.getTopicName(), ctrlEntity2.getTopicName());
+ Assert.assertEquals(ctrlEntity4.getTopicId(), ctrlEntity2.getTopicId());
+ Assert.assertEquals(ctrlEntity4.getAuthCtrlStatus(), ctrlEntity2.getAuthCtrlStatus());
+ Assert.assertEquals(ctrlEntity4.getMaxMsgSizeInB(), ctrlEntity2.getMaxMsgSizeInB());
+ Assert.assertEquals(ctrlEntity4.getCreateUser(), ctrlEntity2.getModifyUser());
+ Assert.assertEquals(ctrlEntity4.getCreateDate(), ctrlEntity2.getModifyDate());
+ Assert.assertEquals(ctrlEntity4.getDataVerId(), ctrlEntity2.getDataVerId());
+ }
+
+}
diff --git a/tubemq-server/src/test/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/ClusterSettingEntityTest.java b/tubemq-server/src/test/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/ClusterSettingEntityTest.java
new file mode 100644
index 0000000..dd64820
--- /dev/null
+++ b/tubemq-server/src/test/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/ClusterSettingEntityTest.java
@@ -0,0 +1,185 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tubemq.server.master.metamanage.metastore.dao.entity;
+
+import java.util.Date;
+import org.apache.tubemq.corebase.TBaseConstants;
+import org.apache.tubemq.corebase.utils.SettingValidUtils;
+import org.apache.tubemq.server.common.TServerConstants;
+import org.apache.tubemq.server.common.statusdef.EnableStatus;
+import org.apache.tubemq.server.master.bdbstore.bdbentitys.BdbClusterSettingEntity;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+
+public class ClusterSettingEntityTest {
+
+ @Test
+ public void clusterSettingEntityTest() {
+ // case 1
+ ClusterSettingEntity setting1 = new ClusterSettingEntity();
+ setting1.fillDefaultValue();
+ Assert.assertEquals(setting1.getBrokerPort(), TBaseConstants.META_DEFAULT_BROKER_PORT);
+ Assert.assertEquals(setting1.getBrokerTLSPort(), TBaseConstants.META_DEFAULT_BROKER_TLS_PORT);
+ Assert.assertEquals(setting1.getBrokerWebPort(), TBaseConstants.META_DEFAULT_BROKER_WEB_PORT);
+ Assert.assertEquals(setting1.getMaxMsgSizeInMB(), TBaseConstants.META_MIN_ALLOWED_MESSAGE_SIZE_MB);
+ Assert.assertEquals(setting1.getMaxMsgSizeInB(),
+ SettingValidUtils.validAndXfeMaxMsgSizeFromMBtoB(
+ TBaseConstants.META_MIN_ALLOWED_MESSAGE_SIZE_MB));
+
+ Assert.assertEquals(setting1.getQryPriorityId(), TServerConstants.QRY_PRIORITY_DEF_VALUE);
+ Assert.assertEquals(setting1.getGloFlowCtrlStatus(), EnableStatus.STATUS_DISABLE);
+ Assert.assertEquals(setting1.getGloFlowCtrlRuleCnt(), 0);
+ Assert.assertEquals(setting1.getGloFlowCtrlRuleInfo(), TServerConstants.BLANK_FLOWCTRL_RULES);
+ TopicPropGroup defProps = new TopicPropGroup();
+ defProps.fillDefaultValue();
+ Assert.assertEquals(setting1.getClsDefTopicProps(), defProps);
+ // case 2
+ String recordKey = "test_key";
+ long configId = 2223335555L;
+ int brokerPort = 8888;
+ int brokerTLSPort = 9999;
+ int brokerWebPort = 7777;
+ int numTopicStores = 9;
+ int numPartitions = 10;
+ int unflushThreshold = 20;
+ int unflushInterval = 25;
+ int unflushDataHold = 30;
+ int memCacheMsgCntInK = 44;
+ int memCacheFlushIntvl = 50;
+ int memCacheMsgSizeInMB = 33;
+ boolean acceptPublish = false;
+ boolean acceptSubscribe = true;
+ String deletePolicy = "delete,5h";
+ int qryPriorityId = 202;
+ int maxMsgSizeInB = 1024 * 1024;
+ String attributes = "";
+ String modifyUser = "modifyUser";
+ Date modifyDate = new Date();
+ BdbClusterSettingEntity bdbEntity =
+ new BdbClusterSettingEntity(recordKey, configId, brokerPort, brokerTLSPort,
+ brokerWebPort, numTopicStores, numPartitions, unflushThreshold,
+ unflushInterval, unflushDataHold, memCacheMsgCntInK, memCacheFlushIntvl,
+ memCacheMsgSizeInMB, acceptPublish, acceptSubscribe, deletePolicy,
+ qryPriorityId, maxMsgSizeInB, attributes, modifyUser, modifyDate);
+ ClusterSettingEntity setting2 = new ClusterSettingEntity(bdbEntity);
+ Assert.assertEquals(setting2.getBrokerPort(), bdbEntity.getBrokerPort());
+ Assert.assertEquals(setting2.getBrokerTLSPort(), bdbEntity.getBrokerTLSPort());
+ Assert.assertEquals(setting2.getBrokerWebPort(), bdbEntity.getBrokerWebPort());
+ Assert.assertEquals(setting2.getMaxMsgSizeInB(), bdbEntity.getMaxMsgSizeInB());
+ Assert.assertEquals(setting2.getQryPriorityId(), bdbEntity.getQryPriorityId());
+ Assert.assertFalse(setting2.getGloFlowCtrlStatus().isEnable());
+ Assert.assertNull(bdbEntity.getEnableGloFlowCtrl());
+ Assert.assertEquals(setting2.getGloFlowCtrlRuleCnt(), 0);
+ Assert.assertEquals(bdbEntity.getGloFlowCtrlCnt(), TBaseConstants.META_VALUE_UNDEFINED);
+ Assert.assertEquals(setting2.getGloFlowCtrlRuleInfo(), TServerConstants.BLANK_FLOWCTRL_RULES);
+ Assert.assertNull(bdbEntity.getGloFlowCtrlInfo());
+ TopicPropGroup defProps2 = setting2.getClsDefTopicProps();
+ Assert.assertEquals(defProps2.getNumTopicStores(), bdbEntity.getNumTopicStores());
+ Assert.assertEquals(defProps2.getNumPartitions(), bdbEntity.getNumPartitions());
+ Assert.assertEquals(defProps2.getUnflushThreshold(), bdbEntity.getUnflushThreshold());
+ Assert.assertEquals(defProps2.getUnflushInterval(), bdbEntity.getUnflushInterval());
+ Assert.assertEquals(defProps2.getUnflushDataHold(), bdbEntity.getUnflushDataHold());
+ Assert.assertEquals(defProps2.getMemCacheMsgSizeInMB(), bdbEntity.getMemCacheMsgSizeInMB());
+ Assert.assertEquals(defProps2.getMemCacheFlushIntvl(), bdbEntity.getMemCacheFlushIntvl());
+ Assert.assertEquals(defProps2.getMemCacheMsgCntInK(), bdbEntity.getMemCacheMsgCntInK());
+ Assert.assertEquals(defProps2.getAcceptPublish(), bdbEntity.isAcceptPublish());
+ Assert.assertEquals(defProps2.getAcceptSubscribe(), bdbEntity.isAcceptSubscribe());
+ Assert.assertEquals(defProps2.getDataStoreType(), bdbEntity.getDefDataType());
+ Assert.assertEquals(defProps2.getDataPath(), "");
+ Assert.assertNull(bdbEntity.getDefDataPath());
+ Assert.assertEquals(defProps2.getDeletePolicy(), bdbEntity.getDeletePolicy());
+ // case 3
+ BdbClusterSettingEntity bdbSetting = setting2.buildBdbClsDefSettingEntity();
+ Assert.assertEquals(setting2.getBrokerPort(), bdbSetting.getBrokerPort());
+ Assert.assertEquals(setting2.getBrokerTLSPort(), bdbSetting.getBrokerTLSPort());
+ Assert.assertEquals(setting2.getBrokerWebPort(), bdbSetting.getBrokerWebPort());
+ Assert.assertEquals(setting2.getMaxMsgSizeInB(), bdbSetting.getMaxMsgSizeInB());
+ Assert.assertEquals(setting2.getQryPriorityId(), bdbSetting.getQryPriorityId());
+ Assert.assertEquals(setting2.getGloFlowCtrlStatus().isEnable(), bdbSetting.getEnableGloFlowCtrl());
+ Assert.assertEquals(setting2.getGloFlowCtrlRuleCnt(), bdbSetting.getGloFlowCtrlCnt());
+ Assert.assertEquals(setting2.getGloFlowCtrlRuleInfo(), bdbSetting.getGloFlowCtrlInfo());
+ TopicPropGroup defProps3 = setting2.getClsDefTopicProps();
+ Assert.assertEquals(defProps3.getNumTopicStores(), bdbSetting.getNumTopicStores());
+ Assert.assertEquals(defProps3.getNumPartitions(), bdbSetting.getNumPartitions());
+ Assert.assertEquals(defProps3.getUnflushThreshold(), bdbSetting.getUnflushThreshold());
+ Assert.assertEquals(defProps3.getUnflushInterval(), bdbSetting.getUnflushInterval());
+ Assert.assertEquals(defProps3.getUnflushDataHold(), bdbSetting.getUnflushDataHold());
+ Assert.assertEquals(defProps3.getMemCacheMsgSizeInMB(), bdbSetting.getMemCacheMsgSizeInMB());
+ Assert.assertEquals(defProps3.getMemCacheFlushIntvl(), bdbSetting.getMemCacheFlushIntvl());
+ Assert.assertEquals(defProps3.getMemCacheMsgCntInK(), bdbSetting.getMemCacheMsgCntInK());
+ Assert.assertEquals(defProps3.getAcceptPublish(), bdbSetting.isAcceptPublish());
+ Assert.assertEquals(defProps3.getAcceptSubscribe(), bdbSetting.isAcceptSubscribe());
+ Assert.assertEquals(defProps3.getDataStoreType(), bdbSetting.getDefDataType());
+ Assert.assertEquals(defProps3.getDataPath(), "");
+ Assert.assertNull(bdbSetting.getDefDataPath());
+ Assert.assertEquals(defProps3.getDeletePolicy(), bdbSetting.getDeletePolicy());
+ // case 4
+ ClusterSettingEntity setting4 = new ClusterSettingEntity(bdbSetting);
+ Assert.assertEquals(setting4.getBrokerPort(), bdbSetting.getBrokerPort());
+ Assert.assertEquals(setting4.getBrokerTLSPort(), bdbSetting.getBrokerTLSPort());
+ Assert.assertEquals(setting4.getBrokerWebPort(), bdbSetting.getBrokerWebPort());
+ Assert.assertEquals(setting4.getMaxMsgSizeInB(), bdbSetting.getMaxMsgSizeInB());
+ Assert.assertEquals(setting4.getQryPriorityId(), bdbSetting.getQryPriorityId());
+ Assert.assertEquals(setting4.getGloFlowCtrlStatus().isEnable(), bdbSetting.getEnableGloFlowCtrl());
+ Assert.assertEquals(setting4.getGloFlowCtrlRuleCnt(), bdbSetting.getGloFlowCtrlCnt());
+ Assert.assertEquals(setting4.getGloFlowCtrlRuleInfo(), bdbSetting.getGloFlowCtrlInfo());
+ TopicPropGroup defProps4 = setting4.getClsDefTopicProps();
+ Assert.assertEquals(defProps4.getNumTopicStores(), bdbSetting.getNumTopicStores());
+ Assert.assertEquals(defProps4.getNumPartitions(), bdbSetting.getNumPartitions());
+ Assert.assertEquals(defProps4.getUnflushThreshold(), bdbSetting.getUnflushThreshold());
+ Assert.assertEquals(defProps4.getUnflushInterval(), bdbSetting.getUnflushInterval());
+ Assert.assertEquals(defProps4.getUnflushDataHold(), bdbSetting.getUnflushDataHold());
+ Assert.assertEquals(defProps4.getMemCacheMsgSizeInMB(), bdbSetting.getMemCacheMsgSizeInMB());
+ Assert.assertEquals(defProps4.getMemCacheFlushIntvl(), bdbSetting.getMemCacheFlushIntvl());
+ Assert.assertEquals(defProps4.getMemCacheMsgCntInK(), bdbSetting.getMemCacheMsgCntInK());
+ Assert.assertEquals(defProps4.getAcceptPublish(), bdbSetting.isAcceptPublish());
+ Assert.assertEquals(defProps4.getAcceptSubscribe(), bdbSetting.isAcceptSubscribe());
+ Assert.assertEquals(defProps4.getDataStoreType(), bdbSetting.getDefDataType());
+ Assert.assertEquals(defProps4.getDataPath(), "");
+ Assert.assertNull(bdbSetting.getDefDataPath());
+ Assert.assertEquals(defProps4.getDeletePolicy(), bdbSetting.getDeletePolicy());
+ // case 5
+ long newDataVerId = 99;
+ int newBrokerPort = 52;
+ int newBrokerTLSPort = 22;
+ int newBrokerWebPort = 32;
+ int newMaxMsgSizeMB = 2;
+ int newQryPriorityId = 101;
+ Boolean newFlowCtrlEnable = true;
+ int newFlowRuleCnt = 5;
+ String newFlowCtrlRuleInfo = "[{},{},{},{},{}]";
+ TopicPropGroup newProps = new TopicPropGroup();
+ newProps.fillDefaultValue();
+ ClusterSettingEntity setting5 = setting2.clone();
+ Assert.assertTrue(setting5.updModifyInfo(newDataVerId, newBrokerPort, newBrokerTLSPort,
+ newBrokerWebPort, newMaxMsgSizeMB, newQryPriorityId, newFlowCtrlEnable,
+ newFlowRuleCnt, newFlowCtrlRuleInfo, newProps));
+ Assert.assertNotEquals(setting5.getBrokerPort(), setting2.getBrokerPort());
+ Assert.assertNotEquals(setting5.getBrokerTLSPort(), setting2.getBrokerTLSPort());
+ Assert.assertNotEquals(setting5.getBrokerWebPort(), setting2.getBrokerWebPort());
+ Assert.assertNotEquals(setting5.getMaxMsgSizeInB(), setting2.getMaxMsgSizeInB());
+ Assert.assertNotEquals(setting5.getQryPriorityId(), setting2.getQryPriorityId());
+ Assert.assertNotEquals(setting5.getGloFlowCtrlStatus(), setting2.getGloFlowCtrlStatus());
+ Assert.assertNotEquals(setting5.getGloFlowCtrlRuleCnt(), setting2.getGloFlowCtrlRuleCnt());
+ Assert.assertNotEquals(setting5.getGloFlowCtrlRuleInfo(), setting2.getGloFlowCtrlRuleInfo());
+ Assert.assertNotEquals(setting5.getClsDefTopicProps(), setting2.getClsDefTopicProps());
+ }
+
+}
diff --git a/tubemq-server/src/test/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/GroupConsumeCtrlEntityTest.java b/tubemq-server/src/test/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/GroupConsumeCtrlEntityTest.java
new file mode 100644
index 0000000..91ec3bc
--- /dev/null
+++ b/tubemq-server/src/test/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/GroupConsumeCtrlEntityTest.java
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tubemq.server.master.metamanage.metastore.dao.entity;
+
+import java.util.Date;
+import org.apache.tubemq.server.master.bdbstore.bdbentitys.BdbGroupFilterCondEntity;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+
+
+public class GroupConsumeCtrlEntityTest {
+
+ @Test
+ public void groupConsumeCtrlEntityTest() {
+ // case 1
+ String topicName = "test_1";
+ String groupName = "group_1";
+ int controlStatus = 2;
+ String filterCondStr = "[1,2,3,4]";
+ String attributes = "key=val&ke2=val3";
+ String createUser = "creater";
+ Date createDate = new Date();
+ BdbGroupFilterCondEntity bdbEntity1 =
+ new BdbGroupFilterCondEntity(topicName, groupName, controlStatus,
+ filterCondStr, attributes, createUser, createDate);
+
+ GroupConsumeCtrlEntity ctrlEntry1 = new GroupConsumeCtrlEntity(bdbEntity1);
+ Assert.assertEquals(ctrlEntry1.getGroupName(), bdbEntity1.getConsumerGroupName());
+ Assert.assertEquals(ctrlEntry1.getTopicName(), bdbEntity1.getTopicName());
+ Assert.assertEquals(ctrlEntry1.getFilterCondStr(), bdbEntity1.getFilterCondStr());
+ Assert.assertEquals(bdbEntity1.getControlStatus(), 2);
+ Assert.assertTrue(ctrlEntry1.getFilterEnable().isEnable());
+ Assert.assertEquals(ctrlEntry1.getConsumeEnable(), bdbEntity1.getConsumeEnable());
+ Assert.assertEquals(ctrlEntry1.getCreateUser(), bdbEntity1.getCreateUser());
+ Assert.assertEquals(ctrlEntry1.getCreateDate(), bdbEntity1.getCreateDate());
+ Assert.assertEquals(ctrlEntry1.getAttributes(), bdbEntity1.getAttributes());
+ Assert.assertEquals(ctrlEntry1.getDisableReason(), bdbEntity1.getDisableConsumeReason());
+ Assert.assertEquals(ctrlEntry1.getRecordKey(), bdbEntity1.getRecordKey());
+ // case 2
+ long newDataVerId = 5555;
+ boolean consumeEnable = true;
+ String disableRsn = "disable";
+ boolean filterEnable = true;
+ String newFilterCondStr = "[1,2,4]";
+ BaseEntity opInfoEntity =
+ new BaseEntity(newDataVerId, "modify", new Date());
+ GroupConsumeCtrlEntity ctrlEntry2 = ctrlEntry1.clone();
+ Assert.assertTrue(ctrlEntry2.isMatched(ctrlEntry1));
+ ctrlEntry2.updBaseModifyInfo(opInfoEntity);
+ Assert.assertTrue(ctrlEntry2.updModifyInfo(opInfoEntity.getDataVerId(),
+ consumeEnable, disableRsn, filterEnable, newFilterCondStr));
+ // case 3
+ BdbGroupFilterCondEntity bdbEntity3 = ctrlEntry2.buildBdbGroupFilterCondEntity();
+ Assert.assertEquals(ctrlEntry2.getGroupName(), bdbEntity3.getConsumerGroupName());
+ Assert.assertEquals(ctrlEntry2.getTopicName(), bdbEntity3.getTopicName());
+ Assert.assertEquals(ctrlEntry2.getFilterCondStr(), bdbEntity3.getFilterCondStr());
+ Assert.assertEquals(bdbEntity3.getControlStatus(), 2);
+ Assert.assertTrue(ctrlEntry2.getFilterEnable().isEnable());
+ Assert.assertEquals(ctrlEntry2.getConsumeEnable(), bdbEntity3.getConsumeEnable());
+ Assert.assertEquals(opInfoEntity.getCreateUser(), bdbEntity3.getCreateUser());
+ Assert.assertEquals(opInfoEntity.getCreateDate(), bdbEntity3.getCreateDate());
+ Assert.assertNotEquals(ctrlEntry2.getCreateDate(), bdbEntity3.getCreateDate());
+ Assert.assertNotEquals(ctrlEntry2.getCreateUser(), bdbEntity3.getCreateUser());
+ Assert.assertEquals(ctrlEntry2.getAttributes(), bdbEntity3.getAttributes());
+ Assert.assertEquals(ctrlEntry2.getDisableReason(), bdbEntity3.getDisableConsumeReason());
+ Assert.assertEquals(ctrlEntry2.getRecordKey(), bdbEntity3.getRecordKey());
+
+
+
+
+ }
+
+}
diff --git a/tubemq-server/src/test/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/GroupResCtrlEntityTest.java b/tubemq-server/src/test/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/GroupResCtrlEntityTest.java
new file mode 100644
index 0000000..615f13b
--- /dev/null
+++ b/tubemq-server/src/test/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/GroupResCtrlEntityTest.java
@@ -0,0 +1,129 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tubemq.server.master.metamanage.metastore.dao.entity;
+
+import java.util.Date;
+import org.apache.tubemq.corebase.TBaseConstants;
+import org.apache.tubemq.server.common.TServerConstants;
+import org.apache.tubemq.server.common.statusdef.EnableStatus;
+import org.apache.tubemq.server.master.bdbstore.bdbentitys.BdbGroupFlowCtrlEntity;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+
+public class GroupResCtrlEntityTest {
+
+ @Test
+ public void groupResCtrlEntityTest() {
+ // case 1
+ String groupName = "test_group";
+ GroupResCtrlEntity resEntry = new GroupResCtrlEntity();
+ resEntry.setGroupName(groupName);
+ resEntry.fillDefaultValue();
+ Assert.assertEquals(resEntry.getGroupName(), groupName);
+ Assert.assertEquals(resEntry.getResCheckStatus(), EnableStatus.STATUS_DISABLE);
+ Assert.assertEquals(resEntry.getAllowedBrokerClientRate(), 0);
+ Assert.assertEquals(resEntry.getQryPriorityId(), TServerConstants.QRY_PRIORITY_DEF_VALUE);
+ Assert.assertEquals(resEntry.getFlowCtrlStatus(), EnableStatus.STATUS_DISABLE);
+ Assert.assertEquals(resEntry.getFlowCtrlInfo(), TServerConstants.BLANK_FLOWCTRL_RULES);
+ Assert.assertEquals(resEntry.getRuleCnt(), 0);
+ // case 2
+ long dataVerId = 55;
+ String groupName2 = "group_2";
+ int ruleCnt = 4;
+ String flowCtrlInfo = "[{},{},{},{}]";
+ int statusId = 1;
+ int qryPriorityId = 203;
+ String attributes = "key=val&key2=va2";
+ String createUser = "create";
+ Date createDate = new Date();
+ BdbGroupFlowCtrlEntity bdbEntity2 =
+ new BdbGroupFlowCtrlEntity(dataVerId, groupName2,
+ flowCtrlInfo, statusId, ruleCnt, qryPriorityId,
+ attributes, createUser, createDate);
+ Assert.assertEquals(bdbEntity2.getGroupName(), groupName2);
+ Assert.assertEquals(bdbEntity2.getResCheckStatus(), EnableStatus.STATUS_UNDEFINE);
+ Assert.assertEquals(bdbEntity2.getAllowedBrokerClientRate(), TBaseConstants.META_VALUE_UNDEFINED);
+ Assert.assertEquals(bdbEntity2.getQryPriorityId(), 203);
+ Assert.assertEquals(bdbEntity2.getStatusId(), 1);
+ Assert.assertEquals(bdbEntity2.getFlowCtrlInfo(), flowCtrlInfo);
+ Assert.assertEquals(bdbEntity2.getRuleCnt(), ruleCnt);
+ Assert.assertEquals(bdbEntity2.getCreateUser(), createUser);
+ Assert.assertEquals(bdbEntity2.getCreateDate(), createDate);
+ Assert.assertEquals(bdbEntity2.getSerialId(), dataVerId);
+ bdbEntity2.setResCheckStatus(EnableStatus.STATUS_ENABLE);
+ // case 3
+ GroupResCtrlEntity resEntry3 = new GroupResCtrlEntity(bdbEntity2);
+ Assert.assertEquals(bdbEntity2.getGroupName(), resEntry3.getGroupName());
+ Assert.assertEquals(bdbEntity2.getResCheckStatus(), resEntry3.getResCheckStatus());
+ Assert.assertEquals(bdbEntity2.getAllowedBrokerClientRate(),
+ resEntry3.getAllowedBrokerClientRate());
+ Assert.assertEquals(bdbEntity2.getQryPriorityId(), resEntry3.getQryPriorityId());
+ Assert.assertTrue(resEntry3.getFlowCtrlStatus().isEnable());
+ Assert.assertEquals(bdbEntity2.getFlowCtrlInfo(), resEntry3.getFlowCtrlInfo());
+ Assert.assertEquals(bdbEntity2.getRuleCnt(), resEntry3.getRuleCnt());
+ Assert.assertEquals(bdbEntity2.getCreateUser(), resEntry3.getCreateUser());
+ Assert.assertEquals(bdbEntity2.getCreateDate(), resEntry3.getCreateDate());
+ Assert.assertEquals(bdbEntity2.getSerialId(), resEntry3.getDataVerId());
+ // case 4
+ long newDataVerId = 99;
+ boolean resChkEnable = true;
+ int newAllowedB2CRate = 5;
+ int newQryPriorityId = 2;
+ boolean newFlowCtrlEnable = false;
+ int newFlowRuleCnt = 2;
+ String newFlowCtrlRuleInfo = "[{},{}]";
+ GroupResCtrlEntity resEntry4 = resEntry3.clone();
+ Assert.assertTrue(resEntry4.isMatched(resEntry3));
+ Assert.assertTrue(resEntry4.updModifyInfo(newDataVerId, resChkEnable, newAllowedB2CRate,
+ newQryPriorityId, newFlowCtrlEnable, newFlowRuleCnt, newFlowCtrlRuleInfo));
+ Assert.assertEquals(resEntry4.getDataVerId(), newDataVerId);
+ Assert.assertEquals(resEntry4.getResCheckStatus().isEnable(), resChkEnable);
+ Assert.assertEquals(resEntry4.getAllowedBrokerClientRate(), newAllowedB2CRate);
+ Assert.assertEquals(resEntry4.getQryPriorityId(), newQryPriorityId);
+ Assert.assertEquals(resEntry4.getFlowCtrlStatus().isEnable(), newFlowCtrlEnable);
+ Assert.assertEquals(resEntry4.getRuleCnt(), newFlowRuleCnt);
+ Assert.assertEquals(resEntry4.getFlowCtrlInfo(), newFlowCtrlRuleInfo);
+ Assert.assertEquals(resEntry4.getGroupName(), resEntry3.getGroupName());
+ Assert.assertEquals(resEntry4.getResCheckStatus(), resEntry3.getResCheckStatus());
+ Assert.assertNotEquals(resEntry4.getAllowedBrokerClientRate(),
+ resEntry3.getAllowedBrokerClientRate());
+ Assert.assertNotEquals(resEntry4.getQryPriorityId(), resEntry3.getQryPriorityId());
+ Assert.assertNotEquals(resEntry4.getFlowCtrlStatus(), resEntry3.getFlowCtrlStatus());
+ Assert.assertNotEquals(resEntry4.getFlowCtrlInfo(), resEntry3.getFlowCtrlInfo());
+ Assert.assertNotEquals(resEntry4.getRuleCnt(), resEntry3.getRuleCnt());
+ Assert.assertEquals(resEntry4.getCreateUser(), resEntry3.getCreateUser());
+ Assert.assertEquals(resEntry4.getCreateDate(), resEntry3.getCreateDate());
+ Assert.assertNotEquals(resEntry4.getDataVerId(), resEntry3.getDataVerId());
+ // case 5
+ BdbGroupFlowCtrlEntity bdbEntity5 = resEntry4.buildBdbGroupFlowCtrlEntity();
+ Assert.assertEquals(bdbEntity5.getSerialId(), newDataVerId);
+ Assert.assertEquals(bdbEntity5.getResCheckStatus().isEnable(), resChkEnable);
+ Assert.assertEquals(bdbEntity5.getAllowedBrokerClientRate(), newAllowedB2CRate);
+ Assert.assertEquals(bdbEntity5.getQryPriorityId(), newQryPriorityId);
+ Assert.assertEquals(bdbEntity5.getStatusId(), 0);
+ Assert.assertEquals(bdbEntity5.getRuleCnt(), newFlowRuleCnt);
+ Assert.assertEquals(bdbEntity5.getFlowCtrlInfo(), newFlowCtrlRuleInfo);
+ Assert.assertEquals(bdbEntity5.getGroupName(), resEntry3.getGroupName());
+
+
+
+ }
+
+}
diff --git a/tubemq-server/src/test/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/TopicCtrlEntityTest.java b/tubemq-server/src/test/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/TopicCtrlEntityTest.java
new file mode 100644
index 0000000..243f783
--- /dev/null
+++ b/tubemq-server/src/test/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/TopicCtrlEntityTest.java
@@ -0,0 +1,119 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tubemq.server.master.metamanage.metastore.dao.entity;
+
+import java.util.Date;
+import org.apache.tubemq.corebase.TBaseConstants;
+import org.apache.tubemq.corebase.utils.SettingValidUtils;
+import org.apache.tubemq.server.common.statusdef.EnableStatus;
+import org.apache.tubemq.server.master.bdbstore.bdbentitys.BdbTopicAuthControlEntity;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+
+public class TopicCtrlEntityTest {
+
+ @Test
+ public void topicCtrlEntityTest() {
+ // case 1
+ String topicName = "test_1";
+ boolean enableAuthControl = false;
+ String attributes = "";
+ String createUser = "creater";
+ Date createDate = new Date();
+ int maxMsgSizeInB = 12222;
+ BdbTopicAuthControlEntity bdbEntity1 =
+ new BdbTopicAuthControlEntity(topicName,
+ enableAuthControl, attributes, createUser, createDate);
+ TopicCtrlEntity ctrlEntity1 = new TopicCtrlEntity(bdbEntity1);
+ // check bdbEntity1
+ Assert.assertEquals(bdbEntity1.getTopicName(), topicName);
+ Assert.assertEquals(bdbEntity1.getTopicId(), TBaseConstants.META_VALUE_UNDEFINED);
+ Assert.assertEquals(bdbEntity1.isEnableAuthControl(), enableAuthControl);
+ Assert.assertEquals(bdbEntity1.getMaxMsgSize(), TBaseConstants.META_VALUE_UNDEFINED);
+ Assert.assertEquals(bdbEntity1.getCreateUser(), createUser);
+ Assert.assertEquals(bdbEntity1.getCreateDate(), createDate);
+ Assert.assertEquals(bdbEntity1.getDataVerId(), TBaseConstants.META_VALUE_UNDEFINED);
+ bdbEntity1.setMaxMsgSize(maxMsgSizeInB);
+ Assert.assertEquals(bdbEntity1.getMaxMsgSize(), maxMsgSizeInB);
+ // check ctrlEntity1
+ Assert.assertEquals(ctrlEntity1.getTopicName(), topicName);
+ Assert.assertEquals(ctrlEntity1.getTopicId(), TBaseConstants.META_VALUE_UNDEFINED);
+ Assert.assertEquals(ctrlEntity1.getAuthCtrlStatus(), EnableStatus.STATUS_DISABLE);
+ Assert.assertEquals(ctrlEntity1.getMaxMsgSizeInB(),
+ TBaseConstants.META_MAX_MESSAGE_DATA_SIZE);
+ Assert.assertEquals(ctrlEntity1.getMaxMsgSizeInMB(),
+ TBaseConstants.META_MIN_ALLOWED_MESSAGE_SIZE_MB);
+ Assert.assertEquals(ctrlEntity1.getCreateUser(), createUser);
+ Assert.assertEquals(ctrlEntity1.getCreateDate(), createDate);
+ Assert.assertEquals(ctrlEntity1.getDataVerId(), TBaseConstants.META_VALUE_UNDEFINED);
+ // case 2
+ long dataVerId2 = 555;
+ int topicId2 = 222;
+ String topicName2 = "test_1";
+ boolean enableAuthControl2 = true;
+ String attributes2 = "";
+ String createUser2 = "creater2";
+ Date createDate2 = new Date();
+ int maxMsgSizeInB2 = 14;
+ TopicCtrlEntity ctrlEntity2 = ctrlEntity1.clone();
+ Assert.assertTrue(ctrlEntity2.isDataEquals(ctrlEntity1));
+ BaseEntity opInfoEntry = new BaseEntity(dataVerId2, createUser2, createDate2);
+ Assert.assertTrue(ctrlEntity2.updBaseModifyInfo(opInfoEntry));
+ Assert.assertTrue(ctrlEntity2.updModifyInfo(opInfoEntry.getDataVerId(),
+ topicId2, maxMsgSizeInB2, enableAuthControl2));
+ Assert.assertFalse(ctrlEntity2.isDataEquals(ctrlEntity1));
+ Assert.assertFalse(ctrlEntity2.isMatched(ctrlEntity1));
+ // check ctrlEntity2
+ Assert.assertEquals(ctrlEntity2.getTopicName(), topicName);
+ Assert.assertEquals(ctrlEntity2.getTopicId(), topicId2);
+ Assert.assertEquals(ctrlEntity2.getAuthCtrlStatus(), EnableStatus.STATUS_ENABLE);
+ Assert.assertEquals(ctrlEntity2.getMaxMsgSizeInB(),
+ SettingValidUtils.validAndXfeMaxMsgSizeFromMBtoB(maxMsgSizeInB2));
+ Assert.assertEquals(ctrlEntity2.getMaxMsgSizeInMB(), maxMsgSizeInB2);
+ Assert.assertEquals(ctrlEntity2.getCreateUser(), createUser);
+ Assert.assertEquals(ctrlEntity2.getCreateDate(), createDate);
+ Assert.assertEquals(ctrlEntity2.getModifyUser(), createUser2);
+ Assert.assertEquals(ctrlEntity2.getModifyDate(), createDate2);
+ Assert.assertEquals(ctrlEntity2.getDataVerId(), dataVerId2);
+ // case 3
+ BdbTopicAuthControlEntity bdbEntity3 =
+ ctrlEntity2.buildBdbTopicAuthControlEntity();
+ Assert.assertEquals(bdbEntity3.getTopicName(), ctrlEntity2.getTopicName());
+ Assert.assertEquals(bdbEntity3.getTopicId(), ctrlEntity2.getTopicId());
+ Assert.assertEquals(bdbEntity3.isEnableAuthControl(),
+ ctrlEntity2.getAuthCtrlStatus().isEnable());
+ Assert.assertEquals(bdbEntity3.getMaxMsgSize(), ctrlEntity2.getMaxMsgSizeInB());
+ Assert.assertEquals(bdbEntity3.getCreateUser(), ctrlEntity2.getModifyUser());
+ Assert.assertEquals(bdbEntity3.getCreateDate(), ctrlEntity2.getModifyDate());
+ Assert.assertEquals(bdbEntity3.getDataVerId(), ctrlEntity2.getDataVerId());
+ // case 4
+ TopicCtrlEntity ctrlEntity4 = new TopicCtrlEntity(bdbEntity3);
+ // check ctrlEntity4
+ Assert.assertTrue(ctrlEntity4.isDataEquals(ctrlEntity2));
+ Assert.assertEquals(ctrlEntity4.getTopicName(), ctrlEntity2.getTopicName());
+ Assert.assertEquals(ctrlEntity4.getTopicId(), ctrlEntity2.getTopicId());
+ Assert.assertEquals(ctrlEntity4.getAuthCtrlStatus(), ctrlEntity2.getAuthCtrlStatus());
+ Assert.assertEquals(ctrlEntity4.getMaxMsgSizeInB(), ctrlEntity2.getMaxMsgSizeInB());
+ Assert.assertEquals(ctrlEntity4.getCreateUser(), ctrlEntity2.getModifyUser());
+ Assert.assertEquals(ctrlEntity4.getCreateDate(), ctrlEntity2.getModifyDate());
+ Assert.assertEquals(ctrlEntity4.getDataVerId(), ctrlEntity2.getDataVerId());
+ }
+
+}
diff --git a/tubemq-server/src/test/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/TopicPropGroupTest.java b/tubemq-server/src/test/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/TopicPropGroupTest.java
new file mode 100644
index 0000000..4dbf3fc
--- /dev/null
+++ b/tubemq-server/src/test/java/org/apache/tubemq/server/master/metamanage/metastore/dao/entity/TopicPropGroupTest.java
@@ -0,0 +1,156 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tubemq.server.master.metamanage.metastore.dao.entity;
+
+import org.apache.tubemq.corebase.TBaseConstants;
+import org.apache.tubemq.server.common.statusdef.CleanPolType;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+
+
+public class TopicPropGroupTest {
+
+ @Test
+ public void topicPropGroupTest() {
+ // case 1
+ TopicPropGroup propsCase1 = new TopicPropGroup();
+ Assert.assertEquals(propsCase1.getNumTopicStores(), TBaseConstants.META_VALUE_UNDEFINED);
+ Assert.assertEquals(propsCase1.getNumPartitions(), TBaseConstants.META_VALUE_UNDEFINED);
+ Assert.assertEquals(propsCase1.getUnflushThreshold(), TBaseConstants.META_VALUE_UNDEFINED);
+ Assert.assertEquals(propsCase1.getUnflushInterval(), TBaseConstants.META_VALUE_UNDEFINED);
+ Assert.assertEquals(propsCase1.getUnflushDataHold(), TBaseConstants.META_VALUE_UNDEFINED);
+ Assert.assertEquals(propsCase1.getMemCacheMsgSizeInMB(), TBaseConstants.META_VALUE_UNDEFINED);
+ Assert.assertEquals(propsCase1.getMemCacheFlushIntvl(), TBaseConstants.META_VALUE_UNDEFINED);
+ Assert.assertEquals(propsCase1.getMemCacheMsgCntInK(), TBaseConstants.META_VALUE_UNDEFINED);
+ Assert.assertTrue((propsCase1.getAcceptPublish() == null));
+ Assert.assertTrue((propsCase1.getAcceptSubscribe() == null));
+ Assert.assertEquals(propsCase1.getDataStoreType(), TBaseConstants.META_VALUE_UNDEFINED);
+ Assert.assertEquals(propsCase1.getDataPath(), "");
+ Assert.assertEquals(propsCase1.getDeletePolicy(), "");
+ // case 2
+ int numTopicStores = 1;
+ int numPartitions = 2;
+ int unflushThreshold = 3;
+ int unflushInterval = 4;
+ int unflushDataHold = 5;
+ int memCacheMsgSizeInMB = 6;
+ int memCacheMsgCntInK = 7;
+ int memCacheFlushIntvl = 8;
+ boolean acceptPublish = true;
+ boolean acceptSubscribe = false;
+ String deletePolicy = "delete,12h";
+ int dataStoreType = 9;
+ String dataPath = "test\\test";
+ TopicPropGroup propsCase2 =
+ new TopicPropGroup(numTopicStores, numPartitions, unflushThreshold,
+ unflushInterval, unflushDataHold, memCacheMsgSizeInMB,
+ memCacheMsgCntInK, memCacheFlushIntvl, acceptPublish,
+ acceptSubscribe, deletePolicy, dataStoreType, dataPath);
+ Assert.assertEquals(propsCase2.getNumTopicStores(), numTopicStores);
+ Assert.assertEquals(propsCase2.getNumPartitions(), numPartitions);
+ Assert.assertEquals(propsCase2.getUnflushThreshold(), unflushThreshold);
+ Assert.assertEquals(propsCase2.getUnflushInterval(), unflushInterval);
+ Assert.assertEquals(propsCase2.getUnflushDataHold(), unflushDataHold);
+ Assert.assertEquals(propsCase2.getMemCacheMsgSizeInMB(), memCacheMsgSizeInMB);
+ Assert.assertEquals(propsCase2.getMemCacheFlushIntvl(), memCacheFlushIntvl);
+ Assert.assertEquals(propsCase2.getMemCacheMsgCntInK(), memCacheMsgCntInK);
+ Assert.assertEquals(propsCase2.getAcceptPublish(), acceptPublish);
+ Assert.assertEquals(propsCase2.getAcceptSubscribe(), acceptSubscribe);
+ Assert.assertEquals(propsCase2.getDataStoreType(), dataStoreType);
+ Assert.assertEquals(propsCase2.getDataPath(), dataPath);
+ Assert.assertEquals(propsCase2.getDeletePolicy(), deletePolicy);
+ Assert.assertEquals(propsCase2.getCleanPolicyType(), CleanPolType.CLEAN_POL_DELETE);
+ Assert.assertEquals(propsCase2.getRetPeriodInMs(), 12 * 3600 * 1000);
+ // case 3
+ int newNumTopicStores = 101;
+ int newNumPartitions = 102;
+ int newUnflushThreshold = 103;
+ int newUnflushInterval = 104;
+ int newUnflushDataHold = 105;
+ int newMemCacheMsgSizeInMB = 106;
+ int newMemCacheMsgCntInK = 107;
+ int newMemCacheFlushIntvl = 108;
+ boolean newAcceptPublish = false;
+ boolean newAcceptSubscribe = true;
+ String newDeletePolicy = "delete,10h";
+ int newDataStoreType = 109;
+ String newDataPath = "newnew";
+ TopicPropGroup propsCase3 = propsCase2.clone();
+ Assert.assertTrue(propsCase3.isMatched(propsCase2));
+ Assert.assertFalse(propsCase2.updModifyInfo(propsCase3));
+ propsCase3.setNumTopicStores(newNumTopicStores);
+ Assert.assertEquals(propsCase3.getNumTopicStores(), newNumTopicStores);
+ Assert.assertNotEquals(propsCase3.getNumTopicStores(), numTopicStores);
+ Assert.assertNotEquals(propsCase3.getNumTopicStores(), propsCase2.getNumTopicStores());
+ propsCase3.setNumPartitions(newNumPartitions);
+ Assert.assertEquals(propsCase3.getNumPartitions(), newNumPartitions);
+ Assert.assertNotEquals(propsCase3.getNumPartitions(), numPartitions);
+ Assert.assertNotEquals(propsCase3.getNumPartitions(), propsCase2.getNumPartitions());
+ propsCase3.setUnflushThreshold(newUnflushThreshold);
+ Assert.assertEquals(propsCase3.getUnflushThreshold(), newUnflushThreshold);
+ Assert.assertNotEquals(propsCase3.getUnflushThreshold(), unflushThreshold);
+ Assert.assertNotEquals(propsCase3.getUnflushThreshold(), propsCase2.getUnflushThreshold());
+ propsCase3.setUnflushInterval(newUnflushInterval);
+ Assert.assertEquals(propsCase3.getUnflushInterval(), newUnflushInterval);
+ Assert.assertNotEquals(propsCase3.getUnflushInterval(), unflushInterval);
+ Assert.assertNotEquals(propsCase3.getUnflushInterval(), propsCase2.getUnflushInterval());
+ propsCase3.setUnflushDataHold(newUnflushDataHold);
+ Assert.assertEquals(propsCase3.getUnflushDataHold(), newUnflushDataHold);
+ Assert.assertNotEquals(propsCase3.getUnflushDataHold(), unflushDataHold);
+ Assert.assertNotEquals(propsCase3.getUnflushDataHold(), propsCase2.getUnflushDataHold());
+ propsCase3.setMemCacheMsgSizeInMB(newMemCacheMsgSizeInMB);
+ Assert.assertEquals(propsCase3.getMemCacheMsgSizeInMB(), newMemCacheMsgSizeInMB);
+ Assert.assertNotEquals(propsCase3.getMemCacheMsgSizeInMB(), memCacheMsgSizeInMB);
+ Assert.assertNotEquals(propsCase3.getMemCacheMsgSizeInMB(), propsCase2.getMemCacheMsgSizeInMB());
+ propsCase3.setMemCacheMsgCntInK(newMemCacheMsgCntInK);
+ Assert.assertEquals(propsCase3.getMemCacheMsgCntInK(), newMemCacheMsgCntInK);
+ Assert.assertNotEquals(propsCase3.getMemCacheMsgCntInK(), memCacheMsgCntInK);
+ Assert.assertNotEquals(propsCase3.getMemCacheMsgCntInK(), propsCase2.getMemCacheMsgCntInK());
+ propsCase3.setMemCacheFlushIntvl(newMemCacheFlushIntvl);
+ Assert.assertEquals(propsCase3.getMemCacheFlushIntvl(), newMemCacheFlushIntvl);
+ Assert.assertNotEquals(propsCase3.getMemCacheFlushIntvl(), memCacheFlushIntvl);
+ Assert.assertNotEquals(propsCase3.getMemCacheFlushIntvl(), propsCase2.getMemCacheFlushIntvl());
+ propsCase3.setAcceptPublish(newAcceptPublish);
+ Assert.assertEquals(propsCase3.getAcceptPublish(), newAcceptPublish);
+ Assert.assertNotEquals(propsCase3.getAcceptPublish(), acceptPublish);
+ Assert.assertNotEquals(propsCase3.getAcceptPublish(), propsCase2.getAcceptPublish());
+ propsCase3.setAcceptSubscribe(newAcceptSubscribe);
+ Assert.assertEquals(propsCase3.getAcceptSubscribe(), newAcceptSubscribe);
+ Assert.assertNotEquals(propsCase3.getAcceptSubscribe(), acceptSubscribe);
+ Assert.assertNotEquals(propsCase3.getAcceptSubscribe(), propsCase2.getAcceptSubscribe());
+ propsCase3.setDataStoreInfo(newDataStoreType, newDataPath);
+ Assert.assertEquals(propsCase3.getDataStoreType(), newDataStoreType);
+ Assert.assertNotEquals(propsCase3.getDataStoreType(), dataStoreType);
+ Assert.assertNotEquals(propsCase3.getDataStoreType(), propsCase2.getDataStoreType());
+ Assert.assertEquals(propsCase3.getDataPath(), newDataPath);
+ Assert.assertNotEquals(propsCase3.getDataPath(), dataPath);
+ Assert.assertNotEquals(propsCase3.getDataPath(), propsCase2.getDataPath());
+ propsCase3.setDeletePolicy(newDeletePolicy);
+ Assert.assertEquals(propsCase3.getDeletePolicy(), newDeletePolicy);
+ Assert.assertNotEquals(propsCase3.getDeletePolicy(), deletePolicy);
+ Assert.assertNotEquals(propsCase3.getDeletePolicy(), propsCase2.getDeletePolicy());
+ Assert.assertEquals(propsCase3.getCleanPolicyType(), CleanPolType.CLEAN_POL_DELETE);
+ Assert.assertEquals(propsCase3.getRetPeriodInMs(), 10 * 3600 * 1000);
+ Assert.assertFalse(propsCase3.isMatched(propsCase2));
+ Assert.assertTrue(propsCase2.updModifyInfo(propsCase3));
+
+ }
+
+}