You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "nit0906 (via GitHub)" <gi...@apache.org> on 2023/05/03 15:59:50 UTC

[GitHub] [jackrabbit-oak] nit0906 commented on a diff in pull request #922: OAK-10225 Utility to rate limit writes in case async indexing is delayed

nit0906 commented on code in PR #922:
URL: https://github.com/apache/jackrabbit-oak/pull/922#discussion_r1183893155


##########
oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/RateLimitUtils.java:
##########
@@ -0,0 +1,137 @@
+/*
+ * 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.plugins.index;
+
+import java.lang.management.ManagementFactory;
+import java.time.Duration;
+import java.time.Instant;
+import java.util.Calendar;
+import java.util.Set;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import org.apache.jackrabbit.util.ISO8601;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RateLimitUtils {
+    
+    private final static Logger LOG = LoggerFactory.getLogger(RateLimitUtils.class);    
+
+    // when getOldestAsyncIndexUpdate was called the last time 
+    private static Instant lastJmxBeanCall = Instant.now();
+
+    // the return value of the last call to getOldestAsyncIndexUpdate
+    private static Instant cachedOldestAsyncUpdate = Instant.now();
+    
+    // the last time the rateLimitWrites was called
+    private static Instant lastRateLimitCall = Instant.now();

Review Comment:
   +1



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org