示例#1
0
 public static void testUnTarGZip()
 {
     Logger.init(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\temp\\scratch 2\\uncompress.log");
     Guid myGuid = Guid.NewGuid();
     string archivePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\temp\\scratch 2\\01010101-0101-0101-0101-010101010101_123_0.tgz";
     string outputDir = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\temp\\scratch 2";
     RestoreTask rt = new RestoreTask(archivePath, outputDir);
     rt.Add("cs 410 2012-12-09\\echo backup logo v1.png");
     StorageThread st = new StorageThread("", myGuid);
     st.EnqueueStorageTask(rt);
     Print("added task to storagethread");
     int x=0;
     while (st.IsWorking())
     {
         x++;
         Thread.Sleep(1000);
         Print("waiting for storagethread to finish working " + x);
     }
     Print("storagethread done");
     st.RequestStop();
     Print("requested stop of storagethread");
     while (st.IsAlive())
     {
         x++;
         Thread.Sleep(1000);
         Print("waiting for storagethread to stop " + x);
     }
     Print("storagethread stopped");
     Console.WriteLine("press a key to continue");
     Console.ReadKey();
 }
示例#2
0
        /// <summary>
        /// tests the basic Tar and GZip functionality.
        /// </summary>
        static void testTarGZip()
        {
            Console.WriteLine("starting testTarBzip2");
            byte[] b = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
            Guid guid = new Guid(b);
            string tempPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\temp\\scratch";
            string tempPath2 = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\temp\\scratch 2";
            StorageThread st = new StorageThread(tempPath, guid);
            BackupTask task = new BackupTask(tempPath, tempPath2, 123, 0);
            st.EnqueueStorageTask(task);
            Console.WriteLine("queued task");
            int x = 0;
            while (st.IsWorking())
            {
                x++;
                Console.WriteLine("waiting for thread to finish." + x);
                Thread.Sleep(1000);
            }
            Console.WriteLine("thread finished.");
            st.RequestStop();
            Console.WriteLine("requested thread terminate.");
            while (st.IsAlive())
            {
                x++;
                Console.WriteLine("waiting for thread to die. " + x);
                Thread.Sleep(1000);
            }
            Console.WriteLine("thread is dead.");
            Console.WriteLine("number of chunks: " + st.NumChunks());
            while (st.NumChunks() > 0)
            {
                Chunk c = st.DequeueChunk();
                Console.WriteLine(c);
            }

            Console.WriteLine("press a key to continue");
            Console.ReadKey();
        }
示例#3
0
        protected override void OnStart(string[] args)
        {
            #region logging
            Logger.Log("Started Service");
            #endregion
            #region heartbeats
            net = new Backend.Networker();
            Logger.Debug2("created NetWorker");
            indexdi = new Backend.IndexDistribution();
            Logger.Debug2("created indexdi");
            indexdi.SetDistribute(true);
            Logger.Debug2("set distribute on indexdi");
            messageThread = new Thread(new ThreadStart(net.processMessages));
            Logger.Debug2("created messagethread");
            rxThread = new Thread(new ThreadStart(net.runReceiver));
            Logger.Debug2("created rxThread");
            txThread = new Thread(new ThreadStart(net.runTransmitter));
            Logger.Debug2("created txthread");
            distributionThread = new Thread(new ThreadStart(indexdi.BeginIndexDistribution));
            Logger.Debug2("created dithread");
            net.startTransmitter();
            Logger.Debug2("Started net transmitter");
            txThread.Start();
            Logger.Debug2("Started txthread");
            net.startReciever();
            Logger.Debug2("Started net receiver");
            messageThread.Start();
            Logger.Debug2("started messagethread");
            rxThread.Start();
            Logger.Debug2("Started rxThread");
            distributionThread.Start();
            Logger.Debug2("started dithread");
            #endregion
            #region networking
            commandServer = new CommandServer(guid);
            Logger.Debug2("started CommandServer");
            #endregion
            #region storage
            storageThread = new StorageThread(Node.GetTemporaryDirectory(), this.guid);
            Logger.Debug2("started StorageThread");
            #endregion

            setupWCF();

            mainThread = new Thread(new ThreadStart(MainLoop));
            //MainLoop();
        }