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

Synchronization problem with IBuildEngine

We are using the RTC Plain Client API to automatically generate Build Definitions (BD). In order to associate them to Build Engines (BE), we fetch the BE by name, add the BD and save it.
The exact snippet is as seen below:
    // Build Definition does not know which Build Engines are serving it. Instead, the correct Build Engine should be
    // fetched and the Build Definition added to it.
IBuildEngine engine = ClientFactory.getTeamBuildClient(teamRepository).getBuildEngine(buildEngineName, new NullProgressMonitor());
IBuildEngine engineCopy = (IBuildEngine) engine.getWorkingCopy();
engineCopy.getSupportedBuildDefinitions().add(definition);
engineCopy = ClientFactory.getTeamBuildClient(teamRepository).save(engineCopy, new NullProgressMonitor());
It works fine for a single or sequential executions. However, we run into trouble when executing this snippet in parallel:
    com.ibm.team.repository.common.TeamRepositoryException: CRJAZ0223I The following item has been changed by another operation:
    Input: com.ibm.team.build.internal.common.model.impl.BuildEngineImpl@32c5b5bf (stateId: [UUID _wRzqQFL9Eeavz4w4jk_eAA], itemId: [UUID _xw0rMNWkEeWkosAiU6sYog], origin: <unset>, immutable: true) (contextId: [UUID _CWw8QHUYEeOxidpm0Kiw-w], modified: 2016-07-26 08:54:10.148, workingCopy: <unset>) (mergePredecessor: null, workingCopyPredecessor: <unset>, workingCopyMergePredecessor: <unset>, predecessor: [UUID _uk6DkFL9Eeavz4w4jk_eAA]) (supportsCancellation: false, engineContactInterval: 0, useTeamScheduler: false, id: CI_Engine_Master_04, active: true, description: )
Current: com.ibm.team.build.internal.common.model.impl.BuildEngineImpl@1339f1c1 (stateId: [UUID _vuQRQFL9Eeavz4w4jk_eAA], itemId: [UUID _xw0rMNWkEeWkosAiU6sYog], origin: <unset>, immutable: true) (contextId: [UUID _CWw8QHUYEeOxidpm0Kiw-w], modified: 2016-07-26 08:54:06.42, workingCopy: <unset>) (mergePredecessor: null, workingCopyPredecessor: <unset>, workingCopyMergePredecessor: <unset>, predecessor: [UUID _uk6DkFL9Eeavz4w4jk_eAA]) (supportsCancellation: false, engineContactInterval: 0, useTeamScheduler: false, id: CI_Engine_Master_04, active: true, description: )
The snippet is executed in separate JVMs, so no Java synchronization feature seems to help.
Would anyone have a proposal to solve the issue?

The only one I can think of is to retry (n-bounded loop) fetching a new (hopefully updated) working copy and save again. Still, that sounds quite a workaround rather than a solution...

0 votes



One answer

Permanent link
But that is the only choice.. the thing you are trying to update has changed..and the data model has some of the data in memory, and it must be refreshed..

you see the same behavior with all the data items

1 vote

Comments

I know that for Work Items there is an IWorkItemWorkingCopyManager available to refresh the state of the local copy. But I cannot find the equivalent for the Build Engine. Is there any?

never seen one.

I don't think there is one... perhaps try wrapping that code in a try/catch block (for a StaleDataException, which I think is what this is in this case) and re-try x number of times.

I think you have to get a fresh working copy.

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
× 10,938

Question asked: Aug 08 '16, 9:13 a.m.

Question was seen: 3,310 times

Last updated: Aug 08 '16, 3:31 p.m.

Confirmation Cancel Confirm