Exemplo n.º 1
0
func LocalNetworkIP() string {
	ip, err := determineLocalIp()
	if err == nil {
		return ip
	} else {
		log.Warningf("Unable to determine local network IP address, going with localhost IP")
		return "127.0.0.1"
	}
}
Exemplo n.º 2
0
func NewTracer(serviceName string, rate int, producer *producer.KafkaProducer, ip string, port int16, topic string) *Tracer {
	log.Infof("[Zipkin] Creating new tracer for service %s with rate 1:%d, topic %s, ip %s, port %d", serviceName, rate,
		topic, ip, port)
	collector := &KafkaCollector{producer: producer, topic: topic}

	convertedIp, err := convertIp(ip)
	if err != nil {
		log.Warningf("Given ip %s is not a valid ipv4 ip address, going with localhost ip")
		convertedIp = &localhost
	}

	tracer := &Tracer{ip: *convertedIp, port: port, collector: collector, rate: rate, serviceName: serviceName}
	return tracer
}
func (ctx *RunOnceApplicationContext) StatusUpdate(driver scheduler.SchedulerDriver, status *mesos.TaskStatus) bool {
	ctx.lock.Lock()
	defer ctx.lock.Unlock()

	hostname := hostnameFromTaskID(status.GetTaskId().GetValue())
	ctx.updateTaskState(status)
	switch status.GetState() {
	case mesos.TaskState_TASK_RUNNING:
		log.Infof("Task %s received status update in state %s", status.GetTaskId().GetValue(), status.GetState().String())
	case mesos.TaskState_TASK_LOST, mesos.TaskState_TASK_FAILED, mesos.TaskState_TASK_ERROR:
		//TODO also kill all other running tasks sometime?
		ctx.StatusChan <- framework.NewApplicationRunStatus(ctx.Application, fmt.Errorf("Application %s failed to run on host %s with status %s: %s", ctx.Application.ID, hostname, status.GetState().String(), status.GetMessage()))
		return true
	case mesos.TaskState_TASK_FINISHED, mesos.TaskState_TASK_KILLED:
		if ctx.allTasksFinished() {
			ctx.StatusChan <- framework.NewApplicationRunStatus(ctx.Application, nil)
			return true
		}
	default:
		log.Warningf("Got unexpected task state %s", pretty.Status(status))
	}

	return false
}