maybe
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 1m58s

This commit is contained in:
matst80
2024-11-10 21:43:40 +01:00
parent 0f3b22e8da
commit c70c5cd930
12 changed files with 84 additions and 153 deletions

View File

@@ -64,11 +64,11 @@ var (
})
)
func (p *SyncedPool) PongHandler(data []byte) (uint16, []byte, error) {
func (p *SyncedPool) PongHandler(data []byte) (uint32, []byte, error) {
return Pong, data, nil
}
func (p *SyncedPool) GetCartIdHandler(data []byte) (uint16, []byte, error) {
func (p *SyncedPool) GetCartIdHandler(data []byte) (uint32, []byte, error) {
ids := make([]string, 0, len(p.local.grains))
for id := range p.local.grains {
ids = append(ids, id.String())
@@ -76,7 +76,7 @@ func (p *SyncedPool) GetCartIdHandler(data []byte) (uint16, []byte, error) {
return CartIdsResponse, []byte(strings.Join(ids, ";")), nil
}
func (p *SyncedPool) NegotiateHandler(data []byte) (uint16, []byte, error) {
func (p *SyncedPool) NegotiateHandler(data []byte) (uint32, []byte, error) {
negotiationCount.Inc()
log.Printf("Handling negotiation\n")
for _, host := range p.ExcludeKnown(strings.Split(string(data), ";")) {
@@ -89,7 +89,7 @@ func (p *SyncedPool) NegotiateHandler(data []byte) (uint16, []byte, error) {
return RemoteNegotiateResponse, []byte("ok"), nil
}
func (p *SyncedPool) GrainOwnerChangeHandler(data []byte) (uint16, []byte, error) {
func (p *SyncedPool) GrainOwnerChangeHandler(data []byte) (uint32, []byte, error) {
grainSyncCount.Inc()
idAndHostParts := strings.Split(string(data), ";")
@@ -241,15 +241,15 @@ func (p *SyncedPool) RemoveHostMappedCarts(host *RemoteHost) {
}
const (
RemoteNegotiate = uint16(3)
RemoteGrainChanged = uint16(4)
AckChange = uint16(5)
//AckError = uint16(6)
Ping = uint16(7)
Pong = uint16(8)
GetCartIds = uint16(9)
CartIdsResponse = uint16(10)
RemoteNegotiateResponse = uint16(11)
RemoteNegotiate = uint32(3)
RemoteGrainChanged = uint32(4)
AckChange = uint32(5)
//AckError = uint32(6)
Ping = uint32(7)
Pong = uint32(8)
GetCartIds = uint32(9)
CartIdsResponse = uint32(10)
RemoteNegotiateResponse = uint32(11)
)
func (h *RemoteHost) Negotiate(knownHosts []string) ([]string, error) {
@@ -430,17 +430,8 @@ func (p *SyncedPool) getGrain(id CartId) (Grain, error) {
remoteGrain, ok := p.remoteIndex[id]
p.mu.RUnlock()
if ok {
if remoteGrain == nil {
// p.remoteIndex[id].Delete(id)
p.mu.Lock()
delete(p.remoteIndex, id)
p.mu.Unlock()
log.Printf("Remote grain %s is nil\n", id)
//return nil, fmt.Errorf("remote pool is nil for %v", id)
} else {
remoteLookupCount.Inc()
return remoteGrain, nil
}
remoteLookupCount.Inc()
return remoteGrain, nil
}
err := p.RequestOwnership(id)