Search in sources :

Example 1 with MetricInfoCollection

use of org.platformlayer.metrics.model.MetricInfoCollection in project platformlayer by platformlayer.

the class MetricCollector method toMetricInfo.

public static MetricInfoCollection toMetricInfo(MetricConfig metricConfig) {
    MetricInfoCollection metricInfo = new MetricInfoCollection();
    populateMetricInfo(metricInfo, "", metricConfig);
    return metricInfo;
}
Also used : MetricInfoCollection(org.platformlayer.metrics.model.MetricInfoCollection)

Example 2 with MetricInfoCollection

use of org.platformlayer.metrics.model.MetricInfoCollection in project platformlayer by platformlayer.

the class MetricsResource method listMetrics.

@GET
@Produces({ XML, JSON })
public MetricInfoCollection listMetrics() throws OpsException, RepositoryException {
    final ItemBase managedItem = getManagedItem();
    final ServiceProvider serviceProvider = getServiceProvider();
    OpsContextBuilder opsContextBuilder = objectInjector.getInstance(OpsContextBuilder.class);
    final OpsContext opsContext = opsContextBuilder.buildTemporaryOpsContext(getServiceType(), getProjectAuthorization());
    return OpsContext.runInContext(opsContext, new CheckedCallable<MetricInfoCollection, Exception>() {

        @Override
        public MetricInfoCollection call() throws Exception {
            BindingScope bindingScope = BindingScope.push(managedItem, managedItem);
            try {
                Object controller = serviceProvider.getController(managedItem);
                MetricConfig metricConfig = opsContext.getMetricInfo(controller);
                return MetricCollector.toMetricInfo(metricConfig);
            } finally {
                bindingScope.pop();
            }
        }
    });
}
Also used : MetricConfig(org.platformlayer.ops.model.metrics.MetricConfig) ItemBase(org.platformlayer.core.model.ItemBase) ServiceProvider(org.platformlayer.xaas.services.ServiceProvider) MetricInfoCollection(org.platformlayer.metrics.model.MetricInfoCollection) OpsContext(org.platformlayer.ops.OpsContext) RepositoryException(org.platformlayer.RepositoryException) OpsException(org.platformlayer.ops.OpsException) OpsContextBuilder(org.platformlayer.ops.tasks.OpsContextBuilder) BindingScope(org.platformlayer.ops.BindingScope) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with MetricInfoCollection

use of org.platformlayer.metrics.model.MetricInfoCollection in project platformlayer by platformlayer.

the class HttpPlatformLayerClient method listMetrics.

@Override
public MetricInfoCollection listMetrics(PlatformLayerKey key) throws PlatformLayerClientException {
    String relativePath = buildRelativePath(key) + "/metrics";
    String retval = doRequest(HttpMethod.GET, relativePath, String.class, Format.XML, null, null);
    MetricInfoCollection items;
    try {
        items = JaxbHelper.deserializeXmlObject(retval, MetricInfoCollection.class);
    } catch (UnmarshalException e) {
        throw new PlatformLayerClientException("Error parsing returned data", e);
    }
    return items;
}
Also used : UnmarshalException(javax.xml.bind.UnmarshalException) MetricInfoCollection(org.platformlayer.metrics.model.MetricInfoCollection)

Example 4 with MetricInfoCollection

use of org.platformlayer.metrics.model.MetricInfoCollection in project platformlayer by platformlayer.

the class ListMetrics method runCommand.

@Override
public Object runCommand() throws PlatformLayerClientException {
    PlatformLayerClient client = getPlatformLayerClient();
    PlatformLayerKey key = getContext().pathToItem(getProject(), path);
    MetricInfoCollection items = client.listMetrics(key);
    return items;
}
Also used : PlatformLayerClient(org.platformlayer.PlatformLayerClient) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) MetricInfoCollection(org.platformlayer.metrics.model.MetricInfoCollection)

Aggregations

MetricInfoCollection (org.platformlayer.metrics.model.MetricInfoCollection)4 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 UnmarshalException (javax.xml.bind.UnmarshalException)1 PlatformLayerClient (org.platformlayer.PlatformLayerClient)1 RepositoryException (org.platformlayer.RepositoryException)1 ItemBase (org.platformlayer.core.model.ItemBase)1 PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)1 BindingScope (org.platformlayer.ops.BindingScope)1 OpsContext (org.platformlayer.ops.OpsContext)1 OpsException (org.platformlayer.ops.OpsException)1 MetricConfig (org.platformlayer.ops.model.metrics.MetricConfig)1 OpsContextBuilder (org.platformlayer.ops.tasks.OpsContextBuilder)1 ServiceProvider (org.platformlayer.xaas.services.ServiceProvider)1