blob: 05db1264171bf165fdfe302151d6f19d9d4d7f69 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/**
* Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Simon McDuff - initial API and implementation
* Eike Stepper - maintenance
*/
package org.eclipse.emf.cdo.internal.server.protocol;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDTemp;
import org.eclipse.emf.cdo.common.io.CDODataInput;
import org.eclipse.emf.cdo.common.io.CDODataOutput;
import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.internal.server.XATransactionCommitContext;
import org.eclipse.emf.cdo.internal.server.XATransactionCommitContext.CommitState;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
import org.eclipse.net4j.util.om.monitor.OMMonitor;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import java.util.concurrent.ExecutionException;
/**
* @author Simon McDuff
*/
public class CommitTransactionPhase2Indication extends CommitTransactionIndication
{
private static final ContextTracer PROTOCOL = new ContextTracer(OM.DEBUG_PROTOCOL,
CommitTransactionPhase2Indication.class);
public CommitTransactionPhase2Indication(CDOServerProtocol protocol)
{
super(protocol, CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION_PHASE2);
}
@Override
protected void indicating(CDODataInput in, OMMonitor monitor) throws Exception
{
indicatingTransaction(in);
XATransactionCommitContext xaContextContext = (XATransactionCommitContext)commitContext;
int size = in.readInt();
if (PROTOCOL.isEnabled())
{
PROTOCOL.format("Receiving {0} mapping informations", size);
}
for (int i = 0; i < size; i++)
{
CDOIDTemp oldID = (CDOIDTemp)in.readCDOID();
CDOID newID = in.readCDOID();
xaContextContext.addIDMapping(oldID, newID);
}
// Mapping information from others CDOTransactions was added. Notify the commit process to continue.
xaContextContext.getState().set(CommitState.APPLY_ID_MAPPING_DONE);
}
@Override
protected void responding(CDODataOutput out, OMMonitor monitor) throws Exception
{
String exceptionMessage = null;
try
{
// Return to the client only when the process is ready to commit
getRepository().getCommitManager().waitForTermination(commitContext.getTransaction());
}
catch (InterruptedException ex)
{
exceptionMessage = ex.getMessage();
}
catch (ExecutionException ex)
{
exceptionMessage = ex.getMessage();
}
if (exceptionMessage == null)
{
exceptionMessage = commitContext.getRollbackMessage();
}
respondingException(out, exceptionMessage);
}
@Override
protected void indicatingTransaction(CDODataInput in) throws Exception
{
int viewID = in.readInt();
commitContext = getRepository().getCommitManager().get(getTransaction(viewID));
}
}
|