|
|
@ -40,7 +40,7 @@ type Store struct { |
|
|
|
dataCenter string // optional informaton, overwriting master setting if exists
|
|
|
|
rack string // optional information, overwriting master setting if exists
|
|
|
|
connected bool |
|
|
|
NeedleMapType NeedleMapType |
|
|
|
NeedleMapKind NeedleMapKind |
|
|
|
NewVolumesChan chan master_pb.VolumeShortInformationMessage |
|
|
|
DeletedVolumesChan chan master_pb.VolumeShortInformationMessage |
|
|
|
NewEcShardsChan chan master_pb.VolumeEcShardInformationMessage |
|
|
@ -52,8 +52,8 @@ func (s *Store) String() (str string) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func NewStore(grpcDialOption grpc.DialOption, port int, ip, publicUrl string, dirnames []string, maxVolumeCounts []int, minFreeSpacePercents []float32, idxFolder string, needleMapKind NeedleMapType) (s *Store) { |
|
|
|
s = &Store{grpcDialOption: grpcDialOption, Port: port, Ip: ip, PublicUrl: publicUrl, NeedleMapType: needleMapKind} |
|
|
|
func NewStore(grpcDialOption grpc.DialOption, port int, ip, publicUrl string, dirnames []string, maxVolumeCounts []int, minFreeSpacePercents []float32, idxFolder string, needleMapKind NeedleMapKind) (s *Store) { |
|
|
|
s = &Store{grpcDialOption: grpcDialOption, Port: port, Ip: ip, PublicUrl: publicUrl, NeedleMapKind: needleMapKind} |
|
|
|
s.Locations = make([]*DiskLocation, 0) |
|
|
|
for i := 0; i < len(dirnames); i++ { |
|
|
|
location := NewDiskLocation(dirnames[i], maxVolumeCounts[i], minFreeSpacePercents[i], idxFolder) |
|
|
@ -69,7 +69,7 @@ func NewStore(grpcDialOption grpc.DialOption, port int, ip, publicUrl string, di |
|
|
|
|
|
|
|
return |
|
|
|
} |
|
|
|
func (s *Store) AddVolume(volumeId needle.VolumeId, collection string, needleMapKind NeedleMapType, replicaPlacement string, ttlString string, preallocate int64, MemoryMapMaxSizeMb uint32) error { |
|
|
|
func (s *Store) AddVolume(volumeId needle.VolumeId, collection string, needleMapKind NeedleMapKind, replicaPlacement string, ttlString string, preallocate int64, MemoryMapMaxSizeMb uint32) error { |
|
|
|
rt, e := super_block.NewReplicaPlacementFromString(replicaPlacement) |
|
|
|
if e != nil { |
|
|
|
return e |
|
|
@ -114,7 +114,7 @@ func (s *Store) FindFreeLocation() (ret *DiskLocation) { |
|
|
|
} |
|
|
|
return ret |
|
|
|
} |
|
|
|
func (s *Store) addVolume(vid needle.VolumeId, collection string, needleMapKind NeedleMapType, replicaPlacement *super_block.ReplicaPlacement, ttl *needle.TTL, preallocate int64, memoryMapMaxSizeMb uint32) error { |
|
|
|
func (s *Store) addVolume(vid needle.VolumeId, collection string, needleMapKind NeedleMapKind, replicaPlacement *super_block.ReplicaPlacement, ttl *needle.TTL, preallocate int64, memoryMapMaxSizeMb uint32) error { |
|
|
|
if s.findVolume(vid) != nil { |
|
|
|
return fmt.Errorf("Volume Id %d already exists!", vid) |
|
|
|
} |
|
|
@ -362,7 +362,7 @@ func (s *Store) MarkVolumeWritable(i needle.VolumeId) error { |
|
|
|
|
|
|
|
func (s *Store) MountVolume(i needle.VolumeId) error { |
|
|
|
for _, location := range s.Locations { |
|
|
|
if found := location.LoadVolume(i, s.NeedleMapType); found == true { |
|
|
|
if found := location.LoadVolume(i, s.NeedleMapKind); found == true { |
|
|
|
glog.V(0).Infof("mount volume %d", i) |
|
|
|
v := s.findVolume(i) |
|
|
|
s.NewVolumesChan <- master_pb.VolumeShortInformationMessage{ |
|
|
|