|
@ -59,7 +59,7 @@ func NewStore(grpcDialOption grpc.DialOption, port int, ip, publicUrl string, di |
|
|
|
|
|
|
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
func (s *Store) AddVolume(volumeId needle.VolumeId, collection string, needleMapKind NeedleMapType, replicaPlacement string, ttlString string, preallocate int64) error { |
|
|
|
|
|
|
|
|
func (s *Store) AddVolume(volumeId needle.VolumeId, collection string, needleMapKind NeedleMapType, replicaPlacement string, ttlString string, preallocate int64, in_memory bool) error { |
|
|
rt, e := NewReplicaPlacementFromString(replicaPlacement) |
|
|
rt, e := NewReplicaPlacementFromString(replicaPlacement) |
|
|
if e != nil { |
|
|
if e != nil { |
|
|
return e |
|
|
return e |
|
@ -68,7 +68,7 @@ func (s *Store) AddVolume(volumeId needle.VolumeId, collection string, needleMap |
|
|
if e != nil { |
|
|
if e != nil { |
|
|
return e |
|
|
return e |
|
|
} |
|
|
} |
|
|
e = s.addVolume(volumeId, collection, needleMapKind, rt, ttl, preallocate) |
|
|
|
|
|
|
|
|
e = s.addVolume(volumeId, collection, needleMapKind, rt, ttl, preallocate, in_memory) |
|
|
return e |
|
|
return e |
|
|
} |
|
|
} |
|
|
func (s *Store) DeleteCollection(collection string) (e error) { |
|
|
func (s *Store) DeleteCollection(collection string) (e error) { |
|
@ -101,14 +101,14 @@ func (s *Store) FindFreeLocation() (ret *DiskLocation) { |
|
|
} |
|
|
} |
|
|
return ret |
|
|
return ret |
|
|
} |
|
|
} |
|
|
func (s *Store) addVolume(vid needle.VolumeId, collection string, needleMapKind NeedleMapType, replicaPlacement *ReplicaPlacement, ttl *needle.TTL, preallocate int64) error { |
|
|
|
|
|
|
|
|
func (s *Store) addVolume(vid needle.VolumeId, collection string, needleMapKind NeedleMapType, replicaPlacement *ReplicaPlacement, ttl *needle.TTL, preallocate int64, in_memory bool) error { |
|
|
if s.findVolume(vid) != nil { |
|
|
if s.findVolume(vid) != nil { |
|
|
return fmt.Errorf("Volume Id %d already exists!", vid) |
|
|
return fmt.Errorf("Volume Id %d already exists!", vid) |
|
|
} |
|
|
} |
|
|
if location := s.FindFreeLocation(); location != nil { |
|
|
if location := s.FindFreeLocation(); location != nil { |
|
|
glog.V(0).Infof("In dir %s adds volume:%v collection:%s replicaPlacement:%v ttl:%v", |
|
|
glog.V(0).Infof("In dir %s adds volume:%v collection:%s replicaPlacement:%v ttl:%v", |
|
|
location.Directory, vid, collection, replicaPlacement, ttl) |
|
|
location.Directory, vid, collection, replicaPlacement, ttl) |
|
|
if volume, err := NewVolume(location.Directory, collection, vid, needleMapKind, replicaPlacement, ttl, preallocate); err == nil { |
|
|
|
|
|
|
|
|
if volume, err := NewVolume(location.Directory, collection, vid, needleMapKind, replicaPlacement, ttl, preallocate, in_memory); err == nil { |
|
|
location.SetVolume(vid, volume) |
|
|
location.SetVolume(vid, volume) |
|
|
glog.V(0).Infof("add volume %d", vid) |
|
|
glog.V(0).Infof("add volume %d", vid) |
|
|
s.NewVolumesChan <- master_pb.VolumeShortInformationMessage{ |
|
|
s.NewVolumesChan <- master_pb.VolumeShortInformationMessage{ |
|
|