Package org.apache.flink.runtime.instance

Examples of org.apache.flink.runtime.instance.AllocatedSlot


  }

  public boolean addIfInstanceIsAllocatedByJob(InternalInstanceProfilingData instanceProfilingData) {

    for (ExecutionVertex executionVertex : this.executionGraph.getAllExecutionVertices()) {
      AllocatedSlot slot = executionVertex.getCurrentAssignedResource();
      if (slot != null && slot.getInstance().getInstanceConnectionInfo().equals(
          instanceProfilingData.getInstanceConnectionInfo()))
      {
        this.collectedInstanceProfilingData.put(instanceProfilingData.getInstanceConnectionInfo(), instanceProfilingData);
        return true;
      }
View Full Code Here


  public InstanceSummaryProfilingEvent getInstanceSummaryProfilingData(long timestamp) {

    final Set<Instance> tempSet = new HashSet<Instance>();
   
    for (ExecutionVertex executionVertex : this.executionGraph.getAllExecutionVertices()) {
      AllocatedSlot slot = executionVertex.getCurrentAssignedResource();
      if (slot != null) {
        tempSet.add(slot.getInstance());
      }
    }

    // Now compare the size of the collected data set and the allocated instance set.
    // If their sizes are equal we can issue an instance summary.
View Full Code Here

      TaskOperationProtocol taskManager = mock(TaskOperationProtocol.class);
      when(taskManager.submitTask(Matchers.any(TaskDeploymentDescriptor.class))).thenReturn(new TaskOperationResult(execId, true));
      when(taskManager.cancelTask(execId)).thenReturn(new TaskOperationResult(execId, true), new TaskOperationResult(execId, false));
     
      Instance instance = getInstance(taskManager);
      AllocatedSlot slot = instance.allocateSlot(new JobID());
     
      vertex.deployToSlot(slot);
     
      assertEquals(ExecutionState.DEPLOYING, vertex.getExecutionState());
     
      vertex.cancel();
      
      assertEquals(ExecutionState.CANCELING, vertex.getExecutionState());
     
      verify(taskManager, times(0)).submitTask(Matchers.any(TaskDeploymentDescriptor.class));
      verify(taskManager, times(0)).cancelTask(execId);

      // first action happens (deploy)
      actions.triggerNextAction();
      assertEquals(ExecutionState.CANCELING, vertex.getExecutionState());
      verify(taskManager, times(1)).submitTask(Matchers.any(TaskDeploymentDescriptor.class));
     
      // the deploy call found itself in canceling after it returned and needs to send a cancel call
      // the call did not yet execute, so it is still in canceling
      assertEquals(ExecutionState.CANCELING, vertex.getExecutionState());
     
      // second action happens (cancel call from cancel function)
      actions.triggerNextAction();
     
      // TaskManager reports back (canceling done)
      vertex.getCurrentExecutionAttempt().cancelingComplete();
     
      // should properly set state to cancelled
      assertEquals(ExecutionState.CANCELED, vertex.getExecutionState());
     
      // trigger the correction canceling call
      actions.triggerNextAction();
      assertEquals(ExecutionState.CANCELED, vertex.getExecutionState());
     
      verify(taskManager, times(2)).cancelTask(execId);
     
      assertTrue(slot.isReleased());
     
      assertNull(vertex.getFailureCause());
     
      assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0);
      assertTrue(vertex.getStateTimestamp(ExecutionState.CANCELING) > 0);
View Full Code Here

     
      // first return NOT SUCCESS (task not found, cancel call overtook deploy call), then success (cancel call after deploy call)
      when(taskManager.cancelTask(execId)).thenReturn(new TaskOperationResult(execId, false), new TaskOperationResult(execId, true));
     
      Instance instance = getInstance(taskManager);
      AllocatedSlot slot = instance.allocateSlot(new JobID());
     
      vertex.deployToSlot(slot);
     
      assertEquals(ExecutionState.DEPLOYING, vertex.getExecutionState());
     
      vertex.cancel();
      
      assertEquals(ExecutionState.CANCELING, vertex.getExecutionState());
     
      verify(taskManager, times(0)).submitTask(Matchers.any(TaskDeploymentDescriptor.class));
      verify(taskManager, times(0)).cancelTask(execId);

      // first action happens (deploy)
      Runnable deployAction = actions.popNextAction();
      Runnable cancelAction = actions.popNextAction();
     
      // cancel call first
      cancelAction.run();
     
      // did not find the task, not properly cancelled, stay in canceling
      assertEquals(ExecutionState.CANCELING, vertex.getExecutionState());
     
      // deploy action next
      deployAction.run();
     
      verify(taskManager, times(1)).submitTask(Matchers.any(TaskDeploymentDescriptor.class));
     
      // the deploy call found itself in canceling after it returned and needs to send a cancel call
      // the call did not yet execute, so it is still in canceling
      assertEquals(ExecutionState.CANCELING, vertex.getExecutionState());
     
      // trigger the correcting cancel call, should properly set state to cancelled
      actions.triggerNextAction();
      vertex.getCurrentExecutionAttempt().cancelingComplete();
     
      assertEquals(ExecutionState.CANCELED, vertex.getExecutionState());
     
      verify(taskManager, times(2)).cancelTask(execId);
     
      assertTrue(slot.isReleased());
     
      assertNull(vertex.getFailureCause());
     
      assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0);
      assertTrue(vertex.getStateTimestamp(ExecutionState.CANCELING) > 0);
View Full Code Here

      final TaskOperationProtocol taskManager = mock(TaskOperationProtocol.class);
      when(taskManager.cancelTask(execId)).thenReturn(new TaskOperationResult(execId, true));
     
      Instance instance = getInstance(taskManager);
      AllocatedSlot slot = instance.allocateSlot(new JobID());

      setVertexState(vertex, ExecutionState.RUNNING);
      setVertexResource(vertex, slot);
     
      assertEquals(ExecutionState.RUNNING, vertex.getExecutionState());
     
      vertex.cancel();
      vertex.getCurrentExecutionAttempt().cancelingComplete(); // responce by task manager once actially canceled
     
      assertEquals(ExecutionState.CANCELED, vertex.getExecutionState());
     
      verify(taskManager).cancelTask(execId);
     
      assertTrue(slot.isReleased());
     
      assertNull(vertex.getFailureCause());
     
      assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0);
      assertTrue(vertex.getStateTimestamp(ExecutionState.CANCELING) > 0);
View Full Code Here

      final TaskOperationProtocol taskManager = mock(TaskOperationProtocol.class);
      when(taskManager.cancelTask(execId)).thenReturn(new TaskOperationResult(execId, true));
     
      Instance instance = getInstance(taskManager);
      AllocatedSlot slot = instance.allocateSlot(new JobID());

      setVertexState(vertex, ExecutionState.RUNNING);
      setVertexResource(vertex, slot);
     
      assertEquals(ExecutionState.RUNNING, vertex.getExecutionState());
     
      vertex.cancel();
     
      assertEquals(ExecutionState.CANCELING, vertex.getExecutionState());
     
      vertex.cancel();
     
      assertEquals(ExecutionState.CANCELING, vertex.getExecutionState());
     
      // callback by TaskManager after canceling completes
      vertex.getCurrentExecutionAttempt().cancelingComplete();
     
      assertEquals(ExecutionState.CANCELED, vertex.getExecutionState());
     
      // check that we did not overdo our cancel calls
      verify(taskManager, times(1)).cancelTask(execId);
     
      assertTrue(slot.isReleased());
     
      assertNull(vertex.getFailureCause());
     
      assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0);
      assertTrue(vertex.getStateTimestamp(ExecutionState.CANCELING) > 0);
View Full Code Here

      final TaskOperationProtocol taskManager = mock(TaskOperationProtocol.class);
      when(taskManager.cancelTask(execId)).thenReturn(new TaskOperationResult(execId, false));
     
      Instance instance = getInstance(taskManager);
      AllocatedSlot slot = instance.allocateSlot(new JobID());

      setVertexState(vertex, ExecutionState.RUNNING);
      setVertexResource(vertex, slot);
     
      assertEquals(ExecutionState.RUNNING, vertex.getExecutionState());
View Full Code Here

      final TaskOperationProtocol taskManager = mock(TaskOperationProtocol.class);
      when(taskManager.cancelTask(execId)).thenThrow(new IOException("RPC call failed"));
     
      Instance instance = getInstance(taskManager);
      AllocatedSlot slot = instance.allocateSlot(new JobID());

      setVertexState(vertex, ExecutionState.RUNNING);
      setVertexResource(vertex, slot);
     
      assertEquals(ExecutionState.RUNNING, vertex.getExecutionState());
     
      vertex.cancel();
     
      assertEquals(ExecutionState.FAILED, vertex.getExecutionState());
     
      assertTrue(slot.isReleased());
     
      assertNotNull(vertex.getFailureCause());
     
      assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0);
      assertTrue(vertex.getStateTimestamp(ExecutionState.CANCELING) > 0);
View Full Code Here

      final TaskOperationProtocol taskManager = mock(TaskOperationProtocol.class);
      when(taskManager.cancelTask(execId)).thenThrow(new IOException("RPC call failed"));
     
      Instance instance = getInstance(taskManager);
      AllocatedSlot slot = instance.allocateSlot(new JobID());

      setVertexState(vertex, ExecutionState.RUNNING);
      setVertexResource(vertex, slot);
     
      assertEquals(ExecutionState.RUNNING, vertex.getExecutionState());
     
      vertex.cancel();
     
      assertEquals(ExecutionState.CANCELING, vertex.getExecutionState());
     
      vertex.getCurrentExecutionAttempt().markFailed(new Throwable("test"));
     
      assertTrue(vertex.getExecutionState() == ExecutionState.CANCELED || vertex.getExecutionState() == ExecutionState.FAILED);
     
      assertTrue(slot.isReleased());
     
      assertEquals(0, vertex.getExecutionGraph().getRegisteredExecutions().size());
    }
    catch (Exception e) {
      e.printStackTrace();
View Full Code Here

      // deploying after canceling from CREATED needs to raise an exception, because
      // the scheduler (or any caller) needs to know that the slot should be released
      try {
        TaskOperationProtocol taskManager = mock(TaskOperationProtocol.class);
        Instance instance = getInstance(taskManager);
        AllocatedSlot slot = instance.allocateSlot(new JobID());
       
        vertex.deployToSlot(slot);
        fail("Method should throw an exception");
      }
      catch (IllegalStateException e) {
View Full Code Here

TOP

Related Classes of org.apache.flink.runtime.instance.AllocatedSlot

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.