IsConsistent() public method

public IsConsistent ( ) : bool
return bool
Exemplo n.º 1
0
        public static WebRoleData MakeWebRoleData()
        {
            WebRoleData wrd = null;

            try              // create WebRoleData structure and store as blob, available to webrole on next _reload
            {
                var sw = new Stopwatch();
                sw.Start();
                wrd = new WebRoleData();
                sw.Stop();
                GenUtils.LogMsg("info", "new wrd: " + sw.Elapsed.ToString(), null);
                var info = String.Format("new wrd: where_ids: {0}, what_ids: {1}, region_ids {2}", wrd.where_ids.Count, wrd.what_ids.Count, wrd.region_ids.Count);
                GenUtils.LogMsg("info", info, null);
                GenUtils.LogMsg("info", "new wrd: " + wrd.str_ready_ids, null);
                sw.Start();
                if (wrd.IsConsistent())
                {
                    SaveWrd(wrd);
                }
                else
                {
                    GenUtils.PriorityLogMsg("warning", "MakeWebRoleData: inconsistent", null);
                    wrd = GetWrd();                     // fall back to last known good
                }
                sw.Stop();
                GenUtils.LogMsg("info", "save wrd: " + sw.Elapsed.ToString(), null);
            }
            catch (Exception e3)
            {
                GenUtils.PriorityLogMsg("exception", "MakeWebRoleData: creating wrd", e3.Message);
            }

            return(wrd);
        }
Exemplo n.º 2
0
        public static void SaveWrd(WebRoleData wrd)
        {
            if (!wrd.IsConsistent())
            {
                GenUtils.PriorityLogMsg("warning", "inconsistent WebRoleData!", null);
                return;
            }
            var bs             = BlobStorage.MakeDefaultBlobStorage();
            var lease_response = bs.RetryAcquireLease("admin", "wrd.obj");

            if (lease_response.status == HttpStatusCode.Created)
            {
                var lease_id = lease_response.headers["x-ms-lease-id"];
                var bytes    = ObjectUtils.SerializeObject(wrd);
                var headers  = new Hashtable()
                {
                    { "x-ms-lease-id", lease_id }
                };
                var r = bs.PutBlob("admin", "wrd.obj", headers, bytes, "binary/octet-stream");
                if (r.HttpResponse.status != HttpStatusCode.Created)
                {
                    GenUtils.PriorityLogMsg("warning", "SaveWrd: cannot save", null);
                }

                SaveTimestampedWrd(wrd);
            }
            else
            {
                GenUtils.PriorityLogMsg("warning", "SaveWrd: cannot lease", null);
            }
        }
Exemplo n.º 3
0
        public static WebRoleData MakeWebRoleData()
        {
            WebRoleData wrd = null;
            try  // create WebRoleData structure and store as blob, available to webrole on next _reload
            {
                var sw = new Stopwatch();
                sw.Start();
                wrd = new WebRoleData();
                sw.Stop();
                GenUtils.LogMsg("info", "new wrd: " + sw.Elapsed.ToString(), null);
                var info = String.Format("new wrd: where_ids: {0}, what_ids: {1}, region_ids {2}", wrd.where_ids.Count, wrd.what_ids.Count, wrd.region_ids.Count);
                GenUtils.LogMsg("info", info, null);
                GenUtils.LogMsg("info", "new wrd: " + wrd.str_ready_ids, null);
                sw.Start();
                if (wrd.IsConsistent())
                    SaveWrd(wrd);
                else
                {
                    GenUtils.PriorityLogMsg("warning", "MakeWebRoleData: inconsistent", null);
                    wrd = GetWrd(); // fall back to last known good
                }
                sw.Stop();
                GenUtils.LogMsg("info", "save wrd: " + sw.Elapsed.ToString(), null);
            }
            catch (Exception e3)
            {
                GenUtils.PriorityLogMsg("exception", "MakeWebRoleData: creating wrd", e3.Message);
            }

            return wrd;
        }
Exemplo n.º 4
0
        public static void SaveWrd(WebRoleData wrd)
        {
            if (!wrd.IsConsistent())
            {
                GenUtils.PriorityLogMsg("warning", "inconsistent WebRoleData!", null);
                return;
            }
            var bs = BlobStorage.MakeDefaultBlobStorage();
            var lease_response = bs.RetryAcquireLease("admin", "wrd.obj");
            if (lease_response.status == HttpStatusCode.Created)
            {
                var lease_id = lease_response.headers["x-ms-lease-id"];
                var bytes = ObjectUtils.SerializeObject(wrd);
                var headers = new Hashtable() { { "x-ms-lease-id", lease_id } };
                var r = bs.PutBlob("admin", "wrd.obj", headers, bytes, "binary/octet-stream");
                if (r.HttpResponse.status != HttpStatusCode.Created)
                    GenUtils.PriorityLogMsg("warning", "SaveWrd: cannot save", null);

                SaveTimestampedWrd(wrd);
            }
            else
            {
                GenUtils.PriorityLogMsg("warning", "SaveWrd: cannot lease", null);
            }
        }