Beispiel #1
0
// rebuild tasks from zk
func (m *MigrateManager) RebuildTasks(migrateMetas []*meta.MigrateMeta, cluster *topo.Cluster) {
	if migrateMetas != nil {
		for _, mm := range migrateMetas {
			task, err := m.CreateTask(mm.SourceId, mm.TargetId, mm.Ranges, cluster)
			if err == nil {
				log.Info(task.TaskName(), "Load task from zk")
			} else {
				log.Warning(task.TaskName(), "CreateTask failed, %v", err)
			}
		}
	}
}
Beispiel #2
0
					return false
				}
			}
		}
		log.Info(getNodeState(i).Addr(), "Can failover slave")
		return true
	}

	MasterAutoFailoverConstraint = func(i interface{}) bool {
		ctx := i.(StateContext)
		cs := ctx.ClusterState
		ns := ctx.NodeState

		// 如果AutoFailover没开,且不是执行Failover的信号
		if !meta.AutoFailover() && ctx.Input.Command != CMD_FAILOVER_BEGIN_SIGNAL {
			log.Warning(ns.Addr(), "Check constraint failed, autofailover off or no FL begin signal")
			return false
		}

		rs := cs.FindReplicaSetByNode(ns.Id())
		if rs == nil {
			log.Warning(ns.Addr(), "Check constraint failed, can not find replicaset by the failure node")
			return false
		}
		// Region至少还有一个节点
		localRegionNodes := rs.RegionNodes(ns.node.Region)
		if len(localRegionNodes) < 2 {
			log.Warningf(ns.Addr(), "Check constraint failed, %s region nodes %d < 2\n",
				ns.node.Region, len(localRegionNodes))
			return false
		}