func (frn *FrameworkRiakNode) handleStartingToRunningTransition(sc *SchedulerCore, frc *FrameworkRiakCluster) { rexHostname := fmt.Sprintf("%s:%d", frn.LastOfferUsed.GetHostname(), frn.TaskData.RexPort) rexc := rexclient.NewRiakExplorerClient(rexHostname) for _, riakNode := range sc.schedulerState.Clusters[frc.Name].Nodes { if riakNode.CurrentState == process_state.Started { // We should try to join against this node log.Infof("Joining %+v to %+v", frn.TaskData.FullyQualifiedNodeName, riakNode.TaskData.FullyQualifiedNodeName) joinReply, joinErr := rexc.Join(frn.TaskData.FullyQualifiedNodeName, riakNode.TaskData.FullyQualifiedNodeName) log.Infof("Triggered join: %+v, %+v", joinReply, joinErr) if joinErr == nil { break // We're done here } } } }
func NewRiakExplorer(port int64, nodename string, c *cepm.CEPM, root string, useSuperChroot bool) (*RiakExplorer, error) { exepath := "/riak_explorer/bin/riak_explorer" var err error args := []string{"console", "-noinput"} healthCheckFun := func() error { log.Info("Running healthcheck: ", port) _, err := rexclient.NewRiakExplorerClient(fmt.Sprintf("localhost:%d", port)).Ping() log.Info("Healthcheck result ", err) return err } tearDownFun := func() { log.Info("Tearing down riak explorer") //err := os.RemoveAll("riak_explorer") //if err != nil { /// log.Error(err) //} } re := &RiakExplorer{ port: port, } if c != nil { // This is gross -- we're passing "hidden" state by passing it through the unix environment variables. // Fix it -- we should convert the NewRiakExplorer into using a fluent pattern? libpath := filepath.Join(root, "riak_explorer", "lib", "basho-patches") os.Mkdir(libpath, 0777) err := cepm.InstallInto(libpath) if err != nil { log.Panic(err) } if err := common.KillEPMD(filepath.Join(root, "riak_explorer")); err != nil { log.Fatal("Could not kill EPMd: ", err) } args = append(args, "-no_epmd") re.configureAdvanced(c.GetPort(), root) } re.configure(port, nodename, root) log.Debugf("Starting up Riak Explorer %v", exepath) re.pm, err = process_manager.NewProcessManager(tearDownFun, exepath, args, healthCheckFun, &root, useSuperChroot) if err != nil { log.Error("Could not start Riak Explorer: ", err) } return re, err }
func (frn *FrameworkRiakNode) handleUpToDownTransition(sc *SchedulerCore, frc *FrameworkRiakCluster) { for _, riakNode := range sc.schedulerState.Clusters[frc.Name].Nodes { if riakNode.CurrentState == process_state.Started && riakNode != frn { rexc := rexclient.NewRiakExplorerClient(fmt.Sprintf("%s:%d", riakNode.LastOfferUsed.GetHostname(), riakNode.TaskData.RexPort)) // We should try to join against this node log.Infof("Making leave: %+v to %+v", frn.TaskData.FullyQualifiedNodeName, riakNode.TaskData.FullyQualifiedNodeName) leaveReply, leaveErr := rexc.ForceRemove(riakNode.TaskData.FullyQualifiedNodeName, frn.TaskData.FullyQualifiedNodeName) log.Infof("Triggered leave: %+v, %+v", leaveReply, leaveErr) if leaveErr == nil { log.Info("Leave successful") break // We're done here } } } }
func (re *RiakExplorer) NewRiakExplorerClient() *rexclient.RiakExplorerClient { return rexclient.NewRiakExplorerClient(fmt.Sprintf("localhost:%d", re.port)) }