Class ProcessDebugService

java.lang.Object
io.skipcheck.tm1.client.service.process.ProcessDebugService

public final class ProcessDebugService extends Object
Process debugging: a run of a process that stops at breakpoints and steps line by line, held on the server as a ProcessDebugContext until deleted.

debug(String, Map, ODataQuery) starts one, paused before the first line; resume(String, ODataQuery) runs to the next breakpoint (or the end), and the step… methods move a line at a time. Each returns the context as it then is. TM1 (11.8) answers a start, a resume or a step without waiting for the run to stop again, so the status is RUNNING or PAUSED depending on which came first; get(String, ODataQuery) reads it again. A step past a procedure's last line either pauses with an empty call stack or completes the run.

TM1 (11.8) refuses to delete a debug context: a run ends by running to completion, which finish(String) does, and debugging(String, Map, Function) does when its work is done. A finished context stays readable until the session ends. ProcessDebugContexts lists none, though each reads by ID.

Stop at a breakpoint and see where the run is, with debugging(String, Map, Function) finishing the run afterwards:

// Where the run stops at a breakpoint on line 3 of the prolog. debugging()
// runs it to the end afterwards.
ProcessDebugService debug = tm1.processDebugging();
return debug.debugging("Load Sales", Map.of("pVersion", "Forecast"), context -> {
	String id = Objects.requireNonNull(context.id());
	ProcessDebugContextLineBreakpointPatch line3 = ProcessDebugContextLineBreakpointPatch.builder()
		.id(1) // TM1 needs an ID chosen by the caller
		.processName("Load Sales")
		.procedure(ProcessProcedure.PROLOG)
		.lineNumber(3)
		.enabled(true)
		.build();
	return debug.addBreakpoint(id, line3)
		.then(debug.resume(id, ODataQuery.none()))
		.thenMany(debug.callStack(id, ODataQuery.none()))
		.map(frame -> frame.procedure() + ", line " + frame.lineNumber());
});

Step through a run started with debug(String, Map, ODataQuery), and finish it:

// Without debugging(), end the run with finish(): TM1 can't delete it
ProcessDebugService debug = tm1.processDebugging();
return debug.debug("Load Sales", Map.of(), ODataQuery.none())
	.map(context -> Objects.requireNonNull(context.id()))
	.flatMap(id -> debug.stepOver(id, ODataQuery.none())
		.then(debug.stepOver(id, ODataQuery.none()))
		.then(debug.finish(id)));
  • Constructor Details

    • ProcessDebugService

      public ProcessDebugService(Tm1Session session)
      A service sending its requests through session.
      Parameters:
      session - the session
  • Method Details

    • debug

      @Tm1Endpoint("Action Process/Debug") public reactor.core.publisher.Mono<ProcessDebugContext> debug(String process, Map<String,?> parameters, ODataQuery query)
      tm1.Debug: starts debugging a process.
      Parameters:
      process - the process's name
      parameters - its parameters, by name, in order; may be empty
      query - what to expand of the context
      Returns:
      the debug context, with its ID
    • debugging

      @Tm1Endpoint("Action Process/Debug") @Tm1Endpoint("EntitySet ProcessDebugContexts") public <R> reactor.core.publisher.Flux<R> debugging(String process, Map<String,?> parameters, Function<ProcessDebugContext, org.reactivestreams.Publisher<R>> work)
      Debugs a process for the length of work, then finishes the run: when the work completes, fails or is cancelled. TM1 (11.8) refuses to delete a debug context, so finishing it is how the run ends.
      Type Parameters:
      R - what the work gives
      Parameters:
      process - the process's name
      parameters - its parameters, by name, in order; may be empty
      work - what to do with the context: set breakpoints, step, read variables
      Returns:
      what the work gives, with the run finished at the end
    • list

      @Tm1Endpoint("EntitySet ProcessDebugContexts") public reactor.core.publisher.Flux<ProcessDebugContext> list(ODataQuery query)
      GET ProcessDebugContexts, streamed. TM1 (11.8) lists none, though each reads by ID with get(String, ODataQuery).
      Parameters:
      query - what to select and expand
      Returns:
      the contexts
    • get

      @Tm1Endpoint("EntitySet ProcessDebugContexts") public reactor.core.publisher.Mono<ProcessDebugContext> get(String id, ODataQuery query)
      GET ProcessDebugContexts('id').
      Parameters:
      id - the context's ID
      query - what to expand
      Returns:
      the context, or a Tm1NotFoundException if there's none
    • finish

      @Tm1Endpoint("Action ProcessDebugContext/Continue") @Tm1Endpoint("Navigation ProcessDebugContext/Breakpoints") public reactor.core.publisher.Mono<ProcessDebugContext> finish(String id)
      Runs a debug run to its end: removes its breakpoints, then resumes until it's Complete. TM1 (11.8) refuses to delete a debug context, so finishing the run is how to end one; the context stays readable, complete, until the session ends.
      Parameters:
      id - the context's ID
      Returns:
      the context, complete, with the run's Result
    • resume

      @Tm1Endpoint("Action ProcessDebugContext/Continue") public reactor.core.publisher.Mono<ProcessDebugContext> resume(String id, ODataQuery query)
      tm1.Continue: runs to the next breakpoint, or to the end.
      Parameters:
      id - the context's ID
      query - what to expand of the context
      Returns:
      the context, paused or complete
    • stepIn

      @Tm1Endpoint("Action ProcessDebugContext/StepIn") public reactor.core.publisher.Mono<ProcessDebugContext> stepIn(String id, ODataQuery query)
      tm1.StepIn: runs one line, into a process it calls.
      Parameters:
      id - the context's ID
      query - what to expand of the context
      Returns:
      the context after the step
    • stepOut

      @Tm1Endpoint("Action ProcessDebugContext/StepOut") public reactor.core.publisher.Mono<ProcessDebugContext> stepOut(String id, ODataQuery query)
      tm1.StepOut: runs to the end of the current procedure or called process.
      Parameters:
      id - the context's ID
      query - what to expand of the context
      Returns:
      the context after the step
    • stepOver

      @Tm1Endpoint("Action ProcessDebugContext/StepOver") public reactor.core.publisher.Mono<ProcessDebugContext> stepOver(String id, ODataQuery query)
      tm1.StepOver: runs one line, over any process it calls.
      Parameters:
      id - the context's ID
      query - what to expand of the context
      Returns:
      the context after the step
    • breakpoints

      @Tm1Endpoint("Navigation ProcessDebugContext/Breakpoints") public reactor.core.publisher.Flux<ProcessDebugContextBreakpoint> breakpoints(String id, ODataQuery query)
      GET …/Breakpoints, streamed, each as its kind: line, data or lock.
      Parameters:
      id - the context's ID
      query - what to select
      Returns:
      the breakpoints
    • addBreakpoint

      @Tm1Endpoint("Navigation ProcessDebugContext/Breakpoints") public reactor.core.publisher.Mono<ProcessDebugContextBreakpoint> addBreakpoint(String id, ProcessDebugContextBreakpointPatch breakpoint)
      POST …/Breakpoints: adds a breakpoint, its kind given by the patch (ProcessDebugContextLineBreakpointPatch, …Data…, …Lock…).

      The caller chooses the breakpoint's ID: TM1 (11.8) stores one sent without an ID as -1, which it then refuses in a path, so it can't be changed or removed, and a second one without an ID conflicts (409).

      Parameters:
      id - the context's ID
      breakpoint - the breakpoint, with an ID of 0 or more, unique in the context
      Returns:
      the breakpoint as created
      Throws:
      IllegalArgumentException - if the patch has no ID of 0 or more
    • updateBreakpoint

      @Tm1Endpoint("Navigation ProcessDebugContext/Breakpoints") public reactor.core.publisher.Mono<Void> updateBreakpoint(String id, int breakpoint, ProcessDebugContextBreakpointPatch patch)
      PATCH …/Breakpoints(n): changes a breakpoint, such as enabling or disabling it.
      Parameters:
      id - the context's ID
      breakpoint - the breakpoint's ID
      patch - the changes, of the breakpoint's kind
      Returns:
      completes when it's changed
    • removeBreakpoint

      @Tm1Endpoint("Navigation ProcessDebugContext/Breakpoints") public reactor.core.publisher.Mono<Void> removeBreakpoint(String id, int breakpoint)
      DELETE …/Breakpoints(n).
      Parameters:
      id - the context's ID
      breakpoint - the breakpoint's ID
      Returns:
      completes when it's removed
    • currentBreakpoint

      @Tm1Endpoint("Navigation ProcessDebugContext/CurrentBreakpoint") public reactor.core.publisher.Mono<ProcessDebugContextBreakpoint> currentBreakpoint(String id, ODataQuery query)
      GET …/CurrentBreakpoint: the breakpoint the run is paused at.
      Parameters:
      id - the context's ID
      query - what to select
      Returns:
      the breakpoint, or empty if it isn't paused at one
    • callStack

      @Tm1Endpoint("Navigation ProcessDebugContext/CallStack") public reactor.core.publisher.Flux<ProcessDebugContextStackFrame> callStack(String id, ODataQuery query)
      GET …/CallStack, streamed: where the run is, innermost frame first.
      Parameters:
      id - the context's ID
      query - what to select and expand, such as Variables
      Returns:
      the stack frames
    • variables

      @Tm1Endpoint("Navigation ProcessDebugContextStackFrame/Variables") public reactor.core.publisher.Flux<ProcessDebugContextVariable> variables(String id, String frame, ODataQuery query)
      GET …/CallStack('frame')/Variables, streamed: the frame's variables and their values. TM1 (11.8) lists TurboIntegrator's own variables (NVALUE, DATASOURCE…), not the process's local ones.
      Parameters:
      id - the context's ID
      frame - the frame's ID
      query - what to select and filter
      Returns:
      the variables
    • frameProcess

      @Tm1Endpoint("Navigation ProcessDebugContextStackFrame/Process") public reactor.core.publisher.Mono<Process> frameProcess(String id, String frame, ODataQuery query)
      GET …/CallStack('frame')/Process: the process the frame runs.
      Parameters:
      id - the context's ID
      frame - the frame's ID
      query - what to select
      Returns:
      the process
    • process

      @Tm1Endpoint("Navigation ProcessDebugContext/Process") public reactor.core.publisher.Mono<Process> process(String id, ODataQuery query)
      GET …/Process: the process being debugged.
      Parameters:
      id - the context's ID
      query - what to select
      Returns:
      the process
    • thread

      @Tm1Endpoint("Navigation ProcessDebugContext/Thread") public reactor.core.publisher.Mono<Thread> thread(String id, ODataQuery query)
      GET …/Thread: the server thread running the debug run.
      Parameters:
      id - the context's ID
      query - what to select
      Returns:
      the thread