示例#1
0
文件: main.go 项目: icsnju/apt-mesos
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
}
示例#2
0
import (
	"io"
	"net/http"
	"net/http/httptest"
	"strings"
	"testing"

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

var (
	s      = schedulerImpl.NewFCFSScheduler()
	c      = core.NewCore("192.168.33.1:3030", "192.168.33.10:5050", s)
	h      = NewHandler(c)
	m      = martini.Classic()
	reader io.Reader
)

func TestHandShake(t *testing.T) {
	Convey("handshake api", t, func() {
		m.Get("/handshake", h.Handshake())

		res := httptest.NewRecorder()
		req, _ := http.NewRequest("GET", "/handshake", nil)
		m.ServeHTTP(res, req)

		So(res.Code, ShouldEqual, http.StatusOK)
	})