manager is responsible for managing and co-ordinating various parts of the seesaw engine.
()
| 364 | // manager is responsible for managing and co-ordinating various parts of the |
| 365 | // seesaw engine. |
| 366 | func (e *Engine) manager() { |
| 367 | for { |
| 368 | // process ha state updates first before processing others |
| 369 | select { |
| 370 | case state := <-e.haManager.stateChan: |
| 371 | log.Infof("Received HA state notification %v", state) |
| 372 | e.haManager.setState(state) |
| 373 | continue |
| 374 | case status := <-e.haManager.statusChan: |
| 375 | log.V(1).Infof("Received HA status notification (%v)", status.State) |
| 376 | e.haManager.setStatus(status) |
| 377 | continue |
| 378 | default: |
| 379 | } |
| 380 | select { |
| 381 | case state := <-e.haManager.stateChan: |
| 382 | log.Infof("Received HA state notification %v", state) |
| 383 | e.haManager.setState(state) |
| 384 | |
| 385 | case status := <-e.haManager.statusChan: |
| 386 | log.V(1).Infof("Received HA status notification (%v)", status.State) |
| 387 | e.haManager.setStatus(status) |
| 388 | |
| 389 | case n := <-e.notifier.C: |
| 390 | log.Infof("Received cluster config notification; %v", &n) |
| 391 | e.syncServer.notify(&SyncNote{Type: SNTConfigUpdate, Time: time.Now()}) |
| 392 | |
| 393 | vua, err := newVserverUserAccess(n.Cluster) |
| 394 | if err != nil { |
| 395 | log.Errorf("Ignoring notification due to invalid vserver access configuration: %v", err) |
| 396 | return |
| 397 | } |
| 398 | |
| 399 | e.clusterLock.Lock() |
| 400 | e.cluster = n.Cluster |
| 401 | e.clusterLock.Unlock() |
| 402 | |
| 403 | e.vserverAccess.update(vua) |
| 404 | |
| 405 | if n.MetadataOnly { |
| 406 | log.Infof("Only metadata changes found, processing complete.") |
| 407 | continue |
| 408 | } |
| 409 | |
| 410 | if ha, err := e.haConfig(); err != nil { |
| 411 | log.Errorf("Manager failed to determine haConfig: %v", err) |
| 412 | } else if ha.Enabled { |
| 413 | e.haManager.enable() |
| 414 | } else { |
| 415 | e.haManager.disable() |
| 416 | } |
| 417 | |
| 418 | node, err := e.thisNode() |
| 419 | if err != nil { |
| 420 | log.Errorf("Manager failed to identify local node: %v", err) |
| 421 | continue |
| 422 | } |
| 423 | if !node.VserversEnabled { |
no test coverage detected