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

Golang store.StoreManager类代码示例

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

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



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

示例1: replaceConfig

func replaceConfig(e *store.StoreManager, config []byte) error {
	lsid, err := e.GetLeaderSentinelId()
	if err != nil {
		die("cannot get leader sentinel info")
	}

	lsi, _, err := e.GetSentinelInfo(lsid)
	if lsi == nil {
		return fmt.Errorf("leader sentinel info not available")
	}

	req, err := http.NewRequest("PUT", fmt.Sprintf("http://%s:%s/config/current", lsi.ListenAddress, lsi.Port), bytes.NewReader(config))
	if err != nil {
		return fmt.Errorf("cannot create request: %v", err)
	}
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{}
	res, err := client.Do(req)
	if err != nil {
		return fmt.Errorf("error setting config: %v", err)
	}
	if res.StatusCode != http.StatusOK {
		return fmt.Errorf("error setting config: leader sentinel returned non ok code: %s", res.Status)
	}
	return nil
}
开发者ID:giannisalinetti,项目名称:stolon,代码行数:27,代码来源:config_replace.go


示例2: getConfig

func getConfig(e *store.StoreManager) (*cluster.NilConfig, error) {
	cv, _, err := e.GetClusterView()
	if err != nil {
		return nil, fmt.Errorf("cannot get clusterview: %v", err)
	}
	if cv == nil {
		return nil, fmt.Errorf("no clusterview available")
	}
	cfg := cv.Config
	if cfg == nil {
		return nil, nil
	}
	return cfg, nil
}
开发者ID:giannisalinetti,项目名称:stolon,代码行数:14,代码来源:config_get.go


示例3: WaitClusterDataWithMaster

func WaitClusterDataWithMaster(e *store.StoreManager, timeout time.Duration) (string, error) {
	start := time.Now()
	for time.Now().Add(-timeout).Before(start) {
		cd, _, err := e.GetClusterData()
		if err != nil || cd == nil {
			goto end
		}
		if cd.Cluster.Status.Phase == cluster.ClusterPhaseNormal && cd.Cluster.Status.Master != "" {
			return cd.DBs[cd.Cluster.Status.Master].Spec.KeeperUID, nil
		}
	end:
		time.Sleep(2 * time.Second)
	}
	return "", fmt.Errorf("timeout")
}
开发者ID:sgotti,项目名称:stolon,代码行数:15,代码来源:utils.go


示例4: WaitClusterPhase

func WaitClusterPhase(e *store.StoreManager, phase cluster.ClusterPhase, timeout time.Duration) error {
	start := time.Now()
	for time.Now().Add(-timeout).Before(start) {
		cd, _, err := e.GetClusterData()
		if err != nil || cd == nil {
			goto end
		}
		if cd.Cluster.Status.Phase == phase {
			return nil
		}
	end:
		time.Sleep(2 * time.Second)
	}
	return fmt.Errorf("timeout")
}
开发者ID:sgotti,项目名称:stolon,代码行数:15,代码来源:utils.go


示例5: WaitNumDBs

func WaitNumDBs(e *store.StoreManager, n int, timeout time.Duration) error {
	start := time.Now()
	for time.Now().Add(-timeout).Before(start) {
		cd, _, err := e.GetClusterData()
		if err != nil || cd == nil {
			goto end
		}
		if len(cd.DBs) == n {
			return nil
		}
	end:
		time.Sleep(sleepInterval)
	}
	return fmt.Errorf("timeout")
}
开发者ID:sorintlab,项目名称:stolon,代码行数:15,代码来源:utils.go


示例6: getClusterData

func getClusterData(e *store.StoreManager) (*cluster.ClusterData, *kvstore.KVPair, error) {
	cd, pair, err := e.GetClusterData()
	if err != nil {
		return nil, nil, fmt.Errorf("cannot get cluster data: %v", err)
	}
	if cd == nil {
		return nil, nil, fmt.Errorf("nil cluster data: %v", err)
	}
	if cd.FormatVersion != cluster.CurrentCDFormatVersion {
		return nil, nil, fmt.Errorf("unsupported cluster data format version %d", cd.FormatVersion)
	}
	if err := cd.Cluster.Spec.Validate(); err != nil {
		return nil, nil, fmt.Errorf("clusterdata validation failed: %v", err)
	}
	return cd, pair, nil
}
开发者ID:sorintlab,项目名称:stolon,代码行数:16,代码来源:stolonctl.go


示例7: WaitClusterInitialized

func WaitClusterInitialized(e *store.StoreManager, timeout time.Duration) error {
	start := time.Now()
	for time.Now().Add(-timeout).Before(start) {
		cv, _, err := e.GetClusterView()
		if err != nil {
			goto end
		}
		if cv != nil {
			if cv.Version > 0 {
				return nil
			}
		}
	end:
		time.Sleep(2 * time.Second)
	}
	return fmt.Errorf("timeout")
}
开发者ID:giannisalinetti,项目名称:stolon,代码行数:17,代码来源:utils.go


示例8: WaitClusterDataMaster

func WaitClusterDataMaster(master string, e *store.StoreManager, timeout time.Duration) error {
	start := time.Now()
	for time.Now().Add(-timeout).Before(start) {
		cd, _, err := e.GetClusterData()
		if err != nil || cd == nil {
			goto end
		}
		if cd.Cluster.Status.Phase == cluster.ClusterPhaseNormal && cd.Cluster.Status.Master != "" {
			if cd.DBs[cd.Cluster.Status.Master].Spec.KeeperUID == master {
				return nil
			}
		}
	end:
		time.Sleep(sleepInterval)
	}
	return fmt.Errorf("timeout")
}
开发者ID:sorintlab,项目名称:stolon,代码行数:17,代码来源:utils.go


示例9: WaitClusterDataSynchronousStandbys

// WaitClusterDataSynchronousStandbys waits for:
// * synchrnous standby defined in masterdb spec
// * synchrnous standby reported from masterdb status
func WaitClusterDataSynchronousStandbys(synchronousStandbys []string, e *store.StoreManager, timeout time.Duration) error {
	sort.Sort(sort.StringSlice(synchronousStandbys))
	start := time.Now()
	for time.Now().Add(-timeout).Before(start) {
		cd, _, err := e.GetClusterData()
		if err != nil || cd == nil {
			goto end
		}
		if cd.Cluster.Status.Phase == cluster.ClusterPhaseNormal && cd.Cluster.Status.Master != "" {
			masterDB := cd.DBs[cd.Cluster.Status.Master]
			// get keepers for db spec synchronousStandbys
			keepersUIDs := []string{}
			for _, dbUID := range masterDB.Spec.SynchronousStandbys {
				db, ok := cd.DBs[dbUID]
				if ok {
					keepersUIDs = append(keepersUIDs, db.Spec.KeeperUID)
				}
			}
			sort.Sort(sort.StringSlice(keepersUIDs))
			if !reflect.DeepEqual(synchronousStandbys, keepersUIDs) {
				goto end
			}

			// get keepers for db status synchronousStandbys
			keepersUIDs = []string{}
			for _, dbUID := range masterDB.Status.SynchronousStandbys {
				db, ok := cd.DBs[dbUID]
				if ok {
					keepersUIDs = append(keepersUIDs, db.Spec.KeeperUID)
				}
			}
			sort.Sort(sort.StringSlice(keepersUIDs))
			if !reflect.DeepEqual(synchronousStandbys, keepersUIDs) {
				goto end
			}
			return nil
		}
	end:
		time.Sleep(sleepInterval)
	}
	return fmt.Errorf("timeout")
}
开发者ID:sorintlab,项目名称:stolon,代码行数:45,代码来源:utils.go


示例10: WaitClusterDataKeeperInitialized

func WaitClusterDataKeeperInitialized(keeperUID string, e *store.StoreManager, timeout time.Duration) error {
	start := time.Now()
	for time.Now().Add(-timeout).Before(start) {
		cd, _, err := e.GetClusterData()
		if err != nil || cd == nil {
			goto end
		}
		// Check for db on keeper to be initialized
		for _, db := range cd.DBs {
			if db.Spec.KeeperUID == keeperUID {
				if db.Status.CurrentGeneration >= cluster.InitialGeneration {
					return nil
				}
			}
		}
	end:
		time.Sleep(sleepInterval)
	}
	return fmt.Errorf("timeout")
}
开发者ID:sorintlab,项目名称:stolon,代码行数:20,代码来源:utils.go


示例11: WaitStandbyKeeper

func WaitStandbyKeeper(e *store.StoreManager, keeperUID string, timeout time.Duration) error {
	start := time.Now()
	for time.Now().Add(-timeout).Before(start) {
		cd, _, err := e.GetClusterData()
		if err != nil || cd == nil {
			goto end
		}

		for _, db := range cd.DBs {
			if db.UID == cd.Cluster.Status.Master {
				continue
			}
			if db.Spec.KeeperUID == keeperUID && db.Spec.Role == common.RoleStandby {
				return nil
			}
		}
	end:
		time.Sleep(sleepInterval)
	}
	return fmt.Errorf("timeout")
}
开发者ID:sorintlab,项目名称:stolon,代码行数:21,代码来源:utils.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang cotterpin.Snapshotable类代码示例发布时间:2022-05-28
下一篇:
Golang store.NewStoreManager函数代码示例发布时间: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