This commit is contained in:
@@ -74,8 +74,16 @@ func (p *SyncedPool) PongHandler(data []byte) (uint32, []byte, error) {
|
|||||||
func (p *SyncedPool) GetCartIdHandler(data []byte) (uint32, []byte, error) {
|
func (p *SyncedPool) GetCartIdHandler(data []byte) (uint32, []byte, error) {
|
||||||
ids := make([]string, 0, len(p.local.grains))
|
ids := make([]string, 0, len(p.local.grains))
|
||||||
for id := range p.local.grains {
|
for id := range p.local.grains {
|
||||||
ids = append(ids, id.String())
|
if p.local.grains[id] == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
s := id.String()
|
||||||
|
if s == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
ids = append(ids, s)
|
||||||
}
|
}
|
||||||
|
log.Printf("Returning %d cart ids\n", len(ids))
|
||||||
return CartIdsResponse, []byte(strings.Join(ids, ";")), nil
|
return CartIdsResponse, []byte(strings.Join(ids, ";")), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +91,9 @@ func (p *SyncedPool) NegotiateHandler(data []byte) (uint32, []byte, error) {
|
|||||||
negotiationCount.Inc()
|
negotiationCount.Inc()
|
||||||
log.Printf("Handling negotiation\n")
|
log.Printf("Handling negotiation\n")
|
||||||
for _, host := range p.ExcludeKnown(strings.Split(string(data), ";")) {
|
for _, host := range p.ExcludeKnown(strings.Split(string(data), ";")) {
|
||||||
go p.AddRemote(host)
|
if !p.IsKnown(host) {
|
||||||
|
go p.AddRemote(host)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return RemoteNegotiateResponse, []byte("ok"), nil
|
return RemoteNegotiateResponse, []byte("ok"), nil
|
||||||
@@ -118,7 +128,9 @@ func (p *SyncedPool) GrainOwnerChangeHandler(data []byte) (uint32, []byte, error
|
|||||||
return AckChange, []byte("ok"), nil
|
return AckChange, []byte("ok"), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return AckChange, []byte{}, fmt.Errorf("remote host not found")
|
|
||||||
|
go p.AddRemote(host)
|
||||||
|
return AckChange, []byte("ok"), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSyncedPool(local *GrainLocalPool, hostname string, discovery Discovery) (*SyncedPool, error) {
|
func NewSyncedPool(local *GrainLocalPool, hostname string, discovery Discovery) (*SyncedPool, error) {
|
||||||
@@ -264,6 +276,7 @@ func (g *RemoteHost) GetCartMappings() ([]CartId, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if reply.StatusCode != 200 {
|
if reply.StatusCode != 200 {
|
||||||
|
log.Printf("Remote returned error on get cart mappings: %s", string(reply.Data))
|
||||||
return nil, fmt.Errorf("remote returned error: %s", string(reply.Data))
|
return nil, fmt.Errorf("remote returned error: %s", string(reply.Data))
|
||||||
}
|
}
|
||||||
parts := strings.Split(string(reply.Data), ";")
|
parts := strings.Split(string(reply.Data), ";")
|
||||||
|
|||||||
Reference in New Issue
Block a user