ThreadService
import io.skipcheck.tm1.client.service.security.ThreadService; 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();
Members
ThreadService constructor | A service sending its requests through session. |
list | GET Threads, streamed. |
get | GET Threads(id). |
session | GET Threads(id)/Session. |
cancel | Asks the thread to stop what it's doing, such as a running process. |
ThreadService
constructorThreadService(Tm1Session session) A service sending its requests through session.
Parameters
session- the session
list
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
TM1 REST EntitySet Threads
get
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
Tm1NotFoundExceptionif it's gone
TM1 REST EntitySet Threads
session
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
TM1 REST Navigation Thread/Session
cancel
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
TM1 REST Action Thread/CancelOperation
Also in the Javadoc.