Esempio n. 1
0
        public static void GlobalStateToBlob(GlobalState globalState, string containerName, string blobName)
        {
            StreamWriter output = new StreamWriter(BlobLibrary.getBlobWriteStream(containerName, blobName));

            output.WriteLine("#S " + globalState.S.Length);
            for (int i = 0; i < globalState.S.Length; i++)
            {
                output.Write(globalState.S[i] + " ");
            }
            output.Write("\n");

            output.WriteLine("#W " + globalState.W.Length);
            for (int i = 0; i < globalState.W.Length; i++)
            {
                output.Write(globalState.W[i] + " ");
            }
            output.Write("\n");
            output.WriteLine("#Nonstubs " + globalState.nonStubs.Count);
            for (int i = 0; i < globalState.nonStubs.Count; i++)
            {
                output.Write(globalState.nonStubs[i] + " ");
            }
            output.Write("\n");
            output.Close();
        }
Esempio n. 2
0
        public static void miniDestinationToBlob(MiniDestination d, string containerName, string blobName)
        {
            //set up streamwriter for the blob.
            StreamWriter output = new StreamWriter(BlobLibrary.getBlobWriteStream(containerName, blobName));

            miniDestinationToStream(d, output);
            output.Close();
        }
Esempio n. 3
0
        public static void SToBlob(bool[] S, string containerName, string blobName)
        {
            StreamWriter output = new StreamWriter(BlobLibrary.getBlobWriteStream(containerName, blobName));

            for (int i = 0; i < S.Length; i++)
            {
                output.Write(S[i] + " ");
            }
            output.Write("\n");
            output.Close();
        }
Esempio n. 4
0
        public static void messageToBlob(Message m, string containerName, string blobName)
        {
            StreamWriter output = new StreamWriter(BlobLibrary.getBlobWriteStream(containerName, blobName));

            for (int i = 0; i < m.UBefore.Length; i++)
            {
                output.Write(m.UBefore[i] + " ");
            }
            output.Write("\n");
            for (int i = 0; i < m.UAfter.Length; i++)
            {
                output.Write(m.UAfter[i] + " ");
            }
            output.Write("\n");
            output.Close();
        }
Esempio n. 5
0
        public static string writeIterationToBlob(string containerName, Int32 t, ref Int64[] Before, ref Int64[] After, ref bool[] State)
        {
            string baseUri         = "";
            string paddedContainer = "";

            SimulatorLibrary.generateDirectoryName(containerName, ref paddedContainer);

            CloudBlobContainer blobContainer = BlobLibrary.initContainer(paddedContainer, ref baseUri);

            int    tries   = 0;
            bool   success = false;
            string errors  = "";

            do
            {
                try
                {
                    blobContainer.CreateIfNotExist();
                    success = true;
                }
                catch (Exception e)
                {
                    BlobLibrary.logToBlog("error when creating iteration result blob. " + e.Message + " retrying...", AccountInfo.masterLog);
                    Console.WriteLine("error when creating iteration result blob. " + e.Message + " retrying...");
                    errors = errors + e.Message + "\n";
                    Thread.Sleep(3000);
                    tries++;
                }
            } while (tries < 5 && !success);
            if (!success)
            {
                return(errors);
            }
            var perms = new BlobContainerPermissions
            {
                PublicAccess = BlobContainerPublicAccessType.Container // Blob (see files if you know the name) or Container (enumerate like a directory)
            };

            blobContainer.SetPermissions(perms); // This line makes the blob public so it is available from a web browser (no magic needed to read it)

            StreamWriter BeforeOutput = new StreamWriter(BlobLibrary.getBlobWriteStream(paddedContainer, paddedContainer + "." + Constants._UBeforeFileName + "." + t));
            StreamWriter AfterOutput  = new StreamWriter(BlobLibrary.getBlobWriteStream(paddedContainer, paddedContainer + "." + Constants._UAfterFileName + "." + t));
            StreamWriter StateOutput  = new StreamWriter(BlobLibrary.getBlobWriteStream(paddedContainer, paddedContainer + "." + Constants._SFileName + "." + t));

            for (int i = 0; i < Before.Length; i++)
            {
                BeforeOutput.Write(Before[i] + ",");
            }
            for (int i = 0; i < After.Length; i++)
            {
                AfterOutput.Write(After[i] + ",");
            }
            for (int i = 0; i < State.Length; i++)
            {
                if (State[i])
                {
                    StateOutput.Write("1,");
                }
                else
                {
                    StateOutput.Write("0,");
                }
            }

            BeforeOutput.Write("\n");
            AfterOutput.Write("\n");
            StateOutput.Write("\n");

            BeforeOutput.Close();
            AfterOutput.Close();
            StateOutput.Close();

            return("");
        }