Class VManagerSessionsClient
/rest/sessions/list endpoint
used to obtain run-state counts for a list of session names.
The endpoint expects a POST with JSON body of the form:
{
"filter": { "@c":".InFilter", "attName":"session_name", "operand":"IN", "values":[...] },
"grouping": ["region_identifier"],
"projection": { "type":"SELECTION_ONLY",
"selection":[ "region_identifier","failed_runs","passed_runs",
"running","waiting","other_runs","number_of_entities" ] }
}
The response is a JSON array of objects, one per region group, with the
fields above. fetchAggregated(java.lang.String, java.util.Collection<java.lang.String>, com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials) sums the run-state counts across
all returned rows.
For internal vManager servers with self-signed certs we trust all certificates and hostnames (consistent with the rest of the plugin).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classAggregated "Run Anomalies" counts for a set of sessions, used by the build-level Run Anomalies chart.static final classAggregated run-state totals for a set of sessions. -
Method Summary
Modifier and TypeMethodDescriptionfetchAggregated(String baseUrl, Collection<String> sessionNames, com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials creds) Posts the sessions list query and returns the summed counts across all region groups returned by the server.fetchAggregated(String baseUrl, Collection<String> sessionNames, com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials creds, TaskListener listener) Same asfetchAggregated(String, Collection, StandardUsernamePasswordCredentials)but logs the URL, headers and payload tolistener(if non-null).fetchRunAnomalies(String baseUrl, Collection<String> sessionNames, com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials creds, TaskListener listener) Two-step fetch for the build-level Run Anomalies chart: POST/rest/sessions/listwith.InFilteronsession_nameand projection[name, id, total_runs_in_session]to translate session names → ids and sumtotal_runs_in_sessionacross them. POST/rest/data-mining/get-sessions-exceptions-aggregated-countswith the resulting array of ids as the raw JSON body; the response is a single object with the*_critical_ex_count_vmgr_latestand*_unknown_ex_count_vmgr_latestfields for each of the four metrics. Returnsnullif there are no sessions or no ids could be resolved (caller should skip storing the build action in that case).fetchSessionAttributeSums(String baseUrl, Collection<String> sessionNames, Collection<String> attributeIds, com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials creds) Posts a sessions-list query selecting an arbitrary set of attribute ids and returns the summed numeric value for each attribute across all returned rows.fetchSessionAttributeSums(String baseUrl, Collection<String> sessionNames, Collection<String> attributeIds, com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials creds, TaskListener listener) Same asfetchSessionAttributeSums(String, Collection, Collection, StandardUsernamePasswordCredentials)but logs the URL, headers and payload tolistener(if non-null).fetchSessionNamesByIds(String baseUrl, Collection<String> ids, com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials creds, TaskListener listener) Translates a list of session ids (e.g.fetchSessionTatWarnings(String baseUrl, Collection<String> sessionNames, com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials creds, TaskListener listener) Posts a sessions-list query for the given session names and inspects three vManager attributes per session —total_runs_in_session,real_max_runs_in_parallel_vmgrandmax_runs_in_parallel— to detect sessions whose configured parallelism could not be met at runtime.
-
Method Details
-
fetchSessionNamesByIds
public static List<String> fetchSessionNamesByIds(String baseUrl, Collection<String> ids, com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials creds, TaskListener listener) throws IOException Translates a list of session ids (e.g. lines of a.session_launch.outputfile produced by the vManager Jenkins Plugin in launch mode) into a list of session names by POSTing to/rest/sessions/listwith an.InFilteroveridand aSELECTION_ONLYprojection ofname.Trace lines mirror the rest of the plugin: the outbound URL / headers / payload and the response summary go to the build console when
BuildLog.isVerbose()is on, and the same information is mirrored to Jenkins' system log atLevel.FINE.- Returns:
- the session names returned by the server (empty if the input
is empty, the base URL is blank, or the response shape is
unexpected). Never
null. - Throws:
IOException
-
fetchAggregated
public static VManagerSessionsClient.SessionAggregates fetchAggregated(String baseUrl, Collection<String> sessionNames, com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials creds) throws IOException Posts the sessions list query and returns the summed counts across all region groups returned by the server.- Parameters:
baseUrl- vManager server base URL (e.g.https://host:port/vmgr/vapi)sessionNames- one or more session names;null/empty returns zeros.creds- credentials for HTTP Basic auth; may benull(no auth header).- Throws:
IOException
-
fetchAggregated
public static VManagerSessionsClient.SessionAggregates fetchAggregated(String baseUrl, Collection<String> sessionNames, com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials creds, TaskListener listener) throws IOException Same asfetchAggregated(String, Collection, StandardUsernamePasswordCredentials)but logs the URL, headers and payload tolistener(if non-null).- Throws:
IOException
-
fetchSessionAttributeSums
public static Map<String,Double> fetchSessionAttributeSums(String baseUrl, Collection<String> sessionNames, Collection<String> attributeIds, com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials creds) throws IOException Posts a sessions-list query selecting an arbitrary set of attribute ids and returns the summed numeric value for each attribute across all returned rows.- Parameters:
baseUrl- vManager server base URL.sessionNames- one or more session names;null/empty returns an empty map.attributeIds- attribute ids to project (e.g."passed_runs","MyCustomAtt");null/empty returns an empty map.creds- credentials for HTTP Basic auth; may benull.- Returns:
- map of attribute id → summed value (only numeric fields are summed; non-numeric
attributes are skipped). Never
null. - Throws:
IOException
-
fetchSessionAttributeSums
public static Map<String,Double> fetchSessionAttributeSums(String baseUrl, Collection<String> sessionNames, Collection<String> attributeIds, com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials creds, TaskListener listener) throws IOException Same asfetchSessionAttributeSums(String, Collection, Collection, StandardUsernamePasswordCredentials)but logs the URL, headers and payload tolistener(if non-null).- Throws:
IOException
-
fetchSessionTatWarnings
public static Map<String,String> fetchSessionTatWarnings(String baseUrl, Collection<String> sessionNames, com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials creds, TaskListener listener) throws IOException Posts a sessions-list query for the given session names and inspects three vManager attributes per session —total_runs_in_session,real_max_runs_in_parallel_vmgrandmax_runs_in_parallel— to detect sessions whose configured parallelism could not be met at runtime. Returns a map ofsessionName→ warning text for every such session; sessions that do not match the condition are absent from the returned map.The condition for adding a warning is:
total_runs_in_session > real_max_runs_in_parallel_vmgr AND max_runs_in_parallel > 1.25 * real_max_runs_in_parallel_vmgr
- Throws:
IOException
-
fetchRunAnomalies
public static VManagerSessionsClient.RunAnomalies fetchRunAnomalies(String baseUrl, Collection<String> sessionNames, com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials creds, TaskListener listener) throws IOException Two-step fetch for the build-level Run Anomalies chart:- POST
/rest/sessions/listwith.InFilteronsession_nameand projection[name, id, total_runs_in_session]to translate session names → ids and sumtotal_runs_in_sessionacross them. - POST
/rest/data-mining/get-sessions-exceptions-aggregated-countswith the resulting array of ids as the raw JSON body; the response is a single object with the*_critical_ex_count_vmgr_latestand*_unknown_ex_count_vmgr_latestfields for each of the four metrics.
nullif there are no sessions or no ids could be resolved (caller should skip storing the build action in that case).- Throws:
IOException
- POST
-