Skip to content

Commit

Permalink
Merge pull request #505 from nobodyiam/config-service-optimize
Browse files Browse the repository at this point in the history
Config service optimize
  • Loading branch information
lepdou authored Dec 28, 2016
2 parents 75bed9b + 967041c commit 3ddf3e6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 28 deletions.
10 changes: 0 additions & 10 deletions apollo-adminservice/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,4 @@
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>github</id>
<properties>
<package.environment>github</package.environment>
</properties>
<dependencies>
</dependencies>
</profile>
</profiles>
</project>
10 changes: 0 additions & 10 deletions apollo-configservice/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,4 @@
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>github</id>
<properties>
<package.environment>github</package.environment>
</properties>
<dependencies>
</dependencies>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class InstanceConfigAuditUtil implements InitializingBean {
private static final int INSTANCE_CONFIG_AUDIT_MAX_SIZE = 2000;
private static final int INSTANCE_CACHE_MAX_SIZE = 10000;
private static final int INSTANCE_CONFIG_CACHE_MAX_SIZE = 10000;
private static final long OFFER_TIME_LAST_MODIFIED_TIME_THRESHOLD_IN_MILLI = TimeUnit.MINUTES.toMillis(10);//10 minutes
private static final Joiner STRING_JOINER = Joiner.on(ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR);
private final ExecutorService auditExecutorService;
private final AtomicBoolean auditStopped;
Expand Down Expand Up @@ -93,6 +94,10 @@ void doAudit(InstanceConfigAuditModel auditModel) {
instanceConfig.setConfigClusterName(auditModel.getConfigClusterName());
instanceConfig.setReleaseKey(auditModel.getReleaseKey());
instanceConfig.setReleaseDeliveryTime(auditModel.getOfferTime());
} else if (offerTimeAndLastModifiedTimeCloseEnough(auditModel.getOfferTime(),
instanceConfig.getDataChangeLastModifiedTime())) {
//when releaseKey is the same, optimize to reduce writes if the record was updated not long ago
return;
}
//we need to update no matter the release key is the same or not, to ensure the
//last modified time is updated each day
Expand All @@ -117,6 +122,11 @@ void doAudit(InstanceConfigAuditModel auditModel) {
}
}

private boolean offerTimeAndLastModifiedTimeCloseEnough(Date offerTime, Date lastModifiedTime) {
return (offerTime.getTime() - lastModifiedTime.getTime()) <
OFFER_TIME_LAST_MODIFIED_TIME_THRESHOLD_IN_MILLI;
}

private long prepareInstanceId(InstanceConfigAuditModel auditModel) {
Instance instance = instanceService.findInstance(auditModel.getAppId(), auditModel
.getClusterName(), auditModel.getDataCenter(), auditModel.getIp());
Expand Down
8 changes: 0 additions & 8 deletions apollo-portal/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,5 @@
</dependency>
</dependencies>
</profile>
<profile>
<id>github</id>
<properties>
<package.environment>github</package.environment>
</properties>
<dependencies>
</dependencies>
</profile>
</profiles>
</project>

0 comments on commit 3ddf3e6

Please sign in to comment.