use of org.syncany.chunk.NoTransformer in project syncany by syncany.
the class FrameworkCombinationTest method fillCombinations.
private void fillCombinations() throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException {
// MultiChunks
List<MultiChunker> multiChunkers = new LinkedList<MultiChunker>();
int[] multiChunkSizes = new int[] { 250000, 500000 };
for (int i = 0; i < multiChunkSizes.length; i++) {
//multiChunkers.add(new CustomMultiChunker(multiChunkSizes[i]));
multiChunkers.add(new ZipMultiChunker(multiChunkSizes[i]));
}
// Chunks
List<Chunker> chunkers = new LinkedList<Chunker>();
int[] chunkSizes = new int[] { 8000, 16000 };
String[] digestAlgs = new String[] { /*"MD5" ,*/
"SHA1" };
String[] fingerprinters = new String[] { "Adler32" };
for (int i = 0; i < chunkSizes.length; i++) {
for (int j = 0; j < digestAlgs.length; j++) {
for (int k = 0; k < fingerprinters.length; k++) {
chunkers.add(new TttdChunker(chunkSizes[i], TttdChunker.DEFAULT_WINDOW_SIZE, digestAlgs[j], fingerprinters[k]));
}
}
}
// Compression/Encryption
List<CipherSpec> cipherSpecs = new ArrayList<CipherSpec>();
cipherSpecs.add(CipherSpecs.getCipherSpec(1));
cipherSpecs.add(CipherSpecs.getCipherSpec(2));
List<Transformer> transformerChains = new LinkedList<Transformer>();
transformerChains.add(new NoTransformer());
transformerChains.add(new GzipTransformer());
transformerChains.add(new CipherTransformer(cipherSpecs, masterKey));
transformerChains.add(new GzipTransformer(new CipherTransformer(cipherSpecs, masterKey)));
for (MultiChunker multiChunker : multiChunkers) {
for (Transformer transformer : transformerChains) {
for (Chunker chunker : chunkers) {
String configName = multiChunker + "/" + chunker + "/" + transformer;
combinations.add(new FrameworkCombination(configName, chunker, multiChunker, transformer));
}
}
}
}
use of org.syncany.chunk.NoTransformer in project syncany by syncany.
the class Config method initTransformers.
private void initTransformers(RepoTO repoTO) throws Exception {
if (repoTO.getTransformers() == null || repoTO.getTransformers().size() == 0) {
transformer = new NoTransformer();
} else {
List<TransformerTO> transformerTOs = new ArrayList<TransformerTO>(repoTO.getTransformers());
Transformer lastTransformer = null;
for (int i = transformerTOs.size() - 1; i >= 0; i--) {
TransformerTO transformerTO = transformerTOs.get(i);
Transformer transformer = Transformer.getInstance(transformerTO.getType());
if (transformer == null) {
throw new ConfigException("Cannot find transformer '" + transformerTO.getType() + "'");
}
if (transformer instanceof CipherTransformer) {
// Dirty workaround
transformerTO.getSettings().put(CipherTransformer.PROPERTY_MASTER_KEY, StringUtil.toHex(getMasterKey().getEncoded()));
transformerTO.getSettings().put(CipherTransformer.PROPERTY_MASTER_KEY_SALT, StringUtil.toHex(getMasterKey().getSalt()));
}
transformer.init(transformerTO.getSettings());
if (lastTransformer != null) {
transformer.setNextTransformer(lastTransformer);
}
lastTransformer = transformer;
}
transformer = lastTransformer;
}
}
use of org.syncany.chunk.NoTransformer in project syncany by syncany.
the class MultiChunkerTest method chunkFileIntoMultiChunks.
public void chunkFileIntoMultiChunks(Chunker chunker, MultiChunker multiChunker, int minMultiChunkSize) throws Exception {
File tempDir = TestFileUtil.createTempDirectoryInSystemTemp();
int fileSizeBig = 4560000;
int fileSizeSmall = 1230;
int fileAmountSizeSmall = 2;
int fileAmountSizeBig = 3;
List<File> files = TestFileUtil.createRandomFilesInDirectory(tempDir, fileSizeSmall, fileAmountSizeSmall);
files.addAll(TestFileUtil.createRandomFilesInDirectory(tempDir, fileSizeBig, fileAmountSizeBig));
logger.log(Level.INFO, "- In " + tempDir + " ...");
Set<MultiChunk> resultMultiChunks = chunkFileIntoMultiChunks(tempDir, files, chunker, multiChunker, new NoTransformer());
long totalFilesSize = (fileSizeBig * fileAmountSizeBig) + (fileSizeSmall * fileAmountSizeSmall);
assertEquals(totalFilesSize / minMultiChunkSize / 1024, resultMultiChunks.size());
TestFileUtil.deleteDirectory(tempDir);
}
Aggregations