Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
rskjetlein committed Dec 10, 2020
1 parent 355604b commit 1a509e7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
10 changes: 7 additions & 3 deletions integration_test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ OUTDIR="$(mktemp -d $BASEDIR/steno.XXXXXXXXXX)"
/bin/chmod g+rx "$OUTDIR"
Info "Writing output to directory '$OUTDIR'"

mkdir $OUTDIR/{pkt,idx,certs}
mkdir $OUTDIR/{pkt{0,1},idx{0,1},certs}

Info "Setting up $DUMMY interface"
sudo /sbin/modprobe dummy
Expand Down Expand Up @@ -104,8 +104,12 @@ trap CleanUp EXIT
cat > $OUTDIR/config << EOF
{
"Threads": [
{ "PacketsDirectory": "$OUTDIR/pkt"
, "IndexDirectory": "$OUTDIR/idx"
{ "PacketsDirectory": "$OUTDIR/pkt0"
, "IndexDirectory": "$OUTDIR/idx0"
, "DiskFreePercentage": 1
},
{ "PacketsDirectory": "$OUTDIR/pkt1"
, "IndexDirectory": "$OUTDIR/idx1"
, "DiskFreePercentage": 1
}
]
Expand Down
9 changes: 8 additions & 1 deletion thread/thread.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"io/ioutil"
"log"
"math/rand"
"net/http"
"os"
"path/filepath"
Expand All @@ -44,6 +45,7 @@ var (
v = base.V // verbose logging
currentFiles = stats.S.Get("current_files")
agedFiles = stats.S.Get("aged_files")
threadsNum int
)

const (
Expand Down Expand Up @@ -84,6 +86,7 @@ func Threads(configs []config.ThreadConfig, baseDir string, fc *filecache.Cache)
return nil, err
}
threads[i] = thread
threadsNum++
}
return threads, nil
}
Expand Down Expand Up @@ -361,7 +364,11 @@ func (t *Thread) Lookup(ctx context.Context, q query.Query) *base.PacketChan {
func (t *Thread) SyncFiles() {
t.mu.Lock()
t.syncFilesWithDisk()
t.cleanUpOnLowDiskSpace()
// Quick fix for when several threads writes to same underlying volume
if s := rand.Intn(threadsNum) + 1; s == t.id {
v(1, "Thread %d of %d checking diskspace", t.id, threadsNum)
t.cleanUpOnLowDiskSpace()
}
t.mu.Unlock()
}

Expand Down

0 comments on commit 1a509e7

Please sign in to comment.