Ejemplo n.º 1
0
func main() {
	if debug {
		log.SetLevel(log.DebugLevel)
	}

	// create a new scheduler
	var schedule scheduler.Scheduler
	if strategy == scheduler.FCFS {
		schedule = schedulerImpl.NewFCFSScheduler()
	} else {
		schedule = schedulerImpl.NewDRFScheduler()
	}

	// start a new core
	core := core.NewCore(addr, master, schedule)

	// start a new file explorer
	fe := fs.NewMfsFileExplorer()

	// Start HTTP server
	comm.ListenAndServe(addr, core, fe)
	log.Infof("Current scheduling stragy is %v", reflect.TypeOf(schedule))

	// try to register framework to master
	if err := core.Run(); err != nil {
		log.Fatal(err)
	}

	exit := make(chan bool)
	<-exit
}
Ejemplo n.º 2
0
package impl

import (
	"testing"

	"github.com/icsnju/apt-mesos/registry"
	schedulerImpl "github.com/icsnju/apt-mesos/scheduler/impl"
	. "github.com/smartystreets/goconvey/convey"
)

var (
	s    = schedulerImpl.NewFCFSScheduler()
	c    = NewCore("192.168.33.1:3030", "192.168.33.10:5050", s)
	task = &registry.Task{
		ID:    "1",
		State: "TASK_WAITING",
	}
)

func TestAddTask(t *testing.T) {
	Convey("add task", t, func() {
		err := c.AddTask("1", task)
		So(err, ShouldBeNil)
	})
}

func TestGetTask(t *testing.T) {
	Convey("get exist task", t, func() {
		task, err := c.GetTask("1")
		So(err, ShouldBeNil)
		So(task, ShouldNotBeNil)