diff --git a/field.go b/field.go index 670071c6d..899e6f399 100644 --- a/field.go +++ b/field.go @@ -80,7 +80,7 @@ func (p *protected) Get() time.Duration { return p.duration } -var AvailableShardFileFlushDuration = &protected{ +var availableShardFileFlushDuration = &protected{ duration: 5 * time.Second, } @@ -636,7 +636,7 @@ func nonBlockingWriteAvailableShards(fieldPath string, availableShardBytes []byt func (f *Field) writeAvailableShards() { defer f.wg.Done() - ticker := time.NewTicker(AvailableShardFileFlushDuration.Get()) + ticker := time.NewTicker(availableShardFileFlushDuration.Get()) var data []byte tracker := make(chan bool) writing := false diff --git a/field_internal_test.go b/field_internal_test.go index 688f1cda2..ee13a269c 100644 --- a/field_internal_test.go +++ b/field_internal_test.go @@ -351,7 +351,7 @@ func TestField_RowTime(t *testing.T) { } func TestField_PersistAvailableShards(t *testing.T) { - AvailableShardFileFlushDuration.Set(200 * time.Millisecond) //shorten the default time to force a file write + availableShardFileFlushDuration.Set(200 * time.Millisecond) //shorten the default time to force a file write f := OpenField(t, OptFieldTypeDefault()) // bm represents remote available shards. @@ -360,7 +360,7 @@ func TestField_PersistAvailableShards(t *testing.T) { if err := f.AddRemoteAvailableShards(bm); err != nil { t.Fatal(err) } - time.Sleep(2 * AvailableShardFileFlushDuration.Get()) + time.Sleep(2 * availableShardFileFlushDuration.Get()) // Reload field and verify that shard data is persisted. if err := f.Reopen(); err != nil { @@ -372,7 +372,7 @@ func TestField_PersistAvailableShards(t *testing.T) { } func TestField_CorruptAvailableShards(t *testing.T) { - AvailableShardFileFlushDuration.Set(200 * time.Millisecond) //shorten the default time to force a file write + availableShardFileFlushDuration.Set(200 * time.Millisecond) //shorten the default time to force a file write f := OpenField(t, OptFieldTypeDefault()) // bm represents remote available shards. @@ -381,7 +381,7 @@ func TestField_CorruptAvailableShards(t *testing.T) { if err := f.AddRemoteAvailableShards(bm); err != nil { t.Fatal(err) } - time.Sleep(2 * AvailableShardFileFlushDuration.Get()) + time.Sleep(2 * availableShardFileFlushDuration.Get()) path := filepath.Join(f.path, ".available.shards") @@ -404,7 +404,7 @@ func TestField_CorruptAvailableShards(t *testing.T) { } func TestField_TruncatedAvailableShards(t *testing.T) { - AvailableShardFileFlushDuration.Set(200 * time.Millisecond) //shorten the default time to force a file write + availableShardFileFlushDuration.Set(200 * time.Millisecond) //shorten the default time to force a file write f := OpenField(t, OptFieldTypeDefault()) // bm represents remote available shards. @@ -413,7 +413,7 @@ func TestField_TruncatedAvailableShards(t *testing.T) { if err := f.AddRemoteAvailableShards(bm); err != nil { t.Fatal(err) } - time.Sleep(2 * AvailableShardFileFlushDuration.Get()) + time.Sleep(2 * availableShardFileFlushDuration.Get()) path := filepath.Join(f.path, ".available.shards") @@ -434,7 +434,7 @@ func TestField_TruncatedAvailableShards(t *testing.T) { // Ensure that persisting available shards having a smaller footprint (for example, // when going from a bitmap to a smaller, RLE representation) succeeds. func TestField_PersistAvailableShardsFootprint(t *testing.T) { - AvailableShardFileFlushDuration.Set(200 * time.Millisecond) //shorten the default time to force a file write + availableShardFileFlushDuration.Set(200 * time.Millisecond) //shorten the default time to force a file write f := OpenField(t, OptFieldTypeDefault()) // bm represents remote available shards. @@ -449,7 +449,7 @@ func TestField_PersistAvailableShardsFootprint(t *testing.T) { if err := f.AddRemoteAvailableShards(bm); err != nil { t.Fatal(err) } - time.Sleep(2 * AvailableShardFileFlushDuration.Get()) + time.Sleep(2 * availableShardFileFlushDuration.Get()) // Reload field and verify that shard data is persisted. if err := f.Reopen(); err != nil { diff --git a/holder_internal_test.go b/holder_internal_test.go index ecc479be1..ccc52c5b0 100644 --- a/holder_internal_test.go +++ b/holder_internal_test.go @@ -99,7 +99,7 @@ func TestHolder_Optn(t *testing.T) { if os.Geteuid() == 0 { t.Skip("Skipping permissions test since user is root.") } - AvailableShardFileFlushDuration.Set(100 * time.Millisecond) + availableShardFileFlushDuration.Set(100 * time.Millisecond) h := newHolder() defer h.Close() @@ -184,7 +184,7 @@ func TestHolder_Optn(t *testing.T) { // Ensure holder can clean up orphaned fragments. func TestHolderCleaner_CleanHolder(t *testing.T) { - AvailableShardFileFlushDuration.Set(100 * time.Millisecond) //shorten the default time to force a file write + availableShardFileFlushDuration.Set(100 * time.Millisecond) //shorten the default time to force a file write cluster := NewTestCluster(2) // Create a local holder. @@ -226,7 +226,7 @@ func TestHolderCleaner_CleanHolder(t *testing.T) { if err != nil { t.Fatalf("adding remote shards: %v", err) } - time.Sleep(2 * AvailableShardFileFlushDuration.Get()) + time.Sleep(2 * availableShardFileFlushDuration.Get()) // Keep replication the same and ensure we get the expected results. cluster.ReplicaN = 2 diff --git a/utils_internal_test.go b/utils_internal_test.go index 9a52cfcd0..83751f4bf 100644 --- a/utils_internal_test.go +++ b/utils_internal_test.go @@ -34,7 +34,7 @@ func NewTestCluster(n int) *cluster { panic(err) } - AvailableShardFileFlushDuration.Set(100 * time.Millisecond) + availableShardFileFlushDuration.Set(100 * time.Millisecond) c := newCluster() c.ReplicaN = 1 c.Hasher = NewTestModHasher()