Search in sources :

Example 1 with QueryParameterSource

use of org.apache.geode.management.internal.web.domain.QueryParameterSource in project geode by apache.

the class AbstractHttpOperationInvoker method queryNames.

/**
   * This method searches the MBean server, based on the OperationsInvoker's JMX-based or remoting
   * capable MBean server connection, for MBeans matching a specific ObjectName or matching an
   * ObjectName pattern along with satisfying criteria from the Query expression.
   * 
   * @param objectName the ObjectName or pattern for which matching MBeans in the target MBean
   *        server will be returned.
   * @param queryExpression the JMX-based query expression used to filter matching MBeans.
   * @return a set of ObjectName's matching MBeans in the MBean server matching the ObjectName and
   *         Query expression criteria.
   * @see #createHttpRequest(org.apache.geode.management.internal.web.domain.Link)
   * @see #findLink(String)
   * @see #send(org.apache.geode.management.internal.web.http.ClientHttpRequest, Class)
   * @see javax.management.ObjectName
   * @see javax.management.QueryExp
   */
@Override
@SuppressWarnings("unchecked")
public Set<ObjectName> queryNames(final ObjectName objectName, final QueryExp queryExpression) {
    final Link link = findLink(MBEAN_QUERY_LINK_RELATION);
    if (link != null) {
        final ClientHttpRequest request = createHttpRequest(link);
        request.setContent(new QueryParameterSource(objectName, queryExpression));
        try {
            return (Set<ObjectName>) IOUtils.deserializeObject(send(request, byte[].class));
        } catch (Exception e) {
            throw new MBeanAccessException(String.format("An error occurred while querying for MBean names using ObjectName pattern (%1$s) and Query expression (%2$s)!", objectName, queryExpression), e);
        }
    } else {
        printSevere("Running a query to get the ObjectNames of all MBeans matching the ObjectName pattern (%1$s) and Query expression (%2$s) is currently unsupported!", objectName, queryExpression);
        throw new RestApiCallForCommandNotFoundException(MBEAN_QUERY_LINK_RELATION);
    }
}
Also used : Set(java.util.Set) QueryParameterSource(org.apache.geode.management.internal.web.domain.QueryParameterSource) ClientHttpRequest(org.apache.geode.management.internal.web.http.ClientHttpRequest) Link(org.apache.geode.management.internal.web.domain.Link) AuthenticationFailedException(org.apache.geode.security.AuthenticationFailedException) NotAuthorizedException(org.apache.geode.security.NotAuthorizedException) ResourceAccessException(org.springframework.web.client.ResourceAccessException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 Set (java.util.Set)1 Link (org.apache.geode.management.internal.web.domain.Link)1 QueryParameterSource (org.apache.geode.management.internal.web.domain.QueryParameterSource)1 ClientHttpRequest (org.apache.geode.management.internal.web.http.ClientHttpRequest)1 AuthenticationFailedException (org.apache.geode.security.AuthenticationFailedException)1 NotAuthorizedException (org.apache.geode.security.NotAuthorizedException)1 ResourceAccessException (org.springframework.web.client.ResourceAccessException)1