Example #1
0
        private bool CreateBlobWithJob(IFetchRequest request, string hash, double allowedCreationTimeSec)
        {
            var requestBlob = resultsContainer.GetPageBlobReference(ResultBlobName(hash));

            while (true)
            {
                try
                {
                    JobManagerTrace.TraceVerbose("Trying to create blob ({0})", hash);
                    requestBlob.Create(0, accessCondition: AccessCondition.GenerateIfNotExistsCondition());
                    JobManagerTrace.TraceVerbose("Blob {0} successfully created", hash);

                    //loading request into blob
                    string blobUri = ResultDataSetUri(hash, true).ToString();

                    JobManagerTrace.TraceVerbose("Filling blob with request. uri = {0}", blobUri);

                    RequestDataSetFormat.CreateRequestBlobDataSet(blobUri, request).Dispose();

                    return(true);
                }
                catch (StorageException e)
                {
                    // Blob already exist - probably someone already works with it
                    if (e.RequestInformation.HttpStatusCode == 412 /* Procondition Failed*/)
                    {
                        JobManagerTrace.TraceVerbose("Can't create blob {0}. It is already exists", hash);
                        try
                        {
                            requestBlob.FetchAttributes();
                        }
                        catch (StorageException)
                        {
                            JobManagerTrace.TraceWarning("Can't get modification time of blob {0}. Retrying", hash);
                            continue;
                        }
                        double allowdSeconds = allowedCreationTimeSec;
                        if ((DateTime.UtcNow - requestBlob.Properties.LastModified.Value).TotalSeconds > allowdSeconds)
                        {
                            JobManagerTrace.TraceWarning("Job blob {0} exists but there are no job records in the job table exists longer than permitted time ({1}). deleting it", hash, allowdSeconds);
                            requestBlob.DeleteIfExists();
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }
Example #2
0
        public Task <DataSet> FetchAsync(FetchRequest request, Action <FetchStatus> progressReport = null)
        {
            if (configProvider == null)
            {
                configProvider = new SqlExtendedConfigurationProvider(SharedConstants.LocalConfigurationConnectionString);
            }

            var cfg    = configProvider.GetConfiguration(request.ReproducibilityTimestamp);
            var feType = Type.GetType(cfg.FetchEngineTypeName);

            if (feType == null)
            {
                throw new InvalidOperationException("Cannot load fetch engine type " + feType);
            }
            var fe = (IFetchEngine)feType.GetConstructor(new Type[1] {
                typeof(IExtendedConfigurationProvider)
            }).Invoke(new object[1] {
                new SqlExtendedConfigurationProvider(SharedConstants.LocalConfigurationConnectionString)
            });

            return(fe.PerformRequestAsync(request).
                   ContinueWith(t => RequestDataSetFormat.CreateCompletedRequestDataSet("msds:memory", request, t.Result.Values, t.Result.Provenance, t.Result.Uncertainty)));
        }