35 lines
1019 B
Go

package managed_job
import (
"gitea.com/logicamp/lc"
api "github.com/logi-camp/go-flink-client"
"go.uber.org/zap"
)
// restore the job from savepoint and jarId in managedJob
func (job *ManagedJob) restore() error {
if job.state.LastSavepointPath == nil {
lc.Logger.Error("[managed-job] [restore]", zap.Error(ErrNoSavepointPath))
return ErrNoSavepointPath
}
lc.Logger.Debug("[managed-job] [restore] restoring", zap.String("savepointPath", *job.state.LastSavepointPath))
runJarResp, err := job.client.RunJar(api.RunOpts{
JarID: job.jarId,
AllowNonRestoredState: true,
EntryClass: job.def.Spec.EntryClass,
SavepointPath: *job.state.LastSavepointPath,
})
if err != nil {
lc.Logger.Error("[managed-job] [run]", zap.Error(err))
return err
}
lc.Logger.Debug("[main] after run jar", zap.Any("run-jar-resp", runJarResp))
job.state.JobId = &runJarResp.JobId
job.state.Status = JobStatusCreating
job.state.Error = nil
job.updateState(*job.state)
return err
}