Package org.syncany.database

Examples of org.syncany.database.DatabaseVersion


    purgeDatabaseVersionHeader.setType(DatabaseVersionType.PURGE);
    purgeDatabaseVersionHeader.setDate(new Date());
    purgeDatabaseVersionHeader.setClient(config.getMachineName());
    purgeDatabaseVersionHeader.setVectorClock(purgeVectorClock);

    DatabaseVersion purgeDatabaseVersion = new DatabaseVersion();
    purgeDatabaseVersion.setHeader(purgeDatabaseVersionHeader);

    for (Entry<FileHistoryId, FileVersion> fileHistoryEntry : mostRecentPurgeFileVersions.entrySet()) {
      PartialFileHistory purgeFileHistory = new PartialFileHistory(fileHistoryEntry.getKey());

      purgeFileHistory.addFileVersion(fileHistoryEntry.getValue());
      purgeDatabaseVersion.addFileHistory(purgeFileHistory);

      logger.log(Level.FINE, "- Pruning file history " + fileHistoryEntry.getKey() + " versions <= " + fileHistoryEntry.getValue() + " ...");
    }

    return purgeDatabaseVersion;
View Full Code Here


   * @param files List of files to be deduplicated
   * @return New database version containing new/changed/deleted entities
   * @throws IOException If the chunking/deduplication cannot read/process any of the files
   */
  public DatabaseVersion index(List<File> files) throws IOException {
    DatabaseVersion newDatabaseVersion = new DatabaseVersion();

    // Load file history cache
    List<PartialFileHistory> fileHistoriesWithLastVersion = localDatabase.getFileHistoriesWithLastVersion();

    // TODO [medium] This should be in FileHistoryDao
View Full Code Here

      throw new RuntimeException("Unexpected database version type: " + databaseVersionHeader.getType());
    }     
  }

  private DatabaseVersion createDatabaseVersionFromRowDefault(DatabaseVersionHeader databaseVersionHeader, ResultSet resultSet) {
    DatabaseVersion databaseVersion = new DatabaseVersion();
    databaseVersion.setHeader(databaseVersionHeader);
   
    Map<ChunkChecksum, ChunkEntry> chunks = chunkDao.getChunks(databaseVersionHeader.getVectorClock());
    Map<MultiChunkId, MultiChunkEntry> multiChunks = multiChunkDao.getMultiChunks(databaseVersionHeader.getVectorClock());
    Map<FileChecksum, FileContent> fileContents = fileContentDao.getFileContents(databaseVersionHeader.getVectorClock());
    Map<FileHistoryId, PartialFileHistory> fileHistories = fileHistoryDao.getFileHistoriesWithFileVersions(databaseVersionHeader.getVectorClock());

    for (ChunkEntry chunk : chunks.values()) {
      databaseVersion.addChunk(chunk);
    }

    for (MultiChunkEntry multiChunk : multiChunks.values()) {
      databaseVersion.addMultiChunk(multiChunk);
    }

    for (FileContent fileContent : fileContents.values()) {
      databaseVersion.addFileContent(fileContent);
    }

    for (PartialFileHistory fileHistory : fileHistories.values()) {
      databaseVersion.addFileHistory(fileHistory);
    }

    return databaseVersion;
  }
View Full Code Here

    return databaseVersion;
  }
 
  private DatabaseVersion createDatabaseVersionFromRowPurge(DatabaseVersionHeader databaseVersionHeader, ResultSet resultSet) {
    DatabaseVersion purgeDatabaseVersion = new DatabaseVersion();
    purgeDatabaseVersion.setHeader(databaseVersionHeader);
   
    List<PartialFileHistory> purgeFileHistories = fileHistoryDao.getPurgeFileHistoriesWithFileVersions(databaseVersionHeader.getVectorClock());
   
    for (PartialFileHistory fileHistory : purgeFileHistories) {
      purgeDatabaseVersion.addFileHistory(fileHistory);
    }

    return purgeDatabaseVersion;
  }
View Full Code Here

    @Override
    public DatabaseVersion next() {
      if (hasNext) {
        try {
          DatabaseVersion databaseVersion = createDatabaseVersionFromRow(resultSet);
          hasNext = resultSet.next();

          return databaseVersion;
        }
        catch (Exception e) {
View Full Code Here

    xmlOut.writeAttribute("version", XML_FORMAT_VERSION);
    
    xmlOut.writeStartElement("databaseVersions");
          
    while (databaseVersions.hasNext()) {
      DatabaseVersion databaseVersion = databaseVersions.next();
     
      // Database version
      xmlOut.writeStartElement("databaseVersion");
     
      // Header, chunks, multichunks, file contents, and file histories
      writeDatabaseVersionHeader(xmlOut, databaseVersion);
      writeChunks(xmlOut, databaseVersion.getChunks());
      writeMultiChunks(xmlOut, databaseVersion.getMultiChunks());
      writeFileContents(xmlOut, databaseVersion.getFileContents());
      writeFileHistories(xmlOut, databaseVersion.getFileHistories())
     
      xmlOut.writeEndElement(); // </databaserVersion>
    }
   
    xmlOut.writeEndElement(); // </databaseVersions>
View Full Code Here

  @Override
  public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
    elementPath += "/" + qName;

    if (elementPath.equalsIgnoreCase("/database/databaseVersions/databaseVersion")) {
      databaseVersion = new DatabaseVersion();
    }
    else if (elementPath.equalsIgnoreCase("/database/databaseVersions/databaseVersion/header/type")) {
      String typeStr = attributes.getValue("value");
      databaseVersion.getHeader().setType(DatabaseVersionType.valueOf(typeStr));
    }
View Full Code Here

 
  public static DatabaseVersion createDatabaseVersion(DatabaseVersionHeader basedOnDatabaseVersionHeader, Date date) {
    VectorClock vectorClock = (basedOnDatabaseVersionHeader != null) ? basedOnDatabaseVersionHeader.getVectorClock().clone() : new VectorClock();
    vectorClock.incrementClock("someclient");
   
    DatabaseVersion databaseVersion = new DatabaseVersion();
   
    databaseVersion.setClient("someclient");
    databaseVersion.setTimestamp(date);
    databaseVersion.setVectorClock(vectorClock);
   
    return databaseVersion;
  }
View Full Code Here

    Iterator<DatabaseVersion> databaseVersionsDirtyB = databaseVersionDao.getDirtyDatabaseVersions();
    List<DatabaseVersion> databaseVersionsDirtyListB = TestCollectionUtil.toList(databaseVersionsDirtyB);
   
    assertEquals(1, databaseVersionsDirtyListB.size());
   
    DatabaseVersion dirtyDatabaseVersionB = databaseVersionsDirtyListB.get(0);
    assertNotNull(dirtyDatabaseVersionB);
    assertEquals(1, dirtyDatabaseVersionB.getFileHistories().size());
   
    PartialFileHistory fileHistoryFile1B = dirtyDatabaseVersionB.getFileHistories().iterator().next();   
    assertNotNull(fileHistoryFile1B);
    assertEquals(1, fileHistoryFile1B.getFileVersions().size());
    assertEquals("A-file1.jpg", fileHistoryFile1B.getLastVersion().getPath());
       
    assertFileEquals(clientA.getLocalFile("A-file1.jpg"), clientB.getLocalFile("A-file1.jpg"));
View Full Code Here

TOP

Related Classes of org.syncany.database.DatabaseVersion

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.