Search in sources :

Example 1 with Namespace

use of com.emc.ecs.management.entity.Namespace 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 Namespace

use of com.emc.ecs.management.entity.Namespace 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 Namespace

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

the class NamespaceBO method getNamespaces.

/**
 * Gathers all namespaces present on a cluster
 *
 * @return List - List of namespace
 */
public List<Namespace> getNamespaces() {
    List<Namespace> namespaceList = new ArrayList<Namespace>();
    ListNamespaceRequest listNamespaceRequest = new ListNamespaceRequest();
    // first batch
    ListNamespacesResult namespacesResult = client.listNamespaces(listNamespaceRequest);
    namespaceList.addAll(namespacesResult.getNamespaces());
    // n subsequent batches
    while (namespacesResult.getNextMarker() != null) {
        listNamespaceRequest.setNextMarker(namespacesResult.getNextMarker());
        namespacesResult = client.listNamespaces(listNamespaceRequest);
        if (namespacesResult.getNamespaces() != null) {
            namespaceList.addAll(namespacesResult.getNamespaces());
        }
    }
    return namespaceList;
}
Also used : ListNamespacesResult(com.emc.ecs.management.entity.ListNamespacesResult) ArrayList(java.util.ArrayList) ListNamespaceRequest(com.emc.ecs.management.entity.ListNamespaceRequest) Namespace(com.emc.ecs.management.entity.Namespace)

Example 4 with Namespace

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

the class NamespaceBO method collectNamespaceDetails.

/**
 * Gathers all namespaces details present on a cluster
 *
 * @return List - List of namespace details
 */
public void collectNamespaceDetails(Date collectionTime) {
    // Start collecting namespace data details 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) {
        LOGGER.info("Collecting Details for namespace: " + namespace.getName());
        NamespaceDetail namespaceDetail = client.getNamespaceDetails(namespace.getId());
        if (namespaceDetail == null) {
            continue;
        }
        objCounter++;
        // Push collected details into datastore
        if (namespaceDAO != null) {
            // insert something
            namespaceDAO.insert(namespaceDetail, collectionTime);
        }
    }
    // peg global counter
    this.objectCount.getAndAdd(objCounter);
}
Also used : NamespaceDetail(com.emc.ecs.management.entity.NamespaceDetail) Namespace(com.emc.ecs.management.entity.Namespace)

Example 5 with Namespace

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

the class BillingBO method getNamespaces.

/**
 *  Gathers all namespaces present on a cluster
 * @return List - List of namespace
 */
public List<Namespace> getNamespaces() {
    // Start collecting billing data from ECS systems
    List<Namespace> namespaceList = new ArrayList<Namespace>();
    // collect namespace names
    ListNamespaceRequest listNamespaceRequest = new ListNamespaceRequest();
    // first batch
    ListNamespacesResult namespacesResult = client.listNamespaces(listNamespaceRequest);
    namespaceList.addAll(namespacesResult.getNamespaces());
    // n subsequent batches
    while (namespacesResult.getNextMarker() != null) {
        listNamespaceRequest.setNextMarker(namespacesResult.getNextMarker());
        namespacesResult = client.listNamespaces(listNamespaceRequest);
        if (namespacesResult.getNamespaces() != null) {
            namespaceList.addAll(namespacesResult.getNamespaces());
        }
    }
    return namespaceList;
}
Also used : ListNamespacesResult(com.emc.ecs.management.entity.ListNamespacesResult) ArrayList(java.util.ArrayList) ListNamespaceRequest(com.emc.ecs.management.entity.ListNamespaceRequest) Namespace(com.emc.ecs.management.entity.Namespace)

Aggregations

Namespace (com.emc.ecs.management.entity.Namespace)6 ListNamespaceRequest (com.emc.ecs.management.entity.ListNamespaceRequest)5 NamespaceRequest (com.emc.ecs.management.entity.NamespaceRequest)3 ListNamespacesResult (com.emc.ecs.management.entity.ListNamespacesResult)2 ObjectBucket (com.emc.ecs.management.entity.ObjectBucket)2 ArrayList (java.util.ArrayList)2 BucketBillingInfo (com.emc.ecs.management.entity.BucketBillingInfo)1 NamespaceBillingInfo (com.emc.ecs.management.entity.NamespaceBillingInfo)1 NamespaceDetail (com.emc.ecs.management.entity.NamespaceDetail)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