Class ThreadService
java.lang.Object
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();
-
Constructor Summary
ConstructorsConstructorDescriptionThreadService(Tm1Session session) A service sending its requests throughsession. -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Void> cancel(long id) tm1.CancelOperation: asks the thread to stop what it's doing, such as a running process.reactor.core.publisher.Mono<Thread> get(long id, ODataQuery query) GET Threads(id).reactor.core.publisher.Flux<Thread> list(ODataQuery query) GET Threads, streamed.reactor.core.publisher.Mono<Session> session(long id, ODataQuery query) GET Threads(id)/Session.
-
Constructor Details
-
ThreadService
A service sending its requests throughsession.- Parameters:
session- the session
-
-
Method Details
-
list
GET Threads, streamed. A process run through REST shows as its request:FunctionisPOST /api/v1/Processes('name')/tm1.ExecuteWithReturn, and TM1 (11.8) leavesObjectNameempty.- Parameters:
query- what to select, filter (such as onFunction) 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 IDquery- what to select and expand- Returns:
- the thread, or a
Tm1NotFoundExceptionif 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 IDquery- 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'sExecuteWithReturnrequest with 500,TM1UserException: Cancel(code 174), rather than reporting itAborted. Needs schema 10.2.2.1.- Parameters:
id- the thread's ID- Returns:
- completes when the request is made; the thread stops soon after
-