Changeset 7563
- Timestamp:
- 03/06/12 15:50:21 (13 years ago)
- Location:
- branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Azure
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Azure/AzureProvider.cs
r7545 r7563 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.IO; 24 25 using HeuristicLab.Clients.Hive.CloudManager.Model; 25 26 … … 161 162 } 162 163 164 public string CreateDeployment(Subscription subscription, string serviceName, string deploymentName, string deploymentSlot, string packageUrl, FileInfo configuration, string label, int instanceCount) { 165 if (subscription == null) { 166 throw new ArgumentNullException("Subscription must not be null.", "subscription"); 167 } 168 if (instanceCount <= 0) { 169 throw new ArgumentException("Instance count must be greater than zero.", "instanceCount"); 170 } 171 172 string config = File.ReadAllText(configuration.FullName); 173 return ServiceManagementOperation.CreateDeployment(subscription.SubscriptionID, subscription.CertificateThumbprint, serviceName, deploymentName, deploymentSlot, packageUrl, config, label, instanceCount); 174 175 } 176 163 177 public string DeleteHostedService(Subscription subscription, string serviceName) { 164 178 if (subscription == null) { -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Azure/CloudBlobExtension.cs
r7550 r7563 1 1 2 using System; 3 using System.Collections.Generic; 4 using System.IO; 5 using System.Text; 6 using System.Threading.Tasks; 2 7 using Microsoft.WindowsAzure.StorageClient; 3 8 namespace HeuristicLab.Clients.Hive.CloudManager.Azure { 4 9 public static class CloudBlobExtension { 10 private class BlockTransferDetail { 11 public int StartPosition { get; set; } 12 public int BytesToRead { get; set; } 13 public string BlockId { get; set; } 14 } 15 5 16 //check if a blob exists 6 17 // see: http://stackoverflow.com/questions/2642919/checking-if-a-blob-exists-in-azure-storage … … 17 28 } 18 29 } 30 } 31 32 public static void UploadParallel(this CloudBlockBlob blob, string filePath) { 33 FileInfo file = new FileInfo(filePath); 34 //CloudBlockBlob blob = blobContainer.GetBlockBlobReference(file.Name); 35 blob.Properties.ContentType = "application/octet-stream"; 36 37 // init 38 int blockSize = 262144; 39 long fileSize = file.Length; 40 long leftToRead = fileSize; 41 int startPosition = 0; 42 43 int blockCount = ((int)Math.Floor((double)(fileSize / blockSize))) + 1; 44 BlockTransferDetail[] transferDetails = new BlockTransferDetail[blockCount]; 45 List<string> blockIdList = new List<string>(); 46 47 // setup control array 48 for (int j = 0; j < transferDetails.Length; j++) { 49 int toRead = (int)(leftToRead > blockSize ? blockSize : leftToRead); 50 string blockId = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(string.Format("BlockId{0}", j.ToString("0000000")))); 51 transferDetails[j] = new BlockTransferDetail() { StartPosition = startPosition, BytesToRead = toRead, BlockId = blockId }; 52 if (toRead > 0) { 53 blockIdList.Add(blockId); 54 } 55 startPosition += toRead; 56 leftToRead -= toRead; 57 } 58 59 // perform parallel upload 60 var result = Parallel.For(0, transferDetails.Length, j => { 61 using (FileStream fs = new FileStream(file.FullName, FileMode.Open, FileAccess.Read)) { 62 byte[] buffer = new byte[transferDetails[j].BytesToRead]; 63 BinaryReader br = new BinaryReader(fs); 64 fs.Seek(transferDetails[j].StartPosition, SeekOrigin.Begin); 65 br.Read(buffer, 0, transferDetails[j].BytesToRead); 66 if (buffer.Length > 0) { 67 using (MemoryStream ms = new MemoryStream(buffer)) { 68 blob.PutBlock(transferDetails[j].BlockId, ms, null); 69 } 70 } 71 } 72 }); 73 blob.PutBlockList(blockIdList); 19 74 } 20 75 -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Azure/Constants.cs
r7550 r7563 92 92 public const string DeploymentPackageUrl = "https://hivestorage.blob.core.windows.net/hiveslave/HeuristicLab.Clients.Hive.Slave.Azure.cspkg"; 93 93 public const string DeploymentConfigurationUrl = "https://hivestorage.blob.core.windows.net/hiveslave/ServiceConfiguration.Cloud.cscfg"; 94 public const string DeploymentConfigurationPath = "files/ServiceConfiguration.Cloud.cscfg"; 94 95 95 public const string DeploymentLabel = "HeuristicLab.Hive.Slave"; 96 96 public const string DeploymentRoleName = "HeuristicLab.Clients.Hive.Slave.AzureClient"; 97 98 public const string DeploymentConfigurationPath = "PackageFiles/ServiceConfiguration.Cloud.cscfg"; 99 public const string DeploymentPackagePathSmall = "PackageFiles/HeuristicLab.Clients.Hive.Slave.Azure.Small.cspkg"; 100 public const string DeploymentPackagePathMedium = "PackageFiles/HeuristicLab.Clients.Hive.Slave.Azure.Medium.cspkg"; 101 public const string DeploymentPackagePathLarge = "PackageFiles/HeuristicLab.Clients.Hive.Slave.Azure.Large.cspkg"; 102 public const string DeploymentPackagePathExtraLarge = "PackageFiles/HeuristicLab.Clients.Hive.Slave.Azure.ExtraLarge.cspkg"; 97 103 98 104 #endregion -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Azure/IAzureProvider.cs
r7545 r7563 21 21 22 22 using System.Collections.Generic; 23 using System.IO; 23 24 using HeuristicLab.Clients.Hive.CloudManager.Model; 24 25 … … 37 38 string CreateDeployment(Subscription subscription, string serviceName, string deploymentName, string deploymentSlot, string packageUrl, string configurationUrl, string label); 38 39 string CreateDeployment(Subscription subscription, string serviceName, string deploymentName, string deploymentSlot, string packageUrl, string configurationUrl, string label, int instanceCount); 40 string CreateDeployment(Subscription subscription, string serviceName, string deploymentName, string deploymentSlot, string packageUrl, FileInfo configuration, string label, int instanceCount); 39 41 string DeleteHostedService(Subscription subscription, string serviceName); 40 42
Note: See TracChangeset
for help on using the changeset viewer.