Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to download logs for individual jobs using java client

Hi,

I would like to download logs for all the jobs run in a single day (logs for all the individual steps for all the jobs). I have written the code using java client api calls.

But here is the problem

The call result.getlogs() for each individual job result hangs and jvm crashes or socket drops the connection when the log for a step is like 70,000 lines. (since each individual line in the log is an object this might be causing the issue).

is there any other better way to download the logs (either entirely in text format or in blocks using pagination)

Any help is appreciated.

Thanks,
Deepak

0 votes



3 answers

Permanent link
Hi,

I would like to download logs for all the jobs run in a single day (logs for all the individual steps for all the jobs). I have written the code using java client api calls.

But here is the problem

The call result.getlogs()
for each individual job result hangs and jvm crashes or socket drops the connection when the log for a step is like 70,000 lines. (since each individual line in the log is an object this might be causing the issue).

is there any other better way to download the logs (either entirely in text format or in blocks using pagination)

Any help is appreciated.

Thanks,
Deepak

Hi,

You should take a look at the findFiltered method.


import com.buildforge.services.client.api.APIClientConnection;

import com.buildforge.services.client.dbo.Build;
import com.buildforge.services.client.dbo.Log;
import com.buildforge.services.client.dbo.Project;
import com.buildforge.services.client.dbo.Result;

import com.buildforge.services.common.db.ColumnRef;
import com.buildforge.services.common.db.QueryFilter;
import com.buildforge.services.common.db.QueryResponse;
import com.buildforge.services.common.db.SqlCond;
import com.buildforge.services.common.db.SqlLimit;

import com.buildforge.services.common.api.APIConstants;

import java.util.List;

/**
* This is an example of using the services layer to
* retrieve log data using findFiltered.
*/
public class GetLogFindFiltered {

private static final String TEST_PROJECT_NAME = "P_1";

/**
* Since this is an example, the main method will do all the
* logic.
*
* @param args The command line arguments
* @throws Exception Any exceptions
*/
public static void main(String[] args) throws Exception {
APIClientConnection conn = new APIClientConnection("localhost", 3966);
conn.authUser("root", "root");

Project project = Project.findByName(conn, TEST_PROJECT_NAME);
if (project == null) {
throw new Exception("Could not find project named \"" + TEST_PROJECT_NAME + "\".");
}

List<Build> builds = Build.findByProjectUuid(conn, project.getUuid());
if (builds.size() <= 0) {
throw new Exception("Could not find any builds for project \"" + TEST_PROJECT_NAME + "\".");
}

Build build = builds.get(0);
List<Result> results = build.getResults();
if (results.size() <= 0) {
throw new Exception("Did not find any results for build with tag of \"" + build.getTag() + "\".");
}

Result result = results.get(0);

QueryFilter filter = new QueryFilter();
int offSet = 0;
int count = 5;
filter.setLimit(new SqlLimit(offSet, count));
filter.setWhere(SqlCond.eq(new ColumnRef(APIConstants.KEY_LOG_RESULT_UUID), result.getUuid()));
filter.setColumnList(new ColumnRef[] {new ColumnRef(APIConstants.KEY_LOG_TYPE), new ColumnRef(APIConstants.KEY_LOG_MESSAGE)});
QueryResponse response = Log.findFiltered(conn, filter);
List<Object[]> rowData = response.getRowData();
for (Object[] data : rowData) {
System.out.println(data[0] + " " + data[1]);
}

conn.logout();
conn.close();
}

}


Brent Ulbricht
RTC Build Lead

0 votes


Permanent link
Thanks, Will look into it

0 votes


Permanent link
Thanks, Will look into it


just use order by sequence to get the logs in correct order

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details

Question asked: Aug 12 '11, 2:24 p.m.

Question was seen: 5,368 times

Last updated: Aug 12 '11, 2:24 p.m.

Confirmation Cancel Confirm