ADR81SGP
New Creator

scheduleEntryControl.isRunning() is true incorrectly

Jump to solution

Dear Community,

I am struggling with a section of code.

What I am trying to do is running a schedule entry, waiting till it terminates, and then execute some more code.

Attached is my code how I execute the entry and await that termination.

What happens is, the schedule entry executes successfully, terminates as I can see in ServerMonitoring, but the call to scheduleEntryControl.isRunning() still returns true although it cannot be the case.

Is it because the scheduleEntryControl object has to be overwritten to update the data about execution? But how can I get an up-to-date scheduleEntryControl without calling scheduleEntry.execute()?

Or maybe you have any better approach how to run a schedule entry, await its termination, and then execute some more code.

Thanks!

0 Kudos
1 Solution

Accepted Solutions
felix_reinhold
Returning Responder

Hi Eric, maybe you should give us some more details about what you're trying to achieve.

I've just tested this code on client-side and server-side and it works for me:

  static boolean executeScheduleEntry(ScheduleEntry scheduleEntry) {

    try {

      final ScheduleEntryControl scheduleEntryControl = scheduleEntry.execute();

      scheduleEntryControl.awaitTermination();

    } catch (ScheduleEntryRunningException e) {

      e.printStackTrace();

      return false;

    }

    return true;

  }

Im starting a generation-entry that runs for a~60 seconds. The method isn't left until it is finished.

Best regards

Felix

View solution in original post

0 Kudos
7 Replies
hbarthel
New Responder

Hi Eric,

there is an awaitTermination method in ScheduleEntryControl. As long as you have no need to execute code during waiting, you can simply do:

ScheduleEntryControl control = job.execute();

control.awaitTermination();

Your implementation burns the CPU Smiley Happy

Cheers, Heiko

0 Kudos

Hi Heiko,

yes, I know that method, but it does not work in this case, it just awaits on server side, not client side. I cannot execute more code on my side just because I called this method.

I also tried to do something like Thread.sleep(5_000), but that led to the same outcome: scheduleEntryControl.isRunning() returns true although it should be false.

0 Kudos

awaitTermination blocks the thread that calls it. I am not sure what you try to achieve...

0 Kudos

I just tested it again. It just calls the method, does nothing and continues executing the code. Difference of 2 sec between the call of the method and continuing:

14:11:52 [main] [INFO] c.b.f.s.r.ScheduleHandler - Schedule Entry is running: script awaits termination of schedule entry...

14:11:54 [main] [INFO] c.b.f.s.r.ScheduleHandler - Schedule Entry execution done!

14:11:54 [main] [INFO] c.b.f.s.r.ScheduleHandlerTest - schedule entry was executed!

0 Kudos
felix_reinhold
Returning Responder

Hi Eric, maybe you should give us some more details about what you're trying to achieve.

I've just tested this code on client-side and server-side and it works for me:

  static boolean executeScheduleEntry(ScheduleEntry scheduleEntry) {

    try {

      final ScheduleEntryControl scheduleEntryControl = scheduleEntry.execute();

      scheduleEntryControl.awaitTermination();

    } catch (ScheduleEntryRunningException e) {

      e.printStackTrace();

      return false;

    }

    return true;

  }

Im starting a generation-entry that runs for a~60 seconds. The method isn't left until it is finished.

Best regards

Felix

0 Kudos

Exactly. Eric: I can imagine you try to start the job twice (and parallel execution is not allowed) and the second instance terminates immediately? Or the schedule finishes really so fast?

0 Kudos
ADR81SGP
New Creator

Ok, let me start again. I have a module (FSM) that is installed on the FS server. What it does is, it changes values in a project, as website name, based on user input in the configuration. After it has changed the values, it runs a schedule entry (here my issue comes into play). After that schedule entry, it should reverse those made changes to original state.

Hi Felix, actually that did do the trick after all. I made some mistake by executing the wrong schedule entry that just ran 2 sec.

Thank you guys!

0 Kudos