Search in sources :

Example 1 with NamespaceQuota

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

the class ManagementClient method getNamespaceQuota.

/**
 * Returns namespace specific details
 * @return NamespaceDetail
 */
public NamespaceQuota getNamespaceQuota(NamespaceRequest namespaceRequest) {
    String authToken = getAuthToken();
    WebResource mgmtResource = this.mgmtClient.resource(uri);
    StringBuilder restStr = new StringBuilder();
    restStr.append(REST_QUOTA_NAMESPACES_FIRST).append(namespaceRequest.getName()).append(REST_QUOTA_NAMESPACES_SECOND);
    // Get Namespace Detail Ressource
    WebResource getNamespaceDetailResource = mgmtResource.path(restStr.toString());
    NamespaceQuota namespaceQuotaResponse = getNamespaceDetailResource.header(X_SDS_AUTH_TOKEN, authToken).get(NamespaceQuota.class);
    return namespaceQuotaResponse;
}
Also used : NamespaceQuota(com.emc.ecs.management.entity.NamespaceQuota) WebResource(com.sun.jersey.api.client.WebResource)

Example 2 with NamespaceQuota

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

the class FileNamespaceDAO method insert.

/**
 * {@inheritDoc}
 */
@Override
public void insert(NamespaceQuota namespaceQuota, Date collectionTime) {
    JAXBContext jaxbContext;
    try {
        jaxbContext = JAXBContext.newInstance(NamespaceQuota.class);
        Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
        jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        OutputStream byteOut = new ByteArrayOutputStream();
        jaxbMarshaller.marshal(namespaceQuota, 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());
    }
}
Also used : Marshaller(javax.xml.bind.Marshaller) OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) JAXBException(javax.xml.bind.JAXBException) NamespaceQuota(com.emc.ecs.management.entity.NamespaceQuota) JAXBContext(javax.xml.bind.JAXBContext) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 3 with NamespaceQuota

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

NamespaceQuota (com.emc.ecs.management.entity.NamespaceQuota)3 ListNamespaceRequest (com.emc.ecs.management.entity.ListNamespaceRequest)1 Namespace (com.emc.ecs.management.entity.Namespace)1 NamespaceRequest (com.emc.ecs.management.entity.NamespaceRequest)1 WebResource (com.sun.jersey.api.client.WebResource)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 OutputStream (java.io.OutputStream)1 JAXBContext (javax.xml.bind.JAXBContext)1 JAXBException (javax.xml.bind.JAXBException)1 Marshaller (javax.xml.bind.Marshaller)1