private JobObjectList AllocateChunk(IDs3Client client, Guid chunkId)
        {
            JobObjectList chunk     = null;
            var           chunkGone = false;

            while (chunk == null && !chunkGone)
            {
                // This is an idempotent operation, so we don't care if it's already allocated.
                client
                .AllocateJobChunk(new AllocateJobChunkRequest(chunkId))
                .Match(
                    allocatedChunk => { chunk = allocatedChunk; },
                    this._wait,
                    () => { chunkGone = true; }
                    );
            }
            return(chunk);
        }
Ejemplo n.º 2
0
        public void AllocateChunkReturnsChunkWithNodeWhenAllocated()
        {
            var responseContent = ReadResource(AllocateJobChunkResponseResourceName);
            var queryParams     = new Dictionary <string, string> {
                { "operation", "allocate" }
            };
            var client = MockNetwork
                         .Expecting(HttpVerb.PUT, "/_rest_/job_chunk/f58370c2-2538-4e78-a9f8-e4d2676bdf44", queryParams, "")
                         .Returning(HttpStatusCode.OK, responseContent, _emptyHeaders)
                         .AsClient;
            var           response    = client.AllocateJobChunk(new AllocateJobChunkRequest(Guid.Parse("f58370c2-2538-4e78-a9f8-e4d2676bdf44")));
            JobObjectList chunkResult = null;

            response.Match(
                chunk => chunkResult = chunk,
                retryAfter => Assert.Fail(),
                Assert.Fail
                );
            Assert.NotNull(chunkResult);
            Assert.AreEqual(Guid.Parse("a02053b9-0147-11e4-8d6a-002590c1177c"), chunkResult.NodeId);
            Assert.AreEqual(Guid.Parse("f58370c2-2538-4e78-a9f8-e4d2676bdf44"), chunkResult.ChunkId);
            Assert.AreEqual(0, chunkResult.ChunkNumber);
            Assert.AreEqual(14, chunkResult.Objects.Count());
        }
Ejemplo n.º 3
0
 public SuccessChunkResponse(JobObjectList jobObjectList)
 {
     this._jobObjectList = jobObjectList;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a response object specifying the object list that was successfully (or already) allocated.
 /// </summary>
 /// <param name="jobObjectList">The job objects that were allocated.</param>
 /// <returns>The response instance.</returns>
 public static AllocateJobChunkResponse Success(JobObjectList jobObjectList)
 {
     return(new SuccessChunkResponse(jobObjectList));
 }