mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
filer: close stores if interrupted
This commit is contained in:
parent
d022b6bc0e
commit
7b37178716
|
@ -184,3 +184,7 @@ func (store *AbstractSqlStore) ListDirectoryEntries(ctx context.Context, fullpat
|
|||
|
||||
return entries, nil
|
||||
}
|
||||
|
||||
func (store *AbstractSqlStore) Shutdown() {
|
||||
store.DB.Close()
|
||||
}
|
||||
|
|
|
@ -154,3 +154,7 @@ func (store *CassandraStore) ListDirectoryEntries(ctx context.Context, fullpath
|
|||
|
||||
return entries, err
|
||||
}
|
||||
|
||||
func (store *CassandraStore) Shutdown() {
|
||||
store.session.Close()
|
||||
}
|
||||
|
|
|
@ -196,3 +196,7 @@ func getNameFromKey(key []byte) string {
|
|||
|
||||
return string(key[sepIndex+1:])
|
||||
}
|
||||
|
||||
func (store *EtcdStore) Shutdown() {
|
||||
store.client.Close()
|
||||
}
|
||||
|
|
|
@ -308,3 +308,7 @@ func (f *Filer) cacheSetDirectory(dirpath string, dirEntry *Entry, level int) {
|
|||
|
||||
f.directoryCache.Set(dirpath, dirEntry, time.Duration(minutes)*time.Minute)
|
||||
}
|
||||
|
||||
func (f *Filer) Shutdown() {
|
||||
f.store.Shutdown()
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ type FilerStore interface {
|
|||
BeginTransaction(ctx context.Context) (context.Context, error)
|
||||
CommitTransaction(ctx context.Context) error
|
||||
RollbackTransaction(ctx context.Context) error
|
||||
|
||||
Shutdown()
|
||||
}
|
||||
|
||||
type FilerStoreWrapper struct {
|
||||
|
@ -133,3 +135,7 @@ func (fsw *FilerStoreWrapper) CommitTransaction(ctx context.Context) error {
|
|||
func (fsw *FilerStoreWrapper) RollbackTransaction(ctx context.Context) error {
|
||||
return fsw.actualStore.RollbackTransaction(ctx)
|
||||
}
|
||||
|
||||
func (fsw *FilerStoreWrapper) Shutdown() {
|
||||
fsw.actualStore.Shutdown()
|
||||
}
|
||||
|
|
|
@ -216,3 +216,7 @@ func getNameFromKey(key []byte) string {
|
|||
return string(key[sepIndex+1:])
|
||||
|
||||
}
|
||||
|
||||
func (store *LevelDBStore) Shutdown() {
|
||||
store.db.Close()
|
||||
}
|
||||
|
|
|
@ -236,3 +236,9 @@ func hashToBytes(dir string, dbCount int) ([]byte, int) {
|
|||
|
||||
return b, int(x) % dbCount
|
||||
}
|
||||
|
||||
func (store *LevelDB2Store) Shutdown() {
|
||||
for d := 0; d < store.dbCount; d++ {
|
||||
store.dbs[d].Close()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,3 +180,8 @@ func (store *UniversalRedisStore) ListDirectoryEntries(ctx context.Context, full
|
|||
func genDirectoryListKey(dir string) (dirList string) {
|
||||
return dir + DIR_LIST_MARKER
|
||||
}
|
||||
|
||||
|
||||
func (store *UniversalRedisStore) Shutdown() {
|
||||
store.Client.Close()
|
||||
}
|
||||
|
|
|
@ -102,6 +102,10 @@ func NewFilerServer(defaultMux, readonlyMux *http.ServeMux, option *FilerOption)
|
|||
|
||||
maybeStartMetrics(fs, option)
|
||||
|
||||
util.OnInterrupt(func() {
|
||||
fs.filer.Shutdown()
|
||||
})
|
||||
|
||||
return fs, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue