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);
}
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);
}
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;
}
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);
}
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;
}
Aggregations