Esempio n. 1
0
  private static _PageDb restoreFromSnapshot(
      PageCache cache,
      Crypto crypto,
      InputStream in,
      byte[] buffer,
      long bufferPage,
      PageArray pa,
      long index)
      throws IOException {
    try {
      while (true) {
        try {
          readFully(in, buffer, 0, buffer.length);
        } catch (EOFException e) {
          break;
        }
        pa.writePage(index, p_transferTo(buffer, bufferPage));
        index++;
      }

      // Ensure newly restored snapshot is durable and also ensure that PageArray (if a
      // MappedPageArray) no longer considers itself to be empty.
      pa.sync(true);
    } finally {
      p_delete(bufferPage);
      closeQuietly(null, in);
    }

    try {
      return new _DurablePageDb(pa, cache, crypto, false);
    } catch (WrongPageSize e) {
      throw e.rethrow();
    }
  }
Esempio n. 2
0
 /**
  * @param cache optional
  * @param crypto optional
  */
 static _DurablePageDb open(PageArray rawArray, PageCache cache, Crypto crypto, boolean destroy)
     throws IOException {
   try {
     return new _DurablePageDb(rawArray, cache, crypto, destroy);
   } catch (WrongPageSize e) {
     throw e.rethrow();
   }
 }
Esempio n. 3
0
 /**
  * @param factory optional
  * @param cache optional
  * @param crypto optional
  */
 static _DurablePageDb open(
     boolean explicitPageSize,
     int pageSize,
     File[] files,
     FileFactory factory,
     EnumSet<OpenOption> options,
     PageCache cache,
     Crypto crypto,
     boolean destroy)
     throws IOException {
   while (true) {
     try {
       return new _DurablePageDb(
           openPageArray(pageSize, files, factory, options), cache, crypto, destroy);
     } catch (WrongPageSize e) {
       if (explicitPageSize) {
         throw e.rethrow();
       }
       pageSize = e.mActual;
       explicitPageSize = true;
     }
   }
 }