Skip to content
This repository has been archived by the owner on Aug 3, 2020. It is now read-only.

Commit

Permalink
Oops, forgot to update these. Commit fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
karalabe committed Mar 6, 2014
1 parent 729b6c5 commit 6df3d53
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
26 changes: 13 additions & 13 deletions config/config_test.go
Expand Up @@ -98,26 +98,26 @@ func TestPack(t *testing.T) {
}
}

func TestOverlay(t *testing.T) {
func TestPastry(t *testing.T) {
// Ensure pastry space is reduced size (at least issue a warning)
if OverlaySpace != 40 {
t.Errorf("config (overlay): address space is invalid: have %v, want %v.", OverlaySpace, 40)
if PastrySpace != 40 {
t.Errorf("config (overlay): address space is invalid: have %v, want %v.", PastrySpace, 40)
}
if size := OverlayResolver().Size() * 8; size < OverlaySpace {
t.Errorf("config (overlay): resolver does not output enough bits for space: have %v, want %v.", size, OverlaySpace)
if size := PastryResolver().Size() * 8; size < PastrySpace {
t.Errorf("config (overlay): resolver does not output enough bits for space: have %v, want %v.", size, PastrySpace)
}
// Do some sanity checks on the parameters
if OverlayBase < 1 {
t.Errorf("config (overlay): invalid base bits: have %v, want min 1.", OverlayBase)
if PastryBase < 1 {
t.Errorf("config (overlay): invalid base bits: have %v, want min 1.", PastryBase)
}
if OverlaySpace%OverlayBase != 0 {
t.Errorf("config (overlay): address space is not divisible into bases: %v %% %v != 0", OverlaySpace, OverlayBase)
if PastrySpace%PastryBase != 0 {
t.Errorf("config (overlay): address space is not divisible into bases: %v %% %v != 0", PastrySpace, PastryBase)
}
if OverlayLeaves != 1<<uint(OverlayBase-1) && OverlayLeaves != 1<<uint(OverlayBase) {
t.Errorf("config (overlay): invalid leave set size: have %v, want %v or %v.", OverlayLeaves, 1<<uint(OverlayBase-1), 1<<uint(OverlayBase))
if PastryLeaves != 1<<uint(PastryBase-1) && PastryLeaves != 1<<uint(PastryBase) {
t.Errorf("config (overlay): invalid leave set size: have %v, want %v or %v.", PastryLeaves, 1<<uint(PastryBase-1), 1<<uint(PastryBase))
}
// Make some trivial checks for the tuning parameters
if OverlayNetBuffer < 16 || OverlayNetBuffer > 128 {
t.Errorf("config (overlay): strange network buffer size: have %v, want from [16..128].", OverlayNetBuffer)
if PastryNetBuffer < 16 || PastryNetBuffer > 128 {
t.Errorf("config (overlay): strange network buffer size: have %v, want from [16..128].", PastryNetBuffer)
}
}
13 changes: 7 additions & 6 deletions proto/carrier/heart.go
Expand Up @@ -23,9 +23,10 @@
package carrier

import (
"github.com/karalabe/iris/config"
"log"
"math/big"

"github.com/karalabe/iris/config"
)

// Load report between two carrier nodes.
Expand All @@ -36,19 +37,19 @@ type report struct {

// Adds the node within the topic to the list of monitored entities.
func (c *carrier) monitor(topic *big.Int, node *big.Int) error {
id := new(big.Int).Add(new(big.Int).Lsh(topic, uint(config.OverlaySpace)), node)
id := new(big.Int).Add(new(big.Int).Lsh(topic, uint(config.PastrySpace)), node)
return c.heart.Monitor(id)
}

// Remove the node of a specific topic from the list of monitored entities.
func (c *carrier) unmonitor(topic *big.Int, node *big.Int) error {
id := new(big.Int).Add(new(big.Int).Lsh(topic, uint(config.OverlaySpace)), node)
id := new(big.Int).Add(new(big.Int).Lsh(topic, uint(config.PastrySpace)), node)
return c.heart.Unmonitor(id)
}

// Updates the last ping time of a node within a topic.
func (c *carrier) ping(topic *big.Int, node *big.Int) error {
id := new(big.Int).Add(new(big.Int).Lsh(topic, uint(config.OverlaySpace)), node)
id := new(big.Int).Add(new(big.Int).Lsh(topic, uint(config.PastrySpace)), node)
return c.heart.Ping(id)
}

Expand Down Expand Up @@ -96,8 +97,8 @@ func (c *carrier) Beat() {
// topic member nodes.
func (c *carrier) Dead(id *big.Int) {
// Split the id into topic and node parts
topic := new(big.Int).Rsh(id, uint(config.OverlaySpace))
node := new(big.Int).Sub(id, new(big.Int).Lsh(topic, uint(config.OverlaySpace)))
topic := new(big.Int).Rsh(id, uint(config.PastrySpace))
node := new(big.Int).Sub(id, new(big.Int).Lsh(topic, uint(config.PastrySpace)))

// Depending on whether it was the topic parent or a child reown or unsub
c.lock.RLock()
Expand Down

0 comments on commit 6df3d53

Please sign in to comment.