Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Contexts are a way to structure the state and Configuration of an Evaluator. A Context exists on one and only one individual Evaluator. Each Evaluator has at least one Context, which we refer to as the root Context. This root context is special, as it is required on all Evaluators and because closing it is synonymous to releasing the Evaluator. In many simple REEF programs, this is the only Context used and it is therefore convenient to think of it as synonymous to "the Evaluator": The Driver can submit Tasks to it, is notifified notified when they are done and can close the root context when it wants to dispose of the Evaluator. 

...

To a first degree, you can think of this structure as the following stack:

 

LevelInjector structure
Task
taskInjector = activeContextInjector.fork(taskConfiguration)
task = taskInjector.getInstance(Task.class)
ActiveContext
activeContextInjector = rootContextInjector.fork(contextConfiguration)
RootContext
rootContextInjector = Tang.newInjector(rootContextConfiguration)

This illustrates how objects and configuration from the lower contexts are shared with the upper contexts in the stack. We rely on Tang to make this happen. However, the above simplifies one core issue: When forking injectors in Tang, the same rules apply as when merging Configuration instances. Most crucially, one cannot override bindings already present in an Injector when forking it. This presents a problem with the above design: every context has its own (injectable) ID using the same named parameter. Hence, one of the fork calls above work. To circumvent this, we use two Configurations and Injectors: One that is local to this Context called ContextConfiguration and one that is shared with subsequent contexts called ServiceContext. In the stack above, this looks like this:

LevelCode on the DriverEvaluator side
Task
activeContext.submit(taskConfiguration)
taskInjector = activeContextInjector.fork(taskConfiguration)task = taskInjector.getInstance(Task.class)
ActiveContext
activeContext.submitContextAndService(contextConfiguration, serviceConfiguration)
activeServiceInjector = rootServiceInjector.fork(serviceConfiguration)
activeContextInjector = activeServiceInjector.fork(contextConfiguration)
RootContext
allocatedEvaluator.submitContextAndService(rootContextConfiguration, rootServiceConfiguration)
rootServiceInjector = Tang.newInjector(rootServiceConfiguration)
rootContextInjector = rootServiceInjector.fork(rootContextConfiguration)

Note that only the content of the ServiceInjector(s) is shared with downstream contexts.