TraceWarning() 정적인 개인적인 메소드

static private TraceWarning ( string message ) : void
message string
리턴 void
예제 #1
0
        public override void OnStop()
        {
            DiagnosticsHelper.TraceInformation("MongoWorkerRole onstop called");
            try
            {
                // should we instead call Process.stop?
                if ((mongodProcess != null) &&
                    !(mongodProcess.HasExited))
                {
                    DatabaseHelper.StepdownIfNeeded(mongodPort);
                }
            }
            catch (Exception e)
            {
                //Ignore exceptions caught on unmount
                DiagnosticsHelper.TraceWarning("Exception in onstop - stepdown failed");
                DiagnosticsHelper.TraceWarning(e.Message);
                DiagnosticsHelper.TraceWarning(e.StackTrace);
            }

            try
            {
                // should we instead call Process.stop?
                DiagnosticsHelper.TraceInformation("Shutdown called on mongod");
                if ((mongodProcess != null) &&
                    !(mongodProcess.HasExited))
                {
                    ShutdownMongo();
                }
                DiagnosticsHelper.TraceInformation("Shutdown completed on mongod");
            }
            catch (Exception e)
            {
                //Ignore exceptions caught on unmount
                DiagnosticsHelper.TraceWarning("Exception in onstop - mongo shutdown");
                DiagnosticsHelper.TraceWarning(e.Message);
                DiagnosticsHelper.TraceWarning(e.StackTrace);
            }

            try
            {
                DiagnosticsHelper.TraceInformation("Unmount called on data drive");
                if (mongoDataDrive != null)
                {
                    mongoDataDrive.Unmount();
                }
                DiagnosticsHelper.TraceInformation("Unmount completed on data drive");
            }
            catch (Exception e)
            {
                //Ignore exceptions caught on unmount
                DiagnosticsHelper.TraceWarning("Exception in onstop - unmount of data drive");
                DiagnosticsHelper.TraceWarning(e.Message);
                DiagnosticsHelper.TraceWarning(e.StackTrace);
            }

            DiagnosticsHelper.TraceInformation("Calling diagnostics shutdown");
            // DiagnosticsHelper.ShutdownDiagnostics();
            base.OnStop();
        }
예제 #2
0
        public override void Run()
        {
            DiagnosticsHelper.TraceInformation("MongoWorkerRole run method called");
            var mongodRunning = CheckIfMongodRunning();

            while (mongodRunning)
            {
                DatabaseHelper.RunCloudCommandLocally(instanceId, mongodPort);
                Thread.Sleep(15000);
                mongodRunning = CheckIfMongodRunning();
            }

            Thread.Sleep(60000);

            DiagnosticsHelper.TraceWarning("MongoWorkerRole run method exiting");
        }
예제 #3
0
        internal static string GetMountedPathFromBlob(
            string localCachePath,
            string cloudDir,
            string containerName,
            string blobName,
            int driveSize,
            out CloudDrive mongoDrive)
        {
            DiagnosticsHelper.TraceInformation(string.Format("In mounting cloud drive for dir {0} on {1} with {2}",
                                                             cloudDir,
                                                             containerName,
                                                             blobName));

            CloudStorageAccount storageAccount = CloudStorageAccount.FromConfigurationSetting(cloudDir);

            var blobClient = storageAccount.CreateCloudBlobClient();

            DiagnosticsHelper.TraceInformation("Get container");
            // this should be the name of your replset
            var driveContainer = blobClient.GetContainerReference(containerName);

            // create blob container (it has to exist before creating the cloud drive)
            try
            {
                driveContainer.CreateIfNotExist();
            }
            catch (Exception e)
            {
                DiagnosticsHelper.TraceInformation("Exception when creating container");
                DiagnosticsHelper.TraceInformation(e.Message);
                DiagnosticsHelper.TraceInformation(e.StackTrace);
            }

            var mongoBlobUri = blobClient.GetContainerReference(containerName).GetPageBlobReference(blobName).Uri.ToString();

            DiagnosticsHelper.TraceInformation(string.Format("Blob uri obtained {0}", mongoBlobUri));

            // create the cloud drive
            mongoDrive = storageAccount.CreateCloudDrive(mongoBlobUri);
            try
            {
                mongoDrive.Create(driveSize);
            }
            catch (Exception e)
            {
                // exception is thrown if all is well but the drive already exists
                DiagnosticsHelper.TraceInformation("Exception when creating cloud drive. safe to ignore");
                DiagnosticsHelper.TraceInformation(e.Message);
                DiagnosticsHelper.TraceInformation(e.StackTrace);
            }

            DiagnosticsHelper.TraceInformation("Initialize cache");
            var localStorage = RoleEnvironment.GetLocalResource(localCachePath);

            CloudDrive.InitializeCache(localStorage.RootPath.TrimEnd('\\'),
                                       localStorage.MaximumSizeInMegabytes);

            // mount the drive and get the root path of the drive it's mounted as
            try
            {
                DiagnosticsHelper.TraceInformation(string.Format("Trying to mount blob as azure drive on {0}",
                                                                 RoleEnvironment.CurrentRoleInstance.Id));
                var driveLetter = mongoDrive.Mount(localStorage.MaximumSizeInMegabytes,
                                                   DriveMountOptions.None);
                DiagnosticsHelper.TraceInformation(string.Format("Write lock acquired on azure drive, mounted as {0}, on role instance",
                                                                 driveLetter, RoleEnvironment.CurrentRoleInstance.Id));
                return(driveLetter);
            }
            catch (Exception e)
            {
                DiagnosticsHelper.TraceWarning("could not acquire blob lock.");
                DiagnosticsHelper.TraceWarning(e.Message);
                DiagnosticsHelper.TraceWarning(e.StackTrace);
                throw;
            }
        }