use of com.emc.ecs.management.entity.BucketOwner in project ecs-dashboard by carone1.
the class ManagementClient method getBucketOwnerFromString.
/**
* @param response
* @return
*/
private BucketOwner getBucketOwnerFromString(String bucketKey, String response) {
final String OWNER_SHIP = "ownerzone";
final String TEXT_VALUE = "textValue:";
final String DOUBLE_QUOTES = "\"";
final String COLON = ":";
final Pattern pattern = Pattern.compile("(?s)(.*?)" + OWNER_SHIP + "(.*?)" + TEXT_VALUE + "(.*?)" + DOUBLE_QUOTES + "(.*?)" + COLON + "(.*?)" + COLON + "(.*?)" + COLON + "(?<vdcid>.*?)" + DOUBLE_QUOTES + "(.*?)$");
final Matcher matcher = pattern.matcher(response);
String vdcId = null;
while (matcher.find()) {
vdcId = matcher.group("vdcid");
}
BucketOwner bucketOwner = new BucketOwner(vdcId, bucketKey);
return bucketOwner;
}
use of com.emc.ecs.management.entity.BucketOwner in project ecs-dashboard by carone1.
the class ManagementClient method getBucketOwner.
/**
* returns bucket owner list
* @return
*/
public List<BucketOwner> getBucketOwner() {
final WebResource mgmtResource = this.mgmtClient.resource(uri);
StringBuilder restStr = new StringBuilder();
restStr.append(REST_ALL_BUCKET_KEYS);
// Get Namespace Detail Ressource
WebResource getNamespaceDetailResource = mgmtResource.path(restStr.toString());
String bucketKeyReponse = getNamespaceDetailResource.get(String.class);
final List<BucketOwner> bucketOwners = new ArrayList<>();
final Map<String, List<String>> urlBucketKeysmap = getUrlBucketKeyMap(bucketKeyReponse);
urlBucketKeysmap.forEach((url, bucketKeys) -> {
final String host = url.split("@@")[0];
final String path = url.split("@@")[1];
bucketKeys.forEach(bucketKey -> {
WebResource getBucketDetailsResource = this.mgmtClient.resource(host).path(path).queryParam(REST_ALL_BUCKET_KEY_PARAMETER, bucketKey).queryParam(REST_ALL_BUCKET_VALUE_PARAMETER, "gpb").queryParam(REST_ALL_BUCKET_STYLE_PARAMETER, "raw");
bucketOwners.add(getBucketOwnerFromString(bucketKey, getBucketDetailsResource.get(String.class)));
});
});
return bucketOwners;
}
use of com.emc.ecs.management.entity.BucketOwner in project ecs-dashboard by carone1.
the class ElasticBucketOwnerDAO method insert.
@Override
public void insert(List<BucketOwner> bucketOwners, Date collectionTime) {
if (bucketOwners != null && !bucketOwners.isEmpty()) {
BulkRequestBuilder requestBuilder = elasticClient.prepareBulk();
// Generate JSON for object buckets info
for (BucketOwner bucketOwner : bucketOwners) {
XContentBuilder objectBucketBuilder = toJsonFormat(bucketOwner, collectionTime);
IndexRequestBuilder request = elasticClient.prepareIndex().setIndex(bucketownerIndexDayName).setType(BUCKET_OWNER_INDEX_TYPE).setSource(objectBucketBuilder);
requestBuilder.add(request);
}
BulkResponse bulkResponse = requestBuilder.execute().actionGet();
int items = bulkResponse.getItems().length;
LOGGER.info("Took " + bulkResponse.getTookInMillis() + " ms to index [" + items + "] items in ElasticSearch" + "index: " + bucketownerIndexDayName + " index type: " + BUCKET_OWNER_INDEX_TYPE);
if (bulkResponse.hasFailures()) {
LOGGER.error("Failures occured while items in ElasticSearch " + "index: " + bucketownerIndexDayName + " index type: " + BUCKET_OWNER_INDEX_TYPE);
}
}
}
use of com.emc.ecs.management.entity.BucketOwner in project ecs-dashboard by carone1.
the class FileVdcDAO method insert.
@Override
public void insert(List<BucketOwner> bucketOwners, Date collectionTime) {
JAXBContext jaxbContext;
for (BucketOwner bucketOwner : bucketOwners) {
try {
jaxbContext = JAXBContext.newInstance(BucketOwner.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
OutputStream byteOut = new ByteArrayOutputStream();
jaxbMarshaller.marshal(bucketOwner, byteOut);
String bytesOutStr = byteOut.toString();
System.out.println(bytesOutStr);
if (this.destinationPath != null) {
// could write the formatted output to a file too
}
} catch (JAXBException e) {
throw new RuntimeException(e.getLocalizedMessage());
}
}
}
Aggregations