This commit is contained in:
crusader 2018-09-06 00:12:17 +09:00
parent 9a8684e25a
commit 32d1d7f100
3 changed files with 11 additions and 13 deletions

View File

@ -100,11 +100,11 @@ func (d *ofDiscoverer) enqueue(req *ofDiscoveryRequest) {
case <-req.dequeue: case <-req.dequeue:
case <-time.After(20 * time.Second): case <-time.After(20 * time.Second):
req.timeout = true req.timeout = true
d.SendMessage(req, types.DiscoveryMessageTypeTimeout, omu.Now(), nil) d.SendMessage(req, types.DiscoveryMessageTypeQueueingTimeout, omu.Now(), nil)
} }
}() }()
default: default:
d.SendMessage(req, types.DiscoveryMessageTypeFailedQueueing, omu.Now(), nil) d.SendMessage(req, types.DiscoveryMessageTypeQueueingFailed, omu.Now(), nil)
select { select {
case <-time.After(time.Microsecond * 500): case <-time.After(time.Microsecond * 500):
} }
@ -131,15 +131,13 @@ LOOP:
} }
req.(*ofDiscoveryRequest).dequeue <- true req.(*ofDiscoveryRequest).dequeue <- true
startTime := time.Now()
d.SendMessage(req, types.DiscoveryMessageTypeStart, omu.Now(), nil) d.SendMessage(req, types.DiscoveryMessageTypeStart, omu.Now(), nil)
s := session.RetainDiscoverySession() s := session.RetainDiscoverySession()
d.discover(req, s) d.discover(req, s)
select { select {
case <-time.After(time.Millisecond * 500): case <-time.After(time.Millisecond * 500):
} }
d.SendMessage(req, types.DiscoveryMessageTypeStop, time.Since(startTime).String(), nil) d.SendMessage(req, types.DiscoveryMessageTypeStop, omu.Now(), nil)
session.ReleaseDiscoverySession(s) session.ReleaseDiscoverySession(s)
req.(*ofDiscoveryRequest).release() req.(*ofDiscoveryRequest).release()

View File

@ -5,8 +5,8 @@ type DiscoveryMessageType int
const ( const (
DiscoveryMessageTypeNone DiscoveryMessageType = iota DiscoveryMessageTypeNone DiscoveryMessageType = iota
DiscoveryMessageTypeQueueing DiscoveryMessageTypeQueueing
DiscoveryMessageTypeFailedQueueing DiscoveryMessageTypeQueueingFailed
DiscoveryMessageTypeTimeout DiscoveryMessageTypeQueueingTimeout
DiscoveryMessageTypeStart DiscoveryMessageTypeStart
DiscoveryMessageTypeStop DiscoveryMessageTypeStop
DiscoveryMessageTypeError DiscoveryMessageTypeError

View File

@ -72,26 +72,26 @@ func (s *DiscoveryService) InitService() {
"/scanner", "/scanner",
) )
log.Print("Queueing ", data) log.Print("Queueing ", data)
case types.DiscoveryMessageTypeFailedQueueing: case types.DiscoveryMessageTypeQueueingFailed:
s.PubSub.Pub( s.PubSub.Pub(
rpc.MakeRPCMessage( rpc.MakeRPCMessage(
[]string{request.RequesterID()}, []string{request.RequesterID()},
"DiscoveryService.FailedQueueing", "DiscoveryService.QueueingFailed",
[]interface{}{data}, []interface{}{data},
), ),
"/scanner", "/scanner",
) )
log.Print("FailedQueueing ", data) log.Print("QueueingFailed ", data)
case types.DiscoveryMessageTypeTimeout: case types.DiscoveryMessageTypeQueueingTimeout:
s.PubSub.Pub( s.PubSub.Pub(
rpc.MakeRPCMessage( rpc.MakeRPCMessage(
[]string{request.RequesterID()}, []string{request.RequesterID()},
"DiscoveryService.Timeout", "DiscoveryService.QueueingTimeout",
[]interface{}{data}, []interface{}{data},
), ),
"/scanner", "/scanner",
) )
log.Print("Timeout ", data) log.Print("QueueingTimeout ", data)
case types.DiscoveryMessageTypeError: case types.DiscoveryMessageTypeError:
s.PubSub.Pub( s.PubSub.Pub(
rpc.MakeRPCMessage( rpc.MakeRPCMessage(