Package org.apache.ambari.server.controller.ivory

Examples of org.apache.ambari.server.controller.ivory.IvoryService


    Set<String>   requestedIds = getRequestPropertyIds(request, predicate);
    Set<Resource> resources    = new HashSet<Resource>();
    List<String>  feedNames    = new LinkedList<String>();

    IvoryService service = getService();
    if (predicate == null) {
      feedNames = service.getFeedNames();
    } else {
      for (Map<String, Object> propertyMap : getPropertyMaps(predicate)) {
        String feedName = (String) propertyMap.get(INSTANCE_FEED_NAME_PROPERTY_ID);
        if (feedName == null) {
          // if any part of the predicate doesn't include feed name then we have to check them all
          feedNames = service.getFeedNames();
          break;
        }
        feedNames.add(feedName);
      }
    }

    for (String feedName : feedNames) {
      List<Instance> instances = service.getInstances(feedName);
      for (Instance instance : instances) {
        Resource resource = new ResourceImpl(Resource.Type.DRInstance);
        setResourceProperty(resource, INSTANCE_FEED_NAME_PROPERTY_ID,
            instance.getFeedName(), requestedIds);
        setResourceProperty(resource, INSTANCE_ID_PROPERTY_ID,
View Full Code Here


  }

  @Override
  public RequestStatus updateResources(Request request, Predicate predicate) throws SystemException,
      UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
    IvoryService service = getService();

    Iterator<Map<String,Object>> iterator = request.getProperties().iterator();
    if (iterator.hasNext()) {

      Map<String, Object> propertyMap = iterator.next();

      String desiredStatus = (String) propertyMap.get(INSTANCE_STATUS_PROPERTY_ID);

      if (desiredStatus != null) {
        // get all the instances that pass the predicate check
        Set<Resource> resources = getResources(PropertyHelper.getReadRequest(), predicate);

        // update all the matching instances with the property values from the request
        for (Resource resource : resources) {
          String status   = (String) resource.getPropertyValue(INSTANCE_STATUS_PROPERTY_ID);
          String feedName = (String) resource.getPropertyValue(INSTANCE_FEED_NAME_PROPERTY_ID);
          String id       = (String) resource.getPropertyValue(INSTANCE_ID_PROPERTY_ID);

          if (desiredStatus.equals("SUSPENDED")) {
            service.suspendInstance(feedName, id);
          } else if (status.equals("SUSPENDED") && desiredStatus.equals("RUNNING")) {
            service.resumeInstance(feedName, id);
          }
        }
      }
    }
    return new RequestStatusImpl(null);
View Full Code Here

  }

  @Override
  public RequestStatus deleteResources(Predicate predicate) throws SystemException,
      UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
    IvoryService service = getService();

    // get all the instances that pass the predicate check
    Set<Resource> resources = getResources(PropertyHelper.getReadRequest(), predicate);

    for (Resource resource : resources) {
      // delete all the matching instances with the property values from the request
      service.killInstance((String) resource.getPropertyValue(INSTANCE_FEED_NAME_PROPERTY_ID),
          (String) resource.getPropertyValue(INSTANCE_ID_PROPERTY_ID));
    }
    return new RequestStatusImpl(null);
  }
View Full Code Here

  }

  @Override
  public RequestStatus createResources(Request request) throws SystemException, UnsupportedPropertyException,
      ResourceAlreadyExistsException, NoSuchParentResourceException {
    IvoryService service = getService();

    Set<Map<String, Object>> propertiesSet = request.getProperties();

    for(Map<String, Object> propertyMap : propertiesSet) {
      service.submitCluster(getCluster((String) propertyMap.get(CLUSTER_NAME_PROPERTY_ID), propertyMap));
    }
    return new RequestStatusImpl(null);
  }
View Full Code Here

  }

  @Override
  public Set<Resource> getResources(Request request, Predicate predicate) throws SystemException,
      UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
    IvoryService  service         = getService();
    List<String>  clusterNames    = service.getClusterNames();
    Set<String>   requestedIds = getRequestPropertyIds(request, predicate);
    Set<Resource> resources    = new HashSet<Resource>();

    for (String clusterName : clusterNames ) {

      Cluster cluster = service.getCluster(clusterName);

      Resource resource = new ResourceImpl(Resource.Type.DRTargetCluster);
      setResourceProperty(resource, CLUSTER_NAME_PROPERTY_ID,
          cluster.getName(), requestedIds);
      setResourceProperty(resource, CLUSTER_COLO_PROPERTY_ID,
View Full Code Here

  }

  @Override
  public RequestStatus updateResources(Request request, Predicate predicate) throws SystemException,
      UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
    IvoryService service = getService();

    Iterator<Map<String,Object>> iterator = request.getProperties().iterator();
    if (iterator.hasNext()) {

      Map<String, Object> propertyMap = iterator.next();

      // get all the clusters that pass the predicate check
      Set<Resource> resources = getResources(PropertyHelper.getReadRequest(), predicate);

      for (Resource resource : resources) {
        // update all the matching clusters with the property values from the request
        service.updateCluster(getCluster((String) resource.getPropertyValue(CLUSTER_NAME_PROPERTY_ID), propertyMap));
      }
    }
    return new RequestStatusImpl(null);
  }
View Full Code Here

  }

  @Override
  public RequestStatus deleteResources(Predicate predicate) throws SystemException, UnsupportedPropertyException,
      NoSuchResourceException, NoSuchParentResourceException {
    IvoryService service = getService();

    // get all the clusters that pass the predicate check
    Set<Resource> resources = getResources(PropertyHelper.getReadRequest(), predicate);

    for (Resource resource : resources) {
      // delete all the matching clusters with the property values from the request
      service.deleteCluster((String) resource.getPropertyValue(CLUSTER_NAME_PROPERTY_ID));
    }
    return new RequestStatusImpl(null);
  }
View Full Code Here

  @Override
  public RequestStatus createResources(Request request)
      throws SystemException, UnsupportedPropertyException,
             ResourceAlreadyExistsException, NoSuchParentResourceException {
    IvoryService service = getService();

    Set<Map<String, Object>> propertiesSet = request.getProperties();

    for(Map<String, Object> propertyMap : propertiesSet) {
      service.submitFeed(getFeed((String) propertyMap.get(FEED_NAME_PROPERTY_ID), propertyMap));
    }
    return new RequestStatusImpl(null);
  }
View Full Code Here

  @Override
  public Set<Resource> getResources(Request request, Predicate predicate)
      throws SystemException, UnsupportedPropertyException,
             NoSuchResourceException, NoSuchParentResourceException {

    IvoryService  service      = getService();
    List<String>  feedNames    = service.getFeedNames();
    Set<String>   requestedIds = getRequestPropertyIds(request, predicate);
    Set<Resource> resources    = new HashSet<Resource>();

    for (String feedName : feedNames ) {

      Feed feed = service.getFeed(feedName);

      Resource resource = new ResourceImpl(Resource.Type.DRFeed);
      setResourceProperty(resource, FEED_NAME_PROPERTY_ID,
          feed.getName(), requestedIds);
      setResourceProperty(resource, FEED_DESCRIPTION_PROPERTY_ID,
View Full Code Here

      // get all the feeds that pass the predicate check
      Set<Resource> resources = getResources(PropertyHelper.getReadRequest(), predicate);

      // update all the matching feeds with the property values from the request
      for (Resource resource : resources) {
        IvoryService service = getService();
        if (desiredStatus != null) {
          String status   = (String) resource.getPropertyValue(FEED_STATUS_PROPERTY_ID);
          String feedName = (String) resource.getPropertyValue(FEED_NAME_PROPERTY_ID);

          if (desiredStatus.equals("SCHEDULED")) {
            service.scheduleFeed(feedName);
          } else if (desiredStatus.equals("SUSPENDED")) {
            service.suspendFeed(feedName);
          } else if (status.equals("SUSPENDED") && desiredStatus.equals("RUNNING")) {
            service.resumeFeed(feedName);
          }
        }
        service.updateFeed(getFeed((String) resource.getPropertyValue(FEED_NAME_PROPERTY_ID),
            getUpdateMap(resource, propertyMap)));
      }
    }
    return new RequestStatusImpl(null);
  }
View Full Code Here

TOP

Related Classes of org.apache.ambari.server.controller.ivory.IvoryService

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.