예제 #1
0
파일: machinetracker.go 프로젝트: bac/juju
// SelectMongoHostPort returns the best hostport for the machine for
// MongoDB use, perhaps using the space provided.
func (m *machineTracker) SelectMongoHostPort(mongoSpace network.SpaceName) string {
	m.mu.Lock()
	defer m.mu.Unlock()

	if mongoSpace != "" {
		return mongo.SelectPeerHostPortBySpace(m.mongoHostPorts, mongoSpace)
	}
	return mongo.SelectPeerHostPort(m.mongoHostPorts)
}
예제 #2
0
파일: mongo_test.go 프로젝트: xushiwei/juju
func (s *MongoSuite) TestSelectPeerHostPort(c *gc.C) {

	hostPorts := []network.HostPort{{
		Address: network.Address{
			Value: "10.0.0.1",
			Type:  network.IPv4Address,
			Scope: network.ScopeCloudLocal,
		},
		Port: environs.DefaultStatePort}, {
		Address: network.Address{
			Value: "8.8.8.8",
			Type:  network.IPv4Address,
			Scope: network.ScopePublic,
		},
		Port: environs.DefaultStatePort}}

	address := mongo.SelectPeerHostPort(hostPorts)
	c.Assert(address, gc.Equals, "10.0.0.1:"+strconv.Itoa(environs.DefaultStatePort))
}
예제 #3
0
파일: mongo_test.go 프로젝트: kapilt/juju
func (s *MongoSuite) TestSelectPeerHostPort(c *gc.C) {

	hostPorts := []network.HostPort{{
		Address: network.Address{
			Value:       "10.0.0.1",
			Type:        network.IPv4Address,
			NetworkName: "cloud",
			Scope:       network.ScopeCloudLocal,
		},
		Port: 37017}, {
		Address: network.Address{
			Value:       "8.8.8.8",
			Type:        network.IPv4Address,
			NetworkName: "public",
			Scope:       network.ScopePublic,
		},
		Port: 37017}}

	address := mongo.SelectPeerHostPort(hostPorts)
	c.Assert(address, gc.Equals, "10.0.0.1:37017")
}
예제 #4
0
파일: worker.go 프로젝트: Pankov404/juju
func (m *machine) mongoHostPort() string {
	return mongo.SelectPeerHostPort(m.mongoHostPorts)
}
예제 #5
0
func (m *machine) mongoHostPort() string {
	if m.mongoSpaceValid {
		return mongo.SelectPeerHostPortBySpace(m.mongoHostPorts, m.mongoSpace)
	}
	return mongo.SelectPeerHostPort(m.mongoHostPorts)
}