public void addChunk(ChunksGroup chunk) { if (fileName != chunk.fileName) { throw new ArgumentException("Intent to add chunk to diffrent file"); } if (chunk.chunkId < 0) { throw new ArgumentException("Chunk has negative id!"); } if (chunks.Contains(chunk)) { foreach (var c in chunks) { if (c.Equals(chunk)) { c.merge(chunk); } } } else { chunks.Add(chunk); } }
public void merge(ChunksGroup chunk) { if (!chunk.Equals(this)) { throw new ArgumentException("Merging diffrent chunks!"); } if (chunk.sizeInBytes != sizeInBytes) { throw new ArgumentException("Merging chunks error: the same name and id, but diffrent SIZE!"); } storedInWorkers.UnionWith(chunk.storedInWorkers); }
public override bool Equals(System.Object obj) { if (obj == null) { return(false); } ChunksGroup p = obj as ChunksGroup; if ((System.Object)p == null) { return(false); } return((fileName == p.fileName) && (chunkId == p.chunkId)); }
public FileHeader(ChunksGroup chunk) { fileName = chunk.fileName; chunks = new HashSet <ChunksGroup> (); chunks.Add(chunk); }