jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1593036 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/ oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/ oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/
Date Wed, 07 May 2014 15:26:13 GMT
Author: mduerig
Date: Wed May  7 15:26:12 2014
New Revision: 1593036

URL: http://svn.apache.org/r1593036
Log:
OAK-1802: increase verbosity on migration progress
Log progress while executing Index and Type hooks. Credits to Chetan for the nice progress
ticker

Added:
    jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/AsciiArtTicker.java
    jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/ProgressNotificationEditor.java
    jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/ProgressTicker.java
    jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/SimpleTicker.java
    jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/TickerTest.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdate.java
    jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdate.java?rev=1593036&r1=1593035&r2=1593036&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdate.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdate.java
Wed May  7 15:26:12 2014
@@ -47,7 +47,7 @@ import org.apache.jackrabbit.oak.spi.sta
 
 import com.google.common.base.Objects;
 
-class IndexUpdate implements Editor {
+public class IndexUpdate implements Editor {
 
     private final IndexEditorProvider provider;
 
@@ -81,7 +81,7 @@ class IndexUpdate implements Editor {
      */
     private final IndexUpdateCallback updateCallback;
 
-    IndexUpdate(
+    public IndexUpdate(
             IndexEditorProvider provider, String async,
             NodeState root, NodeBuilder builder,
             IndexUpdateCallback updateCallback) {

Added: jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/AsciiArtTicker.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/AsciiArtTicker.java?rev=1593036&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/AsciiArtTicker.java
(added)
+++ jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/AsciiArtTicker.java
Wed May  7 15:26:12 2014
@@ -0,0 +1,111 @@
+/*
+ * 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.upgrade;
+
+import java.util.Iterator;
+
+import com.google.common.collect.Iterators;
+
+public class AsciiArtTicker implements ProgressTicker {
+    @Override
+    public String tick() {
+        return ticks.next();
+    }
+
+    private final String[] message = new String[] {
+
+            " __        __",
+            " \\ \\      / /",
+            "  \\ \\ /\\ / / ",
+            "   \\ V  V /  ",
+            "    \\_/\\_/   ",
+            "             ",
+            "  _____ ",
+            " | ____|",
+            " |  _|  ",
+            " | |___ ",
+            " |_____|",
+            "        ",
+            "  _     ",
+            " | |    ",
+            " | |    ",
+            " | |___ ",
+            " |_____|",
+            "        ",
+            "   ____ ",
+            "  / ___|",
+            " | |    ",
+            " | |___ ",
+            "  \\____|",
+            "        ",
+            "   ___  ",
+            "  / _ \\ ",
+            " | | | |",
+            " | |_| |",
+            "  \\___/ ",
+            "        ",
+            "  __  __ ",
+            " |  \\/  |",
+            " | |\\/| |",
+            " | |  | |",
+            " |_|  |_|",
+            "         ",
+            "  _____ ",
+            " | ____|",
+            " |  _|  ",
+            " | |___ ",
+            " |_____|",
+            "        ",
+            "  _____ ",
+            " |_   _|",
+            "   | |  ",
+            "   | |  ",
+            "   |_|  ",
+            "        ",
+            "   ___  ",
+            "  / _ \\ ",
+            " | | | |",
+            " | |_| |",
+            "  \\___/ ",
+            "        ",
+            "   ___  ",
+            "  / _ \\ ",
+            " | | | |",
+            " | |_| |",
+            "  \\___/ ",
+            "        ",
+            "     _    ",
+            "    / \\   ",
+            "   / _ \\  ",
+            "  / ___ \\ ",
+            " /_/   \\_\\",
+            "          ",
+            "  _  __",
+            " | |/ /",
+            " | ' / ",
+            " | . \\ ",
+            " |_|\\_\\",
+            "             ",
+            " =========== ",
+            "             ",
+    };
+
+    private final Iterator<String> ticks = Iterators.cycle(message);
+}

Added: jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/ProgressNotificationEditor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/ProgressNotificationEditor.java?rev=1593036&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/ProgressNotificationEditor.java
(added)
+++ jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/ProgressNotificationEditor.java
Wed May  7 15:26:12 2014
@@ -0,0 +1,112 @@
+/*
+ * 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.upgrade;
+
+import static org.apache.jackrabbit.oak.commons.PathUtils.concat;
+
+import javax.annotation.Nullable;
+
+import com.google.common.base.Function;
+import org.apache.jackrabbit.oak.api.CommitFailedException;
+import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.spi.commit.Editor;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.slf4j.Logger;
+
+/**
+ * This {@code Editor} instance logs invocations to the logger
+ * passed to its constructor after each 10000 calls to it
+ * {@code enter()} method.
+ */
+public class ProgressNotificationEditor implements Editor {
+    private final Editor editor;
+    private final String path;
+    private final Function<String, Void> onProgress;
+
+    public static ProgressNotificationEditor wrap(Editor editor, final Logger logger, final
String message) {
+        return new ProgressNotificationEditor(editor, "/", new Function<String, Void>()
{
+            int count;
+
+            @Nullable
+            @Override
+            public Void apply(String path) {
+                if (++count % 10000 == 0) {
+                    logger.info(message + ' ' + path);
+                }
+                return null;
+            }
+        });
+    }
+
+    private ProgressNotificationEditor(Editor editor, String path, Function<String, Void>
onProgress) {
+        this.editor = editor;
+        this.path = path;
+        this.onProgress = onProgress;
+    }
+
+    @Override
+    public void enter(NodeState before, NodeState after) throws CommitFailedException {
+        onProgress.apply(path);
+        editor.enter(before, after);
+    }
+
+    @Override
+    public void leave(NodeState before, NodeState after) throws CommitFailedException {
+        editor.leave(before, after);
+    }
+
+    @Override
+    public void propertyAdded(PropertyState after) throws CommitFailedException {
+        editor.propertyAdded(after);
+    }
+
+    @Override
+    public void propertyChanged(PropertyState before, PropertyState after) throws CommitFailedException
{
+        editor.propertyChanged(before, after);
+    }
+
+    @Override
+    public void propertyDeleted(PropertyState before) throws CommitFailedException {
+        editor.propertyDeleted(before);
+    }
+
+    @Override
+    public Editor childNodeAdded(String name, NodeState after) throws CommitFailedException
{
+        return createChildEditor(editor.childNodeAdded(name, after), name);
+    }
+
+    @Override
+    public Editor childNodeChanged(String name, NodeState before, NodeState after) throws
CommitFailedException {
+        return createChildEditor(editor.childNodeChanged(name, before, after), name);
+    }
+
+    @Override
+    public Editor childNodeDeleted(String name, NodeState before) throws CommitFailedException
{
+        return createChildEditor(editor.childNodeDeleted(name, before), name);
+    }
+
+    private ProgressNotificationEditor createChildEditor(Editor editor, String name) {
+        if (editor == null) {
+            return null;
+        } else {
+            return new ProgressNotificationEditor(editor, concat(path, name), onProgress);
+        }
+    }
+}

Added: jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/ProgressTicker.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/ProgressTicker.java?rev=1593036&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/ProgressTicker.java
(added)
+++ jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/ProgressTicker.java
Wed May  7 15:26:12 2014
@@ -0,0 +1,24 @@
+/*
+ * 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.upgrade;
+
+public interface ProgressTicker {
+    String tick();
+}

Modified: jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java?rev=1593036&r1=1593035&r2=1593036&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java
(original)
+++ jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java
Wed May  7 15:26:12 2014
@@ -94,7 +94,6 @@ import com.google.common.base.Charsets;
 import com.google.common.collect.HashBiMap;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Lists;
-
 import org.apache.jackrabbit.core.RepositoryContext;
 import org.apache.jackrabbit.core.config.BeanConfig;
 import org.apache.jackrabbit.core.config.LoginModuleConfig;
@@ -106,12 +105,15 @@ import org.apache.jackrabbit.core.nodety
 import org.apache.jackrabbit.core.persistence.PersistenceManager;
 import org.apache.jackrabbit.core.security.authorization.PrivilegeRegistry;
 import org.apache.jackrabbit.core.security.user.UserManagerImpl;
+import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.namepath.GlobalNameMapper;
 import org.apache.jackrabbit.oak.namepath.NameMapper;
 import org.apache.jackrabbit.oak.plugins.index.CompositeIndexEditorProvider;
-import org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider;
+import org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider;
+import org.apache.jackrabbit.oak.plugins.index.IndexUpdate;
+import org.apache.jackrabbit.oak.plugins.index.IndexUpdateCallback;
 import org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider;
 import org.apache.jackrabbit.oak.plugins.index.reference.ReferenceEditorProvider;
 import org.apache.jackrabbit.oak.plugins.name.NamespaceConstants;
@@ -124,7 +126,9 @@ import org.apache.jackrabbit.oak.spi.com
 import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
 import org.apache.jackrabbit.oak.spi.commit.CompositeEditorProvider;
 import org.apache.jackrabbit.oak.spi.commit.CompositeHook;
+import org.apache.jackrabbit.oak.spi.commit.Editor;
 import org.apache.jackrabbit.oak.spi.commit.EditorHook;
+import org.apache.jackrabbit.oak.spi.commit.EditorProvider;
 import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer;
 import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
 import org.apache.jackrabbit.oak.spi.security.SecurityConfiguration;
@@ -293,10 +297,9 @@ public class RepositoryUpgrade {
 
             // type validation, reference and indexing hooks
             hooks.add(new EditorHook(new CompositeEditorProvider(
-                            new TypeEditorProvider(false),
-                            new IndexUpdateProvider(new CompositeIndexEditorProvider(
-                                    new ReferenceEditorProvider(),
-                                    new PropertyIndexEditorProvider())))));
+                createTypeEditorProvider(),
+                createIndexEditorProvider()
+            )));
 
             target.merge(builder, CompositeHook.compose(hooks), CommitInfo.EMPTY);
         } catch (Exception e) {
@@ -304,6 +307,43 @@ public class RepositoryUpgrade {
         }
     }
 
+    private static EditorProvider createTypeEditorProvider() {
+        return new EditorProvider() {
+            @Override
+            public Editor getRootEditor(NodeState before, NodeState after, NodeBuilder builder,
CommitInfo info)
+                    throws CommitFailedException {
+                Editor rootEditor = new TypeEditorProvider(false)
+                        .getRootEditor(before, after, builder, info);
+                return ProgressNotificationEditor.wrap(rootEditor, logger, "Checking node
types:");
+            }
+        };
+    }
+
+    private static EditorProvider createIndexEditorProvider() {
+        final ProgressTicker ticker = new AsciiArtTicker();
+        return new EditorProvider() {
+            @Override
+            public Editor getRootEditor(NodeState before, NodeState after, NodeBuilder builder,
CommitInfo info) {
+                IndexEditorProvider editorProviders = new CompositeIndexEditorProvider(
+                        new ReferenceEditorProvider(),
+                        new PropertyIndexEditorProvider());
+
+                return new IndexUpdate(editorProviders, null, after, builder, new IndexUpdateCallback()
{
+                    String progress = "Updating indexes ";
+                    long t0;
+                    @Override
+                    public void indexUpdate() {
+                        long t = System.currentTimeMillis();
+                        if (t - t0 > 2000) {
+                            logger.info("{} {}", progress, ticker.tick());
+                            t0 = t ;
+                        }
+                    }
+                });
+            }
+        };
+    }
+
     protected ConfigurationParameters mapSecurityConfig(SecurityConfig config) {
         ConfigurationParameters loginConfig = mapConfigurationParameters(
                 config.getLoginModuleConfig(),

Added: jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/SimpleTicker.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/SimpleTicker.java?rev=1593036&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/SimpleTicker.java
(added)
+++ jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/SimpleTicker.java
Wed May  7 15:26:12 2014
@@ -0,0 +1,44 @@
+/*
+ * 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.upgrade;
+
+import com.google.common.base.Strings;
+
+public class SimpleTicker implements ProgressTicker {
+    private final int maxTicks;
+    private int dotCount;
+    private boolean decreasing;
+
+    public SimpleTicker(int maxTicks) {
+        this.maxTicks = maxTicks;
+    }
+
+    @Override
+    public String tick() {
+        int noOfDots = decreasing ? dotCount-- : dotCount++;
+        if(dotCount == 0){
+            decreasing = false;
+        }
+        if(dotCount == maxTicks){
+            decreasing = true;
+        }
+        return Strings.repeat(".", noOfDots);
+    }
+}

Added: jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/TickerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/TickerTest.java?rev=1593036&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/TickerTest.java
(added)
+++ jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/TickerTest.java
Wed May  7 15:26:12 2014
@@ -0,0 +1,44 @@
+/*
+ * 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.upgrade;
+
+import org.junit.Test;
+
+public class TickerTest {
+
+    @Test
+    public void testSimple() throws Exception{
+        ProgressTicker ticker = new SimpleTicker(50);
+
+        for(int i = 0; i < 200; i++){
+            System.out.println(ticker.tick());
+        }
+    }
+
+    @Test
+    public void testAscii() throws Exception{
+        ProgressTicker ticker = new AsciiArtTicker();
+
+        for(int i = 0; i < 200; i++){
+            System.out.println(ticker.tick());
+        }
+    }
+
+}



Mime
View raw message