Package org.apache.flink.runtime.execution

Examples of org.apache.flink.runtime.execution.RuntimeEnvironment


   */
  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);
View Full Code Here


      if (this.runningTasks.putIfAbsent(executionId, task) != null) {
        throw new Exception("TaskManager contains already a task with executionId " + executionId);
      }
     
      final InputSplitProvider splitProvider = new TaskInputSplitProvider(this.globalInputSplitProvider, jobID, vertexId, executionId);
      final RuntimeEnvironment env = new RuntimeEnvironment(task, tdd, userCodeClassLoader, this.memoryManager, this.ioManager, splitProvider, this.accumulatorProtocolProxy, this.bcVarManager);
      task.setEnvironment(env);
     
      // register the task with the network stack and profilers
      this.channelManager.register(task);
     
      final Configuration jobConfig = tdd.getJobConfiguration();

      boolean enableProfiling = this.profiler != null && jobConfig.getBoolean(ProfilingUtils.PROFILE_JOB_KEY, true);

      // Register environment, input, and output gates for profiling
      if (enableProfiling) {
        task.registerProfiler(this.profiler, jobConfig);
      }
     
      // now that the task is successfully created and registered, we can start copying the
      // distributed cache temp files
      Map<String, FutureTask<Path>> cpTasks = new HashMap<String, FutureTask<Path>>();
      for (Entry<String, DistributedCacheEntry> e : DistributedCache.readFileInfoFromConfig(tdd.getJobConfiguration())) {
        FutureTask<Path> cp = this.fileCache.createTmpFile(e.getKey(), e.getValue(), jobID);
        cpTasks.put(e.getKey(), cp);
      }
      env.addCopyTasksForCacheFile(cpTasks);
     
      if (!task.startExecution()) {
        throw new CancelTaskException();
      }
   
View Full Code Here

    // Unregister task from memory manager
    task.unregisterMemoryManager(this.memoryManager);
   
    // remove the local tmp file for unregistered tasks.
    try {
      RuntimeEnvironment re = task.getEnvironment();
      if (re != null) {
        for (Entry<String, DistributedCacheEntry> e: DistributedCache.readFileInfoFromConfig(task.getEnvironment().getJobConfiguration())) {
          this.fileCache.deleteTmpFile(e.getKey(), e.getValue(), task.getJobID());
        }
      }
View Full Code Here

   *
   * @param memoryManager
   *        the central memory manager
   */
  public void unregisterMemoryManager(MemoryManager memoryManager) {
    RuntimeEnvironment env = this.environment;
    if (memoryManager != null && env != null) {
      memoryManager.releaseAll(env.getInvokable());
    }
  }
View Full Code Here

      final JobID jid = new JobID();
      final JobVertexID vid = new JobVertexID();
      final ExecutionAttemptID eid = new ExecutionAttemptID();
     
      final TaskManager taskManager = mock(TaskManager.class);
      final RuntimeEnvironment env = mock(RuntimeEnvironment.class);
     
      Task task = new Task(jid, vid, 2, 7, eid, "TestTask", taskManager);
      task.setEnvironment(env);
     
      assertEquals(ExecutionState.DEPLOYING, task.getExecutionState());
View Full Code Here

            error.set(t);
          }
        }
      };
     
      final RuntimeEnvironment env = mock(RuntimeEnvironment.class);
      when(env.getExecutingThread()).thenReturn(operation);
     
      assertEquals(ExecutionState.DEPLOYING, task.getExecutionState());
     
      // start the execution
      task.setEnvironment(env);
View Full Code Here

            error.set(t);
          }
        }
      };
     
      final RuntimeEnvironment env = mock(RuntimeEnvironment.class);
      when(env.getExecutingThread()).thenReturn(operation);
     
      assertEquals(ExecutionState.DEPLOYING, task.getExecutionState());
     
      // start the execution
      task.setEnvironment(env);
View Full Code Here

            error.set(t);
          }
        }
      };
     
      final RuntimeEnvironment env = mock(RuntimeEnvironment.class);
      when(env.getExecutingThread()).thenReturn(operation);
     
      assertEquals(ExecutionState.DEPLOYING, task.getExecutionState());
     
      // start the execution
      task.setEnvironment(env);
View Full Code Here

          Collections.<GateDeploymentDescriptor>emptyList(),
          new ArrayList<BlobKey>(), 0);
     
      Task task = new Task(jid, vid, 2, 7, eid, "TestTask", taskManager);
     
      RuntimeEnvironment env = new RuntimeEnvironment(task, tdd, getClass().getClassLoader(),
          mock(MemoryManager.class), mock(IOManager.class), mock(InputSplitProvider.class),
          mock(AccumulatorProtocol.class), new BroadcastVariableManager());
     
      task.setEnvironment(env);
     
View Full Code Here

          Collections.<GateDeploymentDescriptor>emptyList(),
          new ArrayList<BlobKey>(), 0);
     
      Task task = new Task(jid, vid, 2, 7, eid, "TestTask", taskManager);
     
      RuntimeEnvironment env = new RuntimeEnvironment(task, tdd, getClass().getClassLoader(),
          mock(MemoryManager.class), mock(IOManager.class), mock(InputSplitProvider.class),
          mock(AccumulatorProtocol.class), new BroadcastVariableManager());
     
      task.setEnvironment(env);
     
View Full Code Here

TOP

Related Classes of org.apache.flink.runtime.execution.RuntimeEnvironment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.