Splunk SDK服务是否需要Disconnect或Close

Does Splunk SDK service require Disconnect or Close

我正在尝试从 Splunk java SDK 进行 Splunk 搜索。这是工作代码。我的问题是我是否需要在每次搜索后关闭 service。如果是,如何关闭它?否则,我可以在每项服务中创建的工作岗位数量是否有上限?

ServiceArgs serviceArgs = new ServiceArgs();
serviceArgs.setUsername(splunkUserName);
serviceArgs.setHost(splunkHostname);
serviceArgs.setPort(Integer.parseInt(splunkPort));
serviceArgs.setPassword(splunkPassword));
HttpService.setSslSecurityProtocol(SSLSecurityProtocol.TLSv1_2);
Service service = Service.connect(serviceArgs);
JobArgs jobArgs = new JobArgs();
jobArgs.setExecutionMode(JobArgs.ExecutionMode.NORMAL);
jobArgs.setEarliestTime(startDate);
jobArgs.setLatestTime(endData);
jobArgs.setMaximumCount(maxResultCount);
Job job = service.getJobs().create(query,jobArgs);

My question is do I need to close service after each search

我会说这取决于你的需求,我不太了解你的应用程序。

If yes, how to close it?

无论如何,您可以:com.splunk.Service 有一个 logout 方法:

/**
 * Forgets the current session token.
 *
 * @return The current {@code Service} instance.
 */
public Service logout() {
    this.token = null;
    this.removeAllCookies();
    return this;
}

Else is there a maximum number of jobs that I can create in each service?

我会说是的,它应该与用户通过 UI.

进行搜索时遇到的限制相同