Package org.apache.ambari.server.state.scheduler

Examples of org.apache.ambari.server.state.scheduler.Schedule


        + firstJobDetail);
    }

    // Create a cron trigger for the first batch job
    // If no schedule is specified create simple trigger to fire right away
    Schedule schedule = requestExecution.getSchedule();

    if (schedule != null) {
      String triggerExpression = schedule.getScheduleExpression();

      Date startDate = null;
      Date endDate = null;
      try {
        String startTime = schedule.getStartTime();
        String endTime = schedule.getEndTime();
        startDate = startTime != null && !startTime.isEmpty() ?
          DateUtils.convertToDate(startTime) : new Date();
        endDate = endTime != null && !endTime.isEmpty() ?
          DateUtils.convertToDate(endTime) : null;
      } catch (ParseException e) {
View Full Code Here


  private void validateRequest(RequestScheduleRequest request) throws AmbariException {
    if (request.getClusterName() == null) {
      throw new IllegalArgumentException("Cluster name is required.");
    }
    Schedule schedule = request.getSchedule();
    if (schedule != null) {
      getManagementController().getExecutionScheduleManager()
        .validateSchedule(schedule);
    }
    Batch batch = request.getBatch();
View Full Code Here

      }
    }

    requestScheduleRequest.setBatch(batch);

    Schedule schedule = new Schedule();
    for (Map.Entry<String, Object> propertyEntry : properties.entrySet()) {
      if (propertyEntry.getKey().equals(SCHEDULE_DAY_OF_WEEK_PROPERTY_ID)) {
        schedule.setDayOfWeek((String) propertyEntry.getValue());
      } else if (propertyEntry.getKey().equals(SCHEDULE_DAYS_OF_MONTH_PROPERTY_ID)) {
        schedule.setDaysOfMonth((String) propertyEntry.getValue());
      } else if (propertyEntry.getKey().equals(SCHEDULE_END_TIME_PROPERTY_ID)) {
        schedule.setEndTime((String) propertyEntry.getValue());
      } else if (propertyEntry.getKey().equals(SCHEDULE_HOURS_PROPERTY_ID)) {
        schedule.setHours((String) propertyEntry.getValue());
      } else if (propertyEntry.getKey().equals(SCHEDULE_MINUTES_PROPERTY_ID)) {
        schedule.setMinutes((String) propertyEntry.getValue());
      } else if (propertyEntry.getKey().equals(SCHEDULE_MONTH_PROPERTY_ID)) {
        schedule.setMonth((String) propertyEntry.getValue());
      } else if (propertyEntry.getKey().equals(SCHEDULE_START_TIME_PROPERTY_ID)) {
        schedule.setStartTime((String) propertyEntry.getValue());
      } else if (propertyEntry.getKey().equals(SCHEDULE_YEAR_PROPERTY_ID)) {
        schedule.setYear((String) propertyEntry.getValue());
      }
    }

    if (!schedule.isEmpty()) {
      requestScheduleRequest.setSchedule(schedule);
    }

    return requestScheduleRequest;
  }
View Full Code Here

        + firstJobDetail);
    }

    // Create a cron trigger for the first batch job
    // If no schedule is specified create simple trigger to fire right away
    Schedule schedule = requestExecution.getSchedule();

    if (schedule != null) {
      String triggerExpression = schedule.getScheduleExpression();

      Date startDate = null;
      Date endDate = null;
      try {
        String startTime = schedule.getStartTime();
        String endTime = schedule.getEndTime();
        startDate = startTime != null && !startTime.isEmpty() ?
          DateUtils.convertToDate(startTime) : new Date();
        endDate = endTime != null && !endTime.isEmpty() ?
          DateUtils.convertToDate(endTime) : null;
      } catch (ParseException e) {
View Full Code Here

  }

  @Transactional
  private RequestExecution createRequestSchedule() throws Exception {
    Batch batches = new Batch();
    Schedule schedule = new Schedule();

    BatchSettings batchSettings = new BatchSettings();
    batchSettings.setTaskFailureToleranceLimit(10);
    batches.setBatchSettings(batchSettings);

    List<BatchRequest> batchRequests = new ArrayList<BatchRequest>();
    BatchRequest batchRequest1 = new BatchRequest();
    batchRequest1.setOrderId(10L);
    batchRequest1.setType(BatchRequest.Type.DELETE);
    batchRequest1.setUri("testUri1");

    BatchRequest batchRequest2 = new BatchRequest();
    batchRequest2.setOrderId(12L);
    batchRequest2.setType(BatchRequest.Type.POST);
    batchRequest2.setUri("testUri2");
    batchRequest2.setBody("testBody");

    batchRequests.add(batchRequest1);
    batchRequests.add(batchRequest2);

    batches.getBatchRequests().addAll(batchRequests);

    schedule.setMinutes("10");
    schedule.setEndTime("2014-01-01 00:00:00");

    RequestExecution requestExecution = requestExecutionFactory.createNew
      (cluster, batches, schedule);

    requestExecution.setStatus(RequestExecution.Status.SCHEDULED);
View Full Code Here

TOP

Related Classes of org.apache.ambari.server.state.scheduler.Schedule

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.