Search in sources :

Example 1 with NamespaceRequest

use of com.emc.ecs.management.entity.NamespaceRequest in project ecs-dashboard by carone1.

the class BillingBO method collectObjectBucketData.

/**
 * Collects Bucket metadata for all namespace defined on a cluster
 * @param objectBucketMap - Object Bucket Map
 * @param collectionTime - Collection Time
 * @param billDAO - Billing DAO Object
 */
private void collectObjectBucketData(Map<String, Set<ObjectBucket>> objectPerNamespaceMap, Map<NamespaceBucketKey, ObjectBucket> objectBucketMap, Date collectionTime, BillingDAO billDAO) {
    // Start collecting billing data from ECS systems
    List<Namespace> namespaceList = getNamespaces();
    // At this point we should have all the namespace supported by the ECS system
    long objCounter = 0;
    for (Namespace namespace : namespaceList) {
        // ===============================================
        // Initial billing request for current namespace
        // ===============================================
        NamespaceRequest namespaceRequest = new NamespaceRequest();
        namespaceRequest.setName(namespace.getName());
        ObjectBuckets objectBucketsResponse = client.getNamespaceBucketInfo(namespaceRequest);
        if (objectBucketsResponse == null) {
            continue;
        }
        logger.info("Collect Billing Data for namespace: " + namespace.getName());
        objCounter += (objectBucketsResponse.getObjectBucket() != null) ? objectBucketsResponse.getObjectBucket().size() : 0;
        // Push collected info into datastore
        if (billDAO != null) {
            // insert something
            billDAO.insert(objectBucketsResponse, collectionTime);
        }
        // Add to return map per namespace and bucket key
        if (objectBucketsResponse.getObjectBucket() != null && objectBucketMap != null) {
            for (ObjectBucket objectBucket : objectBucketsResponse.getObjectBucket()) {
                NamespaceBucketKey key = new NamespaceBucketKey(namespace.getName(), objectBucket.getName());
                objectBucketMap.put(key, objectBucket);
            }
        }
        // Add to return map per namespace key
        if (objectBucketsResponse.getObjectBucket() != null && objectPerNamespaceMap != null) {
            Set<ObjectBucket> objectSet = objectPerNamespaceMap.get(namespace.getName());
            if (objectSet == null) {
                // there isn;t already a set present for that namespace
                // create one
                objectSet = new HashSet<ObjectBucket>();
                // add reference of set to map
                objectPerNamespaceMap.put(namespace.getName(), objectSet);
            }
            for (ObjectBucket objectBucket : objectBucketsResponse.getObjectBucket()) {
                // add all object to set
                objectSet.add(objectBucket);
            }
        }
        // collect n subsequent pages
        while (namespaceRequest.getNextMarker() != null) {
            objectBucketsResponse = client.getNamespaceBucketInfo(namespaceRequest);
            if (objectBucketsResponse != null) {
                objCounter += (objectBucketsResponse.getObjectBucket() != null) ? objectBucketsResponse.getObjectBucket().size() : 0;
                namespaceRequest.setNextMarker(objectBucketsResponse.getNextMarker());
                // Push collected info into datastore
                if (billDAO != null) {
                    // insert something
                    billDAO.insert(objectBucketsResponse, collectionTime);
                }
                // Add to return map
                if (objectBucketsResponse.getObjectBucket() != null && objectBucketMap != null) {
                    for (ObjectBucket objectBucket : objectBucketsResponse.getObjectBucket()) {
                        NamespaceBucketKey key = new NamespaceBucketKey(namespace.getName(), objectBucket.getName());
                        objectBucketMap.put(key, objectBucket);
                    }
                }
                // Add to return map per namespace key
                if (objectBucketsResponse.getObjectBucket() != null && objectPerNamespaceMap != null) {
                    Set<ObjectBucket> objectSet = objectPerNamespaceMap.get(namespace.getName());
                    if (objectSet == null) {
                        // there isn;t already a set present for that namespace
                        // create one
                        objectSet = new HashSet<ObjectBucket>();
                        // add reference of set to map
                        objectPerNamespaceMap.put(namespace.getName(), objectSet);
                    }
                    for (ObjectBucket objectBucket : objectBucketsResponse.getObjectBucket()) {
                        // add all object to set
                        objectSet.add(objectBucket);
                    }
                }
            } else {
                // stop the loop
                namespaceRequest.setNextMarker(null);
            }
        }
    }
    // peg global counter
    this.objectCount.getAndAdd(objCounter);
}
Also used : ObjectBucket(com.emc.ecs.management.entity.ObjectBucket) ObjectBuckets(com.emc.ecs.management.entity.ObjectBuckets) NamespaceRequest(com.emc.ecs.management.entity.NamespaceRequest) ListNamespaceRequest(com.emc.ecs.management.entity.ListNamespaceRequest) Namespace(com.emc.ecs.management.entity.Namespace)

Example 2 with NamespaceRequest

use of com.emc.ecs.management.entity.NamespaceRequest in project ecs-dashboard by carone1.

the class BillingBO method collectBillingData.

/**
 * Collects Billing metadata for all namespace defined on a cluster
 * @param collectionTime - Collection Time
 */
public void collectBillingData(Date collectionTime) {
    // Collect the object bucket data first in order to use some of
    // the fields from object bucket
    Map<NamespaceBucketKey, ObjectBucket> objectBuckets = new HashMap<NamespaceBucketKey, ObjectBucket>();
    Map<String, Set<ObjectBucket>> objectBucketsPerNamespace = new HashMap<String, Set<ObjectBucket>>();
    // Collect bucket data and write to datastore
    // secondly returns classified data per namespace
    // and also per namespace+bucketname
    collectObjectBucketData(objectBucketsPerNamespace, objectBuckets, collectionTime, billingDAO);
    // Start collecting billing data from ECS systems
    List<Namespace> namespaceList = getNamespaces();
    // At this point we should have all namespaces in the ECS system
    long objCounter = 0;
    for (Namespace namespace : namespaceList) {
        // ===============================================
        // Initial billing request for current namespace
        // ===============================================
        NamespaceRequest namespaceRequest = new NamespaceRequest();
        namespaceRequest.setName(namespace.getName());
        if (objectBucketsPerNamespace.get(namespace.getName()) != null && !objectBucketsPerNamespace.get(namespace.getName()).isEmpty()) {
            // There are buckets in that namespace
            // indicate to client to include bucket data
            namespaceRequest.setIncludeBuckets(true);
        }
        NamespaceBillingInfo namespaceBillingResponse = client.getNamespaceBillingInfo(namespaceRequest);
        if (namespaceBillingResponse == null) {
            continue;
        }
        // add object bucket attributes
        for (BucketBillingInfo bucketBillingInfo : namespaceBillingResponse.getBucketBillingInfo()) {
            NamespaceBucketKey namespaceBucketKey = new NamespaceBucketKey(namespace.getName(), bucketBillingInfo.getName());
            ObjectBucket objectBucket = objectBuckets.get(namespaceBucketKey);
            if (objectBucket != null) {
                // set api type
                bucketBillingInfo.setApiType(objectBucket.getApiType());
                // set namespace
                bucketBillingInfo.setNamespace(namespace.getName());
            } else {
                // set api type
                bucketBillingInfo.setApiType("unknown");
                // set namespace
                bucketBillingInfo.setNamespace(namespace.getName());
            }
            objCounter++;
        }
        // Push collected info into datastore
        if (this.billingDAO != null) {
            // insert something
            billingDAO.insert(namespaceBillingResponse, collectionTime);
        }
        // collect n subsequent pages
        while (namespaceRequest.getNextMarker() != null) {
            namespaceBillingResponse = client.getNamespaceBillingInfo(namespaceRequest);
            if (namespaceBillingResponse != null) {
                namespaceRequest.setNextMarker(namespaceBillingResponse.getNextMarker());
                // add object bucket attributes
                for (BucketBillingInfo bucketBillingInfo : namespaceBillingResponse.getBucketBillingInfo()) {
                    ObjectBucket objectBucket = objectBuckets.get(bucketBillingInfo.getName());
                    if (objectBucket != null) {
                        // set api type
                        bucketBillingInfo.setApiType(objectBucket.getApiType());
                        // set namespace
                        bucketBillingInfo.setNamespace(namespace.getName());
                    }
                    objCounter++;
                }
                // Push collected info into datastore
                if (this.billingDAO != null) {
                    // insert something
                    billingDAO.insert(namespaceBillingResponse, collectionTime);
                }
            } else {
                namespaceRequest.setNextMarker(null);
            }
        }
    }
    // peg global counter
    this.objectCount.getAndAdd(objCounter);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) ObjectBucket(com.emc.ecs.management.entity.ObjectBucket) HashMap(java.util.HashMap) BucketBillingInfo(com.emc.ecs.management.entity.BucketBillingInfo) NamespaceRequest(com.emc.ecs.management.entity.NamespaceRequest) ListNamespaceRequest(com.emc.ecs.management.entity.ListNamespaceRequest) Namespace(com.emc.ecs.management.entity.Namespace) NamespaceBillingInfo(com.emc.ecs.management.entity.NamespaceBillingInfo)

Example 3 with NamespaceRequest

use of com.emc.ecs.management.entity.NamespaceRequest in project ecs-dashboard by carone1.

the class NamespaceBO method collectNamespaceQuota.

/**
 * Gathers all namespaces quota present on a cluster
 *
 * @return List - List of namespace quota
 */
public void collectNamespaceQuota(Date collectionTime) {
    // Start collecting namespace data quota from ECS systems
    List<Namespace> namespaceList = getNamespaces();
    // At this point we should have all the namespace supported by the ECS
    // system
    long objCounter = 0;
    for (Namespace namespace : namespaceList) {
        NamespaceRequest namespaceRequest = new NamespaceRequest();
        namespaceRequest.setName(namespace.getName());
        LOGGER.info("Collecting Quota Details for namespace: " + namespace.getName());
        NamespaceQuota namespaceQuota = client.getNamespaceQuota(namespaceRequest);
        if (namespaceQuota == null) {
            continue;
        }
        objCounter++;
        // Push collected details into datastore
        if (namespaceDAO != null) {
            // insert something
            namespaceDAO.insert(namespaceQuota, collectionTime);
        }
    }
    // peg global counter
    this.objectCount.getAndAdd(objCounter);
}
Also used : NamespaceQuota(com.emc.ecs.management.entity.NamespaceQuota) ListNamespaceRequest(com.emc.ecs.management.entity.ListNamespaceRequest) NamespaceRequest(com.emc.ecs.management.entity.NamespaceRequest) Namespace(com.emc.ecs.management.entity.Namespace)

Aggregations

ListNamespaceRequest (com.emc.ecs.management.entity.ListNamespaceRequest)3 Namespace (com.emc.ecs.management.entity.Namespace)3 NamespaceRequest (com.emc.ecs.management.entity.NamespaceRequest)3 ObjectBucket (com.emc.ecs.management.entity.ObjectBucket)2 BucketBillingInfo (com.emc.ecs.management.entity.BucketBillingInfo)1 NamespaceBillingInfo (com.emc.ecs.management.entity.NamespaceBillingInfo)1 NamespaceQuota (com.emc.ecs.management.entity.NamespaceQuota)1 ObjectBuckets (com.emc.ecs.management.entity.ObjectBuckets)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1