You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicecomb.apache.org by GitBox <gi...@apache.org> on 2017/12/26 12:09:46 UTC

[GitHub] little-cui closed pull request #227: SCB-129 Configurable compact interval.

little-cui closed pull request #227: SCB-129 Configurable compact interval.
URL: https://github.com/apache/incubator-servicecomb-service-center/pull/227
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/etc/conf/app.conf b/etc/conf/app.conf
index cd78a03e..1799c304 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 54e801ad..314c572e 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 23ba8b44..cf6ea39c 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 2f959229..b8ab6f54 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")


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services