0
我已经实现了Azure的调度作业数量如何按照以下博客检查的剩余天青scheculer的工作收集
http://fabriccontroller.net/a-complete-overview-to-get-started-with-the-windows-azure-scheduler/
现在我能在调度创建/更新/删除工作,但如何我可以检查工作收集是否已满?基本上我想创建另一个集合,只要我当前的工作集合已满。
分享我的代码片断
public class AzureSchedulerStorage : ISchedulerStorage
{
private CertificateCloudCredentials credentials;
//private CloudServiceManagementClient cloudServiceClient;
private string cloudServiceName;
// private IHalseyLogger logger;
public AzureSchedulerStorage(string cloudServiceName, CertificateCloudCredentials credentials)
{
this.cloudServiceName = cloudServiceName;
this.credentials = credentials;
// this.logger = logger;
}
public SchedulerOperationStatusResponse CreateJobCollection(string jobCollectionName)
{
var schedulerServiceClient = new SchedulerManagementClient(credentials);
var jobCollectionCreateParameters = new JobCollectionCreateParameters()
{
Label = jobCollectionName,
IntrinsicSettings = new JobCollectionIntrinsicSettings()
{
Plan = JobCollectionPlan.Standard,
Quota = new JobCollectionQuota()
{
MaxJobCount = 50,
MaxRecurrence = new JobCollectionMaxRecurrence()
{
Frequency = JobCollectionRecurrenceFrequency.Minute
}
}
}
};
var result = schedulerServiceClient.JobCollections.Create(this.cloudServiceName, jobCollectionName, jobCollectionCreateParameters);
return result;
}
public JobCollectionGetResponse GetJobCollection(string jobCollectionName)
{
var schedulerServiceClient = new SchedulerManagementClient(credentials);
var result = schedulerServiceClient.JobCollections.Get(this.cloudServiceName, jobCollectionName);
return result;
}
public void CreateOrUpdate(string jobcollectionName, string jobId, DateTime startDate)
{
var schedulerClient = new SchedulerClient(this.cloudServiceName, jobcollectionName, this.credentials);
var job = new JobCreateOrUpdateParameters()
{
Action = new JobAction()
{
Type = JobActionType.Https,
Request = new JobHttpRequest()
{
Body = "customer=sandrino&command=sendnewsletter",
Headers = new Dictionary<string, string>()
{
{ "Content-Type", "application/x-www-form-urlencoded" },
{ "x-something", "value123" }
},
Method = "POST",
Uri = new Uri("http://postcatcher.in/catchers/527af9acfe325802000001cb"),
}
},
StartTime = startDate,
};
var result = schedulerClient.Jobs.CreateOrUpdate(jobId, job);
}
}
}
是的我也想同样的方式来捕获配额例外,并创建另一个集合,但只是想着他们怎么会错过这样一个微不足道的事情 – rahulshr
不幸的是,作业计数不提供作为响应的一部分,你可以得到所有的工作内一个工作集合,用于确定是否存在剩余容量,或如所建议的,尝试创建作业并处理错误。 –