@Override public void shutdown() throws IOException { close(null, mPageDb.isDurable()); }
@Override public void shutdown() throws IOException { close(null, mPageDb.isDurable()); }
@Override public void shutdown() throws IOException { close(null, mPageDb.isDurable()); }
@Override public Snapshot beginSnapshot() throws IOException { if (!(mPageDb.isDurable())) { throw new UnsupportedOperationException("Snapshot only allowed for durable databases"); } checkClosed(); _DurablePageDb pageDb = (_DurablePageDb) mPageDb; return pageDb.beginSnapshot(this); }
@Override public Snapshot beginSnapshot() throws IOException { if (!(mPageDb.isDurable())) { throw new UnsupportedOperationException("Snapshot only allowed for durable databases"); } checkClosed(); _DurablePageDb pageDb = (_DurablePageDb) mPageDb; return pageDb.beginSnapshot(this); }
@Override public Snapshot beginSnapshot() throws IOException { if (!(mPageDb.isDurable())) { throw new UnsupportedOperationException("Snapshot only allowed for durable databases"); } checkClosed(); _DurablePageDb pageDb = (_DurablePageDb) mPageDb; return pageDb.beginSnapshot(this); }
private void applyCachePrimer(DatabaseConfig config) { if (mPageDb.isDurable()) { File primer = primerFile(); try { if (config.mCachePriming && primer.exists()) { if (mEventListener != null) { mEventListener.notify(EventType.RECOVERY_CACHE_PRIMING, "Cache priming"); } FileInputStream fin; try { fin = new FileInputStream(primer); try (InputStream bin = new BufferedInputStream(fin)) { applyCachePrimer(bin); } catch (IOException e) { fin.close(); } } catch (IOException e) { } } } finally { if (!mReadOnly) { primer.delete(); } } } }
@Override public void createCachePrimer(OutputStream out) throws IOException { if (!(mPageDb.isDurable())) { throw new UnsupportedOperationException ("Cache priming only allowed for durable databases"); } out = ((_DurablePageDb) mPageDb).encrypt(out); DataOutputStream dout = new DataOutputStream(out); dout.writeLong(PRIMER_MAGIC_NUMBER); for (_TreeRef treeRef : mOpenTrees.values()) { _Tree tree = treeRef.get(); if (tree != null && !_Tree.isInternal(tree.mId)) { // Encode name instead of identifier, to support priming set portability // between databases. The identifiers won't match, but the names might. byte[] name = tree.mName; dout.writeInt(name.length); dout.write(name); tree.writeCachePrimer(dout); } } // Terminator. dout.writeInt(-1); }
@Override public void createCachePrimer(OutputStream out) throws IOException { if (!(mPageDb.isDurable())) { throw new UnsupportedOperationException ("Cache priming only allowed for durable databases"); } out = ((_DurablePageDb) mPageDb).encrypt(out); DataOutputStream dout = new DataOutputStream(out); dout.writeLong(PRIMER_MAGIC_NUMBER); for (_TreeRef treeRef : mOpenTrees.values()) { _Tree tree = treeRef.get(); if (tree != null && !_Tree.isInternal(tree.mId)) { // Encode name instead of identifier, to support priming set portability // between databases. The identifiers won't match, but the names might. byte[] name = tree.mName; dout.writeInt(name.length); dout.write(name); tree.writeCachePrimer(dout); } } // Terminator. dout.writeInt(-1); }
private void applyCachePrimer(DatabaseConfig config) { if (mPageDb.isDurable()) { File primer = primerFile(); try { if (config.mCachePriming && primer.exists()) { if (mEventListener != null) { mEventListener.notify(EventType.RECOVERY_CACHE_PRIMING, "Cache priming"); } FileInputStream fin; try { fin = new FileInputStream(primer); try (InputStream bin = new BufferedInputStream(fin)) { applyCachePrimer(bin); } catch (IOException e) { fin.close(); primer.delete(); } } catch (IOException e) { } } } finally { primer.delete(); } } }
@Override public void createCachePrimer(OutputStream out) throws IOException { if (!(mPageDb.isDurable())) { throw new UnsupportedOperationException ("Cache priming only allowed for durable databases"); } out = ((_DurablePageDb) mPageDb).encrypt(out); DataOutputStream dout = new DataOutputStream(out); dout.writeLong(PRIMER_MAGIC_NUMBER); for (_TreeRef treeRef : mOpenTrees.values()) { _Tree tree = treeRef.get(); if (tree != null && !_Tree.isInternal(tree.mId)) { // Encode name instead of identifier, to support priming set portability // between databases. The identifiers won't match, but the names might. byte[] name = tree.mName; dout.writeInt(name.length); dout.write(name); tree.writeCachePrimer(dout); } } // Terminator. dout.writeInt(-1); }
private void applyCachePrimer(DatabaseConfig config) { if (mPageDb.isDurable()) { File primer = primerFile(); try { if (config.mCachePriming && primer.exists()) { if (mEventListener != null) { mEventListener.notify(EventType.RECOVERY_CACHE_PRIMING, "Cache priming"); } FileInputStream fin; try { fin = new FileInputStream(primer); try (InputStream bin = new BufferedInputStream(fin)) { applyCachePrimer(bin); } catch (IOException e) { fin.close(); } } catch (IOException e) { } } } finally { if (!mReadOnly) { primer.delete(); } } } }
@Override public void checkpoint() throws IOException { if (!mClosed && mPageDb.isDurable()) { try { checkpoint(false, 0, 0); } catch (Throwable e) { DatabaseException.rethrowIfRecoverable(e); closeQuietly(null, this, e); throw e; } } }
@Override public void applyCachePrimer(InputStream in) throws IOException { if (!(mPageDb.isDurable())) { throw new UnsupportedOperationException ("Cache priming only allowed for durable databases");
@Override public void applyCachePrimer(InputStream in) throws IOException { if (!(mPageDb.isDurable())) { throw new UnsupportedOperationException ("Cache priming only allowed for durable databases");
@Override public void checkpoint() throws IOException { while (!isClosed() && mPageDb.isDurable()) { try { checkpoint(false, 0, 0); return; } catch (UnmodifiableReplicaException e) { // Retry. Thread.yield(); } catch (Throwable e) { DatabaseException.rethrowIfRecoverable(e); closeQuietly(this, e); throw e; } } }
@Override public void checkpoint() throws IOException { while (!isClosed() && mPageDb.isDurable()) { try { checkpoint(false, 0, 0); return; } catch (UnmodifiableReplicaException e) { // Retry. Thread.yield(); } catch (Throwable e) { DatabaseException.rethrowIfRecoverable(e); closeQuietly(null, this, e); throw e; } } }
@Override public long preallocate(long bytes) throws IOException { if (!mClosed && mPageDb.isDurable()) { int pageSize = mPageSize; long pageCount = (bytes + pageSize - 1) / pageSize; if (pageCount > 0) { pageCount = mPageDb.allocatePages(pageCount); if (pageCount > 0) { try { checkpoint(true, 0, 0); } catch (Throwable e) { DatabaseException.rethrowIfRecoverable(e); closeQuietly(null, this, e); throw e; } } return pageCount * pageSize; } } return 0; }
@Override public long preallocate(long bytes) throws IOException { if (!isClosed() && mPageDb.isDurable()) { int pageSize = mPageSize; long pageCount = (bytes + pageSize - 1) / pageSize; if (pageCount > 0) { pageCount = mPageDb.allocatePages(pageCount); if (pageCount > 0) { try { checkpoint(true, 0, 0); } catch (Throwable e) { DatabaseException.rethrowIfRecoverable(e); closeQuietly(null, this, e); throw e; } } return pageCount * pageSize; } } return 0; }
@Override public long preallocate(long bytes) throws IOException { if (!isClosed() && mPageDb.isDurable()) { int pageSize = mPageSize; long pageCount = (bytes + pageSize - 1) / pageSize; if (pageCount > 0) { pageCount = mPageDb.allocatePages(pageCount); if (pageCount > 0) { try { checkpoint(true, 0, 0); } catch (Throwable e) { DatabaseException.rethrowIfRecoverable(e); closeQuietly(this, e); throw e; } } return pageCount * pageSize; } } return 0; }