removing set volume location
display version number add default replication type
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"pkg/storage"
|
||||
"pkg/topology"
|
||||
)
|
||||
|
||||
func SendVolumeLocationsList(t *topology.Topology, vid storage.VolumeId) error{
|
||||
// values := make(url.Values)
|
||||
// values.Add("volumeLocationsList", vid.String())
|
||||
// volumeLocations:= []map[string]string{}
|
||||
// list := t.GetVolumeLocations(vid)
|
||||
// m := make(map[string]interface{})
|
||||
// m["Vid"] = vid.String()
|
||||
// for _, dn := range list {
|
||||
// m["Locations"] = append(m["Locations"], dn)
|
||||
// }
|
||||
// for _, dn := range list {
|
||||
// util.Post("http://"+dn.Ip+":"+strconv.Itoa(dn.Port)+"/admin/set_volume_locations_list", values)
|
||||
// }
|
||||
return nil
|
||||
}
|
||||
@@ -140,18 +140,3 @@ func (s *Store) HasVolume(i VolumeId) bool {
|
||||
_, ok := s.volumes[i]
|
||||
return ok
|
||||
}
|
||||
|
||||
type VolumeLocations struct {
|
||||
Vid VolumeId
|
||||
Locations []string
|
||||
}
|
||||
|
||||
func (s *Store) SetVolumeLocations(volumeLocationList []VolumeLocations) error {
|
||||
for _, volumeLocations := range volumeLocationList {
|
||||
vid := volumeLocations.Vid
|
||||
if v := s.volumes[vid]; v != nil {
|
||||
v.locations = volumeLocations.Locations
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -22,8 +22,6 @@ type Volume struct {
|
||||
|
||||
accessLock sync.Mutex
|
||||
|
||||
//transient
|
||||
locations []string
|
||||
}
|
||||
|
||||
func NewVolume(dirname string, id VolumeId, replicationType ReplicationType) (v *Volume) {
|
||||
|
||||
@@ -2,11 +2,11 @@ package topology
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"pkg/directory"
|
||||
"pkg/sequence"
|
||||
"pkg/storage"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
type Topology struct {
|
||||
@@ -24,11 +24,11 @@ type Topology struct {
|
||||
chanDeadDataNodes chan *DataNode
|
||||
chanRecoveredDataNodes chan *DataNode
|
||||
chanFullVolumes chan *storage.VolumeInfo
|
||||
|
||||
|
||||
configuration *Configuration
|
||||
}
|
||||
|
||||
func NewTopology(id string, confFile string, dirname string, filename string, volumeSizeLimit uint64, pulse int) *Topology {
|
||||
func NewTopology(id string, confFile string, dirname string, sequenceFilename string, volumeSizeLimit uint64, pulse int) *Topology {
|
||||
t := &Topology{}
|
||||
t.id = NodeId(id)
|
||||
t.nodeType = "Topology"
|
||||
@@ -38,32 +38,34 @@ func NewTopology(id string, confFile string, dirname string, filename string, vo
|
||||
t.pulse = int64(pulse)
|
||||
t.volumeSizeLimit = volumeSizeLimit
|
||||
|
||||
t.sequence = sequence.NewSequencer(dirname, filename)
|
||||
t.sequence = sequence.NewSequencer(dirname, sequenceFilename)
|
||||
|
||||
t.chanDeadDataNodes = make(chan *DataNode)
|
||||
t.chanRecoveredDataNodes = make(chan *DataNode)
|
||||
t.chanFullVolumes = make(chan *storage.VolumeInfo)
|
||||
|
||||
t.loadConfiguration(confFile)
|
||||
|
||||
t.loadConfiguration(confFile)
|
||||
|
||||
return t
|
||||
}
|
||||
|
||||
func (t *Topology) loadConfiguration(configurationFile string)error{
|
||||
b, e := ioutil.ReadFile(configurationFile);
|
||||
if e ==nil{
|
||||
t.configuration, e = NewConfiguration(b)
|
||||
}
|
||||
return e
|
||||
func (t *Topology) loadConfiguration(configurationFile string) error {
|
||||
b, e := ioutil.ReadFile(configurationFile)
|
||||
if e == nil {
|
||||
t.configuration, e = NewConfiguration(b)
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
func (t *Topology) Lookup(vid storage.VolumeId) (*[]*DataNode) {
|
||||
for _, vl := range t.replicaType2VolumeLayout {
|
||||
if list := vl.Lookup(vid); list!=nil {
|
||||
return list
|
||||
}
|
||||
}
|
||||
return nil
|
||||
func (t *Topology) Lookup(vid storage.VolumeId) *[]*DataNode {
|
||||
for _, vl := range t.replicaType2VolumeLayout {
|
||||
if vl != nil {
|
||||
if list := vl.Lookup(vid); list != nil {
|
||||
return list
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *Topology) RandomlyReserveOneVolume() (bool, *DataNode, *storage.VolumeId) {
|
||||
@@ -119,7 +121,7 @@ func (t *Topology) RegisterVolumeLayout(v *storage.VolumeInfo, dn *DataNode) {
|
||||
}
|
||||
|
||||
func (t *Topology) RegisterVolumes(volumeInfos []storage.VolumeInfo, ip string, port int, publicUrl string, maxVolumeCount int) {
|
||||
dcName, rackName := t.configuration.Locate(ip)
|
||||
dcName, rackName := t.configuration.Locate(ip)
|
||||
dc := t.GetOrCreateDataCenter(dcName)
|
||||
rack := dc.GetOrCreateRack(rackName)
|
||||
dn := rack.GetOrCreateDataNode(ip, port, publicUrl, maxVolumeCount)
|
||||
@@ -143,7 +145,7 @@ func (t *Topology) GetOrCreateDataCenter(dcName string) *DataCenter {
|
||||
|
||||
func (t *Topology) ToMap() interface{} {
|
||||
m := make(map[string]interface{})
|
||||
m["Max"] = t.GetMaxVolumeCount()
|
||||
m["Max"] = t.GetMaxVolumeCount()
|
||||
m["Free"] = t.FreeSpace()
|
||||
var dcs []interface{}
|
||||
for _, c := range t.Children() {
|
||||
|
||||
Reference in New Issue
Block a user