Author: mreutegg
Date: Mon Sep 4 07:20:31 2017
New Revision: 1807193
URL: http://svn.apache.org/viewvc?rev=1807193&view=rev
Log:
OAK-6605: Provide job name for async index update
Added:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexMBeanRegistrationTest.java
(with props)
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexMBeanRegistration.java
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexMBeanRegistration.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexMBeanRegistration.java?rev=1807193&r1=1807192&r2=1807193&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexMBeanRegistration.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexMBeanRegistration.java
Mon Sep 4 07:20:31 2017
@@ -41,7 +41,10 @@ public class IndexMBeanRegistration impl
public void registerAsyncIndexer(AsyncIndexUpdate task, long
delayInSeconds) {
task.setIndexMBeanRegistration(this);
- Map<String, Object> config = ImmutableMap.<String,
Object>of(AsyncIndexUpdate.PROP_ASYNC_NAME, task.getName());
+ Map<String, Object> config = ImmutableMap.<String, Object>of(
+ AsyncIndexUpdate.PROP_ASYNC_NAME, task.getName(),
+ "scheduler.name", AsyncIndexUpdate.class.getName() + "-" +
task.getName()
+ );
regs.add(scheduleWithFixedDelay(whiteboard, task, config,
delayInSeconds, true, true));
regs.add(registerMBean(whiteboard, IndexStatsMBean.class,
task.getIndexStats(), IndexStatsMBean.TYPE, task.getName()));
Added:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexMBeanRegistrationTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexMBeanRegistrationTest.java?rev=1807193&view=auto
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexMBeanRegistrationTest.java
(added)
+++
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexMBeanRegistrationTest.java
Mon Sep 4 07:20:31 2017
@@ -0,0 +1,59 @@
+/*
+ * 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.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore;
+import org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard;
+import org.apache.jackrabbit.oak.spi.whiteboard.Registration;
+import org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class IndexMBeanRegistrationTest {
+
+ @Test
+ public void jobName() throws Exception {
+ final AtomicReference<Map<?, ?>> props = new AtomicReference<Map<?,
?>>();
+ Whiteboard wb = new DefaultWhiteboard(){
+ @Override
+ public <T> Registration register(Class<T> type, T service, Map<?,
?> properties) {
+ if (service instanceof AsyncIndexUpdate) {
+ props.set(properties);
+ }
+ return super.register(type, service, properties);
+ }
+ };
+
+ AsyncIndexUpdate update = new AsyncIndexUpdate("async",
+ new MemoryNodeStore(), new CompositeIndexEditorProvider());
+ IndexMBeanRegistration reg = new IndexMBeanRegistration(wb);
+ reg.registerAsyncIndexer(update, 5);
+ try {
+ Map<?, ?> map = props.get();
+ assertNotNull(map);
+ assertEquals(AsyncIndexUpdate.class.getName() + "-async",
+ map.get("scheduler.name"));
+ } finally {
+ reg.unregister();
+ }
+ }
+}
Propchange:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexMBeanRegistrationTest.java
------------------------------------------------------------------------------
svn:eol-style = native