Ejemplo n.º 1
0
func (watcher *Watcher) handleEvent(logger lager.Logger, event models.Event) {
	switch event := event.(type) {
	case *models.DesiredLRPCreatedEvent:
		schedulingInfo := event.DesiredLrp.DesiredLRPSchedulingInfo()
		watcher.handleDesiredCreate(logger, &schedulingInfo)
	case *models.DesiredLRPChangedEvent:
		before := event.Before.DesiredLRPSchedulingInfo()
		after := event.After.DesiredLRPSchedulingInfo()
		watcher.handleDesiredUpdate(logger, &before, &after)
	case *models.DesiredLRPRemovedEvent:
		schedulingInfo := event.DesiredLrp.DesiredLRPSchedulingInfo()
		watcher.handleDesiredDelete(logger, &schedulingInfo)
	case *models.ActualLRPCreatedEvent:
		watcher.handleActualCreate(logger, routing_table.NewActualLRPRoutingInfo(event.ActualLrpGroup))
	case *models.ActualLRPChangedEvent:
		watcher.handleActualUpdate(logger,
			routing_table.NewActualLRPRoutingInfo(event.Before),
			routing_table.NewActualLRPRoutingInfo(event.After),
		)
	case *models.ActualLRPRemovedEvent:
		watcher.handleActualDelete(logger, routing_table.NewActualLRPRoutingInfo(event.ActualLrpGroup))
	default:
		logger.Info("did-not-handle-unrecognizable-event", lager.Data{"event-type": event.EventType()})
	}
}
Ejemplo n.º 2
0
func NewEventFromModelEvent(eventID int, event models.Event) (sse.Event, error) {
	payload, err := proto.Marshal(event)
	if err != nil {
		return sse.Event{}, err
	}

	encodedPayload := base64.StdEncoding.EncodeToString(payload)
	return sse.Event{
		ID:   strconv.Itoa(eventID),
		Name: string(event.EventType()),
		Data: []byte(encodedPayload),
	}, nil
}
Ejemplo n.º 3
0
		etcdHelper.SetRawDesiredLRP(primerLRP)

	PRIMING:
		for {
			select {
			case <-eventChannel:
				break PRIMING
			case <-time.After(50 * time.Millisecond):
				etcdHelper.SetRawDesiredLRP(primerLRP)
				Expect(err).NotTo(HaveOccurred())
			}
		}

		etcdHelper.DeleteDesiredLRP(primerLRP.ProcessGuid)

		var event models.Event
		for {
			Eventually(eventChannel).Should(Receive(&event))
			if event.EventType() == models.EventTypeDesiredLRPRemoved {
				break
			}
		}
	})

	AfterEach(func() {
		Eventually(done).Should(BeClosed())
		ginkgomon.Kill(bbsProcess)
	})

	It("does not emit latency metrics", func() {
		eventSource.Close()