Tabnine Logo
JmxFeed
Code IndexAdd Tabnine to your IDE (free)

How to use
JmxFeed
in
org.apache.brooklyn.feed.jmx

Best Java code snippets using org.apache.brooklyn.feed.jmx.JmxFeed (Showing top 20 results out of 315)

origin: org.apache.brooklyn/brooklyn-software-messaging

@Override
protected void disconnectSensors() {
  if (jmxFeed != null) jmxFeed.stop();
}

origin: org.apache.brooklyn/brooklyn-software-base

public JmxFeed build() {
  built = true;
  JmxFeed result = new JmxFeed(this);
  result.setEntity(checkNotNull((EntityLocal)entity, "entity"));
  result.start();
  return result;
}
@Override
origin: org.apache.brooklyn/brooklyn-software-base

final SetMultimap<NotificationFilter, JmxNotificationSubscriptionConfig<?>> notificationSubscriptions = getConfig(NOTIFICATION_SUBSCRIPTIONS);
final SetMultimap<List<?>, JmxOperationPollConfig<?>> operationPolls = getConfig(OPERATION_POLLS);
final SetMultimap<String, JmxAttributePollConfig<?>> attributePolls = getConfig(ATTRIBUTE_POLLS);
getPoller().submit(new Callable<Void>() {
    @Override public Void call() {
      getHelper().connect(getConfig(JMX_CONNECTION_TIMEOUT));
  getPoller().submit(new Callable<Void>() {
    @Override public Void call() {
  registerAttributePoller(attributePolls.get(jmxAttributeName));
  registerOperationPoller(operationPolls.get(operationIdentifier));
origin: org.apache.brooklyn/brooklyn-software-base

@Override public Void call() {
  getHelper().connect(getConfig(JMX_CONNECTION_TIMEOUT));
  return null;
}
@Override public String toString() { return "Connect JMX "+getHelper().getUrl(); }
origin: org.apache.brooklyn/brooklyn-software-base

  @Override
  public Object call() throws Exception {
    if (log.isTraceEnabled()) log.trace("jmx attribute polling for {} sensors at {} -> {}", new Object[] {getEntity(), getJmxUri(), jmxAttributeName});
    return getHelper().getAttribute(objectName, jmxAttributeName);
  }
}, 
origin: org.apache.brooklyn/brooklyn-software-messaging

@Override
protected void connectSensors() {
  String queue = String.format("org.apache.activemq:type=Broker,brokerName=%s,destinationType=Queue,destinationName=%s", getBrokerName(), getName());
  
  jmxFeed = JmxFeed.builder()
      .entity(this)
      .helper(jmxHelper)
      .pollAttribute(new JmxAttributePollConfig<Integer>(QUEUE_DEPTH_MESSAGES)
          .objectName(queue)
          .attributeName("QueueSize"))
      .build();
}
origin: org.apache.brooklyn/brooklyn-software-base

/**
 * Registers to poll a jmx-attribute for an ObjectName, where all the given configs are for that same ObjectName + attribute.
 */
private void registerAttributePoller(Set<JmxAttributePollConfig<?>> configs) {
  Set<AttributePollHandler<? super Object>> handlers = Sets.newLinkedHashSet();
  long minPeriod = Integer.MAX_VALUE;
  
  final ObjectName objectName = Iterables.get(configs, 0).getObjectName();
  final String jmxAttributeName = Iterables.get(configs, 0).getAttributeName();
  
  for (JmxAttributePollConfig<?> config : configs) {
    handlers.add(new AttributePollHandler<Object>(config, getEntity(), this));
    if (config.getPeriod() > 0) minPeriod = Math.min(minPeriod, config.getPeriod());
  }
  
  // TODO Not good calling this holding the synchronization lock
  getPoller().scheduleAtFixedRate(
      new Callable<Object>() {
        @Override
        public Object call() throws Exception {
          if (log.isTraceEnabled()) log.trace("jmx attribute polling for {} sensors at {} -> {}", new Object[] {getEntity(), getJmxUri(), jmxAttributeName});
          return getHelper().getAttribute(objectName, jmxAttributeName);
        }
      }, 
      new DelegatingPollHandler<Object>(handlers), minPeriod);
}
origin: org.apache.brooklyn/brooklyn-software-base

@Override
public void setEntity(EntityLocal entity) {
  if (getConfig(HELPER) == null) {
    JmxHelper helper = new JmxHelper(entity);
    setConfig(HELPER, helper);
    setConfig(OWN_HELPER, true);
    setConfig(JMX_URI, helper.getUrl());
  }
  super.setEntity(entity);
}

origin: org.apache.brooklyn/brooklyn-software-base

  AttributePollHandler<javax.management.Notification> handler = new AttributePollHandler<javax.management.Notification>(config, getEntity(), this) {
    @Override protected Object transformValueOnSuccess(javax.management.Notification val) {
      if (config.getOnNotification() != null) {
getHelper().addNotificationListener(objectName, listener, filter);
origin: org.apache.brooklyn/brooklyn-software-base

private void unregisterNotificationListener(ObjectName objectName, NotificationListener listener) {
  try {
    getHelper().removeNotificationListener(objectName, listener);
  } catch (RuntimeException e) {
    log.warn("Failed to unregister listener: "+objectName+", "+listener+"; continuing...", e);
  }
}

origin: org.apache.brooklyn/brooklyn-software-base

public String getJmxUri() {
  return getConfig(JMX_URI);
}

origin: org.apache.brooklyn/brooklyn-software-messaging

@Override
protected void connectSensors() {
  String queue = format("org.apache.qpid:type=VirtualHost.Queue,VirtualHost=\"%s\",name=\"%s\"", virtualHost, getName());
  
  jmxFeed = JmxFeed.builder()
      .entity(this)
      .helper(jmxHelper)
      .pollAttribute(new JmxAttributePollConfig<Integer>(QUEUE_DEPTH_BYTES)
          .objectName(queue)
          .attributeName("QueueDepth"))
      .pollAttribute(new JmxAttributePollConfig<Integer>(QUEUE_DEPTH_MESSAGES)
          .objectName(queue)
          .attributeName("MessageCount"))
      .build();
}
origin: org.apache.brooklyn/brooklyn-software-base

  @Override
  public Object call() throws Exception {
    if (log.isDebugEnabled()) log.debug("jmx operation polling for {} sensors at {} -> {}", new Object[] {getEntity(), getJmxUri(), operationName});
    if (signature.size() == params.size()) {
      return getHelper().operation(objectName, operationName, signature, params);
    } else {
      return getHelper().operation(objectName, operationName, params.toArray());
    }
  }
}, 
origin: org.apache.brooklyn/brooklyn-software-base

@Override
protected void postStop() {
  super.postStop();
  JmxHelper helper = getHelper();
  Boolean ownHelper = getConfig(OWN_HELPER);
  if (helper != null && ownHelper) helper.terminate();
}

origin: org.apache.brooklyn/brooklyn-software-base

  handlers.add(new AttributePollHandler<Object>(config, getEntity(), this));
  if (config.getPeriod() > 0) minPeriod = Math.min(minPeriod, config.getPeriod());
getPoller().scheduleAtFixedRate(
    new Callable<Object>() {
      @Override
origin: org.apache.brooklyn/brooklyn-software-base

  @Override public String toString() { return "Connect JMX "+getHelper().getUrl(); }
});
origin: org.apache.brooklyn/brooklyn-software-base

protected JmxHelper getHelper() {
  return getConfig(HELPER);
}

origin: org.apache.brooklyn/brooklyn-software-messaging

@Override
protected void disconnectSensors() {
  if (jmxFeed != null) jmxFeed.stop();
}
origin: org.apache.brooklyn/brooklyn-software-base

@Test
public void testJmxOperationPolledForSensor() throws Exception {
  // This is awful syntax...
  final int opReturnVal = 123;
  final AtomicInteger invocationCount = new AtomicInteger();
  MBeanOperationInfo opInfo = new MBeanOperationInfo(opName, "my descr", new MBeanParameterInfo[0], Integer.class.getName(), MBeanOperationInfo.ACTION);
  GeneralisedDynamicMBean mbean = jmxService.registerMBean(
      Collections.emptyMap(), 
      ImmutableMap.of(opInfo, new Function<Object[], Integer>() {
          @Override
          public Integer apply(Object[] args) {
            invocationCount.incrementAndGet(); return opReturnVal;
          }}),
      objectName);
  feed = JmxFeed.builder()
      .entity(entity)
      .pollOperation(new JmxOperationPollConfig<Integer>(intAttribute)
          .objectName(objectName)
          .operationName(opName))
      .build();
  
  Asserts.succeedsEventually(ImmutableMap.of("timeout", TIMEOUT_MS), new Runnable() {
    @Override
    public void run() {
      assertTrue(invocationCount.get() > 0, "invocationCount="+invocationCount);
      assertEquals(entity.getAttribute(intAttribute), (Integer)opReturnVal);
    }});
}
origin: org.apache.brooklyn/brooklyn-software-base

@Override
protected boolean isConnected() {
  return super.isConnected() && getHelper().isConnected();
}

org.apache.brooklyn.feed.jmxJmxFeed

Javadoc

Provides a feed of attribute values, by polling or subscribing over jmx. Example usage (e.g. in an entity that extends SoftwareProcessImpl):
 
private JmxFeed feed;{@literal @}Override 
protected void disconnectSensors()  
super.disconnectSensors(); 
if (feed != null) feed.stop(); 
} 
} 

Most used methods

  • stop
  • builder
  • <init>
  • getConfig
  • getEntity
  • getHelper
  • getJmxUri
  • getManagementContext
  • getPoller
  • initUniqueTag
  • registerAttributePoller
    Registers to poll a jmx-attribute for an ObjectName, where all the given configs are for that same O
  • registerOperationPoller
    Registers to poll a jmx-operation for an ObjectName, where all the given configs are for the same Ob
  • registerAttributePoller,
  • registerOperationPoller,
  • setConfig,
  • setEntity,
  • start,
  • unregisterNotificationListener

Popular in Java

  • Updating database using SQL prepared statement
  • getResourceAsStream (ClassLoader)
  • getSystemService (Context)
  • putExtra (Intent)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • String (java.lang)
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now