diff --git a/weed/server/master_server_handlers_admin.go b/weed/server/master_server_handlers_admin.go index bbac62bcd..67c030042 100644 --- a/weed/server/master_server_handlers_admin.go +++ b/weed/server/master_server_handlers_admin.go @@ -11,6 +11,7 @@ import ( "github.com/chrislusf/seaweedfs/weed/operation" "github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb" "github.com/chrislusf/seaweedfs/weed/storage" + "github.com/chrislusf/seaweedfs/weed/storage/memory_map" "github.com/chrislusf/seaweedfs/weed/storage/needle" "github.com/chrislusf/seaweedfs/weed/topology" "github.com/chrislusf/seaweedfs/weed/util" @@ -147,7 +148,7 @@ func (ms *MasterServer) getVolumeGrowOption(r *http.Request) (*topology.VolumeGr if err != nil { return nil, err } - memoryMapMaxSizeMb, err := needle.ReadMemoryMapMaxSizeMb(r.FormValue("memoryMapMaxSizeMb")) + memoryMapMaxSizeMb, err := memory_map.ReadMemoryMapMaxSizeMb(r.FormValue("memoryMapMaxSizeMb")) if err != nil { return nil, err } diff --git a/weed/storage/memory_map/memory_map.go b/weed/storage/memory_map/memory_map.go index 5f0327ea7..e940fcc0e 100644 --- a/weed/storage/memory_map/memory_map.go +++ b/weed/storage/memory_map/memory_map.go @@ -1,10 +1,8 @@ -// +build !windows - package memory_map import ( - "fmt" "os" + "strconv" ) type MemoryBuffer struct { @@ -25,18 +23,10 @@ type MemoryMap struct { var FileMemoryMap = make(map[string]*MemoryMap) -func (mMap *MemoryMap) CreateMemoryMap(file *os.File, maxLength uint64) { -} - -func (mMap *MemoryMap) WriteMemory(offset uint64, length uint64, data []byte) { - -} - -func (mMap *MemoryMap) ReadMemory(offset uint64, length uint64) ([]byte, error) { - dataSlice := []byte{} - return dataSlice, fmt.Errorf("Memory Map not implemented for this platform") -} - -func (mBuffer *MemoryMap) DeleteFileAndMemoryMap() { - +func ReadMemoryMapMaxSizeMb(memoryMapMaxSizeMbString string) (uint32, error) { + if memoryMapMaxSizeMbString == "" { + return 0, nil + } + memoryMapMaxSize64, err := strconv.ParseUint(memoryMapMaxSizeMbString, 10, 32) + return uint32(memoryMapMaxSize64), err } diff --git a/weed/storage/memory_map/memory_map_other.go b/weed/storage/memory_map/memory_map_other.go new file mode 100644 index 000000000..e06a0b59a --- /dev/null +++ b/weed/storage/memory_map/memory_map_other.go @@ -0,0 +1,24 @@ +// +build !windows + +package memory_map + +import ( + "fmt" + "os" +) + +func (mMap *MemoryMap) CreateMemoryMap(file *os.File, maxLength uint64) { +} + +func (mMap *MemoryMap) WriteMemory(offset uint64, length uint64, data []byte) { + +} + +func (mMap *MemoryMap) ReadMemory(offset uint64, length uint64) ([]byte, error) { + dataSlice := []byte{} + return dataSlice, fmt.Errorf("Memory Map not implemented for this platform") +} + +func (mBuffer *MemoryMap) DeleteFileAndMemoryMap() { + +} diff --git a/weed/storage/needle/volume_memory_map_max_size_test.go b/weed/storage/memory_map/memory_map_test.go similarity index 91% rename from weed/storage/needle/volume_memory_map_max_size_test.go rename to weed/storage/memory_map/memory_map_test.go index 64d693d17..33e1a828c 100644 --- a/weed/storage/needle/volume_memory_map_max_size_test.go +++ b/weed/storage/memory_map/memory_map_test.go @@ -1,4 +1,4 @@ -package needle +package memory_map import "testing" diff --git a/weed/storage/memory_map/memory_map_windows.go b/weed/storage/memory_map/memory_map_windows.go index ac4493188..7eb713442 100644 --- a/weed/storage/memory_map/memory_map_windows.go +++ b/weed/storage/memory_map/memory_map_windows.go @@ -11,24 +11,6 @@ import ( "golang.org/x/sys/windows" ) -type MemoryBuffer struct { - aligned_length uint64 - length uint64 - aligned_ptr uintptr - ptr uintptr - Buffer []byte -} - -type MemoryMap struct { - File *os.File - file_memory_map_handle uintptr - write_map_views []MemoryBuffer - max_length uint64 - End_of_file int64 -} - -var FileMemoryMap = make(map[string]*MemoryMap) - type DWORDLONG = uint64 type DWORD = uint32 type WORD = uint16 diff --git a/weed/storage/needle/volume_memory_map_max_size.go b/weed/storage/needle/volume_memory_map_max_size.go deleted file mode 100644 index ca7b03b48..000000000 --- a/weed/storage/needle/volume_memory_map_max_size.go +++ /dev/null @@ -1,14 +0,0 @@ -package needle - -import "strconv" - -func ReadMemoryMapMaxSizeMb(MemoryMapMaxSizeMbString string) (uint32, error) { - if MemoryMapMaxSizeMbString == "" { - return 0, nil - } - var MemoryMapMaxSize64 uint64 - var err error - MemoryMapMaxSize64, err = strconv.ParseUint(MemoryMapMaxSizeMbString, 10, 32) - MemoryMapMaxSize := uint32(MemoryMapMaxSize64) - return MemoryMapMaxSize, err -}