Search in sources :

Example 1 with MetricDataSource

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

the class MetricsResource method getMetrics.

@POST
@Produces({ XML, JSON })
public MetricDataSource getMetrics(final MetricQuery query) throws RepositoryException, OpsException {
    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<MetricDataSource, Exception>() {

        @Override
        public MetricDataSource call() throws Exception {
            BindingScope bindingScope = BindingScope.push(managedItem, managedItem);
            try {
                MetricDataSource metrics = serviceProvider.getMetricValues(managedItem, query);
                return metrics;
            } finally {
                bindingScope.pop();
            }
        }
    });
}
Also used : MetricDataSource(org.platformlayer.metrics.model.MetricDataSource) ItemBase(org.platformlayer.core.model.ItemBase) ServiceProvider(org.platformlayer.xaas.services.ServiceProvider) 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) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Aggregations

POST (javax.ws.rs.POST)1 Produces (javax.ws.rs.Produces)1 RepositoryException (org.platformlayer.RepositoryException)1 ItemBase (org.platformlayer.core.model.ItemBase)1 MetricDataSource (org.platformlayer.metrics.model.MetricDataSource)1 BindingScope (org.platformlayer.ops.BindingScope)1 OpsContext (org.platformlayer.ops.OpsContext)1 OpsException (org.platformlayer.ops.OpsException)1 OpsContextBuilder (org.platformlayer.ops.tasks.OpsContextBuilder)1 ServiceProvider (org.platformlayer.xaas.services.ServiceProvider)1