-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/13381/
-----------------------------------------------------------

(Updated Aug. 7, 2013, 9:58 p.m.)


Review request for mesos, Benjamin Hindman and Vinod Kone.


Changes
-------

Updated the test to use the testing abstractions.


Repository: mesos-git


Description
-------

Throwing this up as a bit of a straw man proposal.

I have code upstream in a branch where I'd like to collect a set of futures, 
but I'd like to process a partial result. That is, it is not a failure if any 
of the Futures fail or become discarded. When this occurs, I would still like 
to process all of the Futures that were successful.

Simplified code below for using await():

{
  list<Future<ResourceStatistics> > futures;

  foreachkey (const FrameworkID& frameworkId, executors) {
    foreachkey (const ExecutorID& executorId, executors[frameworkId]) {
      futures.push_back(
          dispatch(isolator, &Isolator::usage, frameworkId, executorId));
    }
  }

  return process::await(futures)
    .then(lambda::bind(
        __statisticsJSON,
        lambda::_1));
}

Future<http::Response> __statisticsJSON(
    const list<Future<ResourceStatistics> >& statistics)
{
  foreach (const Future<ResourceStatistics>& stats, statistics) {
    // Ignore failed / discarded results, possibly log warnings.
    if (stats.isFailed() || stats.isDiscarded()) {
      continue;
    }
    
    CHECK(stats.isReady());

    // Process the statistics.
  }

  return http::OK(result, jsonp);
}

Alternatively, I could have my code iteratively retry until it gets a 
successful collect() result. However, it requires a guard against infinite 
retries.


Diffs (updated)
-----

  3rdparty/libprocess/include/process/collect.hpp 
3c620aa7ab2af1a8348c1fb190cbf490a7cf1a60 
  3rdparty/libprocess/src/tests/process_tests.cpp 
ed510bed73e688768fe33d14d6974d0085a7c2ed 

Diff: https://reviews.apache.org/r/13381/diff/


Testing
-------

make check (I will add a test if we like this approach).


Thanks,

Ben Mahler

Reply via email to