EvanLjp commented on a change in pull request #10:
URL: 
https://github.com/apache/skywalking-satellite/pull/10#discussion_r545700216



##########
File path: plugins/queue/mmap/queue_opreation.go
##########
@@ -0,0 +1,236 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you under
+// the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package mmap
+
+import (
+       "context"
+       "fmt"
+       "strconv"
+       "strings"
+       "syscall"
+       "time"
+
+       "github.com/apache/skywalking-satellite/internal/pkg/event"
+       "github.com/apache/skywalking-satellite/internal/pkg/log"
+)
+
+const uInt64Size = 8
+
+// flush control the flush operation by timer or counter.
+func (q *Queue) flush() {
+       defer q.showDownWg.Done()
+       ctx, cancel := context.WithCancel(q.ctx)
+       defer cancel()
+       for {
+               timeTicker := time.NewTicker(time.Duration(q.FlushPeriod) * 
time.Millisecond)
+               select {
+               case <-q.flushChannel:
+                       q.doFlush()
+               case <-timeTicker.C:
+                       q.doFlush()
+               case <-ctx.Done():
+                       q.doFlush()
+                       return
+               }
+       }
+}
+
+// doFlush flush the segment and meta files to the disk.
+func (q *Queue) doFlush() {
+       q.Lock()
+       defer q.Unlock()
+       for _, segment := range q.segments {
+               if segment == nil {
+                       continue
+               }
+               if err := segment.Flush(syscall.MS_SYNC); err != nil {
+                       log.Logger.Errorf("cannot flush segment file: %v", err)
+               }
+       }
+       wid, woffset := q.meta.GetWritingOffset()
+       q.meta.PutWatermarkOffset(wid, woffset)
+       if err := q.meta.Flush(); err != nil {
+               log.Logger.Errorf("cannot flush meta file: %v", err)
+       }
+}
+
+// push writes the data into the file system. It first writes the length of 
the data,
+// then the data itself. It means the whole data may not exist in the one 
segments.
+func (q *Queue) push(bytes []byte) error {

Review comment:
       
![image](https://user-images.githubusercontent.com/31562192/102597291-648e3900-4155-11eb-9949-1ce3c58218f7.png)
   
   Already add it before, please have a look again




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to