You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ol...@apache.org on 2018/04/21 22:54:01 UTC

[sling-org-apache-sling-jcr-oak-server] branch master updated (e8e1ea0 -> dcdfdf0)

This is an automated email from the ASF dual-hosted git repository.

olli pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-oak-server.git.


    from e8e1ea0  [maven-release-plugin] prepare for next development iteration
     new 8a1ad8b  SLING-7607 Move ThreadPool (Executor) handling out of OakSlingRepositoryManager
     new dcdfdf0  style

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 bnd.bnd                                            |  9 ++-
 .../internal/DefaultThreadPoolRegistrar.java       | 61 ++++++++++++++++
 .../server/internal/OakSlingRepositoryManager.java | 83 ++++++++--------------
 3 files changed, 97 insertions(+), 56 deletions(-)
 create mode 100644 src/main/java/org/apache/sling/jcr/oak/server/internal/DefaultThreadPoolRegistrar.java

-- 
To stop receiving notification emails like this one, please contact
olli@apache.org.

[sling-org-apache-sling-jcr-oak-server] 01/02: SLING-7607 Move ThreadPool (Executor) handling out of OakSlingRepositoryManager

Posted by ol...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

olli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-oak-server.git

commit 8a1ad8b49b7c6c094a667638f9107a94920184c2
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Sun Apr 22 00:53:09 2018 +0200

    SLING-7607 Move ThreadPool (Executor) handling out of OakSlingRepositoryManager
---
 bnd.bnd                                            |  3 ++
 .../internal/DefaultThreadPoolRegistrar.java       | 61 ++++++++++++++++++++++
 .../server/internal/OakSlingRepositoryManager.java | 23 --------
 3 files changed, 64 insertions(+), 23 deletions(-)

diff --git a/bnd.bnd b/bnd.bnd
index 4069512..e0eb921 100644
--- a/bnd.bnd
+++ b/bnd.bnd
@@ -17,6 +17,9 @@ Import-Package:\
   org.apache.jackrabbit.test; resolution:=optional,\
   *
 
+Provide-Capability:\
+  osgi.service;objectClass:List<String>="java.util.concurrent.Executor,org.apache.sling.commons.threads.ThreadPool"
+
 -baseline: *
 
 -includeresource:\
diff --git a/src/main/java/org/apache/sling/jcr/oak/server/internal/DefaultThreadPoolRegistrar.java b/src/main/java/org/apache/sling/jcr/oak/server/internal/DefaultThreadPoolRegistrar.java
new file mode 100644
index 0000000..2219538
--- /dev/null
+++ b/src/main/java/org/apache/sling/jcr/oak/server/internal/DefaultThreadPoolRegistrar.java
@@ -0,0 +1,61 @@
+/*
+ * 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.sling.jcr.oak.server.internal;
+
+import org.apache.sling.commons.threads.ThreadPool;
+import org.apache.sling.commons.threads.ThreadPoolManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
+
+@Component(
+    immediate = true
+)
+public class DefaultThreadPoolRegistrar {
+
+    @Reference
+    private ThreadPoolManager threadPoolManager;
+
+    private ThreadPool threadPool;
+
+    private ServiceRegistration<ThreadPool> serviceRegistration;
+
+    public DefaultThreadPoolRegistrar() {
+    }
+
+    @Activate
+    private void activate(final BundleContext bundleContext) {
+        threadPool = threadPoolManager.get(null);
+        serviceRegistration = bundleContext.registerService(ThreadPool.class, threadPool, null);
+    }
+
+    @Deactivate
+    private void deactivate() {
+        if (serviceRegistration != null) {
+            serviceRegistration.unregister();
+            serviceRegistration = null;
+        }
+        threadPoolManager.release(threadPool);
+        threadPool = null;
+    }
+
+}
diff --git a/src/main/java/org/apache/sling/jcr/oak/server/internal/OakSlingRepositoryManager.java b/src/main/java/org/apache/sling/jcr/oak/server/internal/OakSlingRepositoryManager.java
index 365f8bf..d7b3143 100644
--- a/src/main/java/org/apache/sling/jcr/oak/server/internal/OakSlingRepositoryManager.java
+++ b/src/main/java/org/apache/sling/jcr/oak/server/internal/OakSlingRepositoryManager.java
@@ -25,8 +25,6 @@ import static org.apache.jackrabbit.oak.plugins.index.IndexUtils.createIndexDefi
 
 import java.util.Collections;
 import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.concurrent.Executor;
 
 import javax.jcr.Repository;
 
@@ -55,8 +53,6 @@ import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
 import org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard;
-import org.apache.sling.commons.threads.ThreadPool;
-import org.apache.sling.commons.threads.ThreadPoolManager;
 import org.apache.sling.jcr.base.AbstractSlingRepository2;
 import org.apache.sling.jcr.base.AbstractSlingRepositoryManager;
 import org.apache.sling.serviceusermapping.ServiceUserMapper;
@@ -96,13 +92,6 @@ public class OakSlingRepositoryManager extends AbstractSlingRepositoryManager {
 
     private ComponentContext componentContext;
 
-    @Reference
-    private ThreadPoolManager threadPoolManager = null;
-
-    private ThreadPool threadPool;
-
-    private ServiceRegistration oakExecutorServiceReference;
-
     private final WhiteboardIndexProvider indexProvider = new WhiteboardIndexProvider();
 
     private final WhiteboardIndexEditorProvider indexEditorProvider = new WhiteboardIndexEditorProvider();
@@ -130,13 +119,6 @@ public class OakSlingRepositoryManager extends AbstractSlingRepositoryManager {
         final Whiteboard whiteboard = new OsgiWhiteboard(bundleContext);
         this.indexProvider.start(whiteboard);
         this.indexEditorProvider.start(whiteboard);
-        this.oakExecutorServiceReference = bundleContext.registerService(
-                Executor.class.getName(), new Executor() {
-            @Override
-            public void execute(Runnable command) {
-                threadPool.execute(command);
-            }
-        }, new Hashtable<String, Object>());
 
         final Oak oak = new Oak(nodeStore)
             .withAsyncIndexing("async", 5);
@@ -192,8 +174,6 @@ public class OakSlingRepositoryManager extends AbstractSlingRepositoryManager {
     protected void disposeRepository(Repository repository) {
         this.indexProvider.stop();
         this.indexEditorProvider.stop();
-        this.oakExecutorServiceReference.unregister();
-        this.oakExecutorServiceReference = null;
         ((JackrabbitRepository) repository).shutdown();
     }
 
@@ -209,7 +189,6 @@ public class OakSlingRepositoryManager extends AbstractSlingRepositoryManager {
         if (configuration.oak_observation_limitCommitRate()) {
             commitRateLimiter = new CommitRateLimiter();
         }
-        this.threadPool = threadPoolManager.get("oak-observation");
         this.nodeAggregatorRegistration = bundleContext.registerService(NodeAggregator.class.getName(), getNodeAggregator(), null);
 
         super.start(bundleContext, new Config(defaultWorkspace, disableLoginAdministrative));
@@ -219,8 +198,6 @@ public class OakSlingRepositoryManager extends AbstractSlingRepositoryManager {
     private void deactivate() {
         super.stop();
         this.componentContext = null;
-        this.threadPoolManager.release(this.threadPool);
-        this.threadPool = null;
         this.nodeAggregatorRegistration.unregister();
     }
 

-- 
To stop receiving notification emails like this one, please contact
olli@apache.org.

[sling-org-apache-sling-jcr-oak-server] 02/02: style

Posted by ol...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

olli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-oak-server.git

commit dcdfdf015d9b634d56a5ba08f11a894e4bd39c0e
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Sun Apr 22 00:53:44 2018 +0200

    style
---
 bnd.bnd                                            |  6 +--
 .../server/internal/OakSlingRepositoryManager.java | 60 +++++++++++-----------
 2 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/bnd.bnd b/bnd.bnd
index e0eb921..e5461b3 100644
--- a/bnd.bnd
+++ b/bnd.bnd
@@ -9,12 +9,12 @@ Bundle-License: Apache License, Version 2.0
 Bundle-Vendor: The Apache Software Foundation
 
 Import-Package:\
-  com.mongodb; resolution:=optional,\
+  com.mongodb;resolution:=optional,\
   org.apache.felix.jaas.boot,\
   org.apache.jackrabbit.oak,\
-  org.apache.jackrabbit.oak.security.user; resolution:=optional,\
+  org.apache.jackrabbit.oak.security.user;resolution:=optional,\
   org.apache.jackrabbit.oak.spi.security.authentication,\
-  org.apache.jackrabbit.test; resolution:=optional,\
+  org.apache.jackrabbit.test;resolution:=optional,\
   *
 
 Provide-Capability:\
diff --git a/src/main/java/org/apache/sling/jcr/oak/server/internal/OakSlingRepositoryManager.java b/src/main/java/org/apache/sling/jcr/oak/server/internal/OakSlingRepositoryManager.java
index d7b3143..e37c71c 100644
--- a/src/main/java/org/apache/sling/jcr/oak/server/internal/OakSlingRepositoryManager.java
+++ b/src/main/java/org/apache/sling/jcr/oak/server/internal/OakSlingRepositoryManager.java
@@ -18,11 +18,6 @@
  */
 package org.apache.sling.jcr.oak.server.internal;
 
-import static com.google.common.collect.ImmutableSet.of;
-import static java.util.Collections.singleton;
-import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NAME;
-import static org.apache.jackrabbit.oak.plugins.index.IndexUtils.createIndexDefinition;
-
 import java.util.Collections;
 import java.util.Dictionary;
 
@@ -69,6 +64,11 @@ import org.osgi.service.component.annotations.ReferencePolicy;
 import org.osgi.service.component.annotations.ReferencePolicyOption;
 import org.osgi.service.metatype.annotations.Designate;
 
+import static com.google.common.collect.ImmutableSet.of;
+import static java.util.Collections.singleton;
+import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NAME;
+import static org.apache.jackrabbit.oak.plugins.index.IndexUtils.createIndexDefinition;
+
 /**
  * A Sling repository implementation that wraps the Oak repository
  * implementation from the Jackrabbit Oak project.
@@ -104,7 +104,7 @@ public class OakSlingRepositoryManager extends AbstractSlingRepositoryManager {
         policy = ReferencePolicy.STATIC,
         policyOption = ReferencePolicyOption.GREEDY
     )
-    private SecurityProvider securityProvider = null;
+    private SecurityProvider securityProvider;
 
     private ServiceRegistration nodeAggregatorRegistration;
 
@@ -124,26 +124,26 @@ public class OakSlingRepositoryManager extends AbstractSlingRepositoryManager {
             .withAsyncIndexing("async", 5);
 
         final Jcr jcr = new Jcr(oak, false)
-        .with(new InitialContent())
-        .with(new ExtraSlingContent())
+            .with(new InitialContent())
+            .with(new ExtraSlingContent())
 
-        .with(JcrConflictHandler.createJcrConflictHandler())
-        .with(new VersionHook())
+            .with(JcrConflictHandler.createJcrConflictHandler())
+            .with(new VersionHook())
 
-        .with(securityProvider)
+            .with(securityProvider)
 
-        .with(new NameValidatorProvider())
-        .with(new NamespaceEditorProvider())
-        .with(new TypeEditorProvider())
-        .with(new ConflictValidatorProvider())
+            .with(new NameValidatorProvider())
+            .with(new NamespaceEditorProvider())
+            .with(new TypeEditorProvider())
+            .with(new ConflictValidatorProvider())
 
-        // index stuff
-        .with(indexProvider)
-        .with(indexEditorProvider)
-        .with(getDefaultWorkspace())
-        .with(whiteboard)
-        .withFastQueryResultSize(true)
-        .withObservationQueueLength(configuration.oak_observation_queue_length());
+            // index stuff
+            .with(indexProvider)
+            .with(indexEditorProvider)
+            .with(getDefaultWorkspace())
+            .with(whiteboard)
+            .withFastQueryResultSize(true)
+            .withObservationQueueLength(configuration.oak_observation_queue_length());
 
         if (commitRateLimiter != null) {
             jcr.with(commitRateLimiter);
@@ -238,14 +238,14 @@ public class OakSlingRepositoryManager extends AbstractSlingRepositoryManager {
                 // lucene full-text index
                 if (!index.hasChildNode("lucene")) {
                     LuceneIndexHelper.newLuceneIndexDefinition(
-                            index, "lucene", LuceneIndexHelper.JR_PROPERTY_INCLUDES,
-                            of(
-                               "jcr:createdBy",
-                               "jcr:lastModifiedBy",
-                               "sling:alias",
-                               "sling:resourceType",
-                               "sling:vanityPath"),
-                            "async");
+                        index, "lucene", LuceneIndexHelper.JR_PROPERTY_INCLUDES,
+                        of(
+                            "jcr:createdBy",
+                            "jcr:lastModifiedBy",
+                            "sling:alias",
+                            "sling:resourceType",
+                            "sling:vanityPath"),
+                        "async");
                 }
 
             }

-- 
To stop receiving notification emails like this one, please contact
olli@apache.org.