You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by ad...@apache.org on 2018/04/20 12:19:35 UTC

svn commit: r1829648 - in /jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment: SegmentNodeStoreMonitorService.java SegmentNodeStoreService.java SegmentNodeStoreStats.java

Author: adulceanu
Date: Fri Apr 20 12:19:35 2018
New Revision: 1829648

URL: http://svn.apache.org/viewvc?rev=1829648&view=rev
Log:
OAK-7420 - Introduce SegmentNodeStoreMonitorService for exposing writerGroups as an OSGi config property

Added:
    jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreMonitorService.java
Modified:
    jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java
    jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreStats.java

Added: jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreMonitorService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreMonitorService.java?rev=1829648&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreMonitorService.java (added)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreMonitorService.java Fri Apr 20 12:19:35 2018
@@ -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<String, ?> config) throws IOException {
+        augmentSegmentNodeStoreStatsMBean(config);
+    }
+
+    private void augmentSegmentNodeStoreStatsMBean(Map<String, ?> config) {
+        snsStatsMBean.setWriterGroupsForLastMinuteCounts(
+                PropertiesUtil.toStringArray(config.get(COMMITS_TRACKER_WRITER_GROUPS), null));
+    }
+}

Modified: jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java?rev=1829648&r1=1829647&r2=1829648&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java Fri Apr 20 12:19:35 2018
@@ -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(),

Modified: jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreStats.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreStats.java?rev=1829648&r1=1829647&r2=1829648&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreStats.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreStats.java Fri Apr 20 12:19:35 2018
@@ -44,8 +44,9 @@ import org.apache.jackrabbit.oak.stats.S
 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 imple
     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) {