|
@@ -336,27 +336,65 @@ func (h *HostInfo) setPort(port int) *HostInfo {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (h *HostInfo) update(from *HostInfo) {
|
|
func (h *HostInfo) update(from *HostInfo) {
|
|
|
|
|
+ if h == from {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
h.mu.Lock()
|
|
h.mu.Lock()
|
|
|
defer h.mu.Unlock()
|
|
defer h.mu.Unlock()
|
|
|
|
|
|
|
|
- h.peer = from.peer
|
|
|
|
|
- h.broadcastAddress = from.broadcastAddress
|
|
|
|
|
- h.listenAddress = from.listenAddress
|
|
|
|
|
- h.rpcAddress = from.rpcAddress
|
|
|
|
|
- h.preferredIP = from.preferredIP
|
|
|
|
|
- h.connectAddress = from.connectAddress
|
|
|
|
|
- h.port = from.port
|
|
|
|
|
- h.dataCenter = from.dataCenter
|
|
|
|
|
- h.rack = from.rack
|
|
|
|
|
- h.hostId = from.hostId
|
|
|
|
|
- h.workload = from.workload
|
|
|
|
|
- h.graph = from.graph
|
|
|
|
|
- h.dseVersion = from.dseVersion
|
|
|
|
|
- h.partitioner = from.partitioner
|
|
|
|
|
- h.clusterName = from.clusterName
|
|
|
|
|
- h.version = from.version
|
|
|
|
|
- h.state = from.state
|
|
|
|
|
- h.tokens = from.tokens
|
|
|
|
|
|
|
+ from.mu.RLock()
|
|
|
|
|
+ defer from.mu.RUnlock()
|
|
|
|
|
+
|
|
|
|
|
+ // autogenerated do not update
|
|
|
|
|
+ if h.peer == nil {
|
|
|
|
|
+ h.peer = from.peer
|
|
|
|
|
+ }
|
|
|
|
|
+ if h.broadcastAddress == nil {
|
|
|
|
|
+ h.broadcastAddress = from.broadcastAddress
|
|
|
|
|
+ }
|
|
|
|
|
+ if h.listenAddress == nil {
|
|
|
|
|
+ h.listenAddress = from.listenAddress
|
|
|
|
|
+ }
|
|
|
|
|
+ if h.rpcAddress == nil {
|
|
|
|
|
+ h.rpcAddress = from.rpcAddress
|
|
|
|
|
+ }
|
|
|
|
|
+ if h.preferredIP == nil {
|
|
|
|
|
+ h.preferredIP = from.preferredIP
|
|
|
|
|
+ }
|
|
|
|
|
+ if h.connectAddress == nil {
|
|
|
|
|
+ h.connectAddress = from.connectAddress
|
|
|
|
|
+ }
|
|
|
|
|
+ if h.port == 0 {
|
|
|
|
|
+ h.port = from.port
|
|
|
|
|
+ }
|
|
|
|
|
+ if h.dataCenter == "" {
|
|
|
|
|
+ h.dataCenter = from.dataCenter
|
|
|
|
|
+ }
|
|
|
|
|
+ if h.rack == "" {
|
|
|
|
|
+ h.rack = from.rack
|
|
|
|
|
+ }
|
|
|
|
|
+ if h.hostId == "" {
|
|
|
|
|
+ h.hostId = from.hostId
|
|
|
|
|
+ }
|
|
|
|
|
+ if h.workload == "" {
|
|
|
|
|
+ h.workload = from.workload
|
|
|
|
|
+ }
|
|
|
|
|
+ if h.dseVersion == "" {
|
|
|
|
|
+ h.dseVersion = from.dseVersion
|
|
|
|
|
+ }
|
|
|
|
|
+ if h.partitioner == "" {
|
|
|
|
|
+ h.partitioner = from.partitioner
|
|
|
|
|
+ }
|
|
|
|
|
+ if h.clusterName == "" {
|
|
|
|
|
+ h.clusterName = from.clusterName
|
|
|
|
|
+ }
|
|
|
|
|
+ if h.version == (cassVersion{}) {
|
|
|
|
|
+ h.version = from.version
|
|
|
|
|
+ }
|
|
|
|
|
+ if h.tokens == nil {
|
|
|
|
|
+ h.tokens = from.tokens
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (h *HostInfo) IsUp() bool {
|
|
func (h *HostInfo) IsUp() bool {
|
|
@@ -402,13 +440,13 @@ func checkSystemSchema(control *controlConn) (bool, error) {
|
|
|
|
|
|
|
|
// Given a map that represents a row from either system.local or system.peers
|
|
// Given a map that represents a row from either system.local or system.peers
|
|
|
// return as much information as we can in *HostInfo
|
|
// return as much information as we can in *HostInfo
|
|
|
-func (s *Session) hostInfoFromMap(row map[string]interface{}) (*HostInfo, error) {
|
|
|
|
|
|
|
+func (s *Session) hostInfoFromMap(row map[string]interface{}, port int) (*HostInfo, error) {
|
|
|
const assertErrorMsg = "Assertion failed for %s"
|
|
const assertErrorMsg = "Assertion failed for %s"
|
|
|
var ok bool
|
|
var ok bool
|
|
|
|
|
|
|
|
// Default to our connected port if the cluster doesn't have port information
|
|
// Default to our connected port if the cluster doesn't have port information
|
|
|
host := HostInfo{
|
|
host := HostInfo{
|
|
|
- port: s.cfg.Port,
|
|
|
|
|
|
|
+ port: port,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
for key, value := range row {
|
|
for key, value := range row {
|
|
@@ -527,7 +565,7 @@ func (r *ringDescriber) getClusterPeerInfo() ([]*HostInfo, error) {
|
|
|
|
|
|
|
|
for _, row := range rows {
|
|
for _, row := range rows {
|
|
|
// extract all available info about the peer
|
|
// extract all available info about the peer
|
|
|
- host, err := r.session.hostInfoFromMap(row)
|
|
|
|
|
|
|
+ host, err := r.session.hostInfoFromMap(row, r.session.cfg.Port)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return nil, err
|
|
return nil, err
|
|
|
} else if !isValidPeer(host) {
|
|
} else if !isValidPeer(host) {
|
|
@@ -589,7 +627,7 @@ func (r *ringDescriber) getHostInfo(ip net.IP, port int) (*HostInfo, error) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
for _, row := range rows {
|
|
for _, row := range rows {
|
|
|
- h, err := r.session.hostInfoFromMap(row)
|
|
|
|
|
|
|
+ h, err := r.session.hostInfoFromMap(row, port)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return nil, err
|
|
return nil, err
|
|
|
}
|
|
}
|