private void pushLogs(DataBufferName bufferName, string age) { if (IsTransferInProgress()) { TransferErrorMessage.Text = "Another transfer is in progress. Please wait for this transfer to complete before requesting another."; TransferErrorMessage.Visible = true; return; } var queueName = "hellofabric-" + Guid.NewGuid().ToString().ToLowerInvariant(); var manager = new DeploymentDiagnosticManager(RoleEnvironment.GetConfigurationSettingValue("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString"), RoleEnvironment.DeploymentId); foreach (var role in manager.GetRoleNames()) { foreach (var instanceManager in manager.GetRoleInstanceDiagnosticManagersForRole(role)) { var guid = instanceManager.BeginOnDemandTransfer(bufferName, getTransferParameters(age, queueName)); System.Diagnostics.Trace.WriteLine(string.Format("data transfer started for role {0}...", role)); } } TransferProgressPanel.Visible = true; TransferSetupPanel.Visible = false; }
static void Main() { var accountName = ConfigurationManager.AppSettings["Cloud Diagnostics Storage Account Name"]; Console.WriteLine(string.Format("Cloud Diagnostics Storage Account Name: {0}", accountName)); var accountKey = ConfigurationManager.AppSettings["Cloud Diagnostics Storage Account Key"]; Console.WriteLine(string.Format("Cloud Diagnostics Storage Account Key: {0}", new string('*', accountKey.Length))); var storageCredentialsAccountAndKey = new StorageCredentialsAccountAndKey(accountName, accountKey); var storageAccount = new CloudStorageAccount(storageCredentialsAccountAndKey, true); Console.WriteLine(string.Format("Deployment ID: ")); var deploymentID = Console.ReadLine(); var deploymentDiagnosticManager = new DeploymentDiagnosticManager(storageAccount, deploymentID); string roleInstanceName; Guid guid; var roleNames = deploymentDiagnosticManager.GetRoleNames(); foreach (var roleName in roleNames) { Console.WriteLine(string.Format("Role Name: {0}", roleName)); foreach (var roleInstanceDiagnosticManager in deploymentDiagnosticManager.GetRoleInstanceDiagnosticManagersForRole(roleName)) { roleInstanceName = roleInstanceDiagnosticManager.RoleInstanceId; Console.WriteLine(string.Format("Role Instance Name: {0}", roleInstanceName)); Console.WriteLine("Calling to transfer logs."); guid = Transfer(roleInstanceDiagnosticManager, DataBufferName.Logs); Console.WriteLine(string.Format("Logs transfer '{0}'", guid)); Console.WriteLine("Calling to transfer directories."); guid = Transfer(roleInstanceDiagnosticManager, DataBufferName.Directories); Console.WriteLine(string.Format("Directories transfer '{0}'", guid)); } } Console.WriteLine("Hit any key to end..."); Console.ReadKey(); }
private bool IsTransferInProgress() { var manager = new DeploymentDiagnosticManager(RoleEnvironment.GetConfigurationSettingValue("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString"), RoleEnvironment.DeploymentId); var account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString")); var queueClient = account.CreateCloudQueueClient(); var result = false; var activeTransfers = new Dictionary <string, List <OnDemandTransferInfo> >(); foreach (var role in manager.GetRoleNames()) { foreach (var instanceManager in manager.GetRoleInstanceDiagnosticManagersForRole(role)) { var transfers = instanceManager.GetActiveTransfers(); foreach (var transfer in transfers) { if (!activeTransfers.ContainsKey(transfer.Value.NotificationQueueName)) { activeTransfers.Add(transfer.Value.NotificationQueueName, new List <OnDemandTransferInfo>()); } activeTransfers[transfer.Value.NotificationQueueName].Add(transfer.Value); } } } foreach (var queueTransfersPair in activeTransfers) { var queue = queueClient.GetQueueReference(queueTransfersPair.Key); if (queue.Exists()) { foreach (var msg in queue.GetMessages(queueTransfersPair.Value.Count)) { var info = OnDemandTransferInfo.FromQueueMessage(msg); var instanceManager = manager.GetRoleInstanceDiagnosticManager(info.RoleName, info.RoleInstanceId); var res = instanceManager.EndOnDemandTransfer(info.RequestId); System.Diagnostics.Trace.WriteLine(string.Format("data transfer complete for role instance {0}.", info.RoleInstanceId)); var pairInfo = queueTransfersPair.Value.Find((value) => value.RequestId == info.RequestId); if (pairInfo != null) { queueTransfersPair.Value.Remove(pairInfo); } queue.DeleteMessage(msg); } } if (queueTransfersPair.Value.Count != 0) { result = true; } else if (queue.Exists()) { queue.Delete(); } } return(result); }
private void pushLogs(DataBufferName bufferName, string age) { if (IsTransferInProgress()) { TransferErrorMessage.Text = "Another transfer is in progress. Please wait for this transfer to complete before requesting another."; TransferErrorMessage.Visible = true; return; } var queueName = "hellofabric-" + Guid.NewGuid().ToString().ToLowerInvariant(); var manager = new DeploymentDiagnosticManager(RoleEnvironment.GetConfigurationSettingValue("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString"), RoleEnvironment.DeploymentId); foreach (var role in manager.GetRoleNames()) { foreach (var instanceManager in manager.GetRoleInstanceDiagnosticManagersForRole(role)) { var guid = instanceManager.BeginOnDemandTransfer(bufferName, getTransferParameters(age, queueName)); System.Diagnostics.Trace.WriteLine(string.Format("data transfer started for role {0}...", role)); } } TransferProgressPanel.Visible = true; TransferSetupPanel.Visible = false; }
private bool IsTransferInProgress() { var manager = new DeploymentDiagnosticManager(RoleEnvironment.GetConfigurationSettingValue("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString"), RoleEnvironment.DeploymentId); var account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString")); var queueClient = account.CreateCloudQueueClient(); var result = false; var activeTransfers = new Dictionary<string, List<OnDemandTransferInfo>>(); foreach (var role in manager.GetRoleNames()) { foreach (var instanceManager in manager.GetRoleInstanceDiagnosticManagersForRole(role)) { var transfers = instanceManager.GetActiveTransfers(); foreach (var transfer in transfers) { if (!activeTransfers.ContainsKey(transfer.Value.NotificationQueueName)) activeTransfers.Add(transfer.Value.NotificationQueueName, new List<OnDemandTransferInfo>()); activeTransfers[transfer.Value.NotificationQueueName].Add(transfer.Value); } } } foreach (var queueTransfersPair in activeTransfers) { var queue = queueClient.GetQueueReference(queueTransfersPair.Key); if (queue.Exists()) { foreach (var msg in queue.GetMessages(queueTransfersPair.Value.Count)) { var info = OnDemandTransferInfo.FromQueueMessage(msg); var instanceManager = manager.GetRoleInstanceDiagnosticManager(info.RoleName, info.RoleInstanceId); var res = instanceManager.EndOnDemandTransfer(info.RequestId); System.Diagnostics.Trace.WriteLine(string.Format("data transfer complete for role instance {0}.", info.RoleInstanceId)); var pairInfo = queueTransfersPair.Value.Find((value) => value.RequestId == info.RequestId); if (pairInfo != null) queueTransfersPair.Value.Remove(pairInfo); queue.DeleteMessage(msg); } } if (queueTransfersPair.Value.Count != 0) result = true; else if (queue.Exists()) queue.Delete(); } return result; }