Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Terry-Mao/bfs
Browse files Browse the repository at this point in the history
  • Loading branch information
Terry-Mao committed Jun 15, 2016
2 parents a7529fe + 9116ece commit 7facb45
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 419 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ _testmain.go
*.test
*.prof
*.gitattributes
<<<<<<< HEAD

*.iml
*.ipr
*.iws
.idea/
=======
>>>>>>> startfeng/master
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,7 @@ $ nohup python runserver.py &

## API
[api文档](https://github.com/Terry-Mao/bfs/blob/master/doc/api.md)

## 更多

* [bfs-image-server](github.com/YonkaFang/bfs-image-server)
1 change: 1 addition & 0 deletions directory/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func (d *Dispatcher) Update(group map[int][]string,
if !write {
continue
}

// calc score
for _, sid = range stores {
totalAdd, totalAddDelay, restSpace, minScore = 0, 0, 0, 0
Expand Down
Binary file removed gops/gops
Binary file not shown.
16 changes: 7 additions & 9 deletions gops/models/ops/ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (o *Ops)LoadRacks() {
)

if racks, err = o.GetRack(); err != nil {
beego.Critical(err)
beego.Error(err)
}

global.STORES = make(map[string]*types.Store)
Expand All @@ -90,7 +90,7 @@ func (o *Ops)LoadGroups() {
)

if groups, err = o.GetGroup(); err != nil {
beego.Critical(err)
beego.Error(err)
}

global.IN_GROUP_STORES = make(map[string]*types.Store)
Expand All @@ -111,13 +111,13 @@ func (o *Ops)LoadGroups() {

func (o *Ops)LoadVolumes() {
var (
volumes []*types.Group
volumes []*types.Volume
err error
volume *types.Group
volume *types.Volume
)

if volumes, err = o.GetGroup(); err != nil {
beego.Critical(err)
if volumes, err = o.GetVolume(); err != nil {
beego.Error(err)
}


Expand Down Expand Up @@ -178,12 +178,11 @@ func (o *Ops)AddGroup(stores []string, copys, racks int) (err error) {
storeId string
)

if len(stores) == 0 || len(stores) % copys != 0 {
if len(stores) == 0 {
err = addGroupParamsErr
return
}

stores = stores[0:copys]
groupId = global.MAX_GROUP_ID + 1
for _, storeId = range stores {
if err = o.zk.CreateGroup(groupId, storeId); err != nil {
Expand All @@ -209,7 +208,6 @@ func (o *Ops) AddVolume(groupId uint64, n int) (err error) {
for i := 0; i < n; i++ {

vid = global.MAX_VOLUME_ID + 1
beego.Info(vid)

for _, store = range group.Stores {
if err = o.store.AddVolume(store.Admin, vid); err != nil {
Expand Down
1 change: 1 addition & 0 deletions gops/models/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type Store struct {
Admin string `json:"admin"`
Rack string `json:"rack"`
Status int `json:"status"`
Volumes []string `json:"volumes"`
}

type Rack struct {
Expand Down
7 changes: 6 additions & 1 deletion gops/models/zk/zk.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ func (z *ZooKeeper) GetRack() (racks []*types.Rack, err error) {
if children, _, err = z.c.Children(_rackRoot); err != nil {
return
}

racks = make([]*types.Rack, len(children))
for i, child := range children {
rack = new(types.Rack)
Expand All @@ -99,6 +98,12 @@ func (z *ZooKeeper) GetRack() (racks []*types.Rack, err error) {
if err = json.Unmarshal(data, store); err != nil {
return
}

if store.Volumes , _, err = z.c.Children(_rackRoot + "/" + child + "/" + child1); err != nil {
return
}


store.Ip = strings.Split(store.Stat, ":")[0]
rack.Stores[j] = store
}
Expand Down
6 changes: 5 additions & 1 deletion gops/static/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ var myapp = ng.module('myapp', []);
var storeInfo = function (host) {
window.open("http://" + host + "/info")
}
var initFreeVolume = function(host){
var initFreeVolume = function(host,storeId){
var dailog = $('#initFreeVolumeDialog');
var scope = dailog.scope();
var formData = {}

scope.formData = formData;
scope.storeId = storeId
formData.host=host;


Expand Down Expand Up @@ -75,6 +77,8 @@ myapp.controller('freeStore', function ($scope, $http) {
}).success(function (data) {
if (data.success){
alert("操作成功")
var dailog = $('#freeStoreDialog');
dailog.modal('hide');
}
})
}
Expand Down
Loading

0 comments on commit 7facb45

Please sign in to comment.