Skip to content

Commit

Permalink
Merge pull request Terry-Mao#53 from StartFeng/master
Browse files Browse the repository at this point in the history
优化gops UI & fix bugs
  • Loading branch information
Terry-Mao committed May 13, 2016
2 parents 568a6c7 + 59bbee9 commit e93a751
Show file tree
Hide file tree
Showing 9 changed files with 69 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
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 e93a751

Please sign in to comment.