Skip to content

Commit

Permalink
feat: remove storage.use.eigen.match properties (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
pangdayuan1 authored Dec 28, 2023
1 parent 1084b8c commit ffe0224
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 53 deletions.
2 changes: 1 addition & 1 deletion arex-storage-config/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<parent>
<artifactId>arex-storage-service</artifactId>
<groupId>com.arextest</groupId>
<version>1.0.56</version>
<version>1.0.57</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion arex-storage-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>arex-storage-service</artifactId>
<groupId>com.arextest</groupId>
<version>1.0.56</version>
<version>1.0.57</version>
</parent>

<profiles>
Expand Down
2 changes: 1 addition & 1 deletion arex-storage-web-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
<parent>
<artifactId>arex-storage-service</artifactId>
<groupId>com.arextest</groupId>
<version>1.0.56</version>
<version>1.0.57</version>
</parent>

<profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ final class DefaultMockResultProviderImpl implements MockResultProvider {
*/
@Value("${arex.storage.cache.expired.seconds:7200}")
private long cacheExpiredSeconds;
@Value("${arex.storage.use.eigen.match}")
private boolean useEigenMatch;
@Value("${arex.storage.query.config:true}")
private boolean queryConfigSwitch;
@Resource
Expand Down Expand Up @@ -134,7 +132,7 @@ private void putRedisValue(byte[] recordOperationKey, int count) {
private <T extends Mocker> int sequencePutRecordData(MockCategoryType category,
byte[] recordIdBytes, int size, byte[] recordKey, T value, int sequence,
Map<byte[], Integer> mockSequenceKeyMaps) {
if (useEigenMatch && MapUtils.isEmpty(value.getEigenMap())) {
if (MapUtils.isEmpty(value.getEigenMap())) {
calculateEigen(value, true);
}
List<byte[]> mockKeyList = matchKeyFactory.build(value);
Expand Down Expand Up @@ -361,9 +359,7 @@ public byte[] getRecordResult(@NotNull Mocker mockItem, MockResultContext contex
String replayId = mockItem.getReplayId();
try {
long start = System.currentTimeMillis();
if (useEigenMatch) {
calculateEigen(mockItem, false);
}
calculateEigen(mockItem, false);
List<byte[]> mockKeyList = matchKeyFactory.build(mockItem);
long end = System.currentTimeMillis();
LOGGER.info("build mock keys cost:{} ms", end - start);
Expand All @@ -385,12 +381,8 @@ public byte[] getRecordResult(@NotNull Mocker mockItem, MockResultContext contex
recordIdBytes, replayIdBytes);
}

if (useEigenMatch) {
return getMockResultWithEigenMatch(category, recordIdBytes, replayIdBytes,
mockKeyList, mockItem, operationName, context);
}
return getMockResultWithSimilarityMatch(category, recordIdBytes, replayIdBytes, mockKeyList,
mockItem, operationName, context);
return getMockResultWithEigenMatch(category, recordIdBytes, replayIdBytes,
mockKeyList, mockItem, operationName, context);
} catch (Throwable throwable) {
LOGGER.error(
"from agent's sequence consumeResult error: {} for category: {}, recordId: {}, replayId: {}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

Expand Down Expand Up @@ -56,8 +55,6 @@ public class DatabaseMatchKeyBuilderImpl implements MatchKeyBuilder {
private static final List<String> SQL_TABLE_KEYS = Arrays.asList("from", "join", "update",
"into");
private final ObjectMapper objectMapper;
@Value("${arex.storage.use.eigen.match}")
private boolean useEigenMatch;

DatabaseMatchKeyBuilderImpl(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
Expand Down Expand Up @@ -171,7 +168,7 @@ private List<byte[]> dbMockKeyBuild(Mocker databaseMocker) {
md5Digest.update(dbNameBytes);
md5Digest.update(operationBytes);
byte[] dbNameMatchKey = md5Digest.digest();
if (useEigenMatch && MapUtils.isNotEmpty(databaseMocker.getEigenMap())) {
if (MapUtils.isNotEmpty(databaseMocker.getEigenMap())) {
try {
md5Digest.update(CacheKeyUtils.toUtf8Bytes(
objectMapper.writeValueAsString(databaseMocker.getEigenMap())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

Expand All @@ -27,9 +26,6 @@
@Order()
final class DefaultDependencyMatchKeyBuilderImpl implements MatchKeyBuilder {

@Value("${arex.storage.use.eigen.match}")
private boolean useEigenMatch;

@Override
public boolean isSupported(MockCategoryType categoryType) {
return !categoryType.isEntryPoint() && !categoryType.isSkipComparison();
Expand All @@ -45,7 +41,7 @@ public List<byte[]> build(Mocker instance) {
MessageDigest messageDigest = MessageDigestWriter.getMD5Digest();
messageDigest.update(operationBytes);
String body = request.getBody();
if (useEigenMatch && MapUtils.isNotEmpty(instance.getEigenMap())) {
if (MapUtils.isNotEmpty(instance.getEigenMap())) {
try {
body = objectMapper.writeValueAsString(instance.getEigenMap());
} catch (JsonProcessingException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

Expand All @@ -28,9 +27,6 @@
@Order(5)
final class DubboConsumerMatchKeyBuilderImpl implements MatchKeyBuilder {

@Value("${arex.storage.use.eigen.match}")
private boolean useEigenMatch;

@Override
public boolean isSupported(MockCategoryType categoryType) {
return Objects.equals(categoryType, MockCategoryType.DUBBO_CONSUMER);
Expand All @@ -46,7 +42,7 @@ public List<byte[]> build(Mocker instance) {
MessageDigest messageDigest = MessageDigestWriter.getMD5Digest();
messageDigest.update(operationBytes);
String body = request.getBody();
if (useEigenMatch && MapUtils.isNotEmpty(instance.getEigenMap())) {
if (MapUtils.isNotEmpty(instance.getEigenMap())) {
try {
body = objectMapper.writeValueAsString(instance.getEigenMap());
} catch (JsonProcessingException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

Expand All @@ -24,9 +23,6 @@
@Slf4j
final class DynamicClassMatchKeyBuilderImpl implements MatchKeyBuilder {

@Value("${arex.storage.use.eigen.match}")
private boolean useEigenMatch;

@Override
public boolean isSupported(MockCategoryType categoryType) {
return Objects.equals(categoryType, MockCategoryType.DYNAMIC_CLASS);
Expand All @@ -44,7 +40,7 @@ public List<byte[]> build(Mocker instance) {
messageDigest.update(operationNameBytes);

String body = targetRequest.getBody();
if (useEigenMatch && MapUtils.isNotEmpty(instance.getEigenMap())) {
if (MapUtils.isNotEmpty(instance.getEigenMap())) {
try {
body = objectMapper.writeValueAsString(instance.getEigenMap());
} catch (JsonProcessingException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

Expand All @@ -30,9 +29,6 @@
@Order(15)
final class HttpClientMatchKeyBuilderImpl implements MatchKeyBuilder {

@Value("${arex.storage.use.eigen.match}")
private boolean useEigenMatch;

private final ObjectMapper objectMapper;
private static final String BODY = "body";
HttpClientMatchKeyBuilderImpl(ObjectMapper objectMapper) {
Expand Down Expand Up @@ -64,7 +60,7 @@ public List<byte[]> build(Mocker instance) {
return Arrays.asList(httpMethodWithUrlBytes, operationBytes);
}
String body = request.getBody();
if (useEigenMatch && MapUtils.isNotEmpty(instance.getEigenMap())) {
if (MapUtils.isNotEmpty(instance.getEigenMap())) {
try {
body = objectMapper.writeValueAsString(instance.getEigenMap());
} catch (JsonProcessingException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

Expand All @@ -28,9 +27,6 @@
@Order(20)
final class QMessageProduceMatchKeyBuilderImpl implements MatchKeyBuilder {

@Value("${arex.storage.use.eigen.match}")
private boolean useEigenMatch;

@Override
public boolean isSupported(MockCategoryType categoryType) {
return Objects.equals(categoryType, MockCategoryType.Q_MESSAGE_PRODUCER);
Expand All @@ -46,7 +42,7 @@ public List<byte[]> build(Mocker instance) {
MessageDigest messageDigest = MessageDigestWriter.getMD5Digest();
messageDigest.update(operationBytes);
String body = request.getBody();
if (useEigenMatch && MapUtils.isNotEmpty(instance.getEigenMap())) {
if (MapUtils.isNotEmpty(instance.getEigenMap())) {
try {
body = objectMapper.writeValueAsString(instance.getEigenMap());
} catch (JsonProcessingException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

Expand All @@ -27,8 +26,6 @@ final class RedisMatchKeyBuilderImpl implements MatchKeyBuilder {

private final ObjectMapper objectMapper;
private static final String BODY = "body";
@Value("${arex.storage.use.eigen.match}")
private boolean useEigenMatch;
RedisMatchKeyBuilderImpl(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}
Expand All @@ -47,7 +44,7 @@ public List<byte[]> build(Mocker instance) {
}
MessageDigest messageDigest = MessageDigestWriter.getMD5Digest();
messageDigest.update(operationBytes);
if (useEigenMatch && MapUtils.isNotEmpty(instance.getEigenMap())) {
if (MapUtils.isNotEmpty(instance.getEigenMap())) {
String eigenBody = request.getBody();
try {
eigenBody = objectMapper.writeValueAsString(instance.getEigenMap());
Expand Down
4 changes: 0 additions & 4 deletions arex-storage-web-api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,5 @@ arex:
timeMock: true
prometheus:
port: 20093
storage:
use:
eigen:
match: false
pom:
version: ${project.version}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -408,5 +408,5 @@
<url>https://github.com/arextest/arex-storage</url>


<version>1.0.56</version>
<version>1.0.57</version>
</project>

0 comments on commit ffe0224

Please sign in to comment.