当前位置: 首页>>代码示例>>Golang>>正文


Golang netutil.URLStringsEqual函数代码示例

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


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

示例1: VerifyBootstrapConfig

// VerifyBootstrapConfig sanity-checks the initial config and returns an error
// for things that should never happen.
func (c *ServerConfig) VerifyBootstrapConfig() error {
	m := c.Cluster.MemberByName(c.Name)
	// Make sure the cluster at least contains the local server.
	if m == nil {
		return fmt.Errorf("couldn't find local name %q in the initial cluster configuration", c.Name)
	}
	if uint64(m.ID) == raft.None {
		return fmt.Errorf("cannot use %x as member id", raft.None)
	}

	if c.DiscoveryURL == "" && !c.NewCluster {
		return fmt.Errorf("initial cluster state unset and no wal or discovery URL found")
	}

	// No identical IPs in the cluster peer list
	urlMap := make(map[string]bool)
	for _, m := range c.Cluster.Members() {
		for _, url := range m.PeerURLs {
			if urlMap[url] {
				return fmt.Errorf("duplicate url %v in cluster config", url)
			}
			urlMap[url] = true
		}
	}

	// Advertised peer URLs must match those in the cluster peer list
	// TODO: Remove URLStringsEqual after improvement of using hostnames #2150 #2123
	apurls := c.PeerURLs.StringSlice()
	sort.Strings(apurls)
	if !netutil.URLStringsEqual(apurls, m.PeerURLs) {
		return fmt.Errorf("%s has different advertised URLs in the cluster and advertised peer URLs list", c.Name)
	}
	return nil
}
开发者ID:CedarLogic,项目名称:arangodb,代码行数:36,代码来源:config.go

示例2: verifyLocalMember

// verifyLocalMember verifies the configured member is in configured
// cluster. If strict is set, it also verifies the configured member
// has the same peer urls as configured advertised peer urls.
func (c *ServerConfig) verifyLocalMember(strict bool) error {
	urls := c.InitialPeerURLsMap[c.Name]
	// Make sure the cluster at least contains the local server.
	if urls == nil {
		return fmt.Errorf("couldn't find local name %q in the initial cluster configuration", c.Name)
	}

	// Advertised peer URLs must match those in the cluster peer list
	apurls := c.PeerURLs.StringSlice()
	sort.Strings(apurls)
	urls.Sort()
	if strict {
		if !netutil.URLStringsEqual(apurls, urls.StringSlice()) {
			return fmt.Errorf("advertise URLs of %q do not match in --initial-advertise-peer-urls %s and --initial-cluster %s", c.Name, apurls, urls.StringSlice())
		}
	}
	return nil
}
开发者ID:nathanpalmer,项目名称:etcd,代码行数:21,代码来源:config.go

示例3: verifyLocalMember

// verifyLocalMember verifies the configured member is in configured
// cluster. If strict is set, it also verifies the configured member
// has the same peer urls as configured advertised peer urls.
func (c *ServerConfig) verifyLocalMember(strict bool) error {
	urls := c.InitialPeerURLsMap[c.Name]
	// Make sure the cluster at least contains the local server.
	if urls == nil {
		return fmt.Errorf("couldn't find local name %q in the initial cluster configuration", c.Name)
	}

	// Advertised peer URLs must match those in the cluster peer list
	apurls := c.PeerURLs.StringSlice()
	sort.Strings(apurls)
	urls.Sort()
	if strict {
		if !netutil.URLStringsEqual(apurls, urls.StringSlice()) {
			umap := map[string]types.URLs{c.Name: c.PeerURLs}
			return fmt.Errorf("--initial-cluster must include %s given --initial-advertise-peer-urls=%s", types.URLsMap(umap).String(), strings.Join(apurls, ","))
		}
	}
	return nil
}
开发者ID:WUMUXIAN,项目名称:etcd,代码行数:22,代码来源:config.go

示例4: ValidateClusterAndAssignIDs

// ValidateClusterAndAssignIDs validates the local cluster by matching the PeerURLs
// with the existing cluster. If the validation succeeds, it assigns the IDs
// from the existing cluster to the local cluster.
// If the validation fails, an error will be returned.
func ValidateClusterAndAssignIDs(local *cluster, existing *cluster) error {
	ems := existing.Members()
	lms := local.Members()
	if len(ems) != len(lms) {
		return fmt.Errorf("member count is unequal")
	}
	sort.Sort(MembersByPeerURLs(ems))
	sort.Sort(MembersByPeerURLs(lms))

	for i := range ems {
		if !netutil.URLStringsEqual(ems[i].PeerURLs, lms[i].PeerURLs) {
			return fmt.Errorf("unmatched member while checking PeerURLs")
		}
		lms[i].ID = ems[i].ID
	}
	local.members = make(map[types.ID]*Member)
	for _, m := range lms {
		local.members[m.ID] = m
	}
	return nil
}
开发者ID:CNDonny,项目名称:scope,代码行数:25,代码来源:cluster.go

示例5: verifyLocalMember

// verifyLocalMember verifies the configured member is in configured
// cluster. If strict is set, it also verifies the configured member
// has the same peer urls as configured advertised peer urls.
func (c *ServerConfig) verifyLocalMember(strict bool) error {
	m := c.Cluster.MemberByName(c.Name)
	// Make sure the cluster at least contains the local server.
	if m == nil {
		return fmt.Errorf("couldn't find local name %q in the initial cluster configuration", c.Name)
	}
	if uint64(m.ID) == raft.None {
		return fmt.Errorf("cannot use %x as member id", raft.None)
	}

	// Advertised peer URLs must match those in the cluster peer list
	// TODO: Remove URLStringsEqual after improvement of using hostnames #2150 #2123
	apurls := c.PeerURLs.StringSlice()
	sort.Strings(apurls)
	if strict {
		if !netutil.URLStringsEqual(apurls, m.PeerURLs) {
			return fmt.Errorf("%s has different advertised URLs in the cluster and advertised peer URLs list", c.Name)
		}
	}
	return nil
}
开发者ID:jhadvig,项目名称:origin,代码行数:24,代码来源:config.go

示例6: ValidateClusterAndAssignIDs

// ValidateClusterAndAssignIDs validates the local cluster by matching the PeerURLs
// with the existing cluster. If the validation succeeds, it assigns the IDs
// from the existing cluster to the local cluster.
// If the validation fails, an error will be returned.
func ValidateClusterAndAssignIDs(local *Cluster, existing *Cluster) error {
	ems := existing.Members()
	lms := local.Members()
	if len(ems) != len(lms) {
		return fmt.Errorf("member count is unequal")
	}
	sort.Sort(SortableMemberSliceByPeerURLs(ems))
	sort.Sort(SortableMemberSliceByPeerURLs(lms))

	for i := range ems {
		// TODO: Remove URLStringsEqual after improvement of using hostnames #2150 #2123
		if !netutil.URLStringsEqual(ems[i].PeerURLs, lms[i].PeerURLs) {
			return fmt.Errorf("unmatched member while checking PeerURLs")
		}
		lms[i].ID = ems[i].ID
	}
	local.members = make(map[types.ID]*Member)
	for _, m := range lms {
		local.members[m.ID] = m
	}
	return nil
}
开发者ID:jhadvig,项目名称:origin,代码行数:26,代码来源:cluster.go


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