public static void TestRegisterFilePart(string db, string file, string offset, string count)
 {
     logger.DebugFormat("DB file path: {0}", db);
     var dbs = new ChunkDbService(db, false);
     var dedup = new DeduplicationService(dbs);
     dedup.RegisterFilePart(file, long.Parse(offset), int.Parse(count));
 }
Esempio n. 2
0
 public static void TestAddFileWithBasicChunkMap(string db, string filePath)
 {
     logger.DebugFormat("DB file path: {0}", db);
     var dbs = new ChunkDbService(db, true);
     dbs.AddFileWithBasicChunkMap(filePath);
     logger.Debug("Data file processing finished.");
 }
        public static void TestDownloadFile(string db, string torrentPath, string savePath)
        {
            //System.Diagnostics.Debugger.Launch();
            var dbs            = new ChunkDbService(db, false);
            var ds             = new DeduplicationService(dbs);
            var writer         = new DedupDiskWriter(ds);
            var engineSettings = new EngineSettings();

            engineSettings.PreferEncryption  = false;
            engineSettings.AllowedEncryption = EncryptionTypes.All;
            int port = 33123;
            var ip   = NetUtil.GetLocalIPByInterface("Local Area Connection");

            engineSettings.ReportedAddress = new IPEndPoint(ip, port);
            var engine  = new ClientEngine(engineSettings, new DedupDiskWriter(ds));
            var vd      = new VirtualDiskDownloadService(engine, new FileInfoTable <TorrentManager>());
            var torrent = Torrent.Load(torrentPath);

            logger.DebugFormat("Loaded torrent file: {0}, piece length: {1}.",
                               torrent.Name, torrent.PieceLength);
            var filePath = Path.Combine(savePath, torrent.Name);

            vd.StartDownloadingFile(torrent, savePath, dbs.GetManagedFile(filePath).ChunkMap.LastPieceInProfile);
            Console.Read();
        }
Esempio n. 4
0
        public static void TestRegisterFilePart(string db, string file, string offset, string count)
        {
            logger.DebugFormat("DB file path: {0}", db);
            var dbs   = new ChunkDbService(db, false);
            var dedup = new DeduplicationService(dbs);

            dedup.RegisterFilePart(file, long.Parse(offset), int.Parse(count));
        }
        public static void TestAddFileWithBasicChunkMap(string db, string filePath)
        {
            logger.DebugFormat("DB file path: {0}", db);
            var dbs = new ChunkDbService(db, true);

            dbs.AddFileWithBasicChunkMap(filePath);
            logger.Debug("Data file processing finished.");
        }
Esempio n. 6
0
 public static void TestReadFileIntoChunkDb(string filePath)
 {
     var dbFilePath = Path.Combine(Path.GetTempPath(), "newChunkDB.db");
     logger.DebugFormat("DB file path: {0}", dbFilePath);
     var dbs = new ChunkDbService(dbFilePath, true);
     dbs.AddFileAllChunks(filePath);
     logger.Debug("Data file processing finished.");
 }
 public static void TestGetDedupFileParts1(string db, string path, string offset, string count)
 {
     logger.DebugFormat("DB file path: {0}", db);
     var dbs = new ChunkDbService(db, false);
     var ds = new DeduplicationService(dbs);
     IList<Tuple<string, long, int>> result =
         ds.GetDedupFileSourceLocations(path, long.Parse(offset), int.Parse(count));
     result.ToList().ForEach(x => logger.Debug(x));
 }
 public FullProfileChunkMapBuilder(string profileDbFile, string dataFilePath, 
     ChunkDbService chunkDbService)
 {
     _profileDbFile = profileDbFile;
     _sessionFactory = CreateSessionFactory();
     _chunkDbService = chunkDbService;
     _fileHelper = new FileUtil(_chunkDbService);
     _datafilePath = dataFilePath;
 }
Esempio n. 9
0
 public static void TestGetChunkLocations(string db, string file, string chunksStr)
 {
     var dbs = new ChunkDbService(db, false);
     var chunks = chunksStr.Split(',');
     int[] chunkArray = Array.ConvertAll<string, int>(chunks, x => int.Parse(x));
     var locations = dbs.GetChunkLocations(file, chunkArray);
     foreach (var loc in locations) {
         logger.Debug(loc);
     }
 }
 public void TestGenerateChunkMap(string filePath)
 {
     XmlConfigurator.ConfigureAndWatch(new FileInfo("NHibernate.Debug.config.xml"));
     var logger = LogManager.GetLogger("CreateChunkDb");
     var dbFilePath = Path.Combine(Path.GetTempPath(), "newChunkDB.db");
     logger.DebugFormat("DB file path: {0}", dbFilePath);
     var dbs = new ChunkDbService(dbFilePath, true);
     dbs.AddFileAllChunks(filePath);
     logger.Debug("Data file processing finished.");
 }
Esempio n. 11
0
        public static void TestGetDedupFileParts1(string db, string path, string offset, string count)
        {
            logger.DebugFormat("DB file path: {0}", db);
            var dbs = new ChunkDbService(db, false);
            var ds  = new DeduplicationService(dbs);
            IList <Tuple <string, long, int> > result =
                ds.GetDedupFileSourceLocations(path, long.Parse(offset), int.Parse(count));

            result.ToList().ForEach(x => logger.Debug(x));
        }
        public static void TestReadFileIntoChunkDb(string filePath)
        {
            var dbFilePath = Path.Combine(Path.GetTempPath(), "newChunkDB.db");

            logger.DebugFormat("DB file path: {0}", dbFilePath);
            var dbs = new ChunkDbService(dbFilePath, true);

            dbs.AddFileAllChunks(filePath);
            logger.Debug("Data file processing finished.");
        }
Esempio n. 13
0
 public static void TestAddFileToDownload(string chunkDb, string datafile,
     string chunkMap, string torrentFile)
 {
     logger.DebugFormat("DB file path: {0}", chunkDb);
     var dbs = new ChunkDbService(chunkDb, false);
     var ds = new DeduplicationService(dbs);
     var torrentBytes = File.ReadAllBytes(torrentFile);
     var torrent = Torrent.Load(torrentBytes);
     ds.AddFileToDownload(datafile, File.ReadAllBytes(chunkMap),
         torrentBytes, torrent.Files[0].Length);
 }
        public void TestGenerateChunkMap(string filePath)
        {
            XmlConfigurator.ConfigureAndWatch(new FileInfo("NHibernate.Debug.config.xml"));
            var logger     = LogManager.GetLogger("CreateChunkDb");
            var dbFilePath = Path.Combine(Path.GetTempPath(), "newChunkDB.db");

            logger.DebugFormat("DB file path: {0}", dbFilePath);
            var dbs = new ChunkDbService(dbFilePath, true);

            dbs.AddFileAllChunks(filePath);
            logger.Debug("Data file processing finished.");
        }
Esempio n. 15
0
        public static void TestAddFileToDownload(string chunkDb, string datafile,
                                                 string chunkMap, string torrentFile)
        {
            logger.DebugFormat("DB file path: {0}", chunkDb);
            var dbs          = new ChunkDbService(chunkDb, false);
            var ds           = new DeduplicationService(dbs);
            var torrentBytes = File.ReadAllBytes(torrentFile);
            var torrent      = Torrent.Load(torrentBytes);

            ds.AddFileToDownload(datafile, File.ReadAllBytes(chunkMap),
                                 torrentBytes, torrent.Files[0].Length);
        }
        public static void TestGetChunkLocations(string db, string file, string chunksStr)
        {
            var dbs    = new ChunkDbService(db, false);
            var chunks = chunksStr.Split(',');

            int[] chunkArray = Array.ConvertAll <string, int>(chunks, x => int.Parse(x));
            var   locations  = dbs.GetChunkLocations(file, chunkArray);

            foreach (var loc in locations)
            {
                logger.Debug(loc);
            }
        }
Esempio n. 17
0
        public static void TestRead(string db, string file, string length, string offset, string count, string realfile)
        {
            logger.DebugFormat("DB file path: {0}", db);
            var dbs = new ChunkDbService(db, false);
            var ds = new DeduplicationService(dbs);
            var writer = new DedupDiskWriter(ds);
            var c = int.Parse(count);
            var buffer = new byte[c];
            var f = new TorrentFile(file, long.Parse(length));
            var o = long.Parse(offset);
            int actualRead = writer.Read(f, o, buffer, 0, c);

            byte[] bufferToCompare = new byte[c];
            using (var rf = File.OpenRead(realfile)) {
                rf.Seek(o, SeekOrigin.Begin);
                rf.Read(bufferToCompare, 0, bufferToCompare.Length);
            }

            Assert.IsTrue(buffer.SequenceEqual(bufferToCompare));
        }
Esempio n. 18
0
        public static void TestRead(string db, string file, string length, string offset, string count, string realfile)
        {
            logger.DebugFormat("DB file path: {0}", db);
            var dbs        = new ChunkDbService(db, false);
            var ds         = new DeduplicationService(dbs);
            var writer     = new DedupDiskWriter(ds);
            var c          = int.Parse(count);
            var buffer     = new byte[c];
            var f          = new TorrentFile(file, long.Parse(length));
            var o          = long.Parse(offset);
            int actualRead = writer.Read(f, o, buffer, 0, c);

            byte[] bufferToCompare = new byte[c];
            using (var rf = File.OpenRead(realfile)) {
                rf.Seek(o, SeekOrigin.Begin);
                rf.Read(bufferToCompare, 0, bufferToCompare.Length);
            }

            Assert.IsTrue(buffer.SequenceEqual(bufferToCompare));
        }
 public static void TestDownloadFile(string db, string torrentPath, string savePath)
 {
     //System.Diagnostics.Debugger.Launch();
     var dbs = new ChunkDbService(db, false);
     var ds = new DeduplicationService(dbs);
     var writer = new DedupDiskWriter(ds);
     var engineSettings = new EngineSettings();
     engineSettings.PreferEncryption = false;
     engineSettings.AllowedEncryption = EncryptionTypes.All;
     int port = 33123;
     var ip = NetUtil.GetLocalIPByInterface("Local Area Connection");
     engineSettings.ReportedAddress = new IPEndPoint(ip, port);
     var engine = new ClientEngine(engineSettings, new DedupDiskWriter(ds));
     var vd = new VirtualDiskDownloadService(engine, new FileInfoTable<TorrentManager>());
     var torrent = Torrent.Load(torrentPath);
     logger.DebugFormat("Loaded torrent file: {0}, piece length: {1}.",
         torrent.Name, torrent.PieceLength);
     var filePath = Path.Combine(savePath, torrent.Name);
     vd.StartDownloadingFile(torrent, savePath, dbs.GetManagedFile(filePath).ChunkMap.LastPieceInProfile);
     Console.Read();
 }
Esempio n. 20
0
 public DeduplicationService(ChunkDbService chunkDbService)
 {
     _chunkDbService = chunkDbService;
 }
Esempio n. 21
0
        public static void TestReadFile(string db, string torrentPath, string baseDir, string filePath, string origianlFile)
        {
            //System.Diagnostics.Debugger.Launch();
            var kernel = new StandardKernel();
            kernel.Load(new ServiceNinjectModule());

            kernel.Bind<FileInfoTable<TorrentManager>>().ToSelf().InSingletonScope();

            var dbs = new ChunkDbService(db, false);
            var ds = new DeduplicationService(dbs);
            kernel.Bind<DeduplicationService>().ToConstant(ds).InSingletonScope();

            var writer = new DedupDiskWriter(ds);

            var engineSettings = new EngineSettings();
            engineSettings.PreferEncryption = false;
            engineSettings.AllowedEncryption = EncryptionTypes.All;
            int port = 33123;
            var ip = NetUtil.GetLocalIPByInterface("Local Area Connection");
            engineSettings.ReportedAddress = new IPEndPoint(ip, port);
            var engine = new ClientEngine(engineSettings, new DedupDiskWriter(ds));

            kernel.Bind<DiskManager>().ToConstant(engine.DiskManager).InSingletonScope();
            kernel.Bind<ClientEngine>().ToConstant(engine).InSingletonScope();

            kernel.Bind<DistributedDiskManager>().ToSelf();
            kernel.Bind<FileService>().ToSelf().WithConstructorArgument("baseDir", baseDir);

            kernel.Bind<VirtualDiskDownloadService>().ToSelf();
            var vd = kernel.Get<VirtualDiskDownloadService>();

            var torrent = Torrent.Load(torrentPath);
            logger.DebugFormat("Loaded torrent file: {0}, piece length: {1}.",
                torrent.Name, torrent.PieceLength);
            vd.StartDownloadingFile(torrent, baseDir, -1);

            KernelContainer.Kernel = kernel;

            var m = new HurricaneServiceManager();
            m.Start();

            var url = string.Format("http://{0}:18081/FileService/", ip.ToString());
            logger.DebugFormat("Contacting service at {0}", url);
            var client = new ManualFileServiceClient(url);
            string tstmsg = "tstmsg";
            var resp = client.Echo(tstmsg);
            Assert.AreEqual(resp, tstmsg);

            byte[] resultData = null;

            try {
                var pathStatus = client.GetPathStatus(filePath);
                logger.DebugFormat("File size: {0}", pathStatus.FileSize);
            } catch (Exception ex) {
                logger.Error(ex);
            }

            try {
                // can only read 49352.
                resultData = client.Read(filePath, 0, 49253);
            } catch (Exception ex) {
                logger.Error(ex);
            }

            var actualData = IOUtil.Read(origianlFile, 0, 49252);

            try {
                Assert.IsTrue(actualData.SequenceEqual(resultData),
                    "File part should match.");
                logger.Debug("Read succeeded.");
            } catch (Exception ex) {
                logger.Error(ex);
            }

            Console.Read();
        }
        public static void TestAddFile(string db, string filePath, string chunkMapDto)
        {
            var dbs = new ChunkDbService(db, false);

            dbs.AddFile(filePath, File.ReadAllBytes(chunkMapDto));
        }
Esempio n. 23
0
 public FileUtil(ChunkDbService chunkDbService)
 {
     _chunkDbService = chunkDbService;
 }
Esempio n. 24
0
        public static void TestReadFile(string db, string torrentPath, string baseDir, string filePath, string origianlFile)
        {
            //System.Diagnostics.Debugger.Launch();
            var kernel = new StandardKernel();

            kernel.Load(new ServiceNinjectModule());

            kernel.Bind <FileInfoTable <TorrentManager> >().ToSelf().InSingletonScope();

            var dbs = new ChunkDbService(db, false);
            var ds  = new DeduplicationService(dbs);

            kernel.Bind <DeduplicationService>().ToConstant(ds).InSingletonScope();

            var writer = new DedupDiskWriter(ds);

            var engineSettings = new EngineSettings();

            engineSettings.PreferEncryption  = false;
            engineSettings.AllowedEncryption = EncryptionTypes.All;
            int port = 33123;
            var ip   = NetUtil.GetLocalIPByInterface("Local Area Connection");

            engineSettings.ReportedAddress = new IPEndPoint(ip, port);
            var engine = new ClientEngine(engineSettings, new DedupDiskWriter(ds));

            kernel.Bind <DiskManager>().ToConstant(engine.DiskManager).InSingletonScope();
            kernel.Bind <ClientEngine>().ToConstant(engine).InSingletonScope();

            kernel.Bind <DistributedDiskManager>().ToSelf();
            kernel.Bind <FileService>().ToSelf().WithConstructorArgument("baseDir", baseDir);

            kernel.Bind <VirtualDiskDownloadService>().ToSelf();
            var vd = kernel.Get <VirtualDiskDownloadService>();

            var torrent = Torrent.Load(torrentPath);

            logger.DebugFormat("Loaded torrent file: {0}, piece length: {1}.",
                               torrent.Name, torrent.PieceLength);
            vd.StartDownloadingFile(torrent, baseDir, -1);

            KernelContainer.Kernel = kernel;

            var m = new HurricaneServiceManager();

            m.Start();

            var url = string.Format("http://{0}:18081/FileService/", ip.ToString());

            logger.DebugFormat("Contacting service at {0}", url);
            var    client = new ManualFileServiceClient(url);
            string tstmsg = "tstmsg";
            var    resp   = client.Echo(tstmsg);

            Assert.AreEqual(resp, tstmsg);

            byte[] resultData = null;

            try {
                var pathStatus = client.GetPathStatus(filePath);
                logger.DebugFormat("File size: {0}", pathStatus.FileSize);
            } catch (Exception ex) {
                logger.Error(ex);
            }

            try {
                // can only read 49352.
                resultData = client.Read(filePath, 0, 49253);
            } catch (Exception ex) {
                logger.Error(ex);
            }

            var actualData = IOUtil.Read(origianlFile, 0, 49252);

            try {
                Assert.IsTrue(actualData.SequenceEqual(resultData),
                              "File part should match.");
                logger.Debug("Read succeeded.");
            } catch (Exception ex) {
                logger.Error(ex);
            }

            Console.Read();
        }
        public static void TestAddTorrent(string db, string filePath, string torrent)
        {
            var dbs = new ChunkDbService(db, false);

            dbs.AddTorrent(filePath, File.ReadAllBytes(torrent));
        }
Esempio n. 26
0
 public static void TestAddFile(string db, string filePath, string chunkMapDto)
 {
     var dbs = new ChunkDbService(db, false);
     dbs.AddFile(filePath, File.ReadAllBytes(chunkMapDto));
 }
Esempio n. 27
0
 public static void TestAddTorrent(string db, string filePath, string torrent)
 {
     var dbs = new ChunkDbService(db, false);
     dbs.AddTorrent(filePath, File.ReadAllBytes(torrent));
 }