Package org.syncany.database

Examples of org.syncany.database.MultiChunkEntry$MultiChunkId


    newDatabaseVersion.addFileHistory(newFileHistory);

    ChunkEntry newChunkEntry = new ChunkEntry(ChunkChecksum.parseChunkChecksum("aaaaaaaaaaaaaaaaaaaaab2b263ffa4cc48e282f"), 1);
    newDatabaseVersion.addChunk(newChunkEntry);
   
    MultiChunkEntry newMultiChunkEntry = new MultiChunkEntry(MultiChunkId.parseMultiChunkId("1234567890987654321234567876543456555555"), 10);
    newMultiChunkEntry.addChunk(newChunkEntry.getChecksum());
    newDatabaseVersion.addMultiChunk(newMultiChunkEntry);
   
    FileContent newFileContent = new FileContent();
    newFileContent.setChecksum(FileChecksum.parseFileChecksum("aaaaaaaaaaaaaaaaaaaaab2b263ffa4cc48e282f"));
    newFileContent.setSize(1L);   
    newFileContent.addChunk(newChunkEntry.getChecksum());
    newDatabaseVersion.addFileContent(newFileContent);   
   
    // c. Persist database version
    databaseVersionDao.persistDatabaseVersion(newDatabaseVersion);
   
    // d. Capture new last database version header
    DatabaseVersionHeader lastDatabaseVersionHeaderAfter = databaseVersionDao.getLastDatabaseVersionHeader()
   
    // Test
    assertNotNull(lastDatabaseVersionHeaderBefore);
    assertEquals("A/(A5)/T=1388935689000", lastDatabaseVersionHeaderBefore.toString());
   
    assertNotNull(lastDatabaseVersionHeaderAfter);
    assertEquals("C/(A5,C1)/T=1489977288000", lastDatabaseVersionHeaderAfter.toString());
    assertEquals(newDatabaseVersionHeader.getVectorClock(), lastDatabaseVersionHeaderAfter.getVectorClock());
   
    assertEquals(newChunkEntry, chunkDao.getChunk(ChunkChecksum.parseChunkChecksum("aaaaaaaaaaaaaaaaaaaaab2b263ffa4cc48e282f")));
    assertEquals(newFileContent, fileContentDao.getFileContent(FileChecksum.parseFileChecksum("aaaaaaaaaaaaaaaaaaaaab2b263ffa4cc48e282f"), true));
   
    Map<MultiChunkId, MultiChunkEntry> multiChunkIds = multiChunkDao.getMultiChunks(newDatabaseVersionHeader.getVectorClock());
    assertNotNull(multiChunkIds);
    assertEquals(1, multiChunkIds.size());
   
    MultiChunkEntry actualNewMultiChunkEntry = multiChunkIds.get(MultiChunkId.parseMultiChunkId("1234567890987654321234567876543456555555"));
    assertNotNull(actualNewMultiChunkEntry);
    assertEquals(newMultiChunkEntry.getId(), actualNewMultiChunkEntry.getId());
   
    // Tear down
    databaseConnection.close();
    TestConfigUtil.deleteTestLocalConfigAndData(testConfig);
  }
View Full Code Here


   
    while (resultSet.next()) {
      MultiChunkId multiChunkId = MultiChunkId.parseMultiChunkId(resultSet.getString("id"));
      long multiChunkSize = resultSet.getLong("size");
           
      unusedMultiChunkIds.put(multiChunkId, new MultiChunkEntry(multiChunkId, multiChunkSize));
    }
   
    return unusedMultiChunkIds;
  }
View Full Code Here

   
    while (resultSet.next()) {     
      MultiChunkId multiChunkId = MultiChunkId.parseMultiChunkId(resultSet.getString("multichunk_id"));
      long multiChunkSize = resultSet.getLong("size");
     
      MultiChunkEntry multiChunkEntry = null;
     
      if (currentMultiChunkId != null && currentMultiChunkId.equals(multiChunkId)) {
        multiChunkEntry = multiChunkEntries.get(multiChunkId)
      }
      else {
        multiChunkEntry = new MultiChunkEntry(multiChunkId, multiChunkSize);
      }
     
      multiChunkEntry.addChunk(ChunkChecksum.parseChunkChecksum(resultSet.getString("chunk_checksum")));
      multiChunkEntries.put(multiChunkId, multiChunkEntry);
     
      currentMultiChunkId = multiChunkId;
    }
   
View Full Code Here

    MemoryDatabase database = new MemoryDatabase();

    // Round 1: Add chunk to multichunk
    DatabaseVersion databaseVersion1 = TestDatabaseUtil.createDatabaseVersion();

    MultiChunkEntry multiChunkP1 = new MultiChunkEntry(new MultiChunkId(new byte[] { 8, 8, 8, 8, 8, 8, 8, 8 }), 10);
    ChunkEntry chunkA1 = new ChunkEntry(new ChunkChecksum(new byte[] { 1, 2, 3, 4, 5, 7, 8, 9, 0 }), 12);

    multiChunkP1.addChunk(chunkA1.getChecksum());
    databaseVersion1.addChunk(chunkA1);
    databaseVersion1.addMultiChunk(multiChunkP1);

    database.addDatabaseVersion(databaseVersion1);

    assertEquals(chunkA1, database.getChunk(new ChunkChecksum(new byte[] { 1, 2, 3, 4, 5, 7, 8, 9, 0 })));
    assertEquals(multiChunkP1, database.getMultiChunk(new MultiChunkId(new byte[] { 8, 8, 8, 8, 8, 8, 8, 8 })));

    // Round 2: Add chunk to multichunk
    DatabaseVersion databaseVersion2 = TestDatabaseUtil.createDatabaseVersion(databaseVersion1);

    MultiChunkEntry multiChunkP2 = new MultiChunkEntry(new MultiChunkId(new byte[] { 7, 7, 7, 7, 7, 7, 7, 7, 7 }), 11);
    MultiChunkEntry multiChunkP3 = new MultiChunkEntry(new MultiChunkId(new byte[] { 5, 5, 5, 5, 5, 5, 5, 5, 5 }), 12);

    ChunkEntry chunkA2 = new ChunkEntry(new ChunkChecksum(new byte[] { 9, 2, 3, 4, 5, 7, 8, 9, 0 }), 912);
    ChunkEntry chunkA3 = new ChunkEntry(new ChunkChecksum(new byte[] { 8, 2, 3, 4, 5, 7, 8, 9, 0 }), 812);
    ChunkEntry chunkA4 = new ChunkEntry(new ChunkChecksum(new byte[] { 7, 2, 3, 4, 5, 7, 8, 9, 0 }), 712);

    multiChunkP2.addChunk(chunkA2.getChecksum());
    multiChunkP2.addChunk(chunkA3.getChecksum());
    multiChunkP3.addChunk(chunkA4.getChecksum());

    databaseVersion2.addChunk(chunkA2);
    databaseVersion2.addChunk(chunkA3);
    databaseVersion2.addChunk(chunkA4);
View Full Code Here

   
    // - Database version "A6"
    assertNotNull(multiChunksA6);
    assertEquals(1, multiChunksA6.size());
   
    MultiChunkEntry multiChunkInA6 = multiChunksA6.get(MultiChunkId.parseMultiChunkId("9302d8b104023627f655fa7745927fdeb3df674b"));
   
    assertNotNull(multiChunkInA6);
    assertEquals("9302d8b104023627f655fa7745927fdeb3df674b", multiChunkInA6.getId().toString());
    assertTrue(CollectionUtil.containsExactly(multiChunkInA6.getChunks(),
      ChunkChecksum.parseChunkChecksum("24a39e00d6156804e27f7c0987d00903da8e6682")     
    ));
       
    // - Database version "A8,B3"   
    assertNotNull(multiChunksA7B2);
    assertEquals(1, multiChunksA7B2.size());
   
    MultiChunkEntry multiChunkInA7B2 = multiChunksA7B2.get(MultiChunkId.parseMultiChunkId("51aaca5c1280b1cf95cff8a3266a6bb44b482ad4"));
   
    assertEquals("51aaca5c1280b1cf95cff8a3266a6bb44b482ad4", multiChunkInA7B2.getId().toString());
    assertTrue(CollectionUtil.containsExactly(multiChunkInA7B2.getChunks(),
      ChunkChecksum.parseChunkChecksum("0fecbac8ac8a5f8b7aa12b2741a4ef5db88c5dea"),
      ChunkChecksum.parseChunkChecksum("38a18897e94a901b833e750e8604d9616a02ca84"),
      ChunkChecksum.parseChunkChecksum("47dded182d31799267f12eb9864cdc11127b3352"),
      ChunkChecksum.parseChunkChecksum("5abe80d7dd96369a3e53993cd69279400ec740bd"),
      ChunkChecksum.parseChunkChecksum("5f0b34374821423f69bf2231210245ccf0302df0"),
View Full Code Here

   
    // - Database version "A5"
    assertNotNull(multiChunksA5);
    assertEquals(1, multiChunksA5.size());
   
    MultiChunkEntry multiChunkInA5 = multiChunksA5.get(MultiChunkId.parseMultiChunkId("dddddddddddddddddddddddddddddddddddddddd"));
   
    assertNotNull(multiChunkInA5);
    assertEquals("dddddddddddddddddddddddddddddddddddddddd", multiChunkInA5.getId().toString());
    assertTrue(CollectionUtil.containsExactly(multiChunkInA5.getChunks(),
      ChunkChecksum.parseChunkChecksum("ffffffffffffffffffffffffffffffffffffffff")     
    ));
           
    // Tear down
    databaseConnection.close();
View Full Code Here

    }

    @Override
    public void onMultiChunkOpen(MultiChunk multiChunk) {
      logger.log(Level.FINER, "- +MultiChunk {0}", multiChunk.getId());
      multiChunkEntry = new MultiChunkEntry(multiChunk.getId(), 0); // size unknown so far
    }
View Full Code Here

        if (multiChunkId == null) {
          throw new SAXException("Cannot read ID from multichunk " + multChunkIdStr);
        }

        multiChunk = new MultiChunkEntry(multiChunkId, size);
      }
      else if (elementPath.equalsIgnoreCase("/database/databaseVersions/databaseVersion/multiChunks/multiChunk/chunkRefs/chunkRef")) {
        String chunkChecksumStr = attributes.getValue("ref");

        multiChunk.addChunk(ChunkChecksum.parseChunkChecksum(chunkChecksumStr));
View Full Code Here

TOP

Related Classes of org.syncany.database.MultiChunkEntry$MultiChunkId

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.