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

项目: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    文件:ReservationRequestsPBImpl.java   
@Override
public ReservationRequestInterpreter getInterpreter() {
  ReservationRequestsProtoOrBuilder p = viaProto ? proto : builder;
  if (!p.hasInterpreter()) {
    return null;
  }
  return (convertFromProtoFormat(p.getInterpreter()));
}
项目:hadoop    文件:ReservationRequestsPBImpl.java   
@Override
public void setInterpreter(ReservationRequestInterpreter interpreter) {
  maybeInitBuilder();
  if (interpreter == null) {
    builder.clearInterpreter();
    return;
  }
  builder.setInterpreter(convertToProtoFormat(interpreter));
}
项目: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   
@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    文件:ReservationRequestsPBImpl.java   
@Override
public ReservationRequestInterpreter getInterpreter() {
  ReservationRequestsProtoOrBuilder p = viaProto ? proto : builder;
  if (!p.hasInterpreter()) {
    return null;
  }
  return (convertFromProtoFormat(p.getInterpreter()));
}
项目:aliyun-oss-hadoop-fs    文件:ReservationRequestsPBImpl.java   
@Override
public void setInterpreter(ReservationRequestInterpreter interpreter) {
  maybeInitBuilder();
  if (interpreter == null) {
    builder.clearInterpreter();
    return;
  }
  builder.setInterpreter(convertToProtoFormat(interpreter));
}
项目: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   
@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   
@Test
public void testSingleReservationAccept() throws PlanningException {

  // Prepare basic plan
  int numJobsInScenario = initializeScenario1();

  // Create reservation
  ReservationDefinition rr1 =
      createReservationDefinition(
          5 * step, // Job arrival time
          20 * step, // Job deadline
          new ReservationRequest[] { ReservationRequest.newInstance(
              Resource.newInstance(2048, 2), // Capability
              10, // Num containers
              5, // Concurrency
              10 * step) }, // Duration
          ReservationRequestInterpreter.R_ORDER, "u1");

  // Add reservation
  ReservationId reservationID =
      ReservationSystemTestUtil.getNewReservationId();
  agent.createReservation(reservationID, "u1", plan, rr1);

  // CHECK: allocation was accepted
  assertTrue("Agent-based allocation failed", reservationID != null);
  assertTrue("Agent-based allocation failed", plan.getAllReservations()
      .size() == numJobsInScenario + 1);

  // Get reservation
  ReservationAllocation alloc1 = plan.getReservationById(reservationID);

  // Verify allocation
  assertTrue(alloc1.toString(),
      check(alloc1, 10 * step, 20 * step, 10, 2048, 2));

}
项目:aliyun-oss-hadoop-fs    文件:TestAlignedPlanner.java   
@Test
public void testOrderNoGapImpossible() throws PlanningException {

  // Prepare basic plan
  int numJobsInScenario = initializeScenario2();

  // Create reservation
  ReservationDefinition rr1 =
      createReservationDefinition(
          10L, // Job arrival time
          15 * step, // Job deadline
          new ReservationRequest[] {
              ReservationRequest.newInstance(
                  Resource.newInstance(1024, 1), // Capability
                  20, // Num containers
                  20, // Concurrency
                  step), // Duration
              ReservationRequest.newInstance(
                  Resource.newInstance(1024, 1), // Capability
                  20, // Num containers
                  20, // Concurrency
                  step) }, // Duration
          ReservationRequestInterpreter.R_ORDER_NO_GAP, "u1");

  // Add reservation
  try {
    ReservationId reservationID =
        ReservationSystemTestUtil.getNewReservationId();
    agent.createReservation(reservationID, "u1", plan, rr1);
    fail();
  } catch (PlanningException e) {
    // Expected failure
  }

  // CHECK: allocation was not accepted
  assertTrue("Agent-based allocation should have failed", plan
      .getAllReservations().size() == numJobsInScenario);

}
项目:aliyun-oss-hadoop-fs    文件:TestAlignedPlanner.java   
@Test
public void testOrderNoGapImpossible2() throws PlanningException {

  // Prepare basic plan
  int numJobsInScenario = initializeScenario2();

  // Create reservation
  ReservationDefinition rr1 =
      createReservationDefinition(
          10 * step, // Job arrival time
          13 * step, // Job deadline
          new ReservationRequest[] {
              ReservationRequest.newInstance(
                  Resource.newInstance(1024, 1), // Capability
                  20, // Num containers
                  20, // Concurrency
                  step), // Duration
              ReservationRequest.newInstance(
                  Resource.newInstance(1024, 1), // Capability
                  10, // Num containers
                  10, // Concurrency
                  step) }, // Duration
          ReservationRequestInterpreter.R_ORDER_NO_GAP, "u1");

  // Add reservation
  try {
    ReservationId reservationID =
        ReservationSystemTestUtil.getNewReservationId();
    agent.createReservation(reservationID, "u1", plan, rr1);
    fail();
  } catch (PlanningException e) {
    // Expected failure
  }

  // CHECK: allocation was not accepted
  assertTrue("Agent-based allocation should have failed", plan
      .getAllReservations().size() == numJobsInScenario);

}
项目:aliyun-oss-hadoop-fs    文件:TestAlignedPlanner.java   
@Test
public void testOrderImpossible() throws PlanningException {

  // Prepare basic plan
  int numJobsInScenario = initializeScenario2();

  // Create reservation
  ReservationDefinition rr1 =
      createReservationDefinition(
          10 * step, // Job arrival time
          15 * step, // Job deadline
          new ReservationRequest[] {
              ReservationRequest.newInstance(
                  Resource.newInstance(1024, 1), // Capability
                  20, // Num containers
                  20, // Concurrency
                  2 * step), // Duration
              ReservationRequest.newInstance(
                  Resource.newInstance(1024, 1), // Capability
                  20, // Num containers
                  20, // Concurrency
                  step) }, // Duration
          ReservationRequestInterpreter.R_ORDER, "u1");

  // Add reservation
  try {
    ReservationId reservationID =
        ReservationSystemTestUtil.getNewReservationId();
    agent.createReservation(reservationID, "u1", plan, rr1);
    fail();
  } catch (PlanningException e) {
    // Expected failure
  }

  // CHECK: allocation was not accepted
  assertTrue("Agent-based allocation should have failed", plan
      .getAllReservations().size() == numJobsInScenario);

}
项目:aliyun-oss-hadoop-fs    文件:TestAlignedPlanner.java   
@Test
public void testAnyImpossible() throws PlanningException {

  // Prepare basic plan
  int numJobsInScenario = initializeScenario2();

  // Create reservation
  ReservationDefinition rr1 =
      createReservationDefinition(
          10 * step, // Job arrival time
          15 * step, // Job deadline
          new ReservationRequest[] {
              ReservationRequest.newInstance(
                  Resource.newInstance(1024, 1), // Capability
                  20, // Num containers
                  20, // Concurrency
                  3 * step), // Duration
              ReservationRequest.newInstance(
                  Resource.newInstance(1024, 1), // Capability
                  20, // Num containers
                  20, // Concurrency
                  2 * step) }, // Duration
          ReservationRequestInterpreter.R_ANY, "u1");

  // Add reservation
  try {
    ReservationId reservationID =
        ReservationSystemTestUtil.getNewReservationId();
    agent.createReservation(reservationID, "u1", plan, rr1);
    fail();
  } catch (PlanningException e) {
    // Expected failure
  }

  // CHECK: allocation was not accepted
  assertTrue("Agent-based allocation should have failed", plan
      .getAllReservations().size() == numJobsInScenario);

}
项目:aliyun-oss-hadoop-fs    文件:TestAlignedPlanner.java   
@Test
public void testAllImpossible() throws PlanningException {

  // Prepare basic plan
  int numJobsInScenario = initializeScenario2();

  // Create reservation
  ReservationDefinition rr1 =
      createReservationDefinition(
          10 * step, // Job arrival time
          15 * step, // Job deadline
          new ReservationRequest[] {
              ReservationRequest.newInstance(
                  Resource.newInstance(1024, 1), // Capability
                  20, // Num containers
                  20, // Concurrency
                  step), // Duration
              ReservationRequest.newInstance(
                  Resource.newInstance(1024, 1), // Capability
                  20, // Num containers
                  20, // Concurrency
                  2 * step) }, // Duration
          ReservationRequestInterpreter.R_ALL, "u1");

  // Add reservation
  try {
    ReservationId reservationID =
        ReservationSystemTestUtil.getNewReservationId();
    agent.createReservation(reservationID, "u1", plan, rr1);
    fail();
  } catch (PlanningException e) {
    // Expected failure
  }

  // CHECK: allocation was not accepted
  assertTrue("Agent-based allocation should have failed", plan
      .getAllReservations().size() == numJobsInScenario);

}
项目:aliyun-oss-hadoop-fs    文件:TestAlignedPlanner.java   
@Test
public void testImpossibleDuration() throws PlanningException {

  // Create reservation
  ReservationDefinition rr1 =
      createReservationDefinition(
          10 * step, // Job arrival time
          15 * step, // Job deadline
          new ReservationRequest[] { ReservationRequest.newInstance(
              Resource.newInstance(1024, 1), // Capability
              20, // Num containers
              20, // Concurrency
              10 * step) }, // Duration
          ReservationRequestInterpreter.R_ALL, "u1");

  // Add reservation
  try {
    ReservationId reservationID =
        ReservationSystemTestUtil.getNewReservationId();
    agent.createReservation(reservationID, "u1", plan, rr1);
    fail();
  } catch (PlanningException e) {
    // Expected failure
  }

  // CHECK: allocation was not accepted
  assertTrue("Agent-based allocation should have failed", plan
      .getAllReservations().size() == 0);

}