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

Golang names.ModelTag类代码示例

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

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



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

示例1: NewWatcher

// NewWatcher returns a new Watcher.
func NewWatcher(base *mgo.Collection, modelTag names.ModelTag) *Watcher {
	w := &Watcher{
		modelUUID: modelTag.Id(),
		base:      base,
		pings:     pingsC(base),
		beings:    beingsC(base),
		beingKey:  make(map[int64]string),
		beingSeq:  make(map[string]int64),
		watches:   make(map[string][]chan<- Change),
		request:   make(chan interface{}),
	}
	go func() {
		err := w.loop()
		cause := errors.Cause(err)
		// tomb expects ErrDying or ErrStillAlive as
		// exact values, so we need to log and unwrap
		// the error first.
		if err != nil && cause != tomb.ErrDying {
			logger.Infof("watcher loop failed: %v", err)
		}
		w.tomb.Kill(cause)
		w.tomb.Done()
	}()
	return w
}
开发者ID:makyo,项目名称:juju,代码行数:26,代码来源:presence.go


示例2: AssertModelCall

func (s *ClientSuite) AssertModelCall(c *gc.C, stub *jujutesting.Stub, tag names.ModelTag, call string, err error) {
	expectedArg := params.ModelArgs{ModelTag: tag.String()}
	stub.CheckCalls(c, []jujutesting.StubCall{
		{"MigrationTarget." + call, []interface{}{"", expectedArg}},
	})
	c.Assert(err, gc.ErrorMatches, "boom")
}
开发者ID:makyo,项目名称:juju,代码行数:7,代码来源:client_test.go


示例3: NewPinger

// NewPinger returns a new Pinger to report that key is alive.
// It starts reporting after Start is called.
func NewPinger(base *mgo.Collection, modelTag names.ModelTag, key string) *Pinger {
	return &Pinger{
		base:      base,
		pings:     pingsC(base),
		beingKey:  key,
		modelUUID: modelTag.Id(),
	}
}
开发者ID:makyo,项目名称:juju,代码行数:10,代码来源:presence.go


示例4: envIsDead

func (m *modelWorkerManager) envIsDead(modelTag names.ModelTag) error {
	uuid := modelTag.Id()
	err := m.runner.StopWorker(uuid)
	if err != nil {
		return errors.Trace(err)
	}

	return nil
}
开发者ID:pmatulis,项目名称:juju,代码行数:9,代码来源:modelworkermanager.go


示例5: modelNotFound

// envNotFound stops all workers for that model.
func (m *modelWorkerManager) modelNotFound(modelTag names.ModelTag) error {
	uuid := modelTag.Id()
	if err := m.runner.StopWorker(uuid); err != nil {
		return errors.Trace(err)
	}
	if err := m.runner.StopWorker(dyingModelWorkerId(uuid)); err != nil {
		return errors.Trace(err)
	}
	return nil
}
开发者ID:pmatulis,项目名称:juju,代码行数:11,代码来源:modelworkermanager.go


示例6: GetModel

// GetModel looks for the model identified by the uuid passed in.
func (st *State) GetModel(tag names.ModelTag) (*Model, error) {
	models, closer := st.getCollection(modelsC)
	defer closer()

	env := &Model{st: st}
	if err := env.refresh(models.FindId(tag.Id())); err != nil {
		return nil, errors.Trace(err)
	}
	return env, nil
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:11,代码来源:model.go


示例7: modifyAccess

func (s *modelManagerSuite) modifyAccess(c *gc.C, user names.UserTag, action params.ModelAction, access params.ModelAccessPermission, model names.ModelTag) error {
	args := params.ModifyModelAccessRequest{
		Changes: []params.ModifyModelAccess{{
			UserTag:  user.String(),
			Action:   action,
			Access:   access,
			ModelTag: model.String(),
		}}}
	result, err := s.modelmanager.ModifyModelAccess(args)
	c.Assert(err, jc.ErrorIsNil)
	return result.OneError()
}
开发者ID:makyo,项目名称:juju,代码行数:12,代码来源:modelmanager_test.go


示例8: ResourceTags

// ResourceTags returns tags to set on an infrastructure resource
// for the specified Juju environment.
func ResourceTags(e names.ModelTag, taggers ...ResourceTagger) map[string]string {
	allTags := make(map[string]string)
	for _, tagger := range taggers {
		tags, ok := tagger.ResourceTags()
		if !ok {
			continue
		}
		for k, v := range tags {
			allTags[k] = v
		}
	}
	allTags[JujuModel] = e.Id()
	return allTags
}
开发者ID:exekias,项目名称:juju,代码行数:16,代码来源:tags.go


示例9: assertRemoteEnvironment

func (s *loginSuite) assertRemoteEnvironment(c *gc.C, st api.Connection, expected names.ModelTag) {
	// Look at what the api thinks it has.
	tag, err := st.ModelTag()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(tag, gc.Equals, expected)
	// Look at what the api Client thinks it has.
	client := st.Client()

	// ModelUUID looks at the env tag on the api state connection.
	c.Assert(client.ModelUUID(), gc.Equals, expected.Id())

	// ModelInfo calls a remote method that looks up the environment.
	info, err := client.ModelInfo()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(info.UUID, gc.Equals, expected.Id())
}
开发者ID:OSBI,项目名称:juju,代码行数:16,代码来源:admin_test.go


示例10: Open

// Open connects to the server described by the given
// info, waits for it to be initialized, and returns a new State
// representing the model connected to.
//
// A policy may be provided, which will be used to validate and
// modify behaviour of certain operations in state. A nil policy
// may be provided.
//
// Open returns unauthorizedError if access is unauthorized.
func Open(tag names.ModelTag, info *mongo.MongoInfo, opts mongo.DialOpts, policy Policy) (*State, error) {
	st, err := open(tag, info, opts, policy)
	if err != nil {
		return nil, errors.Trace(err)
	}
	if _, err := st.Model(); err != nil {
		if err := st.Close(); err != nil {
			logger.Errorf("error closing state for unreadable model %s: %v", tag.Id(), err)
		}
		return nil, errors.Annotatef(err, "cannot read model %s", tag.Id())
	}

	// State should only be Opened on behalf of a state server environ; all
	// other *States should be created via ForEnviron.
	if err := st.start(tag); err != nil {
		return nil, errors.Trace(err)
	}
	return st, nil
}
开发者ID:pmatulis,项目名称:juju,代码行数:28,代码来源:open.go


示例11: newState

// newState creates an incomplete *State, with a configured watcher but no
// pwatcher, leadershipManager, or controllerTag. You must start() the returned
// *State before it will function correctly.
func newState(modelTag names.ModelTag, session *mgo.Session, mongoInfo *mongo.MongoInfo, policy Policy) (_ *State, resultErr error) {
	// Set up database.
	rawDB := session.DB(jujuDB)
	database, err := allCollections().Load(rawDB, modelTag.Id())
	if err != nil {
		return nil, errors.Trace(err)
	}
	if err := InitDbLogs(session); err != nil {
		return nil, errors.Trace(err)
	}

	// Create State.
	return &State{
		modelTag:  modelTag,
		mongoInfo: mongoInfo,
		session:   session,
		database:  database,
		policy:    policy,
		watcher:   watcher.New(rawDB.C(txnLogC)),
	}, nil
}
开发者ID:pmatulis,项目名称:juju,代码行数:24,代码来源:open.go


示例12: modelIsDying

func (m *modelWorkerManager) modelIsDying(modelTag names.ModelTag) error {
	id := dyingModelWorkerId(modelTag.Id())
	return m.runner.StartWorker(id, func() (worker.Worker, error) {
		st, err := m.st.ForModel(modelTag)
		if err != nil {
			return nil, errors.Annotatef(err, "failed to open state for model %s", modelTag.Id())
		}
		closeState := func() {
			err := st.Close()
			if err != nil {
				logger.Errorf("error closing state for model %s: %v", modelTag.Id(), err)
			}
		}

		dyingRunner, err := m.dyingModelWorker(m.st, st)
		if err != nil {
			closeState()
			return nil, errors.Trace(err)
		}

		// Close State when the runner for the model is done.
		go func() {
			dyingRunner.Wait()
			closeState()
		}()

		return dyingRunner, nil
	})
}
开发者ID:pmatulis,项目名称:juju,代码行数:29,代码来源:modelworkermanager.go


示例13: dumpLogsForEnv

func (c *dumpLogsCommand) dumpLogsForEnv(ctx *cmd.Context, st0 *state.State, tag names.ModelTag) error {
	st, err := st0.ForModel(tag)
	if err != nil {
		return errors.Annotate(err, "failed open model")
	}
	defer st.Close()

	logName := ctx.AbsPath(filepath.Join(c.outDir, fmt.Sprintf("%s.log", tag.Id())))
	ctx.Infof("writing to %s", logName)

	file, err := os.Create(logName)
	if err != nil {
		return errors.Annotate(err, "failed to open output file")
	}
	defer file.Close()

	writer := bufio.NewWriter(file)
	defer writer.Flush()

	tailer, err := state.NewLogTailer(st, &state.LogTailerParams{NoTail: true})
	if err != nil {
		return errors.Annotate(err, "failed to create a log tailer")
	}
	logs := tailer.Logs()
	for {
		rec, ok := <-logs
		if !ok {
			break
		}
		writer.WriteString(c.format(
			rec.Time,
			rec.Level,
			rec.Entity,
			rec.Module,
			rec.Message,
		) + "\n")
	}

	return nil
}
开发者ID:makyo,项目名称:juju,代码行数:40,代码来源:dumplogs.go


示例14: open

func open(tag names.ModelTag, info *mongo.MongoInfo, opts mongo.DialOpts, policy Policy) (*State, error) {
	logger.Infof("opening state, mongo addresses: %q; entity %v", info.Addrs, info.Tag)
	logger.Debugf("dialing mongo")
	session, err := mongo.DialWithInfo(info.Info, opts)
	if err != nil {
		return nil, maybeUnauthorized(err, "cannot connect to mongodb")
	}
	logger.Debugf("connection established")

	err = mongodbLogin(session, info)
	if err != nil {
		session.Close()
		return nil, errors.Trace(err)
	}
	logger.Debugf("mongodb login successful")

	// In rare circumstances, we may be upgrading from pre-1.23, and not have the
	// model UUID available. In that case we need to infer what it might be;
	// we depend on the assumption that this is the only circumstance in which
	// the the UUID might not be known.
	if tag.Id() == "" {
		logger.Warningf("creating state without model tag; inferring bootstrap model")
		ssInfo, err := readRawStateServerInfo(session)
		if err != nil {
			session.Close()
			return nil, errors.Trace(err)
		}
		tag = ssInfo.ModelTag
	}

	st, err := newState(tag, session, info, policy)
	if err != nil {
		session.Close()
		return nil, errors.Trace(err)
	}
	return st, nil
}
开发者ID:pmatulis,项目名称:juju,代码行数:37,代码来源:open.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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