Skip to content

Commit

Permalink
Update, slots action base unit will be microsecond
Browse files Browse the repository at this point in the history
  • Loading branch information
spinlock committed Jan 5, 2016
1 parent 41c4350 commit b6e1774
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions cmd/fe/assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ <h4 style="padding-left:20px; padding-right:20px; display: inline;">Slots</h4>
class="form-control" placeholder="Slot ID [0,1023]"
ng-model="migrate_slot_id">
<input style="width: 140px; "
pattern="^(?:[1-9][0-9]{3}|[1-9][0-9]{2}|[1-9][0-9]|[1-9])$"
pattern="^(?:[1-9][0-9]{1,3}|[1-9])$"
class="form-control" placeholder="Group ID [1,9999]"
ng-model="migrate_to_group_id">
<button class="btn btn-success" style="width: 120px;"
Expand All @@ -188,7 +188,7 @@ <h4 style="padding-left:20px; padding-right:20px; display: inline;">Slots</h4>
class="form-control" placeholder="End"
ng-model="migrate_slot_id_end">
<input style="width: 120px; "
pattern="^(?:[1-9][0-9]{3}|[1-9][0-9]{2}|[1-9][0-9]|[1-9])$"
pattern="^(?:[1-9][0-9]{1,3}|[1-9])$"
class="form-control" placeholder="Target Group"
ng-model="migrate_range_to_group_id">
<button class="btn btn-warning" style="width: 120px;"
Expand Down Expand Up @@ -227,11 +227,11 @@ <h4 style="padding-left:20px; padding-right:20px; display: inline;">Slots</h4>
</td>
</tr>
<tr>
<td>Action Interval (ms)</td>
<td>Action Interval (us)</td>
<td>
<div class="input-group">
<input type="text" class="form-control" style="height: 22px;"
pattern="^(?:[1][0]{3}|[1-9][0-9]{2}|[1-9][0-9]|[0-9])$"
pattern="^(?:[1][0]{6}|[1-9][0-9]{1,5}|[0-9])$"
placeholder="[[slots_action_interval]]"
ng-model="updated_slots_action_interval">
<span class="input-group-btn">
Expand Down Expand Up @@ -310,7 +310,7 @@ <h4 style="padding-left:20px; padding-right:20px; display: inline;">Slots</h4>
<form class="form-inline">
<h4 style="padding-left:20px; padding-right:20px; display: inline;">Group</h4>
<span ng-if="codis_addr != 'NA'">
<input style="width: 140px; " pattern="^(?:[1-9][0-9]{3}|[1-9][0-9]{2}|[1-9][0-9]|[1-9])$"
<input style="width: 140px; " pattern="^(?:[1-9][0-9]{1,3}|[1-9])$"
class="form-control" placeholder="Group ID [1,9999]"
ng-model="new_group">
<button class="btn btn-success" style="width: 120px;"
Expand All @@ -319,7 +319,7 @@ <h4 style="padding-left:20px; padding-right:20px; display: inline;">Group</h4>
</button>
</span>
<span ng-if="codis_addr != 'NA'" style="float: right;">
<input style="width: 140px; " pattern="^(?:[1-9][0-9]{3}|[1-9][0-9]{2}|[1-9][0-9]|[1-9])$"
<input style="width: 140px; " pattern="^(?:[1-9][0-9]{1,3}|[1-9])$"
class="form-control" placeholder="Group ID [1,9999]"
ng-model="new_server_group">
<input style="width: 250px; " type="text" class="form-control"
Expand Down
12 changes: 6 additions & 6 deletions pkg/topom/topom.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func New(client models.Client, config *Config) (*Topom, error) {
s.exit.C = make(chan struct{})
s.redisp = NewRedisPool(config.ProductAuth, time.Second*10)

s.action.interval.Set(1000)
s.action.interval.Set(1000 * 10)

s.stats.servers = make(map[string]*RedisStats)
s.stats.proxies = make(map[string]*ProxyStats)
Expand Down Expand Up @@ -247,11 +247,11 @@ func (s *Topom) GetSlotActionInterval() int {
return int(s.action.interval.Get())
}

func (s *Topom) SetSlotActionInterval(ms int) {
ms = utils.MaxInt(ms, 0)
ms = utils.MinInt(ms, 1000)
s.action.interval.Set(int64(ms))
log.Warnf("set action interval = %d", ms)
func (s *Topom) SetSlotActionInterval(us int) {
us = utils.MaxInt(us, 0)
us = utils.MinInt(us, 1000*1000)
s.action.interval.Set(int64(us))
log.Warnf("set action interval = %d", us)
}

func (s *Topom) GetSlotActionDisabled() bool {
Expand Down
4 changes: 2 additions & 2 deletions pkg/topom/topom_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ func (s *Topom) processSlotAction(sid int) (err error) {
}
s.action.progress.remain.Set(int64(n))
s.action.progress.failed.Set(false)
if ms := s.GetSlotActionInterval(); ms != 0 {
time.Sleep(time.Millisecond * time.Duration(ms))
if us := s.GetSlotActionInterval(); us != 0 {
time.Sleep(time.Microsecond * time.Duration(us))
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/topom/topom_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,8 +660,8 @@ func (c *ApiClient) SlotRemoveAction(sid int) error {
return rpc.ApiPutJson(url, nil, nil)
}

func (c *ApiClient) SetSlotActionInterval(msecs int) error {
url := c.encodeURL("/api/topom/slots/action/interval/%s/%d", c.xauth, msecs)
func (c *ApiClient) SetSlotActionInterval(usecs int) error {
url := c.encodeURL("/api/topom/slots/action/interval/%s/%d", c.xauth, usecs)
return rpc.ApiPutJson(url, nil, nil)
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ for ((i=0;i<4;i++)); do
codis_admin --create-proxy -x 127.0.0.1:${p1}
done

codis_admin --slot-action --interval=10
codis_admin --slot-action --interval=100
codis_admin --slot-action --create-range --beg=0 --end=1023 --gid=1

echo done
Expand Down

0 comments on commit b6e1774

Please sign in to comment.