Search in sources :

Example 1 with EventListenerMBean

use of org.apache.jackrabbit.api.jmx.EventListenerMBean in project jackrabbit by apache.

the class ListenerTracker method getListenerMBean.

public EventListenerMBean getListenerMBean() {
    return new EventListenerMBean() {

        @Override
        public String getClassName() {
            return listener.getClass().getName();
        }

        @Override
        public String getToString() {
            return listener.toString();
        }

        @Override
        public String getInitStackTrace() {
            StringWriter writer = new StringWriter();
            initStackTrace.printStackTrace(new PrintWriter(writer));
            return writer.toString();
        }

        @Override
        public int getEventTypes() {
            return eventTypes;
        }

        @Override
        public String getAbsPath() {
            return absPath;
        }

        @Override
        public boolean isDeep() {
            return isDeep;
        }

        @Override
        public String[] getUuid() {
            return copy(uuid);
        }

        @Override
        public String[] getNodeTypeName() {
            return copy(nodeTypeName);
        }

        @Override
        public boolean isNoLocal() {
            return noLocal;
        }

        @Override
        public long getEventDeliveries() {
            return eventDeliveries.get();
        }

        @Override
        public long getEventDeliveriesPerHour() {
            return TimeUnit.HOURS.toMillis(getEventDeliveries()) / Math.max(currentTimeMillis() - startTime, 1);
        }

        @Override
        public long getMicrosecondsPerEventDelivery() {
            return TimeUnit.NANOSECONDS.toMicros(eventDeliveryTime.get()) / Math.max(getEventDeliveries(), 1);
        }

        @Override
        public long getEventsDelivered() {
            return eventsDelivered.get();
        }

        @Override
        public long getEventsDeliveredPerHour() {
            return TimeUnit.HOURS.toMillis(getEventsDelivered()) / Math.max(currentTimeMillis() - startTime, 1);
        }

        @Override
        public long getMicrosecondsPerEventDelivered() {
            return TimeUnit.NANOSECONDS.toMicros(eventDeliveryTime.get()) / Math.max(getEventsDelivered(), 1);
        }

        @Override
        public double getRatioOfTimeSpentProcessingEvents() {
            double timeSpentProcessingEvents = TimeUnit.NANOSECONDS.toMillis(eventDeliveryTime.get());
            return timeSpentProcessingEvents / Math.max(currentTimeMillis() - startTime, 1);
        }

        @Override
        public double getEventConsumerTimeRatio() {
            double consumerTime = sum(eventConsumerTime);
            double producerTime = sum(eventProducerTime);
            return consumerTime / Math.max(consumerTime + producerTime, 1);
        }

        @Override
        public boolean isUserInfoAccessedWithoutExternalsCheck() {
            return userInfoAccessedWithoutExternalsCheck.get();
        }

        @Override
        public synchronized boolean isUserInfoAccessedFromExternalEvent() {
            return userInfoAccessedFromExternalEvent.get();
        }

        @Override
        public synchronized boolean isDateAccessedWithoutExternalsCheck() {
            return dateAccessedWithoutExternalsCheck.get();
        }

        @Override
        public synchronized boolean isDateAccessedFromExternalEvent() {
            return dateAccessedFromExternalEvent.get();
        }

        @Override
        public long getQueueBacklogMillis() {
            long t = headTimestamp.get();
            if (t > 0) {
                t = currentTimeMillis() - t;
            }
            return t;
        }

        @Override
        public CompositeData getQueueLength() {
            return asCompositeData(queueLength, "queueLength");
        }

        @Override
        public CompositeData getEventCount() {
            return asCompositeData(eventCount, "eventCount");
        }

        @Override
        public CompositeData getEventConsumerTime() {
            return asCompositeData(eventConsumerTime, "eventConsumerTime");
        }

        @Override
        public CompositeData getEventProducerTime() {
            return asCompositeData(eventProducerTime, "eventProducerTime");
        }
    };
}
Also used : StringWriter(java.io.StringWriter) EventListenerMBean(org.apache.jackrabbit.api.jmx.EventListenerMBean) PrintWriter(java.io.PrintWriter)

Example 2 with EventListenerMBean

use of org.apache.jackrabbit.api.jmx.EventListenerMBean in project jackrabbit-oak by apache.

the class ConsolidatedListenerMBeanImpl method getLeaderBoard.

@Override
public TabularData getLeaderBoard() {
    TabularDataSupport tds;
    try {
        int id = 0;
        TabularType tt = new TabularType(LeaderBoardData.class.getName(), "Leaderboard", LeaderBoardData.TYPE, new String[] { "index" });
        tds = new TabularDataSupport(tt);
        List<LeaderBoardData> leaderBoard = Lists.newArrayList();
        for (Map.Entry<ObjectName, EventListenerMBean> e : eventListeners.entrySet()) {
            String listenerId = getListenerId(e.getKey());
            EventListenerMBean mbean = e.getValue();
            FilterConfigMBean filterConfigMBean = null;
            for (Map.Entry<ObjectName, FilterConfigMBean> ef : filterConfigs.entrySet()) {
                if (Objects.equal(getListenerId(ef.getKey()), listenerId)) {
                    filterConfigMBean = ef.getValue();
                    break;
                }
            }
            leaderBoard.add(new LeaderBoardData(++id, mbean, filterConfigMBean));
        }
        sort(leaderBoard);
        for (LeaderBoardData data : leaderBoard) {
            tds.put(data.toCompositeData());
        }
    } catch (OpenDataException e) {
        throw new IllegalStateException(e);
    }
    return tds;
}
Also used : TabularType(javax.management.openmbean.TabularType) FilterConfigMBean(org.apache.jackrabbit.oak.plugins.observation.filter.FilterConfigMBean) ObjectName(javax.management.ObjectName) OpenDataException(javax.management.openmbean.OpenDataException) TabularDataSupport(javax.management.openmbean.TabularDataSupport) EventListenerMBean(org.apache.jackrabbit.api.jmx.EventListenerMBean) Map(java.util.Map)

Aggregations

EventListenerMBean (org.apache.jackrabbit.api.jmx.EventListenerMBean)2 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 Map (java.util.Map)1 ObjectName (javax.management.ObjectName)1 OpenDataException (javax.management.openmbean.OpenDataException)1 TabularDataSupport (javax.management.openmbean.TabularDataSupport)1 TabularType (javax.management.openmbean.TabularType)1 FilterConfigMBean (org.apache.jackrabbit.oak.plugins.observation.filter.FilterConfigMBean)1