Package org.waveprotocol.box.server.persistence

Examples of org.waveprotocol.box.server.persistence.PersistenceException


      // fsync() before returning.
      file.getChannel().force(true);
      endVersion = lastDelta.transformed.getResultingVersion();
    } catch (IOException e) {
      throw new PersistenceException(e);
    }
  }
View Full Code Here


  @Override
  public FileDeltaCollection open(WaveletName waveletName) throws PersistenceException {
    try {
      return FileDeltaCollection.open(waveletName, basePath);
    } catch (IOException e) {
      throw new PersistenceException("Failed to open deltas for wavelet " + waveletName, e);
    }
  }
View Full Code Here

        return name.endsWith(extension);
      }
    });

    if (files == null) {
      throw new PersistenceException(String.format(
          "Configured %s directory (%s) does not appear to be readable!", dirType, dir));
    }

    /*
     * If file list isn't empty, try opening the first file in the list to make sure it
     * is readable. If the first file is readable, then it is likely that the rest will
     * be readable as well.
     */
    if (files.length > 0) {
      try {
        FileInputStream file = new FileInputStream(files[0]);
        file.read();
      } catch (IOException e) {
        throw new PersistenceException(
            String.format(
              "Failed to read '%s' in configured %s directory '%s'. "
              + "The directory's contents do not appear to be readable.",
              dirType, files[0].getName(), dir),
            e);
      }
    }

    // Make sure the dir is writable.
    try {
      File tmp = File.createTempFile("tempInitialization", ".temp", baseDir);
      FileOutputStream stream = new FileOutputStream(tmp);
      stream.write(new byte[]{'H','e','l','l','o'});
      stream.close();
      tmp.delete();
    } catch (IOException e) {
      throw new PersistenceException(String.format(
          "Configured %s directory (%s) does not appear to be writable!", dirType, dir), e);
    }
  }
View Full Code Here

    // Make sure the dir exists.
    if (!baseDir.exists()) {
      // It doesn't so try and create it.
      if (!baseDir.mkdirs()) {
        throw new PersistenceException(String.format(
            "Configured %s directory (%s) doesn't exist and could not be created!", dirType, dir));
      }
    }

    // Make sure the dir is a directory.
    if (!baseDir.isDirectory()) {
      throw new PersistenceException(String.format(
          "Configured %s path (%s) isn't a directory!", dirType, dir));
    }
    return baseDir;
  }
View Full Code Here

        ImmutableList<WaveletDeltaRecord> deltas = readAll(deltasAccess);
        WaveletData snapshot = WaveletDataUtil.buildWaveletFromDeltas(deltasAccess.getWaveletName(),
            Iterators.transform(deltas.iterator(), TRANSFORMED));
        return new DeltaStoreBasedWaveletState(deltasAccess, deltas, snapshot, persistExecutor);
      } catch (IOException e) {
        throw new PersistenceException("Failed to read stored deltas", e);
      } catch (OperationException e) {
        throw new PersistenceException("Failed to compose stored deltas", e);
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.waveprotocol.box.server.persistence.PersistenceException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.