mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-26 06:07:13 +01:00
Compare commits
17
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
151c281f36 | ||
|
|
d493d626ba | ||
|
|
258e93bc86 | ||
|
|
03c643aa6b | ||
|
|
7635f6b9fa | ||
|
|
1af6c96cd0 | ||
|
|
a2383b3b12 | ||
|
|
7ef4c24f18 | ||
|
|
1ad3200094 | ||
|
|
98c93ca465 | ||
|
|
ee082ae402 | ||
|
|
ac67c3e0e7 | ||
|
|
ee7cdf3668 | ||
|
|
a6d421508a | ||
|
|
50df484d86 | ||
|
|
f69356f589 | ||
|
|
7ffe736d20 |
No files matched your search
@@ -1,5 +1,5 @@
|
||||
apiVersion: v1
|
||||
description: SeaweedFS
|
||||
name: seaweedfs
|
||||
appVersion: "2.26"
|
||||
version: 2.26
|
||||
appVersion: "2.27"
|
||||
version: 2.27
|
||||
@@ -4,7 +4,7 @@ global:
|
||||
registry: ""
|
||||
repository: ""
|
||||
imageName: chrislusf/seaweedfs
|
||||
# imageTag: "2.26" - started using {.Chart.appVersion}
|
||||
# imageTag: "2.27" - started using {.Chart.appVersion}
|
||||
imagePullPolicy: IfNotPresent
|
||||
imagePullSecrets: imagepullsecret
|
||||
restartPolicy: Always
|
||||
|
||||
@@ -4,8 +4,7 @@ import com.google.common.base.Strings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
@@ -94,9 +93,9 @@ public class FilerClient extends FilerGrpcClient {
|
||||
if ("/".equals(path)) {
|
||||
return true;
|
||||
}
|
||||
Path pathObject = Paths.get(path);
|
||||
String parent = pathObject.getParent().toString();
|
||||
String name = pathObject.getFileName().toString();
|
||||
File pathFile = new File(path);
|
||||
String parent = pathFile.getParent();
|
||||
String name = pathFile.getName();
|
||||
|
||||
mkdirs(parent, mode, uid, gid, userName, groupNames);
|
||||
|
||||
@@ -115,13 +114,13 @@ public class FilerClient extends FilerGrpcClient {
|
||||
|
||||
public boolean mv(String oldPath, String newPath) {
|
||||
|
||||
Path oldPathObject = Paths.get(oldPath);
|
||||
String oldParent = oldPathObject.getParent().toString();
|
||||
String oldName = oldPathObject.getFileName().toString();
|
||||
File oldPathFile = new File(oldPath);
|
||||
String oldParent = oldPathFile.getParent();
|
||||
String oldName = oldPathFile.getName();
|
||||
|
||||
Path newPathObject = Paths.get(newPath);
|
||||
String newParent = newPathObject.getParent().toString();
|
||||
String newName = newPathObject.getFileName().toString();
|
||||
File newPathFile = new File(newPath);
|
||||
String newParent = newPathFile.getParent();
|
||||
String newName = newPathFile.getName();
|
||||
|
||||
return atomicRenameEntry(oldParent, oldName, newParent, newName);
|
||||
|
||||
@@ -129,9 +128,9 @@ public class FilerClient extends FilerGrpcClient {
|
||||
|
||||
public boolean rm(String path, boolean isRecursive, boolean ignoreRecusiveError) {
|
||||
|
||||
Path pathObject = Paths.get(path);
|
||||
String parent = pathObject.getParent().toString();
|
||||
String name = pathObject.getFileName().toString();
|
||||
File pathFile = new File(path);
|
||||
String parent = pathFile.getParent();
|
||||
String name = pathFile.getName();
|
||||
|
||||
return deleteEntry(
|
||||
parent,
|
||||
@@ -148,9 +147,9 @@ public class FilerClient extends FilerGrpcClient {
|
||||
|
||||
public boolean touch(String path, int mode, int uid, int gid, String userName, String[] groupNames) {
|
||||
|
||||
Path pathObject = Paths.get(path);
|
||||
String parent = pathObject.getParent().toString();
|
||||
String name = pathObject.getFileName().toString();
|
||||
File pathFile = new File(path);
|
||||
String parent = pathFile.getParent();
|
||||
String name = pathFile.getName();
|
||||
|
||||
FilerProto.Entry entry = lookupEntry(parent, name);
|
||||
if (entry == null) {
|
||||
|
||||
@@ -92,7 +92,7 @@ func main() {
|
||||
|
||||
header := superBlock.Bytes()
|
||||
|
||||
if n, e := datFile.WriteAt(header, 0); n == 0 || e != nil {
|
||||
if n, e := datBackend.WriteAt(header, 0); n == 0 || e != nil {
|
||||
glog.Fatalf("cannot write super block: %v", e)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
flag "github.com/chrislusf/seaweedfs/weed/util/fla9"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
+1
-1
@@ -74,8 +74,8 @@ import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
flag "github.com/chrislusf/seaweedfs/weed/util/fla9"
|
||||
"io"
|
||||
stdLog "log"
|
||||
"os"
|
||||
|
||||
@@ -20,8 +20,8 @@ package glog
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
flag "github.com/chrislusf/seaweedfs/weed/util/fla9"
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
|
||||
@@ -2,7 +2,7 @@ package backend
|
||||
|
||||
import (
|
||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||
"github.com/chrislusf/seaweedfs/weed/util/buffered_writer"
|
||||
. "github.com/chrislusf/seaweedfs/weed/storage/types"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
@@ -14,36 +14,34 @@ var (
|
||||
type DiskFile struct {
|
||||
File *os.File
|
||||
fullFilePath string
|
||||
bufWriterAt *buffered_writer.TimedWriteBuffer
|
||||
fileSize int64
|
||||
modTime time.Time
|
||||
}
|
||||
|
||||
func NewDiskFile(f *os.File) *DiskFile {
|
||||
stat, e := f.Stat()
|
||||
if e != nil {
|
||||
glog.Fatalf("stat file %s: %v", f.Name(), e)
|
||||
stat, err := f.Stat()
|
||||
if err != nil {
|
||||
glog.Fatalf("stat file %s: %v", f.Name(), err)
|
||||
}
|
||||
offset := stat.Size()
|
||||
if offset%NeedlePaddingSize != 0 {
|
||||
offset = offset + (NeedlePaddingSize - offset%NeedlePaddingSize)
|
||||
}
|
||||
|
||||
return &DiskFile{
|
||||
fullFilePath: f.Name(),
|
||||
File: f,
|
||||
bufWriterAt: buffered_writer.NewTimedWriteBuffer(f, 1*1024*1024, 200*time.Millisecond, stat.Size()),
|
||||
fileSize: stat.Size(),
|
||||
fileSize: offset,
|
||||
modTime: stat.ModTime(),
|
||||
}
|
||||
}
|
||||
|
||||
func (df *DiskFile) ReadAt(p []byte, off int64) (n int, err error) {
|
||||
n, _ = df.bufWriterAt.ReadAt(p, off)
|
||||
if len(p) == n {
|
||||
return
|
||||
}
|
||||
return df.File.ReadAt(p, off)
|
||||
}
|
||||
|
||||
func (df *DiskFile) WriteAt(p []byte, off int64) (n int, err error) {
|
||||
n, err = df.bufWriterAt.WriteAt(p, off)
|
||||
n, err = df.File.WriteAt(p, off)
|
||||
if err == nil {
|
||||
waterMark := off + int64(n)
|
||||
if waterMark > df.fileSize {
|
||||
@@ -54,6 +52,10 @@ func (df *DiskFile) WriteAt(p []byte, off int64) (n int, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (df *DiskFile) Append(p []byte) (n int, err error) {
|
||||
return df.WriteAt(p, df.fileSize)
|
||||
}
|
||||
|
||||
func (df *DiskFile) Truncate(off int64) error {
|
||||
err := df.File.Truncate(off)
|
||||
if err == nil {
|
||||
@@ -64,19 +66,11 @@ func (df *DiskFile) Truncate(off int64) error {
|
||||
}
|
||||
|
||||
func (df *DiskFile) Close() error {
|
||||
df.bufWriterAt.Close()
|
||||
return df.File.Close()
|
||||
}
|
||||
|
||||
func (df *DiskFile) GetStat() (datSize int64, modTime time.Time, err error) {
|
||||
if df.fileSize != 0 {
|
||||
return df.fileSize, df.modTime, nil
|
||||
}
|
||||
stat, e := df.File.Stat()
|
||||
if e == nil {
|
||||
return stat.Size(), stat.ModTime(), nil
|
||||
}
|
||||
return 0, time.Time{}, err
|
||||
return df.fileSize, df.modTime, nil
|
||||
}
|
||||
|
||||
func (df *DiskFile) Name() string {
|
||||
@@ -84,7 +78,5 @@ func (df *DiskFile) Name() string {
|
||||
}
|
||||
|
||||
func (df *DiskFile) Sync() error {
|
||||
df.fileSize = 0
|
||||
df.bufWriterAt.Flush()
|
||||
return df.File.Sync()
|
||||
}
|
||||
@@ -161,7 +161,15 @@ func ReadNeedleBlob(r backend.BackendStorageFile, offset int64, size Size, versi
|
||||
dataSize := GetActualSize(size, version)
|
||||
dataSlice = make([]byte, int(dataSize))
|
||||
|
||||
_, err = r.ReadAt(dataSlice, offset)
|
||||
var n int
|
||||
n, err = r.ReadAt(dataSlice, offset)
|
||||
if err != nil && int64(n) == dataSize {
|
||||
err = nil
|
||||
}
|
||||
if err != nil {
|
||||
fileSize, _, _ := r.GetStat()
|
||||
println("n",n, "dataSize", dataSize, "offset", offset, "fileSize", fileSize)
|
||||
}
|
||||
return dataSlice, err
|
||||
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ func TestAppend(t *testing.T) {
|
||||
int64 : -9223372036854775808 to 9223372036854775807
|
||||
*/
|
||||
|
||||
fileSize := int64(4294967295) + 10000
|
||||
fileSize := int64(4294967296) + 10000
|
||||
tempFile.Truncate(fileSize)
|
||||
defer func() {
|
||||
tempFile.Close()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"sync"
|
||||
@@ -41,6 +40,7 @@ type baseNeedleMapper struct {
|
||||
|
||||
indexFile *os.File
|
||||
indexFileAccessLock sync.Mutex
|
||||
indexFileOffset int64
|
||||
}
|
||||
|
||||
func (nm *baseNeedleMapper) IndexFileSize() uint64 {
|
||||
@@ -56,11 +56,10 @@ func (nm *baseNeedleMapper) appendToIndexFile(key NeedleId, offset Offset, size
|
||||
|
||||
nm.indexFileAccessLock.Lock()
|
||||
defer nm.indexFileAccessLock.Unlock()
|
||||
if _, err := nm.indexFile.Seek(0, 2); err != nil {
|
||||
return fmt.Errorf("cannot seek end of indexfile %s: %v",
|
||||
nm.indexFile.Name(), err)
|
||||
written, err := nm.indexFile.WriteAt(bytes, nm.indexFileOffset)
|
||||
if err == nil {
|
||||
nm.indexFileOffset += int64(written)
|
||||
}
|
||||
_, err := nm.indexFile.Write(bytes)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,11 @@ func NewLevelDbNeedleMap(dbFileName string, indexFile *os.File, opts *opt.Option
|
||||
generateLevelDbFile(dbFileName, indexFile)
|
||||
glog.V(1).Infof("Finished Generating %s from %s", dbFileName, indexFile.Name())
|
||||
}
|
||||
if stat, err := indexFile.Stat(); err != nil {
|
||||
glog.Fatalf("stat file %s: %v", indexFile.Name(), err)
|
||||
} else {
|
||||
m.indexFileOffset = stat.Size()
|
||||
}
|
||||
glog.V(1).Infof("Opening %s...", dbFileName)
|
||||
|
||||
if m.db, err = leveldb.OpenFile(dbFileName, opts); err != nil {
|
||||
|
||||
@@ -19,6 +19,11 @@ func NewCompactNeedleMap(file *os.File) *NeedleMap {
|
||||
m: needle_map.NewCompactMap(),
|
||||
}
|
||||
nm.indexFile = file
|
||||
stat, err := file.Stat()
|
||||
if err != nil {
|
||||
glog.Fatalf("stat file %s: %v", file.Name(), err)
|
||||
}
|
||||
nm.indexFileOffset = stat.Size()
|
||||
return nm
|
||||
}
|
||||
|
||||
|
||||
@@ -286,7 +286,7 @@ func (v *Volume) makeupDiff(newDatFileName, newIdxFileName, oldDatFileName, oldI
|
||||
if err != nil {
|
||||
return fmt.Errorf("ReadNeedleBlob %s key %d offset %d size %d failed: %v", oldDatFile.Name(), key, increIdxEntry.offset.ToActualOffset(), increIdxEntry.size, err)
|
||||
}
|
||||
dst.Write(needleBytes)
|
||||
dstDatBackend.Append(needleBytes)
|
||||
util.Uint32toBytes(idxEntryBytes[8:12], uint32(offset/NeedlePaddingSize))
|
||||
} else { //deleted needle
|
||||
//fakeDelNeedle 's default Data field is nil
|
||||
|
||||
@@ -1,167 +0,0 @@
|
||||
package buffered_writer
|
||||
|
||||
import (
|
||||
"io"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type TimedWriteBuffer struct {
|
||||
maxLatencyWriterAt *maxLatencyWriterAt
|
||||
bufWriterAt *bufferedWriterAt
|
||||
}
|
||||
|
||||
func (t *TimedWriteBuffer) ReadAt(p []byte, off int64) (n int, err error) {
|
||||
bufStart := t.bufWriterAt.nextOffset - int64(t.bufWriterAt.dataSize)
|
||||
start := max(bufStart, off)
|
||||
stop := min(t.bufWriterAt.nextOffset, off+int64(len(p)))
|
||||
if start <= stop {
|
||||
n = copy(p, t.bufWriterAt.data[start-bufStart:stop-bufStart])
|
||||
}
|
||||
return
|
||||
}
|
||||
func (t *TimedWriteBuffer) WriteAt(p []byte, offset int64) (n int, err error) {
|
||||
return t.maxLatencyWriterAt.WriteAt(p, offset)
|
||||
}
|
||||
func (t *TimedWriteBuffer) Flush() {
|
||||
t.maxLatencyWriterAt.Flush()
|
||||
}
|
||||
func (t *TimedWriteBuffer) Close() {
|
||||
t.maxLatencyWriterAt.Close()
|
||||
}
|
||||
|
||||
func NewTimedWriteBuffer(writerAt io.WriterAt, size int, latency time.Duration, currentOffset int64) *TimedWriteBuffer {
|
||||
bufWriterAt := newBufferedWriterAt(writerAt, size, currentOffset)
|
||||
maxLatencyWriterAt := newMaxLatencyWriterAt(bufWriterAt, latency)
|
||||
return &TimedWriteBuffer{
|
||||
bufWriterAt: bufWriterAt,
|
||||
maxLatencyWriterAt: maxLatencyWriterAt,
|
||||
}
|
||||
}
|
||||
|
||||
type bufferedWriterAt struct {
|
||||
data []byte
|
||||
dataSize int
|
||||
nextOffset int64
|
||||
writerAt io.WriterAt
|
||||
counter int
|
||||
}
|
||||
|
||||
func newBufferedWriterAt(writerAt io.WriterAt, bufferSize int, currentOffset int64) *bufferedWriterAt {
|
||||
return &bufferedWriterAt{
|
||||
data: make([]byte, bufferSize),
|
||||
nextOffset: currentOffset,
|
||||
dataSize: 0,
|
||||
writerAt: writerAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (b *bufferedWriterAt) WriteAt(p []byte, offset int64) (n int, err error) {
|
||||
if b.nextOffset != offset {
|
||||
println("nextOffset", b.nextOffset, "bufSize", b.dataSize, "offset", offset, "data", len(p))
|
||||
}
|
||||
if b.nextOffset != offset || len(p)+b.dataSize > len(b.data) {
|
||||
if err = b.Flush(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
if len(p)+b.dataSize > len(b.data) {
|
||||
n, err = b.writerAt.WriteAt(p, offset)
|
||||
if err == nil {
|
||||
b.nextOffset = offset + int64(n)
|
||||
}
|
||||
} else {
|
||||
n = copy(b.data[b.dataSize:len(p)+b.dataSize], p)
|
||||
b.dataSize += n
|
||||
b.nextOffset += int64(n)
|
||||
b.counter++
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (b *bufferedWriterAt) Flush() (err error) {
|
||||
if b.dataSize == 0 {
|
||||
return nil
|
||||
}
|
||||
// println("flush", b.counter)
|
||||
b.counter = 0
|
||||
_, err = b.writerAt.WriteAt(b.data[0:b.dataSize], b.nextOffset-int64(b.dataSize))
|
||||
if err == nil {
|
||||
b.dataSize = 0
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// adapted from https://golang.org/src/net/http/httputil/reverseproxy.go
|
||||
|
||||
type writeFlusher interface {
|
||||
io.WriterAt
|
||||
Flush() error
|
||||
}
|
||||
|
||||
type maxLatencyWriterAt struct {
|
||||
dst writeFlusher
|
||||
latency time.Duration // non-zero; negative means to flush immediately
|
||||
mu sync.Mutex // protects t, flushPending, and dst.Flush
|
||||
t *time.Timer
|
||||
flushPending bool
|
||||
}
|
||||
|
||||
func newMaxLatencyWriterAt(dst writeFlusher, latency time.Duration) *maxLatencyWriterAt {
|
||||
return &maxLatencyWriterAt{
|
||||
dst: dst,
|
||||
latency: latency,
|
||||
}
|
||||
}
|
||||
|
||||
func (m *maxLatencyWriterAt) WriteAt(p []byte, offset int64) (n int, err error) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
n, err = m.dst.WriteAt(p, offset)
|
||||
if m.latency < 0 {
|
||||
m.dst.Flush()
|
||||
return
|
||||
}
|
||||
if m.flushPending {
|
||||
return
|
||||
}
|
||||
if m.t == nil {
|
||||
m.t = time.AfterFunc(m.latency, m.Flush)
|
||||
} else {
|
||||
m.t.Reset(m.latency)
|
||||
}
|
||||
m.flushPending = true
|
||||
return
|
||||
}
|
||||
|
||||
func (m *maxLatencyWriterAt) Flush() {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
if !m.flushPending { // if stop was called but AfterFunc already started this goroutine
|
||||
return
|
||||
}
|
||||
m.dst.Flush()
|
||||
m.flushPending = false
|
||||
}
|
||||
|
||||
func (m *maxLatencyWriterAt) Close() {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
m.flushPending = false
|
||||
if m.t != nil {
|
||||
m.t.Stop()
|
||||
}
|
||||
}
|
||||
|
||||
func min(x, y int64) int64 {
|
||||
if x <= y {
|
||||
return x
|
||||
}
|
||||
return y
|
||||
}
|
||||
func max(x, y int64) int64 {
|
||||
if x <= y {
|
||||
return y
|
||||
}
|
||||
return x
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
VERSION = fmt.Sprintf("%s %d.%02d", sizeLimit, 2, 26)
|
||||
VERSION = fmt.Sprintf("%s %d.%02d", sizeLimit, 2, 27)
|
||||
COMMIT = ""
|
||||
)
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -4,8 +4,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
flag "github.com/chrislusf/seaweedfs/weed/util/fla9"
|
||||
"io"
|
||||
"math/rand"
|
||||
"os"
|
||||
|
||||
Reference in new issue
Block a user