<commit_before>package mesos

import (
	"fmt"
	"log"

	"github.com/CiscoCloud/mesos-consul/registry"
)

type registryState struct {
	services	map[string]bool
	followers	map[string]bool
}


var currentState = registryState{
	services:	make(map[string]bool),
	followers:	make(map[string]bool),
}

func (m *Mesos) RegisterHosts(sj StateJSON) {
	log.Print("Running RegisterHosts")

	// Register followers
	for _, f := range sj.Followers {
		id := fmt.Sprintf("%s:%s", f.Id, f.Hostname)
		if _, ok := currentState.followers[id]; ok {
			log.Printf("Id found: '%s': Not registering", id)
			currentState.followers[id] = true
		} else {
			currentState.followers[id] = true

			s := new(registry.Service)

			host, port := parsePID(f.Pid)

			s.ID	= id
			s.Name	= "mesos"
			s.Port	= toPort(port)
			s.IP	= toIP(host)
			s.Tags	= []string{
				"follower",
				}

			log.Print("Registering: ", id)

			m.registry.Register(s)
			if err != nil {
				log.Print(err)
			}
		}
	}

	// Register masters
	// TODO

	// Register leader
	ip, port := m.getLeader()

	s := new(registry.Service)
	s.ID	= fmt.Sprintf("mesos:%s:%s", ip, port)
	s.Name	= "mesos"
	s.Port	= toPort(port)
	s.IP	= toIP(ip)
	s.Tags	= []string{
		"leader",
		"master",
		}
		

	log.Print("Registering: ", s.ID)
	err = m.registry.Register(s)
	if err != nil {
		log.Print(err)
	}
}

func (m *Mesos) register(s *registry.Service) {
	currentState.services[s.ID] = true

	log.Print("Registering ", s.ID)

	err := m.registry.Register(s)
	if err != nil {
		log.Print(err)
	}
}

func (m *Mesos) deregister() {<commit_msg>Build before you push. Build before you push.<commit_after>package mesos

import (
	"fmt"
	"log"

	"github.com/CiscoCloud/mesos-consul/registry"
)

type registryState struct {
	services	map[string]bool
	followers	map[string]bool
}


var currentState = registryState{
	services:	make(map[string]bool),
	followers:	make(map[string]bool),
}

func (m *Mesos) RegisterHosts(sj StateJSON) {
	log.Print("Running RegisterHosts")

	// Register followers
	for _, f := range sj.Followers {
		id := fmt.Sprintf("%s:%s", f.Id, f.Hostname)
		if _, ok := currentState.followers[id]; ok {
			log.Printf("Id found: '%s': Not registering", id)
			currentState.followers[id] = true
		} else {
			currentState.followers[id] = true

			s := new(registry.Service)

			host, port := parsePID(f.Pid)

			s.ID	= id
			s.Name	= "mesos"
			s.Port	= toPort(port)
			s.IP	= toIP(host)
			s.Tags	= []string{
				"follower",
				}

			log.Print("Registering: ", id)

			err := m.registry.Register(s)
			if err != nil {
				log.Print(err)
			}
		}
	}

	// Register masters
	// TODO

	// Register leader
	ip, port := m.getLeader()

	s := new(registry.Service)
	s.ID	= fmt.Sprintf("mesos:%s:%s", ip, port)
	s.Name	= "mesos"
	s.Port	= toPort(port)
	s.IP	= toIP(ip)
	s.Tags	= []string{
		"leader",
		"master",
		}
		

	log.Print("Registering: ", s.ID)
	err := m.registry.Register(s)
	if err != nil {
		log.Print(err)
	}
}

func (m *Mesos) register(s *registry.Service) {
	currentState.services[s.ID] = true

	log.Print("Registering ", s.ID)

	err := m.registry.Register(s)
	if err != nil {
		log.Print(err)
	}
}

func (m *Mesos) deregister() {
{'fraction_non_alphanumeric': 0.16981726528040328, 'fraction_numerical': 0.0, 'mean_word_length': 3.3021680216802167, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1500398', 'n_tokens_mistral': 1403, 'n_tokens_neox': 1270, 'n_words': 260}