diff --git oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreMonitorService.java oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreMonitorService.java new file mode 100644 index 0000000000..dcc2130df2 --- /dev/null +++ oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreMonitorService.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.jackrabbit.oak.segment; + +import java.io.IOException; +import java.util.Map; + +import org.apache.felix.scr.annotations.Activate; +import org.apache.felix.scr.annotations.Component; +import org.apache.felix.scr.annotations.ConfigurationPolicy; +import org.apache.felix.scr.annotations.Property; +import org.apache.felix.scr.annotations.PropertyUnbounded; +import org.apache.felix.scr.annotations.Reference; +import org.apache.jackrabbit.oak.commons.PropertiesUtil; +import org.osgi.service.component.ComponentContext; + +/** + * An OSGi wrapper for segment node store monitoring configurations. + */ +@Component(policy = ConfigurationPolicy.REQUIRE, + metatype = true, + label = "Oak Segment Tar Monitoring service", + description = "This service is responsible for different configurations related to " + + "Oak Segment Tar read/write monitoring." +) +public class SegmentNodeStoreMonitorService { + + @Property(label = "Writer groups", + unbounded = PropertyUnbounded.ARRAY, + description = "Writer groups for which commits are tracked individually" + ) + private static final String COMMITS_TRACKER_WRITER_GROUPS = "commitsTrackerWriterGroups"; + + @Reference + private SegmentNodeStoreStatsMBean snsStatsMBean; + + @Activate + public void activate(ComponentContext context, Map config) throws IOException { + augmentSegmentNodeStoreStatsMBean(config); + } + + private void augmentSegmentNodeStoreStatsMBean(Map config) { + snsStatsMBean.setWriterGroupsForLastMinuteCounts( + PropertiesUtil.toStringArray(config.get(COMMITS_TRACKER_WRITER_GROUPS), null)); + } +} diff --git oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java index bd120fbc76..bd47e8e99f 100644 --- oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java +++ oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java @@ -350,7 +350,7 @@ public class SegmentNodeStoreService { @Reference private StatisticsProvider statisticsProvider = StatisticsProvider.NOOP; - + private Closer closer; /** @@ -713,7 +713,7 @@ public class SegmentNodeStoreService { )); // Expose statistics about the SegmentNodeStore - + closeables.add(registrations.registerMBean( SegmentNodeStoreStatsMBean.class, segmentNodeStore.getStats(), diff --git oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreStats.java oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreStats.java index 407a5ea14e..7a8aed9851 100644 --- oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreStats.java +++ oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreStats.java @@ -44,8 +44,9 @@ import org.apache.jackrabbit.oak.stats.StatsOptions; import org.apache.jackrabbit.oak.stats.TimerStats; public class SegmentNodeStoreStats implements SegmentNodeStoreStatsMBean, SegmentNodeStoreMonitor { - private static final boolean DEFAULT_COLLECT_STACK_TRACES = true; - private static final int DEFAULT_OTHER_WRITERS_LIMIT = 20; + private static final boolean COLLECT_STACK_TRACES = Boolean + .parseBoolean(System.getProperty("oak.commitsTracker.collectStackTraces", "true")); + private static final int OTHER_WRITERS_LIMIT = Integer.getInteger("oak.commitsTracker.otherWritersLimit", 20); public static final String COMMITS_COUNT = "COMMITS_COUNT"; public static final String COMMIT_QUEUE_SIZE = "COMMIT_QUEUE_SIZE"; @@ -59,8 +60,8 @@ public class SegmentNodeStoreStats implements SegmentNodeStoreStatsMBean, Segmen private final TimerStats queueingTime; private volatile CommitsTracker commitsTracker; - private boolean collectStackTraces = DEFAULT_COLLECT_STACK_TRACES; - private int otherWritersLimit = DEFAULT_OTHER_WRITERS_LIMIT; + private boolean collectStackTraces = COLLECT_STACK_TRACES; + private int otherWritersLimit = OTHER_WRITERS_LIMIT; private String[] writerGroups; public SegmentNodeStoreStats(StatisticsProvider statisticsProvider) {