當前位置: 首頁>>代碼示例>>Golang>>正文


Golang mesosproto.FrameworkInfo類代碼示例

本文整理匯總了Golang中github.com/mesos/mesos-go/mesosproto.FrameworkInfo的典型用法代碼示例。如果您正苦於以下問題:Golang FrameworkInfo類的具體用法?Golang FrameworkInfo怎麽用?Golang FrameworkInfo使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了FrameworkInfo類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: registerOnce

// registerOnce returns true if we should attempt another registration later; it is *not*
// guarded by eventLock: all access to mutable members of MesosSchedulerDriver should be
// explicitly synchronized.
func (driver *MesosSchedulerDriver) registerOnce() bool {
	var (
		failover bool
		pid      *upid.UPID
		info     *mesos.FrameworkInfo
	)
	if func() bool {
		driver.eventLock.RLock()
		defer driver.eventLock.RUnlock()

		if driver.stopped() || driver.connected || driver.masterPid == nil || (driver.credential != nil && !driver.authenticated) {
			log.V(1).Infof("skipping registration request: stopped=%v, connected=%v, authenticated=%v",
				driver.stopped(), driver.connected, driver.authenticated)
			return false
		}
		failover = driver.failover
		pid = driver.masterPid
		info = proto.Clone(driver.frameworkInfo).(*mesos.FrameworkInfo)
		return true
	}() {
		// register framework
		var message proto.Message
		if len(info.GetId().GetValue()) > 0 {
			// not the first time, or failing over
			log.V(1).Infof("Reregistering with master: %v", pid)
			message = &mesos.ReregisterFrameworkMessage{
				Framework: info,
				Failover:  proto.Bool(failover),
			}
			fmt.Printf("Reregistering with master: %v\nwith message:\n%v\n", pid, message)
		} else {
			log.V(1).Infof("Registering with master: %v", pid)
			message = &mesos.RegisterFrameworkMessage{
				Framework: info,
			}
			fmt.Printf("Reregistering with master: %v\nwith message:\n%v\n", pid, message)
		}
		if err := driver.send(pid, message); err != nil {
			log.Errorf("failed to send RegisterFramework message: %v", err)
			if _, err = driver.Stop(failover); err != nil {
				log.Errorf("failed to stop scheduler driver: %v", err)
			}
		}
		return true
	}
	return false
}
開發者ID:ilackarms,項目名稱:mesos-go,代碼行數:50,代碼來源:scheduler.go

示例2: prepateCredentials

// create credentials data structure
func prepateCredentials(fwinfo *mesos.FrameworkInfo) *mesos.Credential {
	if *mesosAuthPrincipal != "" {
		fwinfo.Principal = proto.String(*mesosAuthPrincipal)
		secret, err := ioutil.ReadFile(*mesosAuthSecretFile)
		if err != nil {
			log.Fatal(err)
		}
		return &mesos.Credential{
			Principal: proto.String(*mesosAuthPrincipal),
			Secret:    secret,
		}
	} else {
		return nil
	}
}
開發者ID:felixb,項目名稱:none,代碼行數:16,代碼來源:main.go

示例3: cred

func cred(fwinfo *mesos.FrameworkInfo) *mesos.Credential {
	cred := (*mesos.Credential)(nil)
	mesosAuthPrincipal := config.Runonce.AuthPrincipal
	if mesosAuthPrincipal != "" {
		fwinfo.Principal = proto.String(mesosAuthPrincipal)
		cred = &mesos.Credential{
			Principal: proto.String(mesosAuthPrincipal),
		}
		mesosAuthSecretFile := config.Runonce.AuthSecretFile
		if mesosAuthSecretFile != "" {
			_, err := os.Stat(mesosAuthSecretFile)
			if err != nil {
				log.Exit("missing secret file: ", err.Error())
			}
			secret, err := ioutil.ReadFile(mesosAuthSecretFile)
			if err != nil {
				log.Exit("failed to read secret file: ", err.Error())
			}
			cred.Secret = proto.String(strings.TrimSuffix(string(secret), "\n"))
		}
	}
	return cred
}
開發者ID:yp-engineering,項目名稱:mesos-runonce,代碼行數:23,代碼來源:main.go

示例4: Registered

func (e *Executor) Registered(driver executor.ExecutorDriver, executor *mesos.ExecutorInfo, framework *mesos.FrameworkInfo, slave *mesos.SlaveInfo) {
	Logger.Infof("[Registered] framework: %s slave: %s", framework.GetId().GetValue(), slave.GetId().GetValue())
}
開發者ID:elodina,項目名稱:stockpile,代碼行數:3,代碼來源:executor.go


注:本文中的github.com/mesos/mesos-go/mesosproto.FrameworkInfo類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。