• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang mesosproto.MasterInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/mesos/mesos-go/mesosproto.MasterInfo的典型用法代码示例。如果您正苦于以下问题:Golang MasterInfo类的具体用法?Golang MasterInfo怎么用?Golang MasterInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了MasterInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: Registered

func (s *StackDeployScheduler) Registered(driver scheduler.SchedulerDriver, id *mesos.FrameworkID, master *mesos.MasterInfo) {
	Logger.Info("[Registered] framework: %s master: %s:%d", id.GetValue(), master.GetHostname(), master.GetPort())

	s.Storage.FrameworkID = id.GetValue()
	s.Storage.Save()
	s.driver = driver
}
开发者ID:elodina,项目名称:stack-deploy,代码行数:7,代码来源:scheduler.go


示例2: MasterInfoToMesosHost

func MasterInfoToMesosHost(mi *proto.MasterInfo) *MesosHost {
	if mi == nil {
		return &MesosHost{
			Host:         "",
			Ip:           "",
			Port:         0,
			PortString:   "",
			IsLeader:     false,
			IsRegistered: false,
		}
	}

	addr := mi.GetAddress()
	if addr.GetHostname() != "" {
		return &MesosHost{
			Host:         addr.GetHostname(),
			Ip:           addr.GetIp(),
			Port:         int(addr.GetPort()),
			PortString:   fmt.Sprintf("%d", addr.GetPort()),
			IsLeader:     false,
			IsRegistered: false,
		}
	} else {
		log.Debug("Using old protobuf format")
		// Old protobuf format
		return ProtoBufToMesosHost(mi)
	}
}
开发者ID:tooooolong,项目名称:mesos-consul,代码行数:28,代码来源:zk.go


示例3: MasterConnStr

func MasterConnStr(masterInfo *mesos.MasterInfo) string {
	ip := make([]byte, 4)
	native.PutUint32(ip, masterInfo.GetIp())
	addr := net.IP(ip).To4().String()
	port := masterInfo.GetPort()
	return fmt.Sprintf("%s:%d", addr, port)
}
开发者ID:lucmichalski,项目名称:taurus,代码行数:7,代码来源:util.go


示例4: Registered

// Registered is called when the Scheduler is Registered
func (s *eremeticScheduler) Registered(driver sched.SchedulerDriver, frameworkID *mesos.FrameworkID, masterInfo *mesos.MasterInfo) {
	log.Debugf("Framework %s registered with master %s", frameworkID.GetValue(), masterInfo.GetHostname())
	if !s.initialised {
		driver.ReconcileTasks([]*mesos.TaskStatus{})
		s.initialised = true
	} else {
		s.Reconcile(driver)
	}
}
开发者ID:keis,项目名称:eremetic,代码行数:10,代码来源:scheduler.go


示例5: Registered

func (s *Scheduler) Registered(driver scheduler.SchedulerDriver, id *mesos.FrameworkID, master *mesos.MasterInfo) {
	Logger.Infof("[Registered] framework: %s master: %s:%d", id.GetValue(), master.GetHostname(), master.GetPort())

	s.cluster.frameworkID = id.GetValue()
	s.cluster.Save()

	s.driver = driver
	s.reconcileTasks(true)
}
开发者ID:elodina,项目名称:go-kafka-client-mesos,代码行数:9,代码来源:scheduler.go


示例6: Reregistered

// Reregistered is called when the Scheduler is Reregistered
func (s *Scheduler) Reregistered(driver mesossched.SchedulerDriver, masterInfo *mesosproto.MasterInfo) {
	logrus.WithFields(logrus.Fields{
		"master_id": masterInfo.GetId(),
		"master":    masterInfo.GetHostname(),
	}).Debug("Framework re-registered with master.")
	if !s.initialised {
		driver.ReconcileTasks([]*mesosproto.TaskStatus{})
		s.initialised = true
	} else {
		s.Reconcile(driver)
	}
}
开发者ID:klarna,项目名称:eremetic,代码行数:13,代码来源:scheduler.go


示例7: masterHostPort

func masterHostPort(info *mesos.MasterInfo) string {
	host := info.GetHostname()

	if host == "" {
		// unpack IPv4
		octets := make([]byte, 4)
		binary.BigEndian.PutUint32(octets, info.GetIp())
		ipv4 := net.IP(octets)
		host = ipv4.String()
	}

	return net.JoinHostPort(host, masterPort(info))
}
开发者ID:njuettner,项目名称:mesos-dns,代码行数:13,代码来源:masters.go


示例8: masterAddr

// masterAddr returns an address (ip:port) from the given *mesos.MasterInfo or
// an empty string if it nil.
//
// BUG(tsenart): The byte order of the `ip` field in MasterInfo is platform
// dependent. We assume that Mesos is compiled with the same architecture as
// Mesos-DNS and hence same byte order. If this isn't the case, the address
// returned will be wrong. This only affects Mesos versions < 0.24.0
func masterAddr(info *mesos.MasterInfo) string {
	if info == nil {
		return ""
	}
	ip, port := "", int64(0)
	if addr := info.GetAddress(); addr != nil { // Mesos >= 0.24.0
		ip, port = addr.GetIp(), int64(addr.GetPort())
	} else { // Mesos < 0.24.0
		ipv4 := make([]byte, net.IPv4len)
		byteOrder.PutUint32(ipv4, info.GetIp())
		ip, port = net.IP(ipv4).String(), int64(info.GetPort())
	}
	return net.JoinHostPort(ip, strconv.FormatInt(port, 10))
}
开发者ID:GaizkaRubio,项目名称:mesos-dns,代码行数:21,代码来源:masters.go


示例9: onLeaderChange

func (d *ZkLeaderDetector) onLeaderChange(info *mesos.MasterInfo) {
	if info == nil {
		log.Errorln("No leader available in Zookeeper")
	} else {
		leader := ""
		if host := info.GetHostname(); host != "" {
			leader = host
		} else {
			// unpack IPv4
			octets := make([]byte, 4, 4)
			binary.BigEndian.PutUint32(octets, info.GetIp())
			ipv4 := net.IP(octets)
			leader = ipv4.String()
		}
		leader = fmt.Sprintf("%s:%d", leader, info.GetPort())
		log.Infoln("New master in Zookeeper", leader)
		d.newLeader <- &leader
	}
}
开发者ID:felixb,项目名称:none,代码行数:19,代码来源:zk_leader_detector.go


示例10: hostFromMasterInfo

func (m *Mesos) hostFromMasterInfo(mi *mesosproto.MasterInfo) MesosHost {
	var ipstring = ""
	var port = ""

	if mi != nil {
		if host := mi.GetHostname(); host != "" {
			ip, err := net.LookupIP(host)
			if err != nil {
				ipstring = host
			} else {
				for _, i := range ip {
					four := i.To4()
					if four != nil {
						ipstring = i.String()
						break
					}
				}
				// If control reaches here there are no IPv4 addresses
				// returned by net.LookupIP. Use the hostname as ipstring
				//
				ipstring = host
			}
		} else {
			octets := make([]byte, 4, 4)
			binary.BigEndian.PutUint32(octets, mi.GetIp())
			ipv4 := net.IP(octets)
			ipstring = ipv4.String()
		}
	}

	if len(ipstring) > 0 {
		port = fmt.Sprint(mi.GetPort())
	}

	return MesosHost{
		host:     ipstring,
		port:     port,
		isLeader: false,
	}
}
开发者ID:n0n0x,项目名称:mesos-consul,代码行数:40,代码来源:zk.go


示例11: sync

func (u *mesosUpstream) sync() {
	var syncing int32
	syncing = atomic.AddInt32(&u.syncing, 1)
	if syncing > 1 {
		atomic.AddInt32(&u.syncing, -1)
		u.syncWg.Wait()
		return
	}
	u.syncWg.Add(1)
	defer func() {
		u.syncWg.Done()
		atomic.AddInt32(&u.syncing, -1)
		u.lastSync = time.Now()
	}()
	var state mesosState
	var masterHosts []string

	if path, err := url.Parse(u.mesosMaster); err == nil {
		switch path.Scheme {
		case "zk":
			if path.Path == "" || path.Path == "/" {
				log.Printf("[ERROR] no path specified for mesos zk lookup \"%s\"", u.mesosMaster)
				return
			}
			zookeeperPath := path.Path
			if zookeeperPath[0] != '/' {
				zookeeperPath = "/" + zookeeperPath
			}
			if zoo, _, err := zk.Connect(strings.Split(path.Host, ","), 10*time.Second); err == nil {
				defer zoo.Close()
				if children, _, err := zoo.Children(zookeeperPath); err == nil {
					sort.Strings(children)
					for _, child := range children {
						if strings.HasPrefix(child, "info_") {
							if data, _, err := zoo.Get(zookeeperPath + "/" + child); err == nil {
								masterInfo := new(mesosproto.MasterInfo)
								if err := masterInfo.Unmarshal(data); err == nil {
									masterHosts = []string{fmt.Sprintf("%s:%d", masterInfo.GetHostname(), masterInfo.GetPort())}
									break
								} else {
									log.Printf("[ERROR] parsing mesos master from zookeeper. \"%s\"", err.Error())
									return
								}
							} else {
								log.Printf("[ERROR] getting mesos master from zookeeper. \"%s\"", err.Error())
								return
							}
						}
					}
				} else {
					log.Printf("[ERROR] getting mesos masters from zookeeper. \"%s\"", err.Error())
					return
				}
			}
		case "http", "https":
			masterHosts = strings.Split(path.Host, ",")
		default:
			log.Printf("[ERROR] unknown scheme in parsing mesos master url \"%s\"", u.mesosMaster)
			return
		}
	} else {
		masterHosts = strings.Split(u.mesosMaster, ",")
	}

	if len(masterHosts) == 0 {
		log.Printf("[ERROR] No reachable masters.")
		return
	}
	var masterErr error
	for _, host := range masterHosts {
		if resp, err := http.Get("http://" + host + "/state.json"); err == nil {
			defer resp.Body.Close()
			if err := json.NewDecoder(resp.Body).Decode(&state); err == nil {
				masterErr = nil
				break
			} else {
				masterErr = err
			}
		} else {
			masterErr = err
		}
	}
	if masterErr != nil {
		log.Printf("[ERROR] Failed to reach masters. \"%s\"", masterErr.Error())
		return
	}

	if len(state.Frameworks) == 0 {
		log.Println("[WARNING] No frameworks found running.")
		return
	}

	hosts := make(proxy.HostPool, 0, 4)
	for _, framework := range state.Frameworks {
		if framework.Name == u.framework {
			for _, task := range framework.Tasks {
				if task.Name == u.taskName && task.State == "TASK_RUNNING" {
					host := &proxy.UpstreamHost{
						Name:         task.SlaveId,
						Conns:        0,
//.........这里部分代码省略.........
开发者ID:gcnonato,项目名称:caddy-plugin-mesos,代码行数:101,代码来源:mesos-proxy.go


示例12: Reregistered

func (sched *testScheduler) Reregistered(dr SchedulerDriver, mi *mesos.MasterInfo) {
	log.Infoln("Sched.Reregistered() called")
	sched.s.Equal(mi.GetIp(), uint32(123456))
	sched.ch <- true
}
开发者ID:elodina,项目名称:stack-deploy,代码行数:5,代码来源:scheduler_intgr_test.go


示例13: Registered

func (sched *testScheduler) Registered(dr SchedulerDriver, fw *mesos.FrameworkID, mi *mesos.MasterInfo) {
	log.Infoln("Sched.Registered() called.")
	sched.s.Equal(fw.GetValue(), sched.s.registeredFrameworkId.GetValue(), "driver did not register the expected framework ID")
	sched.s.Equal(mi.GetIp(), uint32(123456))
	sched.ch <- true
}
开发者ID:elodina,项目名称:stack-deploy,代码行数:6,代码来源:scheduler_intgr_test.go


示例14: validMasterInfo

func validMasterInfo(info *mesos.MasterInfo) bool {
	return info.GetHostname() != "" || info.GetIp() != 0
}
开发者ID:njuettner,项目名称:mesos-dns,代码行数:3,代码来源:masters.go


示例15: masterString

func masterString(info *mesos.MasterInfo) string {
	return fmt.Sprintf("Id %v Ip %v Hostname %v Port %v Version %v Pid %v",
		info.GetId(), info.GetIp(), info.GetHostname(), info.GetPort(), info.GetVersion(), info.GetPid())
}
开发者ID:cebufooddroid,项目名称:mesos-go,代码行数:4,代码来源:main.go


示例16: Registered

func (s *Scheduler) Registered(driver scheduler.SchedulerDriver, id *mesos.FrameworkID, master *mesos.MasterInfo) {
	Logger.Infof("[Registered] framework: %s master: %s:%d", id.GetValue(), master.GetHostname(), master.GetPort())

	s.driver = driver
}
开发者ID:elodina,项目名称:syscol,代码行数:5,代码来源:scheduler.go


示例17: Registered

func (sched *Scheduler) Registered(driver sched.SchedulerDriver, frameworkID *mesos.FrameworkID, masterInfo *mesos.MasterInfo) {
	glog.Infof("registered with master %s", masterInfo.GetId())
}
开发者ID:betawaffle,项目名称:elevators,代码行数:3,代码来源:scheduler.go


示例18: Reregistered

func (self *MesosManager) Reregistered(driver sched.SchedulerDriver, mi *mesos.MasterInfo) {
	log.Printf("OnReregisterd master:%v:%v", Inet_itoa(mi.GetIp()), mi.GetPort())
}
开发者ID:kellrott,项目名称:agro,代码行数:3,代码来源:scheduler.go


示例19: Registered

func (self *MesosManager) Registered(driver sched.SchedulerDriver, fid *mesos.FrameworkID, mi *mesos.MasterInfo) {
	log.Printf("OnRegisterd master:%v:%v, frameworkId:%v", Inet_itoa(mi.GetIp()), mi.GetPort(), fid.GetValue())

}
开发者ID:kellrott,项目名称:agro,代码行数:4,代码来源:scheduler.go


示例20: masterPort

func masterPort(info *mesos.MasterInfo) string {
	return strconv.FormatUint(uint64(info.GetPort()), 10)
}
开发者ID:njuettner,项目名称:mesos-dns,代码行数:3,代码来源:masters.go



注:本文中的github.com/mesos/mesos-go/mesosproto.MasterInfo类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang mesosproto.Offer类代码示例发布时间:2022-05-28
下一篇:
Golang mesosproto.FrameworkInfo类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap