private static void TEST_SwiftInteractions() { Console.Out.WriteLine("##########################"); Console.Out.WriteLine("# TEST > FileInteraction #"); Console.Out.WriteLine("##########################"); Console.Out.WriteLine(""); string folderName = "file"; fileStorage = new GenericFileStorage(ksManager.Username, ksManager.TokenId, StorageType.SWIFT, ksManager.Project); //fileStorage.CreateFolder("swift://cloudflow/", folderName); List <FileDescription> fds = fileStorage.GetFileDescriptions(); //Test du create & delete folder if (fds.Where(f => f.getVisualName().Equals(folderName)).Count() == 0) { fileStorage.CreateFolder(folderName); } /* * fileStorage.DeleteFolder(folderName); * fds = fileStorage.GetFileDescriptions(); * fileStorage.CreateFolder(folderName); * //*/ //Test du upload & download fds = fileStorage.GetFileDescriptions(folderName); FileDescription myFile; string filename = "image2.png"; List <FileDescription> fdsResult = fds == null ? null : fds.Where(fd => fd.getUniqueName().EndsWith(folderName + "/" + filename)).ToList(); if (fdsResult == null || fdsResult.Count() == 0) { myFile = fileStorage.UploadFile(@"D:\CloudFlow\" + filename, folderName); } else { myFile = fdsResult.First(); } fileStorage.DownloadFile(myFile, @"D:\CloudFlow\DL\", ""); Console.Out.WriteLine(""); Console.Out.WriteLine("################"); Console.Out.WriteLine(""); }
private static void TEST_FileInteractions() { Console.Out.WriteLine("##########################"); Console.Out.WriteLine("# TEST > FileInteraction #"); Console.Out.WriteLine("##########################"); Console.Out.WriteLine(""); fileStorage = new GenericFileStorage(ksManager.Username, ksManager.TokenId, StorageType.FILE, "cloudflow"); List <FileDescription> fds = fileStorage.GetFileDescriptions(); FileDescription myFile; string filename = "image4.PNG"; List <FileDescription> fdsResult = fds.Where(fd => fd.getVisualName() == filename).ToList(); if (fdsResult.Count() == 0) { myFile = fileStorage.UploadFile(@"D:\CloudFlow\" + filename); } else { myFile = fdsResult.First(); } fileStorage.DownloadFile(myFile, @"D:\CloudFlow\DL\", ""); Console.Out.WriteLine(""); Console.Out.WriteLine("################"); Console.Out.WriteLine(""); }
private static void TEST_Perfos() { Console.Out.WriteLine("##########################"); Console.Out.WriteLine("# TEST > Perfos #"); Console.Out.WriteLine("##########################"); Console.Out.WriteLine(""); List <string> perfos = new List <string>(); double ulTotalTime = 0.0; double dlTotalTime = 0.0; string filename = "image2.png"; FileInfo fi = new FileInfo(@"D:\CloudFlow\" + filename); long fileSize = fi.Length; int bufferSize = 128; for (int l = 0; l < 4; l++) { perfos.Add("##########################"); perfos.Add("# " + bufferSize + " #"); perfos.Add("##########################"); fileStorage = new GenericFileStorage(ksManager.Username, ksManager.TokenId, StorageType.SWIFT, "cloudflow"); fileStorage.BufferSize = bufferSize; string folderName = "perfos"; List <FileDescription> fds = fileStorage.GetFileDescriptions(); //Test du create & delete folder if (fds.Where(f => f.getVisualName().Equals(folderName)).Count() == 0) { fileStorage.CreateFolder(folderName); } Console.Out.WriteLine(""); for (int j = 0; j < 10; j++) { fds = fileStorage.GetFileDescriptions(folderName); FileDescription myFile; List <FileDescription> fdsResult = fds == null ? null : fds.Where(fd => fd.getUniqueName().EndsWith(folderName + "/" + filename)).ToList(); if (fdsResult != null && fdsResult.Count() != 0) { fileStorage.RemoveFile(fdsResult.First()); } DateTime startDt = DateTime.Now; myFile = fileStorage.UploadFile(@"D:\CloudFlow\" + filename, folderName); double nbSec = (DateTime.Now - startDt).TotalSeconds; double bw = fileSize / 1024 / nbSec; perfos.Add("UL = " + nbSec + " s" + " >> " + bw + " ko/s"); ulTotalTime += nbSec; startDt = DateTime.Now; fileStorage.DownloadFile(myFile, @"D:\CloudFlow\DL\", ""); nbSec = (DateTime.Now - startDt).TotalSeconds; bw = fileSize / 1024 / nbSec; perfos.Add("DL = " + nbSec + " s" + " >> " + bw + " ko/s"); dlTotalTime += nbSec; Console.Out.Write(" -"); } bufferSize = bufferSize * 2; perfos.Add(">>>> UL moyen = " + fileSize * 10 / ulTotalTime); perfos.Add(">>>> DL moyen = " + fileSize * 10 / dlTotalTime); writeLog(perfos); ulTotalTime = 0; dlTotalTime = 0; } Console.Out.WriteLine(""); Console.Out.WriteLine(""); Console.Out.WriteLine("################"); Console.Out.WriteLine(""); }