blob: 043a8b3b7871370be4f2a80c814afddc77cca54c (
plain)
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
// **********************************************************************
//
// Copyright (c) 2001
// Mutable Realms, Inc.
// Huntsville, AL, USA
//
// All Rights Reserved
//
// **********************************************************************
package Freeze;
class DBTransactionI extends Ice.LocalObjectImpl implements DBTransaction
{
public synchronized void
commit()
{
if(_tid == null)
{
String s = _errorPrefix + "transaction has already been committed or aborted";
DBException ex = new DBException();
ex.message = s;
throw ex;
}
if(_trace >= 2)
{
_communicator.getLogger().trace("DB", "committing transaction for environment \"" + _name + "\"");
}
try
{
_tid.commit(0);
}
catch(com.sleepycat.db.DbDeadlockException e)
{
DBDeadlockException ex = new DBDeadlockException();
ex.initCause(e);
ex.message = _errorPrefix + "DbTxn.commit: " + e.getMessage();
throw ex;
}
catch(com.sleepycat.db.DbException e)
{
DBException ex = new DBException();
ex.initCause(e);
ex.message = _errorPrefix + "DbTxn.commit: " + e.getMessage();
throw ex;
}
_tid = null;
}
public synchronized void
abort()
{
if(_tid == null)
{
String s = _errorPrefix + "transaction has already been committed or aborted";
DBException ex = new DBException();
ex.message = s;
throw ex;
}
if(_trace >= 2)
{
_communicator.getLogger().trace("DB", "aborting transaction for environment \"" + _name +
"\" due to deadlock");
}
try
{
_tid.abort();
}
catch(com.sleepycat.db.DbException e)
{
DBException ex = new DBException();
ex.initCause(e);
ex.message = _errorPrefix + "DbTxn.abort: " + e.getMessage();
throw ex;
}
_tid = null;
}
DBTransactionI(Ice.Communicator communicator, com.sleepycat.db.DbEnv dbEnv, String name)
{
_communicator = communicator;
_name = name;
_errorPrefix = "Freeze::DBTransaction(\"" + _name + "\"): ";
_trace = _communicator.getProperties().getPropertyAsInt("Freeze.Trace.DB");
if(_trace >= 2)
{
_communicator.getLogger().trace("DB", "starting transaction for environment \"" + _name + "\"");
}
try
{
_tid = dbEnv.txn_begin(null, 0);
}
catch(com.sleepycat.db.DbException e)
{
DBException ex = new DBException();
ex.initCause(e);
ex.message = _errorPrefix + "DbEnv.txn_begin: " + e.getMessage();
throw ex;
}
}
private Ice.Communicator _communicator;
private int _trace = 0;
private com.sleepycat.db.DbTxn _tid;
private String _name;
private String _errorPrefix;
}
|