*/
public void register(Task task) throws InsufficientResourcesException {
// Check if we can safely run this task with the given buffers
ensureBufferAvailability(task);
RuntimeEnvironment environment = task.getEnvironment();
// -------------------------------------------------------------------------------------------------------------
// Register output channels
// -------------------------------------------------------------------------------------------------------------
environment.registerGlobalBufferPool(this.globalBufferPool);
if (this.localBuffersPools.containsKey(task.getExecutionId())) {
throw new IllegalStateException("Execution " + task.getExecutionId() + " has a previous buffer pool owner");
}
for (OutputGate gate : environment.outputGates()) {
// add receiver list hints
for (OutputChannel channel : gate.channels()) {
// register envelope dispatcher with the channel
channel.registerEnvelopeDispatcher(this);
switch (channel.getChannelType()) {
case IN_MEMORY:
addReceiverListHint(channel.getID(), channel.getConnectedId());
break;
case NETWORK:
addReceiverListHint(channel.getConnectedId(), channel.getID());
break;
}
this.channels.put(channel.getID(), channel);
}
}
this.localBuffersPools.put(task.getExecutionId(), environment);
// -------------------------------------------------------------------------------------------------------------
// Register input channels
// -------------------------------------------------------------------------------------------------------------
// register global
for (InputGate<?> gate : environment.inputGates()) {
gate.registerGlobalBufferPool(this.globalBufferPool);
for (int i = 0; i < gate.getNumberOfInputChannels(); i++) {
InputChannel<? extends IOReadableWritable> channel = gate.getInputChannel(i);
channel.registerEnvelopeDispatcher(this);