It's all about the answers!

Ask a question

How to download logs for individual jobs using java client


deepak devanapelly (1121) | asked Aug 12 '11, 2:24 p.m.
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

3 answers



permanent link
Brent Ulbricht (2.5k11) | answered Aug 14 '11, 2:23 p.m.
JAZZ DEVELOPER
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

permanent link
deepak devanapelly (1121) | answered Aug 15 '11, 1:26 p.m.
Thanks, Will look into it

permanent link
deepak devanapelly (1121) | answered Sep 13 '11, 7:41 p.m.
Thanks, Will look into it


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

Your answer


Register or 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.