|
|
@ -35,7 +35,7 @@ type FilerLocalStore interface { |
|
|
|
} |
|
|
|
|
|
|
|
type FilerStoreWrapper struct { |
|
|
|
actualStore FilerStore |
|
|
|
ActualStore FilerStore |
|
|
|
} |
|
|
|
|
|
|
|
func NewFilerStoreWrapper(store FilerStore) *FilerStoreWrapper { |
|
|
@ -43,48 +43,48 @@ func NewFilerStoreWrapper(store FilerStore) *FilerStoreWrapper { |
|
|
|
return innerStore |
|
|
|
} |
|
|
|
return &FilerStoreWrapper{ |
|
|
|
actualStore: store, |
|
|
|
ActualStore: store, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func (fsw *FilerStoreWrapper) GetName() string { |
|
|
|
return fsw.actualStore.GetName() |
|
|
|
return fsw.ActualStore.GetName() |
|
|
|
} |
|
|
|
|
|
|
|
func (fsw *FilerStoreWrapper) Initialize(configuration util.Configuration, prefix string) error { |
|
|
|
return fsw.actualStore.Initialize(configuration, prefix) |
|
|
|
return fsw.ActualStore.Initialize(configuration, prefix) |
|
|
|
} |
|
|
|
|
|
|
|
func (fsw *FilerStoreWrapper) InsertEntry(ctx context.Context, entry *Entry) error { |
|
|
|
stats.FilerStoreCounter.WithLabelValues(fsw.actualStore.GetName(), "insert").Inc() |
|
|
|
stats.FilerStoreCounter.WithLabelValues(fsw.ActualStore.GetName(), "insert").Inc() |
|
|
|
start := time.Now() |
|
|
|
defer func() { |
|
|
|
stats.FilerStoreHistogram.WithLabelValues(fsw.actualStore.GetName(), "insert").Observe(time.Since(start).Seconds()) |
|
|
|
stats.FilerStoreHistogram.WithLabelValues(fsw.ActualStore.GetName(), "insert").Observe(time.Since(start).Seconds()) |
|
|
|
}() |
|
|
|
|
|
|
|
filer_pb.BeforeEntrySerialization(entry.Chunks) |
|
|
|
return fsw.actualStore.InsertEntry(ctx, entry) |
|
|
|
return fsw.ActualStore.InsertEntry(ctx, entry) |
|
|
|
} |
|
|
|
|
|
|
|
func (fsw *FilerStoreWrapper) UpdateEntry(ctx context.Context, entry *Entry) error { |
|
|
|
stats.FilerStoreCounter.WithLabelValues(fsw.actualStore.GetName(), "update").Inc() |
|
|
|
stats.FilerStoreCounter.WithLabelValues(fsw.ActualStore.GetName(), "update").Inc() |
|
|
|
start := time.Now() |
|
|
|
defer func() { |
|
|
|
stats.FilerStoreHistogram.WithLabelValues(fsw.actualStore.GetName(), "update").Observe(time.Since(start).Seconds()) |
|
|
|
stats.FilerStoreHistogram.WithLabelValues(fsw.ActualStore.GetName(), "update").Observe(time.Since(start).Seconds()) |
|
|
|
}() |
|
|
|
|
|
|
|
filer_pb.BeforeEntrySerialization(entry.Chunks) |
|
|
|
return fsw.actualStore.UpdateEntry(ctx, entry) |
|
|
|
return fsw.ActualStore.UpdateEntry(ctx, entry) |
|
|
|
} |
|
|
|
|
|
|
|
func (fsw *FilerStoreWrapper) FindEntry(ctx context.Context, fp util.FullPath) (entry *Entry, err error) { |
|
|
|
stats.FilerStoreCounter.WithLabelValues(fsw.actualStore.GetName(), "find").Inc() |
|
|
|
stats.FilerStoreCounter.WithLabelValues(fsw.ActualStore.GetName(), "find").Inc() |
|
|
|
start := time.Now() |
|
|
|
defer func() { |
|
|
|
stats.FilerStoreHistogram.WithLabelValues(fsw.actualStore.GetName(), "find").Observe(time.Since(start).Seconds()) |
|
|
|
stats.FilerStoreHistogram.WithLabelValues(fsw.ActualStore.GetName(), "find").Observe(time.Since(start).Seconds()) |
|
|
|
}() |
|
|
|
|
|
|
|
entry, err = fsw.actualStore.FindEntry(ctx, fp) |
|
|
|
entry, err = fsw.ActualStore.FindEntry(ctx, fp) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
@ -93,33 +93,33 @@ func (fsw *FilerStoreWrapper) FindEntry(ctx context.Context, fp util.FullPath) ( |
|
|
|
} |
|
|
|
|
|
|
|
func (fsw *FilerStoreWrapper) DeleteEntry(ctx context.Context, fp util.FullPath) (err error) { |
|
|
|
stats.FilerStoreCounter.WithLabelValues(fsw.actualStore.GetName(), "delete").Inc() |
|
|
|
stats.FilerStoreCounter.WithLabelValues(fsw.ActualStore.GetName(), "delete").Inc() |
|
|
|
start := time.Now() |
|
|
|
defer func() { |
|
|
|
stats.FilerStoreHistogram.WithLabelValues(fsw.actualStore.GetName(), "delete").Observe(time.Since(start).Seconds()) |
|
|
|
stats.FilerStoreHistogram.WithLabelValues(fsw.ActualStore.GetName(), "delete").Observe(time.Since(start).Seconds()) |
|
|
|
}() |
|
|
|
|
|
|
|
return fsw.actualStore.DeleteEntry(ctx, fp) |
|
|
|
return fsw.ActualStore.DeleteEntry(ctx, fp) |
|
|
|
} |
|
|
|
|
|
|
|
func (fsw *FilerStoreWrapper) DeleteFolderChildren(ctx context.Context, fp util.FullPath) (err error) { |
|
|
|
stats.FilerStoreCounter.WithLabelValues(fsw.actualStore.GetName(), "deleteFolderChildren").Inc() |
|
|
|
stats.FilerStoreCounter.WithLabelValues(fsw.ActualStore.GetName(), "deleteFolderChildren").Inc() |
|
|
|
start := time.Now() |
|
|
|
defer func() { |
|
|
|
stats.FilerStoreHistogram.WithLabelValues(fsw.actualStore.GetName(), "deleteFolderChildren").Observe(time.Since(start).Seconds()) |
|
|
|
stats.FilerStoreHistogram.WithLabelValues(fsw.ActualStore.GetName(), "deleteFolderChildren").Observe(time.Since(start).Seconds()) |
|
|
|
}() |
|
|
|
|
|
|
|
return fsw.actualStore.DeleteFolderChildren(ctx, fp) |
|
|
|
return fsw.ActualStore.DeleteFolderChildren(ctx, fp) |
|
|
|
} |
|
|
|
|
|
|
|
func (fsw *FilerStoreWrapper) ListDirectoryEntries(ctx context.Context, dirPath util.FullPath, startFileName string, includeStartFile bool, limit int) ([]*Entry, error) { |
|
|
|
stats.FilerStoreCounter.WithLabelValues(fsw.actualStore.GetName(), "list").Inc() |
|
|
|
stats.FilerStoreCounter.WithLabelValues(fsw.ActualStore.GetName(), "list").Inc() |
|
|
|
start := time.Now() |
|
|
|
defer func() { |
|
|
|
stats.FilerStoreHistogram.WithLabelValues(fsw.actualStore.GetName(), "list").Observe(time.Since(start).Seconds()) |
|
|
|
stats.FilerStoreHistogram.WithLabelValues(fsw.ActualStore.GetName(), "list").Observe(time.Since(start).Seconds()) |
|
|
|
}() |
|
|
|
|
|
|
|
entries, err := fsw.actualStore.ListDirectoryEntries(ctx, dirPath, startFileName, includeStartFile, limit) |
|
|
|
entries, err := fsw.ActualStore.ListDirectoryEntries(ctx, dirPath, startFileName, includeStartFile, limit) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
@ -130,17 +130,17 @@ func (fsw *FilerStoreWrapper) ListDirectoryEntries(ctx context.Context, dirPath |
|
|
|
} |
|
|
|
|
|
|
|
func (fsw *FilerStoreWrapper) BeginTransaction(ctx context.Context) (context.Context, error) { |
|
|
|
return fsw.actualStore.BeginTransaction(ctx) |
|
|
|
return fsw.ActualStore.BeginTransaction(ctx) |
|
|
|
} |
|
|
|
|
|
|
|
func (fsw *FilerStoreWrapper) CommitTransaction(ctx context.Context) error { |
|
|
|
return fsw.actualStore.CommitTransaction(ctx) |
|
|
|
return fsw.ActualStore.CommitTransaction(ctx) |
|
|
|
} |
|
|
|
|
|
|
|
func (fsw *FilerStoreWrapper) RollbackTransaction(ctx context.Context) error { |
|
|
|
return fsw.actualStore.RollbackTransaction(ctx) |
|
|
|
return fsw.ActualStore.RollbackTransaction(ctx) |
|
|
|
} |
|
|
|
|
|
|
|
func (fsw *FilerStoreWrapper) Shutdown() { |
|
|
|
fsw.actualStore.Shutdown() |
|
|
|
fsw.ActualStore.Shutdown() |
|
|
|
} |