Package org.apache.ambari.server.controller

Examples of org.apache.ambari.server.controller.RequestScheduleRequest


  public RequestStatus deleteResources(Predicate predicate) throws
      SystemException, UnsupportedPropertyException, NoSuchResourceException,
      NoSuchParentResourceException {

    for (Map<String, Object> propertyMap : getPropertyMaps(predicate)) {
      final RequestScheduleRequest requestScheduleRequest =
        getRequestScheduleRequest(propertyMap);

      modifyResources(new Command<Void>() {
        @Override
        public Void invoke() throws AmbariException {
View Full Code Here


    if (idObj != null)  {
      id = idObj instanceof Long ? (Long) idObj :
        Long.parseLong((String) idObj);
    }

    RequestScheduleRequest requestScheduleRequest = new RequestScheduleRequest(
      id,
      (String) properties.get(REQUEST_SCHEDULE_CLUSTER_NAME_PROPERTY_ID),
      (String) properties.get(REQUEST_SCHEDULE_DESC_PROPERTY_ID),
      (String) properties.get(REQUEST_SCHEDULE_STATUS_PROPERTY_ID),
      null,
      null);

    Batch batch = new Batch();
    BatchSettings batchSettings = new BatchSettings();
    List<BatchRequest> batchRequests = new ArrayList<BatchRequest>();

    Object batchObject = properties.get(REQUEST_SCHEDULE_BATCH_PROPERTY_ID);
    if (batchObject != null && batchObject instanceof HashSet<?>) {
      try {
        HashSet<Map<String, Object>> batchMap = (HashSet<Map<String, Object>>) batchObject;

        for (Map<String, Object> batchEntry : batchMap) {
          if (batchEntry != null) {
            for (Map.Entry<String, Object> batchMapEntry : batchEntry.entrySet()) {
              if (batchMapEntry.getKey().equals
                  (REQUEST_SCHEDULE_BATCH_TOLERATION_PROPERTY_ID)) {
                batchSettings.setTaskFailureToleranceLimit(Integer.valueOf
                  ((String) batchMapEntry.getValue()));
              } else if (batchMapEntry.getKey().equals
                  (REQUEST_SCHEDULE_BATCH_SEPARATION_PROPERTY_ID)) {
                batchSettings.setBatchSeparationInSeconds(Integer.valueOf
                  ((String) batchMapEntry.getValue()));
              } else if (batchMapEntry.getKey().equals
                  (REQUEST_SCHEDULE_BATCH_REQUESTS_PROPERTY_ID)) {
                HashSet<Map<String, Object>> requestSet =
                  (HashSet<Map<String, Object>>) batchMapEntry.getValue();

                for (Map<String, Object> requestEntry : requestSet) {
                  if (requestEntry != null) {
                    BatchRequest batchRequest = new BatchRequest();
                    for (Map.Entry<String, Object> requestMapEntry :
                        requestEntry.entrySet()) {
                      if (requestMapEntry.getKey()
                                 .equals(BATCH_REQUEST_TYPE_PROPERTY_ID)) {
                        batchRequest.setType(BatchRequest.Type.valueOf
                          ((String) requestMapEntry.getValue()));
                      } else if (requestMapEntry.getKey()
                                 .equals(BATCH_REQUEST_URI_PROPERTY_ID)) {
                        batchRequest.setUri(
                          (String) requestMapEntry.getValue());
                      } else if (requestMapEntry.getKey()
                                .equals(BATCH_REQUEST_ORDER_ID_PROPERTY_ID)) {
                        batchRequest.setOrderId(Long.parseLong(
                          (String) requestMapEntry.getValue()));
                      } else if (requestMapEntry.getKey()
                                .equals(BATCH_REQUEST_BODY_PROPERTY_ID)) {
                        batchRequest.setBody(
                          (String) requestMapEntry.getValue());
                      }
                    }
                    batchRequests.add(batchRequest);
                  }
                }
              }
            }
          }
        }

        batch.getBatchRequests().addAll(batchRequests);
        batch.setBatchSettings(batchSettings);

      } catch (Exception e) {
        LOG.warn("Request Schedule batch json is unparseable. " +
          batchObject, e);
      }
    }

    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

TOP

Related Classes of org.apache.ambari.server.controller.RequestScheduleRequest

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.