Skip to content

Commit 3ddf3e6

Browse files
authored
Merge pull request apolloconfig#505 from nobodyiam/config-service-optimize
Config service optimize
2 parents 75bed9b + 967041c commit 3ddf3e6

File tree

4 files changed

+10
-28
lines changed

4 files changed

+10
-28
lines changed

apollo-adminservice/pom.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,4 @@
9696
</plugin>
9797
</plugins>
9898
</build>
99-
<profiles>
100-
<profile>
101-
<id>github</id>
102-
<properties>
103-
<package.environment>github</package.environment>
104-
</properties>
105-
<dependencies>
106-
</dependencies>
107-
</profile>
108-
</profiles>
10999
</project>

apollo-configservice/pom.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,4 @@
9797
</plugin>
9898
</plugins>
9999
</build>
100-
<profiles>
101-
<profile>
102-
<id>github</id>
103-
<properties>
104-
<package.environment>github</package.environment>
105-
</properties>
106-
<dependencies>
107-
</dependencies>
108-
</profile>
109-
</profiles>
110100
</project>

apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/util/InstanceConfigAuditUtil.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class InstanceConfigAuditUtil implements InitializingBean {
3636
private static final int INSTANCE_CONFIG_AUDIT_MAX_SIZE = 2000;
3737
private static final int INSTANCE_CACHE_MAX_SIZE = 10000;
3838
private static final int INSTANCE_CONFIG_CACHE_MAX_SIZE = 10000;
39+
private static final long OFFER_TIME_LAST_MODIFIED_TIME_THRESHOLD_IN_MILLI = TimeUnit.MINUTES.toMillis(10);//10 minutes
3940
private static final Joiner STRING_JOINER = Joiner.on(ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR);
4041
private final ExecutorService auditExecutorService;
4142
private final AtomicBoolean auditStopped;
@@ -93,6 +94,10 @@ void doAudit(InstanceConfigAuditModel auditModel) {
9394
instanceConfig.setConfigClusterName(auditModel.getConfigClusterName());
9495
instanceConfig.setReleaseKey(auditModel.getReleaseKey());
9596
instanceConfig.setReleaseDeliveryTime(auditModel.getOfferTime());
97+
} else if (offerTimeAndLastModifiedTimeCloseEnough(auditModel.getOfferTime(),
98+
instanceConfig.getDataChangeLastModifiedTime())) {
99+
//when releaseKey is the same, optimize to reduce writes if the record was updated not long ago
100+
return;
96101
}
97102
//we need to update no matter the release key is the same or not, to ensure the
98103
//last modified time is updated each day
@@ -117,6 +122,11 @@ void doAudit(InstanceConfigAuditModel auditModel) {
117122
}
118123
}
119124

125+
private boolean offerTimeAndLastModifiedTimeCloseEnough(Date offerTime, Date lastModifiedTime) {
126+
return (offerTime.getTime() - lastModifiedTime.getTime()) <
127+
OFFER_TIME_LAST_MODIFIED_TIME_THRESHOLD_IN_MILLI;
128+
}
129+
120130
private long prepareInstanceId(InstanceConfigAuditModel auditModel) {
121131
Instance instance = instanceService.findInstance(auditModel.getAppId(), auditModel
122132
.getClusterName(), auditModel.getDataCenter(), auditModel.getIp());

apollo-portal/pom.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,5 @@
7070
</dependency>
7171
</dependencies>
7272
</profile>
73-
<profile>
74-
<id>github</id>
75-
<properties>
76-
<package.environment>github</package.environment>
77-
</properties>
78-
<dependencies>
79-
</dependencies>
80-
</profile>
8173
</profiles>
8274
</project>

0 commit comments

Comments
 (0)