You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2017/12/26 12:09:44 UTC
[incubator-servicecomb-service-center] branch master updated:
SCB-129 Configurable compact interval (#227)
This is an automated email from the ASF dual-hosted git repository.
littlecui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-service-center.git
The following commit(s) were added to refs/heads/master by this push:
new 4f71782 SCB-129 Configurable compact interval (#227)
4f71782 is described below
commit 4f71782e2aeed629c25270fba96a57e374782ed1
Author: little-cui <su...@qq.com>
AuthorDate: Tue Dec 26 20:09:43 2017 +0800
SCB-129 Configurable compact interval (#227)
---
etc/conf/app.conf | 3 ++-
server/core/info.go | 1 +
server/core/proto/services.go | 1 +
server/server.go | 10 ++++++++--
4 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/etc/conf/app.conf b/etc/conf/app.conf
index cd78a03..1799c30 100644
--- a/etc/conf/app.conf
+++ b/etc/conf/app.conf
@@ -38,7 +38,8 @@ manager_cluster = "127.0.0.1:2379"
auto_sync_interval = 30s
#indicate how many revision you want to keep in etcd
-compact_index_delta=100
+compact_index_delta = 100
+compact_interval = 12h
cipher_plugin = ""
diff --git a/server/core/info.go b/server/core/info.go
index 54e801a..314c572 100644
--- a/server/core/info.go
+++ b/server/core/info.go
@@ -61,6 +61,7 @@ func newInfo() *pb.ServerInformation {
AutoSyncInterval: beego.AppConfig.DefaultString("auto_sync_interval", "30s"),
CompactIndexDelta: beego.AppConfig.DefaultInt64("compact_index_delta", 100),
+ CompactInterval: beego.AppConfig.DefaultString("compact_interval", "12h"),
LoggerName: beego.AppConfig.String("component_name"),
LogRotateSize: maxLogFileSize,
diff --git a/server/core/proto/services.go b/server/core/proto/services.go
index 23ba8b4..cf6ea39 100644
--- a/server/core/proto/services.go
+++ b/server/core/proto/services.go
@@ -101,6 +101,7 @@ type ServerConfig struct {
AutoSyncInterval string `json:"autoSyncInterval"`
CompactIndexDelta int64 `json:"compactIndexDelta"`
+ CompactInterval string `json:"compactInterval"`
LoggerName string `json:"-"`
LogRotateSize int64 `json:"logRotateSize"`
diff --git a/server/server.go b/server/server.go
index 2f95922..b8ab6f5 100644
--- a/server/server.go
+++ b/server/server.go
@@ -114,13 +114,19 @@ func (s *ServiceCenterServer) autoCompactBackend() {
if delta <= 0 {
return
}
+ interval, err := time.ParseDuration(core.ServerInfo.Config.CompactInterval)
+ if err != nil {
+ util.Logger().Errorf(err, "invalid compact interval %s, reset to default interval 12h", core.ServerInfo.Config.CompactInterval)
+ interval = 12 * time.Hour
+ }
util.Go(func(stopCh <-chan struct{}) {
- util.Logger().Infof("start the automatic compact mechanism, compact once every 12h")
+ util.Logger().Infof("start the automatic compact mechanism, compact once every %s",
+ core.ServerInfo.Config.CompactInterval)
for {
select {
case <-stopCh:
return
- case <-time.After(12 * time.Hour):
+ case <-time.After(interval):
lock, err := mux.Try(mux.GLOBAL_LOCK)
if lock == nil {
util.Logger().Warnf(err, "can not compact backend by this service center instance now")
--
To stop receiving notification emails like this one, please contact
['"commits@servicecomb.apache.org" <co...@servicecomb.apache.org>'].