Class ThreadService

java.lang.Object
io.skipcheck.tm1.client.service.security.ThreadService

public final class ThreadService extends Object
Server threads: what the server is doing right now (/Threads), and cancelling an operation, which is how to stop a running process: cancelling a client's request doesn't.

See what the server is busy with:

// What the server is doing now: every thread that isn't idle
return tm1.threads()
	.list(ODataQuery.none()
		.select(Thread.ID, Thread.NAME, Thread.FUNCTION, Thread.ELAPSED_TIME)
		.filter(Thread.STATE.ne("Idle")))
	.map(thread -> thread.name() + ": " + thread.function() + " for " + thread.elapsedTime());

Stop a running process by cancelling its thread, found by its request:

// A process run through REST shows as its request, not by its name
return tm1.threads()
	.list(ODataQuery.none()
		.select(Thread.ID)
		.filter(Filter.contains(Thread.FUNCTION, "Processes('Sales.Load')/tm1.ExecuteWithReturn")))
	.flatMap(thread -> tm1.threads().cancel(thread.id()))
	.then();
  • Constructor Details

    • ThreadService

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

    • list

      @Tm1Endpoint("EntitySet Threads") public reactor.core.publisher.Flux<Thread> list(ODataQuery query)
      GET Threads, streamed. A process run through REST shows as its request: Function is POST /api/v1/Processes('name')/tm1.ExecuteWithReturn, and TM1 (11.8) leaves ObjectName empty.
      Parameters:
      query - what to select, filter (such as on Function) and order
      Returns:
      the threads
    • get

      @Tm1Endpoint("EntitySet Threads") public reactor.core.publisher.Mono<Thread> get(long id, ODataQuery query)
      GET Threads(id).
      Parameters:
      id - the thread's ID
      query - what to select and expand
      Returns:
      the thread, or a Tm1NotFoundException if it's gone
    • session

      @Tm1Endpoint("Navigation Thread/Session") public reactor.core.publisher.Mono<Session> session(long id, ODataQuery query)
      GET Threads(id)/Session.
      Parameters:
      id - the thread's ID
      query - what to select
      Returns:
      the thread's session
    • cancel

      @Tm1Endpoint("Action Thread/CancelOperation") public reactor.core.publisher.Mono<Void> cancel(long id)
      tm1.CancelOperation: asks the thread to stop what it's doing, such as a running process. TM1 (11.8) then fails the process's ExecuteWithReturn request with 500, TM1UserException: Cancel (code 174), rather than reporting it Aborted. Needs schema 10.2.2.1.
      Parameters:
      id - the thread's ID
      Returns:
      completes when the request is made; the thread stops soon after