use of com.emc.ecs.management.entity.ObjectUserDetails in project ecs-dashboard by carone1.
the class ObjectBO method collectObjectVersionData.
public void collectObjectVersionData(Date collectionTime) {
// collect S3 user Id and credentials
List<ObjectUserDetails> objectUserDetailsList = billingBO.getObjectUserSecretKeys();
// Collect bucket details
Map<NamespaceBucketKey, ObjectBucket> objectBucketMap = new HashMap<>();
billingBO.getObjectBucketData(objectBucketMap);
Map<String, S3JerseyClient> s3ObjectClientMap = null;
try {
// create all required S3 jersey clients for very S3 users
s3ObjectClientMap = createS3ObjectClients(objectUserDetailsList, this.ecsObjectHosts);
// collect objects for all users
for (ObjectUserDetails objectUserDetails : objectUserDetailsList) {
if (objectUserDetails.getObjectUser().getUserId() == null || objectUserDetails.getSecretKeys().getSecretKey1() == null) {
// in that case we just skip over that user
continue;
}
String userId = objectUserDetails.getObjectUser().getUserId().toString();
S3JerseyClient s3JerseyClient = s3ObjectClientMap.get(userId);
String namespace = objectUserDetails.getObjectUser().getNamespace().toString();
if (s3JerseyClient != null && namespace != null) {
ObjectCollectionConfig collectionConfig = new ObjectCollectionConfig(s3JerseyClient, namespace, objectDAO, objectBucketMap, collectionTime, objectCount, threadPoolExecutor, futures, // no criteria required here
null);
NamespaceObjectVersionCollection namespaceObjectVersionCollection = new NamespaceObjectVersionCollection(collectionConfig);
try {
// submit namespace collection to thread pool
futures.add(threadPoolExecutor.submit(namespaceObjectVersionCollection));
} catch (RejectedExecutionException e) {
// Thread pool didn't accept bucket collection
// running in the current thread
logger.error("Thread pool didn't accept bucket collection - running in current thread");
try {
namespaceObjectVersionCollection.call();
} catch (Exception e1) {
logger.error("Error occured during namespace object version collection operation - message: " + e.getLocalizedMessage());
}
}
}
}
} finally {
// ensure to clean up S3 jersey clients
if (s3ObjectClientMap != null) {
for (S3JerseyClient s3JerseyClient : s3ObjectClientMap.values()) {
s3JerseyClient.destroy();
}
}
}
}
use of com.emc.ecs.management.entity.ObjectUserDetails in project ecs-dashboard by carone1.
the class ObjectBO method collectObjectData.
public void collectObjectData(Date collectionTime, String queryCriteria) {
// collect S3 user Id and credentials
List<ObjectUserDetails> objectUserDetailsList = billingBO.getObjectUserSecretKeys();
// Collect bucket details
Map<NamespaceBucketKey, ObjectBucket> objectBucketMap = new HashMap<>();
billingBO.getObjectBucketData(objectBucketMap);
Map<String, S3JerseyClient> s3ObjectClientMap = null;
try {
// create all required S3 jersey clients for very S3 users
s3ObjectClientMap = createS3ObjectClients(objectUserDetailsList, this.ecsObjectHosts);
// collect objects for all users
for (ObjectUserDetails objectUserDetails : objectUserDetailsList) {
if (objectUserDetails.getObjectUser().getUserId() == null || objectUserDetails.getSecretKeys().getSecretKey1() == null) {
// in that case we just skip over that user
continue;
}
String userId = objectUserDetails.getObjectUser().getUserId().toString();
S3JerseyClient s3JerseyClient = s3ObjectClientMap.get(userId);
String namespace = objectUserDetails.getObjectUser().getNamespace().toString();
if (s3JerseyClient != null && namespace != null) {
ObjectCollectionConfig collectionConfig = new ObjectCollectionConfig(s3JerseyClient, namespace, this.objectDAO, objectBucketMap, collectionTime, objectCount, threadPoolExecutor, futures, queryCriteria);
NamespaceObjectCollection namespaceObjectCollection = new NamespaceObjectCollection(collectionConfig);
try {
// submit namespace collection to thread pool
futures.add(threadPoolExecutor.submit(namespaceObjectCollection));
} catch (RejectedExecutionException e) {
// Thread pool didn't accept bucket collection
// running in the current thread
logger.error("Thread pool didn't accept bucket collection - running in current thread");
try {
namespaceObjectCollection.call();
} catch (Exception e1) {
logger.error("Error occured during namespace object collection operation - message: " + e.getLocalizedMessage());
}
}
}
}
} finally {
// ensure to clean up S3 jersey clients
if (s3ObjectClientMap != null) {
for (S3JerseyClient s3JerseyClient : s3ObjectClientMap.values()) {
s3JerseyClient.destroy();
}
}
}
}
use of com.emc.ecs.management.entity.ObjectUserDetails in project ecs-dashboard by carone1.
the class BillingBO method getObjectUserSecretKeys.
// ================================
// Public methods
// ================================
/**
* Retrieve Object uid and secret keys
* @return ObjectUserDetails
*/
public List<ObjectUserDetails> getObjectUserSecretKeys() {
List<ObjectUserDetails> userDetails = new ArrayList<ObjectUserDetails>();
// Collect all uids in order to collect secret keys after
List<ObjectUser> objectUserList = new ArrayList<ObjectUser>();
// first batch
ObjectUsersRequest objectUsersRequest = new ObjectUsersRequest();
ObjectUsers objectUsersResult = client.getObjectUsersUid(objectUsersRequest);
if (objectUsersResult != null) {
if (objectUsersResult.getBlobUser() != null) {
objectUserList.addAll(objectUsersResult.getBlobUser());
}
objectUsersRequest.setMarker(objectUsersResult.getNextMarker());
// Subsequent batches
while (objectUsersResult.getNextMarker() != null) {
objectUsersResult = client.getObjectUsersUid(objectUsersRequest);
if (objectUsersResult != null) {
objectUserList.addAll(objectUsersResult.getBlobUser());
objectUsersRequest.setMarker(objectUsersResult.getNextMarker());
} else {
break;
}
}
}
// Collect secret keys
for (ObjectUser objectUser : objectUserList) {
ObjectUserSecretKeys objectUserSecretKeys = client.getObjectUserSecretKeys(objectUser.getUserId().toString(), objectUser.getNamespace().toString());
if (objectUserSecretKeys != null) {
userDetails.add(new ObjectUserDetails(objectUser, objectUserSecretKeys));
}
}
return userDetails;
}
use of com.emc.ecs.management.entity.ObjectUserDetails in project ecs-dashboard by carone1.
the class ObjectBO method createS3ObjectClients.
private Map<String, S3JerseyClient> createS3ObjectClients(List<ObjectUserDetails> objectUserDetailsList, List<String> ecsObjectHosts) {
Map<String, S3JerseyClient> s3JerseyClientList = new HashMap<String, S3JerseyClient>();
// collect objects for all users
for (ObjectUserDetails objectUserDetails : objectUserDetailsList) {
if (objectUserDetails.getObjectUser().getUserId() == null || objectUserDetails.getSecretKeys().getSecretKey1() == null) {
// in that case we just skip over that user
continue;
}
// Create object client user
Vdc vdc = new Vdc((String[]) this.ecsObjectHosts.toArray());
S3Config s3config = new S3Config(Protocol.HTTP, vdc);
// in all cases, you need to provide your credentials
s3config.withIdentity(objectUserDetails.getObjectUser().getUserId().toString()).withSecretKey(objectUserDetails.getSecretKeys().getSecretKey1());
s3config.setSmartClient(true);
URLConnectionClientHandler urlHandler = new URLConnectionClientHandler();
S3JerseyClient s3JerseyClient = new S3JerseyClient(s3config, urlHandler);
s3JerseyClientList.put(objectUserDetails.getObjectUser().getUserId().toString(), s3JerseyClient);
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
logger.error(e.getLocalizedMessage());
}
return s3JerseyClientList;
}
Aggregations