From 731f4fa3ea2ea58b1dccdb62eb14a407594c81d8 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Sun, 20 Mar 2016 00:09:44 +0900 Subject: server: support mrt dump rotation like Quagga Signed-off-by: FUJITA Tomonori --- server/server.go | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'server/server.go') diff --git a/server/server.go b/server/server.go index 09d3fe31..035675f6 100644 --- a/server/server.go +++ b/server/server.go @@ -1163,19 +1163,23 @@ func (server *BgpServer) SetBmpConfig(c []config.BmpServer) error { return nil } -func (server *BgpServer) SetMrtConfig(c config.Mrt) error { - if c.FileName != "" { - ch := make(chan *GrpcResponse) - server.GrpcReqCh <- &GrpcRequest{ - RequestType: REQ_MOD_MRT, - Data: &api.ModMrtArguments{ - Operation: api.Operation_ADD, - Filename: c.FileName, - }, - ResponseCh: ch, - } - if err := (<-ch).Err(); err != nil { - return err +func (server *BgpServer) SetMrtConfig(c []config.Mrt) error { + for _, s := range c { + if s.FileName != "" { + ch := make(chan *GrpcResponse) + server.GrpcReqCh <- &GrpcRequest{ + RequestType: REQ_MOD_MRT, + Data: &api.ModMrtArguments{ + Operation: api.Operation_ADD, + DumpType: int32(s.DumpType.ToInt()), + Filename: s.FileName, + Interval: s.Interval, + }, + ResponseCh: ch, + } + if err := (<-ch).Err(); err != nil { + return err + } } } return nil @@ -2857,7 +2861,11 @@ func (server *BgpServer) handleModMrt(grpcReq *GrpcRequest) { } switch arg.Operation { case api.Operation_ADD: - w, err := newMrtWatcher(arg.Filename) + if arg.Interval != 0 && arg.Interval < 30 { + log.Info("minimum mrt dump interval is 30 seconds") + arg.Interval = 30 + } + w, err := newMrtWatcher(arg.DumpType, arg.Filename, arg.Interval) if err == nil { server.watchers[WATCHER_MRT] = w } @@ -2866,11 +2874,6 @@ func (server *BgpServer) handleModMrt(grpcReq *GrpcRequest) { delete(server.watchers, WATCHER_MRT) w.stop() grpcDone(grpcReq, nil) - case api.Operation_REPLACE: - go func() { - err := w.restart(arg.Filename) - grpcDone(grpcReq, err) - }() } } -- cgit v1.2.3