Java 类org.apache.hadoop.yarn.api.records.ReservationRequests 实例源码

项目:hadoop    文件:TestReservationInputValidator.java   
private ReservationSubmissionRequest createSimpleReservationSubmissionRequest(
    int numRequests, int numContainers, long arrival, long deadline,
    long duration) {
  // create a request with a single atomic ask
  ReservationSubmissionRequest request =
      new ReservationSubmissionRequestPBImpl();
  ReservationDefinition rDef = new ReservationDefinitionPBImpl();
  rDef.setArrival(arrival);
  rDef.setDeadline(deadline);
  if (numRequests > 0) {
    ReservationRequests reqs = new ReservationRequestsPBImpl();
    rDef.setReservationRequests(reqs);
    if (numContainers > 0) {
      ReservationRequest r =
          ReservationRequest.newInstance(Resource.newInstance(1024, 1, 1),
              numContainers, 1, duration);

      reqs.setReservationResources(Collections.singletonList(r));
      reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
    }
  }
  request.setQueue(PLAN_NAME);
  request.setReservationDefinition(rDef);
  return request;
}
项目:hadoop    文件:TestReservationInputValidator.java   
private ReservationUpdateRequest createSimpleReservationUpdateRequest(
    int numRequests, int numContainers, long arrival, long deadline,
    long duration) {
  // create a request with a single atomic ask
  ReservationUpdateRequest request = new ReservationUpdateRequestPBImpl();
  ReservationDefinition rDef = new ReservationDefinitionPBImpl();
  rDef.setArrival(arrival);
  rDef.setDeadline(deadline);
  if (numRequests > 0) {
    ReservationRequests reqs = new ReservationRequestsPBImpl();
    rDef.setReservationRequests(reqs);
    if (numContainers > 0) {
      ReservationRequest r =
          ReservationRequest.newInstance(Resource.newInstance(1024, 1, 1),
              numContainers, 1, duration);

      reqs.setReservationResources(Collections.singletonList(r));
      reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
    }
  }
  request.setReservationDefinition(rDef);
  request.setReservationId(ReservationSystemTestUtil.getNewReservationId());
  return request;
}
项目:hadoop    文件:TestClientRMService.java   
private ReservationSubmissionRequest createSimpleReservationRequest(
    int numContainers, long arrival, long deadline, long duration) {
  // create a request with a single atomic ask
  ReservationRequest r =
      ReservationRequest.newInstance(Resource.newInstance(1024, 1, 1),
          numContainers, 1, duration);
  ReservationRequests reqs =
      ReservationRequests.newInstance(Collections.singletonList(r),
          ReservationRequestInterpreter.R_ALL);
  ReservationDefinition rDef =
      ReservationDefinition.newInstance(arrival, deadline, reqs,
          "testClientRMService#reservation");
  ReservationSubmissionRequest request =
      ReservationSubmissionRequest.newInstance(rDef,
          ReservationSystemTestUtil.reservationQ);
  return request;
}
项目:hadoop    文件:TestYarnClient.java   
private ReservationSubmissionRequest createSimpleReservationRequest(
    int numContainers, long arrival, long deadline, long duration) {
  // create a request with a single atomic ask
  ReservationRequest r =
      ReservationRequest.newInstance(Resource.newInstance(1024, 1),
          numContainers, 1, duration);
  ReservationRequests reqs =
      ReservationRequests.newInstance(Collections.singletonList(r),
          ReservationRequestInterpreter.R_ALL);
  ReservationDefinition rDef =
      ReservationDefinition.newInstance(arrival, deadline, reqs,
          "testYarnClient#reservation");
  ReservationSubmissionRequest request =
      ReservationSubmissionRequest.newInstance(rDef,
          ReservationSystemTestUtil.reservationQ);
  return request;
}
项目:aliyun-oss-hadoop-fs    文件:ReservationSystemTestUtil.java   
public static ReservationSubmissionRequest createSimpleReservationRequest(
    int numContainers, long arrival, long deadline, long duration) {
  // create a request with a single atomic ask
  ReservationRequest r =
      ReservationRequest.newInstance(Resource.newInstance(1024, 1),
          numContainers, 1, duration);
  ReservationRequests reqs =
      ReservationRequests.newInstance(Collections.singletonList(r),
          ReservationRequestInterpreter.R_ALL);
  ReservationDefinition rDef =
      ReservationDefinition.newInstance(arrival, deadline, reqs,
          "testClientRMService#reservation");
  ReservationSubmissionRequest request =
      ReservationSubmissionRequest.newInstance(rDef,
          reservationQ);
  return request;
}
项目:aliyun-oss-hadoop-fs    文件:TestReservationInputValidator.java   
private ReservationSubmissionRequest createSimpleReservationSubmissionRequest(
    int numRequests, int numContainers, long arrival, long deadline,
    long duration) {
  // create a request with a single atomic ask
  ReservationSubmissionRequest request =
      new ReservationSubmissionRequestPBImpl();
  ReservationDefinition rDef = new ReservationDefinitionPBImpl();
  rDef.setArrival(arrival);
  rDef.setDeadline(deadline);
  if (numRequests > 0) {
    ReservationRequests reqs = new ReservationRequestsPBImpl();
    rDef.setReservationRequests(reqs);
    if (numContainers > 0) {
      ReservationRequest r =
          ReservationRequest.newInstance(Resource.newInstance(1024, 1),
              numContainers, 1, duration);

      reqs.setReservationResources(Collections.singletonList(r));
      reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
    }
  }
  request.setQueue(PLAN_NAME);
  request.setReservationDefinition(rDef);
  return request;
}
项目:aliyun-oss-hadoop-fs    文件:TestReservationInputValidator.java   
private ReservationUpdateRequest createSimpleReservationUpdateRequest(
    int numRequests, int numContainers, long arrival, long deadline,
    long duration) {
  // create a request with a single atomic ask
  ReservationUpdateRequest request = new ReservationUpdateRequestPBImpl();
  ReservationDefinition rDef = new ReservationDefinitionPBImpl();
  rDef.setArrival(arrival);
  rDef.setDeadline(deadline);
  if (numRequests > 0) {
    ReservationRequests reqs = new ReservationRequestsPBImpl();
    rDef.setReservationRequests(reqs);
    if (numContainers > 0) {
      ReservationRequest r =
          ReservationRequest.newInstance(Resource.newInstance(1024, 1),
              numContainers, 1, duration);

      reqs.setReservationResources(Collections.singletonList(r));
      reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
    }
  }
  request.setReservationDefinition(rDef);
  request.setReservationId(ReservationSystemTestUtil.getNewReservationId());
  return request;
}
项目:aliyun-oss-hadoop-fs    文件:TestYarnClient.java   
private ReservationSubmissionRequest createSimpleReservationRequest(
    int numContainers, long arrival, long deadline, long duration) {
  // create a request with a single atomic ask
  ReservationRequest r =
      ReservationRequest.newInstance(Resource.newInstance(1024, 1),
          numContainers, 1, duration);
  ReservationRequests reqs =
      ReservationRequests.newInstance(Collections.singletonList(r),
          ReservationRequestInterpreter.R_ALL);
  ReservationDefinition rDef =
      ReservationDefinition.newInstance(arrival, deadline, reqs,
          "testYarnClient#reservation");
  ReservationSubmissionRequest request =
      ReservationSubmissionRequest.newInstance(rDef,
          ReservationSystemTestUtil.reservationQ);
  return request;
}
项目:big-c    文件:TestReservationInputValidator.java   
private ReservationSubmissionRequest createSimpleReservationSubmissionRequest(
    int numRequests, int numContainers, long arrival, long deadline,
    long duration) {
  // create a request with a single atomic ask
  ReservationSubmissionRequest request =
      new ReservationSubmissionRequestPBImpl();
  ReservationDefinition rDef = new ReservationDefinitionPBImpl();
  rDef.setArrival(arrival);
  rDef.setDeadline(deadline);
  if (numRequests > 0) {
    ReservationRequests reqs = new ReservationRequestsPBImpl();
    rDef.setReservationRequests(reqs);
    if (numContainers > 0) {
      ReservationRequest r =
          ReservationRequest.newInstance(Resource.newInstance(1024, 1),
              numContainers, 1, duration);

      reqs.setReservationResources(Collections.singletonList(r));
      reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
    }
  }
  request.setQueue(PLAN_NAME);
  request.setReservationDefinition(rDef);
  return request;
}
项目:big-c    文件:TestReservationInputValidator.java   
private ReservationUpdateRequest createSimpleReservationUpdateRequest(
    int numRequests, int numContainers, long arrival, long deadline,
    long duration) {
  // create a request with a single atomic ask
  ReservationUpdateRequest request = new ReservationUpdateRequestPBImpl();
  ReservationDefinition rDef = new ReservationDefinitionPBImpl();
  rDef.setArrival(arrival);
  rDef.setDeadline(deadline);
  if (numRequests > 0) {
    ReservationRequests reqs = new ReservationRequestsPBImpl();
    rDef.setReservationRequests(reqs);
    if (numContainers > 0) {
      ReservationRequest r =
          ReservationRequest.newInstance(Resource.newInstance(1024, 1),
              numContainers, 1, duration);

      reqs.setReservationResources(Collections.singletonList(r));
      reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
    }
  }
  request.setReservationDefinition(rDef);
  request.setReservationId(ReservationSystemTestUtil.getNewReservationId());
  return request;
}
项目:big-c    文件:TestClientRMService.java   
private ReservationSubmissionRequest createSimpleReservationRequest(
    int numContainers, long arrival, long deadline, long duration) {
  // create a request with a single atomic ask
  ReservationRequest r =
      ReservationRequest.newInstance(Resource.newInstance(1024, 1),
          numContainers, 1, duration);
  ReservationRequests reqs =
      ReservationRequests.newInstance(Collections.singletonList(r),
          ReservationRequestInterpreter.R_ALL);
  ReservationDefinition rDef =
      ReservationDefinition.newInstance(arrival, deadline, reqs,
          "testClientRMService#reservation");
  ReservationSubmissionRequest request =
      ReservationSubmissionRequest.newInstance(rDef,
          ReservationSystemTestUtil.reservationQ);
  return request;
}
项目:big-c    文件:TestYarnClient.java   
private ReservationSubmissionRequest createSimpleReservationRequest(
    int numContainers, long arrival, long deadline, long duration) {
  // create a request with a single atomic ask
  ReservationRequest r =
      ReservationRequest.newInstance(Resource.newInstance(1024, 1),
          numContainers, 1, duration);
  ReservationRequests reqs =
      ReservationRequests.newInstance(Collections.singletonList(r),
          ReservationRequestInterpreter.R_ALL);
  ReservationDefinition rDef =
      ReservationDefinition.newInstance(arrival, deadline, reqs,
          "testYarnClient#reservation");
  ReservationSubmissionRequest request =
      ReservationSubmissionRequest.newInstance(rDef,
          ReservationSystemTestUtil.reservationQ);
  return request;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestReservationInputValidator.java   
private ReservationSubmissionRequest createSimpleReservationSubmissionRequest(
    int numRequests, int numContainers, long arrival, long deadline,
    long duration) {
  // create a request with a single atomic ask
  ReservationSubmissionRequest request =
      new ReservationSubmissionRequestPBImpl();
  ReservationDefinition rDef = new ReservationDefinitionPBImpl();
  rDef.setArrival(arrival);
  rDef.setDeadline(deadline);
  if (numRequests > 0) {
    ReservationRequests reqs = new ReservationRequestsPBImpl();
    rDef.setReservationRequests(reqs);
    if (numContainers > 0) {
      ReservationRequest r =
          ReservationRequest.newInstance(Resource.newInstance(1024, 1),
              numContainers, 1, duration);

      reqs.setReservationResources(Collections.singletonList(r));
      reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
    }
  }
  request.setQueue(PLAN_NAME);
  request.setReservationDefinition(rDef);
  return request;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestReservationInputValidator.java   
private ReservationUpdateRequest createSimpleReservationUpdateRequest(
    int numRequests, int numContainers, long arrival, long deadline,
    long duration) {
  // create a request with a single atomic ask
  ReservationUpdateRequest request = new ReservationUpdateRequestPBImpl();
  ReservationDefinition rDef = new ReservationDefinitionPBImpl();
  rDef.setArrival(arrival);
  rDef.setDeadline(deadline);
  if (numRequests > 0) {
    ReservationRequests reqs = new ReservationRequestsPBImpl();
    rDef.setReservationRequests(reqs);
    if (numContainers > 0) {
      ReservationRequest r =
          ReservationRequest.newInstance(Resource.newInstance(1024, 1),
              numContainers, 1, duration);

      reqs.setReservationResources(Collections.singletonList(r));
      reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
    }
  }
  request.setReservationDefinition(rDef);
  request.setReservationId(ReservationSystemTestUtil.getNewReservationId());
  return request;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestClientRMService.java   
private ReservationSubmissionRequest createSimpleReservationRequest(
    int numContainers, long arrival, long deadline, long duration) {
  // create a request with a single atomic ask
  ReservationRequest r =
      ReservationRequest.newInstance(Resource.newInstance(1024, 1),
          numContainers, 1, duration);
  ReservationRequests reqs =
      ReservationRequests.newInstance(Collections.singletonList(r),
          ReservationRequestInterpreter.R_ALL);
  ReservationDefinition rDef =
      ReservationDefinition.newInstance(arrival, deadline, reqs,
          "testClientRMService#reservation");
  ReservationSubmissionRequest request =
      ReservationSubmissionRequest.newInstance(rDef,
          ReservationSystemTestUtil.reservationQ);
  return request;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestYarnClient.java   
private ReservationSubmissionRequest createSimpleReservationRequest(
    int numContainers, long arrival, long deadline, long duration) {
  // create a request with a single atomic ask
  ReservationRequest r =
      ReservationRequest.newInstance(Resource.newInstance(1024, 1),
          numContainers, 1, duration);
  ReservationRequests reqs =
      ReservationRequests.newInstance(Collections.singletonList(r),
          ReservationRequestInterpreter.R_ALL);
  ReservationDefinition rDef =
      ReservationDefinition.newInstance(arrival, deadline, reqs,
          "testYarnClient#reservation");
  ReservationSubmissionRequest request =
      ReservationSubmissionRequest.newInstance(rDef,
          ReservationSystemTestUtil.reservationQ);
  return request;
}
项目:hops    文件:ReservationSystemTestUtil.java   
public static ReservationSubmissionRequest createSimpleReservationRequest(
    ReservationId reservationId, int numContainers, long arrival,
    long deadline, long duration) {
  // create a request with a single atomic ask
  ReservationRequest r =
      ReservationRequest.newInstance(Resource.newInstance(1024, 1),
          numContainers, 1, duration);
  ReservationRequests reqs =
      ReservationRequests.newInstance(Collections.singletonList(r),
          ReservationRequestInterpreter.R_ALL);
  ReservationDefinition rDef =
      ReservationDefinition.newInstance(arrival, deadline, reqs,
          "testClientRMService#reservation");
  ReservationSubmissionRequest request =
      ReservationSubmissionRequest.newInstance(rDef,
          reservationQ, reservationId);
  return request;
}
项目:hops    文件:TestReservationInputValidator.java   
private ReservationSubmissionRequest createSimpleReservationSubmissionRequest(
    int numRequests, int numContainers, long arrival, long deadline,
    long duration) {
  // create a request with a single atomic ask
  ReservationSubmissionRequest request =
      new ReservationSubmissionRequestPBImpl();
  ReservationDefinition rDef = new ReservationDefinitionPBImpl();
  rDef.setArrival(arrival);
  rDef.setDeadline(deadline);
  if (numRequests > 0) {
    ReservationRequests reqs = new ReservationRequestsPBImpl();
    rDef.setReservationRequests(reqs);
    if (numContainers > 0) {
      ReservationRequest r =
          ReservationRequest.newInstance(Resource.newInstance(1024, 1),
              numContainers, 1, duration);

      reqs.setReservationResources(Collections.singletonList(r));
      reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
    }
  }
  request.setQueue(PLAN_NAME);
  request.setReservationDefinition(rDef);
  return request;
}
项目:hops    文件:TestReservationInputValidator.java   
private ReservationUpdateRequest createSimpleReservationUpdateRequest(
    int numRequests, int numContainers, long arrival, long deadline,
    long duration) {
  // create a request with a single atomic ask
  ReservationUpdateRequest request = new ReservationUpdateRequestPBImpl();
  ReservationDefinition rDef = new ReservationDefinitionPBImpl();
  rDef.setArrival(arrival);
  rDef.setDeadline(deadline);
  if (numRequests > 0) {
    ReservationRequests reqs = new ReservationRequestsPBImpl();
    rDef.setReservationRequests(reqs);
    if (numContainers > 0) {
      ReservationRequest r =
          ReservationRequest.newInstance(Resource.newInstance(1024, 1),
              numContainers, 1, duration);

      reqs.setReservationResources(Collections.singletonList(r));
      reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
    }
  }
  request.setReservationDefinition(rDef);
  request.setReservationId(ReservationSystemTestUtil.getNewReservationId());
  return request;
}
项目:hops    文件:TestYarnClient.java   
private ReservationSubmissionRequest createSimpleReservationRequest(
    ReservationId reservationId, int numContainers, long arrival,
    long deadline, long duration) {
  // create a request with a single atomic ask
  ReservationRequest r =
      ReservationRequest.newInstance(Resource.newInstance(1024, 1),
          numContainers, 1, duration);
  ReservationRequests reqs =
      ReservationRequests.newInstance(Collections.singletonList(r),
          ReservationRequestInterpreter.R_ALL);
  ReservationDefinition rDef =
      ReservationDefinition.newInstance(arrival, deadline, reqs,
          "testYarnClient#reservation");
  ReservationSubmissionRequest request =
      ReservationSubmissionRequest.newInstance(rDef,
          ReservationSystemTestUtil.reservationQ, reservationId);
  return request;
}
项目:hadoop    文件:ReservationDefinitionPBImpl.java   
@Override
public ReservationRequests getReservationRequests() {
  ReservationDefinitionProtoOrBuilder p = viaProto ? proto : builder;
  if (reservationReqs != null) {
    return reservationReqs;
  }
  if (!p.hasReservationRequests()) {
    return null;
  }
  reservationReqs = convertFromProtoFormat(p.getReservationRequests());
  return reservationReqs;
}
项目:hadoop    文件:ReservationDefinitionPBImpl.java   
@Override
public void setReservationRequests(ReservationRequests reservationRequests) {
  if (reservationRequests == null) {
    builder.clearReservationRequests();
    return;
  }
  this.reservationReqs = reservationRequests;
}
项目:hadoop    文件:TestInMemoryReservationAllocation.java   
private ReservationDefinition createSimpleReservationDefinition(long arrival,
    long deadline, long duration) {
  // create a request with a single atomic ask
  ReservationRequest r =
      ReservationRequest.newInstance(Resource.newInstance(1024, 1, 1), 1, 1,
          duration);
  ReservationDefinition rDef = new ReservationDefinitionPBImpl();
  ReservationRequests reqs = new ReservationRequestsPBImpl();
  reqs.setReservationResources(Collections.singletonList(r));
  reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
  rDef.setReservationRequests(reqs);
  rDef.setArrival(arrival);
  rDef.setDeadline(deadline);
  return rDef;
}
项目:hadoop    文件:TestGreedyReservationAgent.java   
@SuppressWarnings("javadoc")
@Test
public void testSimple() throws PlanningException {

  prepareBasicPlan();

  // create a request with a single atomic ask
  ReservationDefinition rr = new ReservationDefinitionPBImpl();
  rr.setArrival(5 * step);
  rr.setDeadline(20 * step);
  ReservationRequest r = ReservationRequest.newInstance(
      Resource.newInstance(2048, 2, 2), 10, 5, 10 * step);
  ReservationRequests reqs = new ReservationRequestsPBImpl();
  reqs.setReservationResources(Collections.singletonList(r));
  rr.setReservationRequests(reqs);

  ReservationId reservationID = ReservationSystemTestUtil
      .getNewReservationId();
  agent.createReservation(reservationID, "u1", plan, rr);

  assertTrue("Agent-based allocation failed", reservationID != null);
  assertTrue("Agent-based allocation failed", plan.getAllReservations()
      .size() == 3);

  ReservationAllocation cs = plan.getReservationById(reservationID);

  System.out.println("--------AFTER SIMPLE ALLOCATION (queue: "
      + reservationID + ")----------");
  System.out.println(plan.toString());
  System.out.println(plan.toCumulativeString());

  for (long i = 10 * step; i < 20 * step; i++) {
    assertTrue(
        "Agent-based allocation unexpected",
        Resources.equals(cs.getResourcesAtTime(i),
            Resource.newInstance(2048 * 10, 2 * 10, 2 * 10)));
  }

}
项目:hadoop    文件:TestGreedyReservationAgent.java   
@Test
public void testSingleSliding() throws PlanningException {
  prepareBasicPlan();

  // create a single request for which we need subsequent (tight) packing.
  ReservationDefinition rr = new ReservationDefinitionPBImpl();
  rr.setArrival(100 * step);
  rr.setDeadline(120 * step);
  ReservationRequests reqs = new ReservationRequestsPBImpl();
  reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
  ReservationRequest r = ReservationRequest.newInstance(
      Resource.newInstance(1024, 1, 1), 200, 10, 10 * step);

  List<ReservationRequest> list = new ArrayList<ReservationRequest>();
  list.add(r);
  reqs.setReservationResources(list);
  rr.setReservationRequests(reqs);

  // submit to agent
  ReservationId reservationID = ReservationSystemTestUtil
      .getNewReservationId();
  agent.createReservation(reservationID, "u1", plan, rr);

  // validate results, we expect the second one to be accepted
  assertTrue("Agent-based allocation failed", reservationID != null);
  assertTrue("Agent-based allocation failed", plan.getAllReservations()
      .size() == 3);

  ReservationAllocation cs = plan.getReservationById(reservationID);

  assertTrue(cs.toString(), check(cs, 100 * step, 120 * step, 100, 1024, 1));

  System.out.println("--------AFTER packed ALLOCATION (queue: "
      + reservationID + ")----------");
  System.out.println(plan.toString());
  System.out.println(plan.toCumulativeString());

}
项目:hadoop    文件:ReservationSystemTestUtil.java   
public static ReservationDefinition generateRandomRR(Random rand, long i) {
  rand.setSeed(i);
  long now = System.currentTimeMillis();

  // start time at random in the next 12 hours
  long arrival = rand.nextInt(12 * 3600 * 1000);
  // deadline at random in the next day
  long deadline = arrival + rand.nextInt(24 * 3600 * 1000);

  // create a request with a single atomic ask
  ReservationDefinition rr = new ReservationDefinitionPBImpl();
  rr.setArrival(now + arrival);
  rr.setDeadline(now + deadline);

  int gang = 1 + rand.nextInt(9);
  int par = (rand.nextInt(1000) + 1) * gang;
  long dur = rand.nextInt(2 * 3600 * 1000); // random duration within 2h
  ReservationRequest r =
      ReservationRequest.newInstance(Resource.newInstance(1024, 1, 1), par,
          gang, dur);
  ReservationRequests reqs = new ReservationRequestsPBImpl();
  reqs.setReservationResources(Collections.singletonList(r));
  rand.nextInt(3);
  ReservationRequestInterpreter[] type =
      ReservationRequestInterpreter.values();
  reqs.setInterpreter(type[rand.nextInt(type.length)]);
  rr.setReservationRequests(reqs);

  return rr;

}
项目:hadoop    文件:ReservationSystemTestUtil.java   
public static ReservationDefinition generateBigRR(Random rand, long i) {
  rand.setSeed(i);
  long now = System.currentTimeMillis();

  // start time at random in the next 2 hours
  long arrival = rand.nextInt(2 * 3600 * 1000);
  // deadline at random in the next day
  long deadline = rand.nextInt(24 * 3600 * 1000);

  // create a request with a single atomic ask
  ReservationDefinition rr = new ReservationDefinitionPBImpl();
  rr.setArrival(now + arrival);
  rr.setDeadline(now + deadline);

  int gang = 1;
  int par = 100000; // 100k tasks
  long dur = rand.nextInt(60 * 1000); // 1min tasks
  ReservationRequest r =
      ReservationRequest.newInstance(Resource.newInstance(1024, 1, 1), par,
          gang, dur);
  ReservationRequests reqs = new ReservationRequestsPBImpl();
  reqs.setReservationResources(Collections.singletonList(r));
  rand.nextInt(3);
  ReservationRequestInterpreter[] type =
      ReservationRequestInterpreter.values();
  reqs.setInterpreter(type[rand.nextInt(type.length)]);
  rr.setReservationRequests(reqs);

  return rr;
}
项目:hadoop    文件:TestInMemoryPlan.java   
private ReservationDefinition createSimpleReservationDefinition(long arrival,
    long deadline, long duration, Collection<ReservationRequest> resources) {
  // create a request with a single atomic ask
  ReservationDefinition rDef = new ReservationDefinitionPBImpl();
  ReservationRequests reqs = new ReservationRequestsPBImpl();
  reqs.setReservationResources(new ArrayList<ReservationRequest>(resources));
  reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
  rDef.setReservationRequests(reqs);
  rDef.setArrival(arrival);
  rDef.setDeadline(deadline);
  return rDef;
}
项目:aliyun-oss-hadoop-fs    文件:ReservationDefinitionPBImpl.java   
@Override
public ReservationRequests getReservationRequests() {
  ReservationDefinitionProtoOrBuilder p = viaProto ? proto : builder;
  if (reservationReqs != null) {
    return reservationReqs;
  }
  if (!p.hasReservationRequests()) {
    return null;
  }
  reservationReqs = convertFromProtoFormat(p.getReservationRequests());
  return reservationReqs;
}
项目:aliyun-oss-hadoop-fs    文件:ReservationDefinitionPBImpl.java   
@Override
public void setReservationRequests(ReservationRequests reservationRequests) {
  if (reservationRequests == null) {
    builder.clearReservationRequests();
    return;
  }
  this.reservationReqs = reservationRequests;
}
项目:aliyun-oss-hadoop-fs    文件:ReservationSystemTestUtil.java   
public static ReservationDefinition createSimpleReservationDefinition(
    long arrival, long deadline, long duration) {
  // create a request with a single atomic ask
  ReservationRequest r =
      ReservationRequest.newInstance(Resource.newInstance(1024, 1), 1, 1,
          duration);
  ReservationDefinition rDef = new ReservationDefinitionPBImpl();
  ReservationRequests reqs = new ReservationRequestsPBImpl();
  reqs.setReservationResources(Collections.singletonList(r));
  reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
  rDef.setReservationRequests(reqs);
  rDef.setArrival(arrival);
  rDef.setDeadline(deadline);
  return rDef;
}
项目:aliyun-oss-hadoop-fs    文件:ReservationSystemTestUtil.java   
public static ReservationDefinition generateRandomRR(Random rand, long i) {
  rand.setSeed(i);
  long now = System.currentTimeMillis();

  // start time at random in the next 12 hours
  long arrival = rand.nextInt(12 * 3600 * 1000);
  // deadline at random in the next day
  long deadline = arrival + rand.nextInt(24 * 3600 * 1000);

  // create a request with a single atomic ask
  ReservationDefinition rr = new ReservationDefinitionPBImpl();
  rr.setArrival(now + arrival);
  rr.setDeadline(now + deadline);

  int gang = 1 + rand.nextInt(9);
  int par = (rand.nextInt(1000) + 1) * gang;
  long dur = rand.nextInt(2 * 3600 * 1000); // random duration within 2h
  ReservationRequest r = ReservationRequest
      .newInstance(Resource.newInstance(1024, 1), par, gang, dur);
  ReservationRequests reqs = new ReservationRequestsPBImpl();
  reqs.setReservationResources(Collections.singletonList(r));
  rand.nextInt(3);
  ReservationRequestInterpreter[] type =
      ReservationRequestInterpreter.values();
  reqs.setInterpreter(type[rand.nextInt(type.length)]);
  rr.setReservationRequests(reqs);

  return rr;

}
项目:aliyun-oss-hadoop-fs    文件:TestInMemoryPlan.java   
private ReservationDefinition createSimpleReservationDefinition(long arrival,
    long deadline, long duration, Collection<ReservationRequest> resources) {
  // create a request with a single atomic ask
  ReservationDefinition rDef = new ReservationDefinitionPBImpl();
  ReservationRequests reqs = new ReservationRequestsPBImpl();
  reqs.setReservationResources(new ArrayList<ReservationRequest>(resources));
  reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
  rDef.setReservationRequests(reqs);
  rDef.setArrival(arrival);
  rDef.setDeadline(deadline);
  return rDef;
}
项目:aliyun-oss-hadoop-fs    文件:TestGreedyReservationAgent.java   
@SuppressWarnings("javadoc")
@Test
public void testSimple() throws PlanningException {

  prepareBasicPlan();

  // create a request with a single atomic ask
  ReservationDefinition rr = new ReservationDefinitionPBImpl();
  rr.setArrival(5 * step);
  rr.setDeadline(20 * step);
  ReservationRequest r = ReservationRequest.newInstance(
      Resource.newInstance(2048, 2), 10, 5, 10 * step);
  ReservationRequests reqs = new ReservationRequestsPBImpl();
  reqs.setReservationResources(Collections.singletonList(r));
  rr.setReservationRequests(reqs);

  ReservationId reservationID = ReservationSystemTestUtil
      .getNewReservationId();
  agent.createReservation(reservationID, "u1", plan, rr);

  assertTrue("Agent-based allocation failed", reservationID != null);
  assertTrue("Agent-based allocation failed", plan.getAllReservations()
      .size() == 3);

  ReservationAllocation cs = plan.getReservationById(reservationID);

  System.out.println("--------AFTER SIMPLE ALLOCATION (queue: "
      + reservationID + ")----------");
  System.out.println(plan.toString());
  System.out.println(plan.toCumulativeString());

  for (long i = 10 * step; i < 20 * step; i++) {
    assertTrue(
        "Agent-based allocation unexpected",
        Resources.equals(cs.getResourcesAtTime(i),
            Resource.newInstance(2048 * 10, 2 * 10)));
  }

}
项目:aliyun-oss-hadoop-fs    文件:TestGreedyReservationAgent.java   
@Test
public void testSingleSliding() throws PlanningException {
  prepareBasicPlan();

  // create a single request for which we need subsequent (tight) packing.
  ReservationDefinition rr = new ReservationDefinitionPBImpl();
  rr.setArrival(100 * step);
  rr.setDeadline(120 * step);
  ReservationRequests reqs = new ReservationRequestsPBImpl();
  reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
  ReservationRequest r = ReservationRequest.newInstance(
      Resource.newInstance(1024, 1), 200, 10, 10 * step);

  List<ReservationRequest> list = new ArrayList<ReservationRequest>();
  list.add(r);
  reqs.setReservationResources(list);
  rr.setReservationRequests(reqs);

  // submit to agent
  ReservationId reservationID = ReservationSystemTestUtil
      .getNewReservationId();
  agent.createReservation(reservationID, "u1", plan, rr);

  // validate results, we expect the second one to be accepted
  assertTrue("Agent-based allocation failed", reservationID != null);
  assertTrue("Agent-based allocation failed", plan.getAllReservations()
      .size() == 3);

  ReservationAllocation cs = plan.getReservationById(reservationID);

  assertTrue(cs.toString(), check(cs, 100 * step, 120 * step, 100, 1024, 1));

  System.out.println("--------AFTER packed ALLOCATION (queue: "
      + reservationID + ")----------");
  System.out.println(plan.toString());
  System.out.println(plan.toCumulativeString());

}
项目:aliyun-oss-hadoop-fs    文件:TestAlignedPlanner.java   
private ReservationDefinition createReservationDefinition(long arrival,
    long deadline, ReservationRequest[] reservationRequests,
    ReservationRequestInterpreter rType, String username) {

  return ReservationDefinition.newInstance(arrival, deadline,
      ReservationRequests.newInstance(Arrays.asList(reservationRequests),
          rType), username);

}
项目:big-c    文件:ReservationDefinitionPBImpl.java   
@Override
public ReservationRequests getReservationRequests() {
  ReservationDefinitionProtoOrBuilder p = viaProto ? proto : builder;
  if (reservationReqs != null) {
    return reservationReqs;
  }
  if (!p.hasReservationRequests()) {
    return null;
  }
  reservationReqs = convertFromProtoFormat(p.getReservationRequests());
  return reservationReqs;
}
项目:big-c    文件:ReservationDefinitionPBImpl.java   
@Override
public void setReservationRequests(ReservationRequests reservationRequests) {
  if (reservationRequests == null) {
    builder.clearReservationRequests();
    return;
  }
  this.reservationReqs = reservationRequests;
}
项目:big-c    文件:TestInMemoryReservationAllocation.java   
private ReservationDefinition createSimpleReservationDefinition(long arrival,
    long deadline, long duration) {
  // create a request with a single atomic ask
  ReservationRequest r =
      ReservationRequest.newInstance(Resource.newInstance(1024, 1), 1, 1,
          duration);
  ReservationDefinition rDef = new ReservationDefinitionPBImpl();
  ReservationRequests reqs = new ReservationRequestsPBImpl();
  reqs.setReservationResources(Collections.singletonList(r));
  reqs.setInterpreter(ReservationRequestInterpreter.R_ALL);
  rDef.setReservationRequests(reqs);
  rDef.setArrival(arrival);
  rDef.setDeadline(deadline);
  return rDef;
}
项目:big-c    文件:TestGreedyReservationAgent.java   
@SuppressWarnings("javadoc")
@Test
public void testSimple() throws PlanningException {

  prepareBasicPlan();

  // create a request with a single atomic ask
  ReservationDefinition rr = new ReservationDefinitionPBImpl();
  rr.setArrival(5 * step);
  rr.setDeadline(20 * step);
  ReservationRequest r = ReservationRequest.newInstance(
      Resource.newInstance(2048, 2), 10, 5, 10 * step);
  ReservationRequests reqs = new ReservationRequestsPBImpl();
  reqs.setReservationResources(Collections.singletonList(r));
  rr.setReservationRequests(reqs);

  ReservationId reservationID = ReservationSystemTestUtil
      .getNewReservationId();
  agent.createReservation(reservationID, "u1", plan, rr);

  assertTrue("Agent-based allocation failed", reservationID != null);
  assertTrue("Agent-based allocation failed", plan.getAllReservations()
      .size() == 3);

  ReservationAllocation cs = plan.getReservationById(reservationID);

  System.out.println("--------AFTER SIMPLE ALLOCATION (queue: "
      + reservationID + ")----------");
  System.out.println(plan.toString());
  System.out.println(plan.toCumulativeString());

  for (long i = 10 * step; i < 20 * step; i++) {
    assertTrue(
        "Agent-based allocation unexpected",
        Resources.equals(cs.getResourcesAtTime(i),
            Resource.newInstance(2048 * 10, 2 * 10)));
  }

}