Example #1
0
// Creates a new router entry from the dynmap passed in
func ToRouterEntry(mp *dynmap.DynMap) (*RouterEntry, error) {
	e := &RouterEntry{
		Self:          false,
		PartitionsMap: make(map[int]bool),
	}
	var ok bool
	e.Address, ok = mp.GetString("address")
	if !ok {
		return nil, fmt.Errorf("No Address in Entry: %s", mp)
	}

	e.JsonPort = mp.MustInt("ports.json", 0)
	e.HttpPort = mp.MustInt("ports.http", 0)

	e.Partitions, ok = mp.GetIntSlice("partitions")
	if !ok {
		return nil, fmt.Errorf("No Partitions in Entry: %s", mp)
	}
	for _, p := range e.Partitions {
		e.PartitionsMap[p] = true
	}
	e.DynMap = e.ToDynMap()
	return e, nil
}