@@ -328,8 +328,12 @@ func (app *Application) SetState(state string) {
328
328
app .sm .SetState (state )
329
329
}
330
330
331
+ func (app * Application ) TriggerAppSubmission () error {
332
+ return app .handle (NewSubmitApplicationEvent (app .applicationID ))
333
+ }
334
+
331
335
func (app * Application ) TriggerAppRecovery () error {
332
- return app .handle (NewSimpleApplicationEvent (app .applicationID , RecoverApplication ))
336
+ return app .handle (NewRecoverApplicationEvent (app .applicationID ))
333
337
}
334
338
335
339
// Schedule is called in every scheduling interval,
@@ -341,12 +345,6 @@ func (app *Application) TriggerAppRecovery() error {
341
345
// return true if the app needs scheduling or false if not
342
346
func (app * Application ) Schedule () bool {
343
347
switch app .GetApplicationState () {
344
- case ApplicationStates ().New :
345
- ev := NewSubmitApplicationEvent (app .GetApplicationID ())
346
- if err := app .handle (ev ); err != nil {
347
- log .Log (log .ShimCacheApplication ).Warn ("failed to handle SUBMIT app event" ,
348
- zap .Error (err ))
349
- }
350
348
case ApplicationStates ().Accepted :
351
349
// once the app is accepted by the scheduler core,
352
350
// the next step is to send requests for scheduling
@@ -406,7 +404,7 @@ func (app *Application) scheduleTasks(taskScheduleCondition func(t *Task) bool)
406
404
}
407
405
}
408
406
409
- func (app * Application ) handleSubmitApplicationEvent () {
407
+ func (app * Application ) handleSubmitApplicationEvent () error {
410
408
log .Log (log .ShimCacheApplication ).Info ("handle app submission" ,
411
409
zap .Stringer ("app" , app ),
412
410
zap .String ("clusterID" , conf .GetSchedulerConf ().ClusterID ))
@@ -435,9 +433,10 @@ func (app *Application) handleSubmitApplicationEvent() {
435
433
log .Log (log .ShimCacheApplication ).Warn ("failed to submit app" , zap .Error (err ))
436
434
dispatcher .Dispatch (NewFailApplicationEvent (app .applicationID , err .Error ()))
437
435
}
436
+ return err
438
437
}
439
438
440
- func (app * Application ) handleRecoverApplicationEvent () {
439
+ func (app * Application ) handleRecoverApplicationEvent () error {
441
440
log .Log (log .ShimCacheApplication ).Info ("handle app recovering" ,
442
441
zap .Stringer ("app" , app ),
443
442
zap .String ("clusterID" , conf .GetSchedulerConf ().ClusterID ))
@@ -466,6 +465,7 @@ func (app *Application) handleRecoverApplicationEvent() {
466
465
log .Log (log .ShimCacheApplication ).Warn ("failed to recover app" , zap .Error (err ))
467
466
dispatcher .Dispatch (NewFailApplicationEvent (app .applicationID , err .Error ()))
468
467
}
468
+ return err
469
469
}
470
470
471
471
func (app * Application ) skipReservationStage () bool {
0 commit comments