1 | /* |
2 | * Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0, |
3 | * and the EPL 1.0 (http://h2database.com/html/license.html). |
4 | * Initial Developer: H2 Group |
5 | */ |
6 | package org.h2.store; |
7 | |
8 | |
9 | /** |
10 | * The session state contains information about when was the last commit of a |
11 | * session. It is only used during recovery. |
12 | */ |
13 | class SessionState { |
14 | |
15 | /** |
16 | * The session id |
17 | */ |
18 | public int sessionId; |
19 | |
20 | /** |
21 | * The last log id where a commit for this session is found. |
22 | */ |
23 | public int lastCommitLog; |
24 | |
25 | /** |
26 | * The position where a commit for this session is found. |
27 | */ |
28 | public int lastCommitPos; |
29 | |
30 | /** |
31 | * The in-doubt transaction if there is one. |
32 | */ |
33 | public PageStoreInDoubtTransaction inDoubtTransaction; |
34 | |
35 | /** |
36 | * Check if this session state is already committed at this point. |
37 | * |
38 | * @param logId the log id |
39 | * @param pos the position in the log |
40 | * @return true if it is committed |
41 | */ |
42 | public boolean isCommitted(int logId, int pos) { |
43 | if (logId != lastCommitLog) { |
44 | return lastCommitLog > logId; |
45 | } |
46 | return lastCommitPos >= pos; |
47 | } |
48 | |
49 | @Override |
50 | public String toString() { |
51 | return "sessionId:" + sessionId + " log:" + lastCommitLog + |
52 | " pos:" + lastCommitPos + " inDoubt:" + inDoubtTransaction; |
53 | } |
54 | } |