Package org.apache.flink.runtime.instance

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


      try {
        ExecutionVertex vertex = new ExecutionVertex(ejv, 0, new IntermediateResult[0]);
        setVertexState(vertex, ExecutionState.CANCELING);
       
        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) {}
     
     
      // fail while canceling
      {
        ExecutionVertex vertex = new ExecutionVertex(ejv, 0, new IntermediateResult[0]);
       
        TaskOperationProtocol taskManager = mock(TaskOperationProtocol.class);
        Instance instance = getInstance(taskManager);
        AllocatedSlot slot = instance.allocateSlot(new JobID());
       
        setVertexResource(vertex, slot);
        setVertexState(vertex, ExecutionState.CANCELING);
       
        Exception failureCause = new Exception("test exception");
View Full Code Here


  @Test
  public void testScheduleWithDyingInstances() {
    try {
      Scheduler scheduler = new Scheduler();
     
      Instance i1 = getRandomInstance(2);
      Instance i2 = getRandomInstance(2);
      Instance i3 = getRandomInstance(1);
     
      scheduler.newInstanceAvailable(i1);
      scheduler.newInstanceAvailable(i2);
      scheduler.newInstanceAvailable(i3);
     
      List<AllocatedSlot> slots = new ArrayList<AllocatedSlot>();
      slots.add(scheduler.scheduleImmediately(new ScheduledUnit(getDummyTask())));
      slots.add(scheduler.scheduleImmediately(new ScheduledUnit(getDummyTask())));
      slots.add(scheduler.scheduleImmediately(new ScheduledUnit(getDummyTask())));
      slots.add(scheduler.scheduleImmediately(new ScheduledUnit(getDummyTask())));
      slots.add(scheduler.scheduleImmediately(new ScheduledUnit(getDummyTask())));
     
      i2.markDead();
     
      for (AllocatedSlot slot : slots) {
        if (slot.getInstance() == i2) {
          assertTrue(slot.isCanceled());
        } else {
          assertFalse(slot.isCanceled());
        }
       
        slot.releaseSlot();
      }
     
      assertEquals(3, scheduler.getNumberOfAvailableSlots());
     
      i1.markDead();
      i3.markDead();
     
      // cannot get another slot, since all instances are dead
      try {
        scheduler.scheduleImmediately(new ScheduledUnit(getDummyTask()));
        fail("Scheduler served a slot from a dead instance");
View Full Code Here

  @Test
  public void testSchedulingLocation() {
    try {
      Scheduler scheduler = new Scheduler();
     
      Instance i1 = getRandomInstance(2);
      Instance i2 = getRandomInstance(2);
      Instance i3 = getRandomInstance(2);
     
      scheduler.newInstanceAvailable(i1);
      scheduler.newInstanceAvailable(i2);
      scheduler.newInstanceAvailable(i3);
     
      // schedule something on an arbitrary instance
      AllocatedSlot s1 = scheduler.scheduleImmediately(new ScheduledUnit(getTestVertex(Collections.<Instance>emptyList())));
     
      // figure out how we use the location hints
      Instance first = s1.getInstance();
      Instance second = first != i1 ? i1 : i2;
      Instance third = first == i3 ? i2 : i3;
     
      // something that needs to go to the first instance again
      AllocatedSlot s2 = scheduler.scheduleImmediately(new ScheduledUnit(getTestVertex(Collections.singletonList(s1.getInstance()))));
      assertEquals(first, s2.getInstance());
View Full Code Here

    InstanceConnectionInfo ci = new InstanceConnectionInfo(address, ipcPort, dataPort);
   
    final long GB = 1024L*1024*1024;
    HardwareDescription resources = new HardwareDescription(4, 4*GB, 3*GB, 2*GB);
   
    return new Instance(ci, new InstanceID(), resources, numSlots);
  }
View Full Code Here

    // we need potentially to loop multiple times, because there may be false positives
    // in the set-with-available-instances
    while (true) {
      if (this.instancesWithAvailableResources.isEmpty()) {
        // check if the asynchronous calls did not yet return the queues
        Instance queuedInstance = this.newlyAvailableInstances.poll();
        if (queuedInstance == null) {
          return null;
        } else {
          this.instancesWithAvailableResources.add(queuedInstance);
        }
      }
     
      Iterator<Instance> locations = requestedLocations == null ? null : requestedLocations.iterator();
     
      Instance instanceToUse = null;
      Locality locality = Locality.UNCONSTRAINED;
     
      if (locations != null && locations.hasNext()) {
        // we have a locality preference
       
        while (locations.hasNext()) {
          Instance location = locations.next();
         
          if (location != null && this.instancesWithAvailableResources.remove(location)) {
            instanceToUse = location;
            locality = Locality.LOCAL;
           
View Full Code Here

  }
 
  private void handleNewSlot() {
   
    synchronized (globalLock) {
      Instance instance = this.newlyAvailableInstances.poll();
      if (instance == null || !instance.hasResourcesAvailable()) {
        // someone else took it
        return;
      }
     
      QueuedTask queued = taskQueue.peek();
     
      // the slot was properly released, we can allocate a new one from that instance
     
      if (queued != null) {
        ScheduledUnit task = queued.getTask();
        ExecutionVertex vertex = task.getTaskToExecute().getVertex();
       
        try {
          AllocatedSlot newSlot = instance.allocateSlot(vertex.getJobId());
          if (newSlot != null) {
           
            // success, remove from the task queue and notify the future
            taskQueue.poll();
            if (queued.getFuture() != null) {
View Full Code Here

          return null;
        }
       
      }).when(assignment).releaseSubSlot(any(SubSlot.class), any(SharedSlot.class));
     
      Instance instance = SchedulerTestUtils.getRandomInstance(1);
     
      SharedSlot slot = new SharedSlot(instance.allocateSlot(new JobID()), assignment);
      assertFalse(slot.isDisposed());
     
      SubSlot ss1 = slot.allocateSubSlot(new JobVertexID());
      assertNotNull(ss1);
     
View Full Code Here

          return null;
        }
       
      }).when(assignment).releaseSubSlot(any(SubSlot.class), any(SharedSlot.class));
     
      Instance instance = SchedulerTestUtils.getRandomInstance(1);
     
      SharedSlot slot = new SharedSlot(instance.allocateSlot(new JobID()), assignment);
      assertFalse(slot.isDisposed());
     
      SubSlot ss1 = slot.allocateSubSlot(new JobVertexID());
      assertNotNull(ss1);
     
View Full Code Here

  }
 
  private SubSlot addNewSlotWithTask(AllocatedSlot slot, AbstractID groupId, JobVertexID vertexId) {
   
    final SharedSlot sharedSlot = new SharedSlot(slot, this);
    final Instance location = slot.getInstance();
   
    synchronized (lock) {
      // add to the total bookkeeping
      allSlots.add(sharedSlot);
     
View Full Code Here

          reference.set(tdd);
          return new TaskOperationResult(tdd.getExecutionId(), true);
        }
      });
     
      final Instance instance = getInstance(taskManager);
      final AllocatedSlot slot = instance.allocateSlot(jobId);
     
      assertEquals(ExecutionState.CREATED, vertex.getExecutionState());
     
      vertex.deployToSlot(slot);
     
View Full Code Here

TOP

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

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.