コード例 #1
0
func (p LeaveProcessor) Process() {

	app := types.GetApp(p.AppId, p.GetAgent())
	app.Lock()
	if app.Exists() {
		keys := []types.AppKey{}
		for _, e := range app.GetExports() {
			keys = append(keys, e.GetAppKey())
		}
		conn, _ := app.GetConnection()
		conn.Close()
		printDebug("LEAVE locking")
		printDebug("LEAVE unlocking")
		if !app.IsNode() {
			for _, exp := range app.GetExports() {
				printDebug("LEAVE unlocking")
				var m messages.RemoveExportMessage
				m.ExportId = exp.GetId()
				var smp SendMessageProcessor
				smp.Msg = m
				smp.GenericProcessor = processor.GetGenericProcessor()
				for _, n := range types.GetNodes(p.GetAgent()) {
					smp.App = n
					p.SpawnProcess(smp)
				}
			}
			for _, imp := range app.GetImports() {
				var m messages.RemoveImportMessage
				m.ImportId = imp.GetId()
				var smp SendMessageProcessor
				smp.Msg = m
				smp.GenericProcessor = processor.GetGenericProcessor()
				for _, n := range types.GetNodes(p.GetAgent()) {
					smp.App = n
					p.SpawnProcess(smp)
				}
			}

			printDebug("LEAVE removing")
			app.Remove()
			printDebug("LEAVE removed")

			for _, k := range keys {
				if k.Exists() {
					var esp ExportedStateProcessor
					esp.AppKey = k
					esp.GenericProcessor = processor.GetGenericProcessor()
					p.SpawnProcess(esp)
				}
			}
		}
	}

}
コード例 #2
0
func (p RequestProcessor) Process() {
	app := types.GetApp(p.AppId, p.GetAgent())
	if !app.Exists() {
		mprint("Could not add jo, app does not exist")
		return
	}
	app.Lock()
	job := types.GetJobFromRequest(p.Request, p.GetAgent())
	job.Create()
	imp := job.GetImport()
	if job.Exists() && imp.HasExporter() {

		var djp DeliverJobProcessor
		djp.Job = job
		djp.GenericProcessor = processor.GetGenericProcessor()

		p.SpawnProcess(djp)

	}
	app.Unlock()
}
コード例 #3
0
func (p AddExportProcessor) Process() {
	app := types.GetApp(p.AppId, p.GetAgent())
	if !app.Exists() {
		mprint("Could not add exmport, app does not exist")
		return
	}
	app.Lock()
	Export := types.GetExport(p.AppId, p.AddExportMsg.AppKey, p.AddExportMsg.Tags, p.AddExportMsg.ExportId, p.GetAgent())
	Export.Add()

	if !app.IsNode() {
		var smp SendMessageProcessor
		smp.App = app
		smp.Msg = messages.ExportAddedMessage{Export.GetId(), p.AddExportMsg.AppKey, p.AddExportMsg.Tags}
		smp.GenericProcessor = processor.GetGenericProcessor()
		p.SpawnProcess(smp)
	}

	var pjp PendingJobProcessor
	pjp.Appkey = Export.GetAppKey()
	pjp.GenericProcessor = processor.GetGenericProcessor()
	p.SpawnProcess(pjp)
	var uesp ExportedStateProcessor
	uesp.AppKey = Export.GetAppKey()
	uesp.GenericProcessor = processor.GetGenericProcessor()
	p.SpawnProcess(uesp)

	if !app.IsNode() {
		p.AddExportMsg.ExportId = Export.GetId()
		for _, node := range types.GetNodes(p.GetAgent()) {
			var smp SendMessageProcessor
			smp.App = node
			smp.Msg = p.AddExportMsg
			smp.GenericProcessor = processor.GetGenericProcessor()
			p.SpawnProcess(smp)
		}
	}
	app.Unlock()

}
コード例 #4
0
func (p DockProcessor) Process() {
	if p.Connection != nil {
		decoder := util.GetCodec(p.Codec)
		if decoder == nil {
			return
		}
		var dmsg messages.DockMessage
		err := decoder.Decode(p.DockMessage, &dmsg)
		if err != nil {
			return
		}
		app := types.GetApp(p.AppId, p.GetAgent())
		ok := app.Create(dmsg, p.Connection)
		if ok {
			app.Lock()
			defer app.Unlock()
			conn, _ := app.GetConnection()
			err = conn.Init()
			if err != nil {
				return
			}
			if app.IsNode() {
				var sp SendMessageProcessor
				sp.App = app
				sp.Msg = messages.DockMessage{"runtime", []string{"JSON"}, true}
				sp.GenericProcessor = processor.GetGenericProcessor()
				p.SpawnProcess(sp)
			}

		}

		var sp SendMessageProcessor
		sp.App = app
		sp.Msg = messages.DockedMessage{ok}
		sp.GenericProcessor = processor.GetGenericProcessor()
		p.SpawnProcess(sp)

		if ok && app.IsNode() {
			for _, localapp := range types.GetApps(p.GetAgent()) {
				for _, imp := range localapp.GetImports() {
					var m messages.AddImportMessage
					m.AppKey = imp.GetAppKey().GetKey()
					m.Tags = imp.GetTagNames()
					m.ImportId = imp.GetId()
					var sp SendMessageProcessor
					sp.App = app
					sp.Msg = m
					sp.GenericProcessor = processor.GetGenericProcessor()
					p.SpawnProcess(sp)
				}
				for _, exp := range localapp.GetExports() {
					var m messages.AddExportMessage
					m.AppKey = exp.GetAppKey().GetKey()
					m.Tags = exp.GetTagNames()
					m.ExportId = exp.GetId()
					var sp SendMessageProcessor
					sp.App = app
					sp.Msg = m
					sp.GenericProcessor = processor.GetGenericProcessor()
					p.SpawnProcess(sp)
				}
			}
		}
	}

}