~pbeaman/akiban-persistit/dynamic-volumes

« back to all changes in this revision

Viewing changes to src/main/java/com/persistit/Tree.java

  • Committer: Peter Beaman
  • Date: 2013-03-10 22:39:09 UTC
  • Revision ID: pbeaman@akiban.com-20130310223909-gj7pgwnovu63f87t
Modifications per review comments

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
 * side-effect, the physical storage for a <code>Tree</code> is not deallocated
47
47
 * until there are no remaining active transactions that started before the
48
48
 * commit timestamp of the current transaction. Concurrent transactions that
49
 
 * attempt to create or remove the same
50
 
 * <code>Tree<code> instance are subject to a
51
 
 * a write-write dependency (see {@link Transaction}); all but one such transaction must roll back.
 
49
 * attempt to create or remove the same <code>Tree</code> instance are subject
 
50
 * to a a write-write dependency (see {@link Transaction}); all but one such
 
51
 * transaction must roll back.
52
52
 * </p>
53
53
 * <p>
54
54
 * <code>Tree</code> instances are created by
141
141
        }
142
142
    }
143
143
 
 
144
    /**
 
145
     * Unchecked wrapper for PersistitException thrown while trying to acquire a
 
146
     * TreeVersion.
 
147
     */
 
148
    public static class TreeVersionException extends RuntimeException {
 
149
        private static final long serialVersionUID = -6372589972106489591L;
 
150
 
 
151
        TreeVersionException(final Exception e) {
 
152
            super(e);
 
153
        }
 
154
    }
 
155
 
144
156
    Tree(final Persistit persistit, final Volume volume, final String name) {
145
157
        super(persistit);
146
158
        final int serializedLength = name.getBytes().length;
153
165
        _timelyResource = new TimelyResource<TreeVersion>(persistit);
154
166
    }
155
167
 
156
 
    private TreeVersion version() {
 
168
    TreeVersion version() {
157
169
        try {
158
170
            return _timelyResource.getVersion(_creator);
159
 
        } catch (final Exception e) {
160
 
            throw new RuntimeException(e); // TODO
 
171
        } catch (final PersistitException e) {
 
172
            throw new TreeVersionException(e);
161
173
        }
162
174
    }
163
175
 
165
177
        return _timelyResource.isEmpty();
166
178
    }
167
179
 
168
 
    boolean isTransactionPrivate() throws TimeoutException, PersistitInterruptedException {
169
 
        return _timelyResource.isTransactionPrivate();
 
180
    boolean isLive() throws TimeoutException, PersistitInterruptedException {
 
181
        return isValid() && !isDeleted();
 
182
    }
 
183
 
 
184
    boolean isTransactionPrivate(final boolean byStep) throws TimeoutException, PersistitInterruptedException {
 
185
        return _timelyResource.isTransactionPrivate(byStep);
170
186
    }
171
187
 
172
188
    boolean hasVersion(final long versionHandle) throws TimeoutException, PersistitInterruptedException {