jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r554909 - in /jackrabbit/trunk/contrib/spi/spi-logger: ./ src/ src/assemble/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/jackrabbit/ src/main/java/org/apache/jackrabbit/spi/ src/main/java/o...
Date Tue, 10 Jul 2007 11:31:50 GMT
Author: mreutegg
Date: Tue Jul 10 04:31:47 2007
New Revision: 554909

URL: http://svn.apache.org/viewvc?view=rev&rev=554909
Log:
- initial checkin of a spi logger

Added:
    jackrabbit/trunk/contrib/spi/spi-logger/   (with props)
    jackrabbit/trunk/contrib/spi/spi-logger/pom.xml   (with props)
    jackrabbit/trunk/contrib/spi/spi-logger/src/
    jackrabbit/trunk/contrib/spi/spi-logger/src/assemble/
    jackrabbit/trunk/contrib/spi/spi-logger/src/assemble/analyzer.xml   (with props)
    jackrabbit/trunk/contrib/spi/spi-logger/src/main/
    jackrabbit/trunk/contrib/spi/spi-logger/src/main/java/
    jackrabbit/trunk/contrib/spi/spi-logger/src/main/java/org/
    jackrabbit/trunk/contrib/spi/spi-logger/src/main/java/org/apache/
    jackrabbit/trunk/contrib/spi/spi-logger/src/main/java/org/apache/jackrabbit/
    jackrabbit/trunk/contrib/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/
    jackrabbit/trunk/contrib/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/
    jackrabbit/trunk/contrib/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/LogAnalyzer.java   (with props)
    jackrabbit/trunk/contrib/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/RepositoryServiceLogger.java   (with props)

Propchange: jackrabbit/trunk/contrib/spi/spi-logger/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Jul 10 04:31:47 2007
@@ -0,0 +1,3 @@
+target
+*.iml
+*.log

Added: jackrabbit/trunk/contrib/spi/spi-logger/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-logger/pom.xml?view=auto&rev=554909
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-logger/pom.xml (added)
+++ jackrabbit/trunk/contrib/spi/spi-logger/pom.xml Tue Jul 10 04:31:47 2007
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+   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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+                             http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+<!-- ====================================================================== -->
+<!-- P R O J E C T  D E S C R I P T I O N                                   -->
+<!-- ====================================================================== -->
+  <parent>
+    <groupId>org.apache.jackrabbit</groupId>
+    <artifactId>jackrabbit-spi-contrib</artifactId>
+    <version>1.4-SNAPSHOT</version>
+    <relativePath>..</relativePath>
+  </parent>
+  <artifactId>jackrabbit-spi-logger</artifactId>
+  <name>SPI usage logger</name>
+
+  <scm>
+    <connection>
+      scm:svn:http://svn.apache.org/repos/asf/jackrabbit/trunk/contrib/spi/spi-logger
+    </connection>
+    <developerConnection>
+      scm:svn:https://svn.apache.org/repos/asf/jackrabbit/trunk/contrib/spi/spi-logger
+    </developerConnection>
+    <url>http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-logger</url>
+  </scm>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jackrabbit-spi</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jackrabbit-spi-commons</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jackrabbit-jcr-commons</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>javax.jcr</groupId>
+      <artifactId>jcr</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <!-- Use Java 1.5 -->
+      <plugin>
+        <inherited>true</inherited>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <target>1.5</target>
+          <source>1.5</source>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <configuration>
+          <descriptors>
+            <descriptor>src/assemble/analyzer.xml</descriptor>
+          </descriptors>
+          <archive>
+            <manifest>
+              <mainClass>org.apache.jackrabbit.spi.logger.LogAnalyzer</mainClass>
+            </manifest>
+          </archive>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Propchange: jackrabbit/trunk/contrib/spi/spi-logger/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi-logger/src/assemble/analyzer.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-logger/src/assemble/analyzer.xml?view=auto&rev=554909
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-logger/src/assemble/analyzer.xml (added)
+++ jackrabbit/trunk/contrib/spi/spi-logger/src/assemble/analyzer.xml Tue Jul 10 04:31:47 2007
@@ -0,0 +1,13 @@
+<assembly>
+  <id>analyzer</id>
+  <formats>
+    <format>jar</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <fileSets>
+    <fileSet>
+      <outputDirectory></outputDirectory>
+      <directory>target/classes</directory>
+    </fileSet>
+  </fileSets>
+</assembly>
\ No newline at end of file

Propchange: jackrabbit/trunk/contrib/spi/spi-logger/src/assemble/analyzer.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/LogAnalyzer.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/LogAnalyzer.java?view=auto&rev=554909
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/LogAnalyzer.java (added)
+++ jackrabbit/trunk/contrib/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/LogAnalyzer.java Tue Jul 10 04:31:47 2007
@@ -0,0 +1,309 @@
+/*
+ * 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.spi.logger;
+
+import java.io.Reader;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.InputStreamReader;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.StringTokenizer;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.Arrays;
+import java.text.NumberFormat;
+
+/**
+ * <code>LogAnalyzer</code> implements an analyzer for the log files created by
+ * the {@link RepositoryServiceLogger}.
+ */
+public class LogAnalyzer {
+
+    private final BufferedReader log;
+
+    private static final Set EXCLUSIONS = new HashSet(Arrays.asList(
+            new String[]{"getEvents(SessionInfo,long,EventFilter[])"}));
+
+    /**
+     * Runs the <code>LogAnalyzer</code> on a given log file. Calls to the
+     * method {@link org.apache.jackrabbit.spi.RepositoryService#getEvents(org.apache.jackrabbit.spi.SessionInfo, long, org.apache.jackrabbit.spi.EventFilter[])}
+     * are excluded because they contain a timeout parameter which would affect
+     * the statistics adversely.
+     *
+     * @param args the first argument must be a valid path to an spi log file.
+     */
+    public static void main(String[] args) {
+        if (args.length == 0) {
+            System.out.println("Please specify the location of your SPI log file.");
+            return;
+        }
+        try {
+            Reader r = new InputStreamReader(new FileInputStream(args[0]));
+            try {
+                new LogAnalyzer(r).getReport(EXCLUSIONS).print(new PrintWriter(System.out));
+            } catch (IOException e) {
+                System.out.println(e.getMessage());
+            } finally {
+                try {
+                    r.close();
+                } catch (IOException e) {
+                    // ignore
+                }
+            }
+        } catch (FileNotFoundException e) {
+            System.out.println(e.getMessage());
+        }
+    }
+
+    /**
+     * Creates a new <code>LogAnalyzer</code>, which reads from the passed
+     * <code>log</code>.
+     *
+     * @param log a reader to an SPI log file.
+     */
+    public LogAnalyzer(Reader log) {
+        this.log = new BufferedReader(log);
+    }
+
+    /**
+     * Creates a <code>Report</code> using a set of excluded methods.
+     *
+     * @param exclusions the methods to exclude from the report.
+     * @return a <code>Report</code>.
+     * @throws IOException if an error occurs while reading from the log
+     *                     reader.
+     */
+    public Report getReport(Set exclusions) throws IOException {
+        Report report = new Report();
+        String line;
+        long start = 0;
+        String time = "";
+        while ((line = log.readLine()) != null) {
+            StringTokenizer tokenizer = new StringTokenizer(line, "|");
+            // first token is timestamp
+            time = tokenizer.nextToken();
+            if (start == 0) {
+                start = Long.parseLong(time);
+            }
+            // second token is methodName
+            String methodName = tokenizer.nextToken();
+            if (exclusions.contains(methodName)) {
+                continue;
+            }
+            // third token is timing
+            long nanos = Long.parseLong(tokenizer.nextToken());
+            // ignore remaining tokens
+
+            report.addMethodCall(methodName, nanos);
+        }
+
+        report.setStartTime(start);
+        report.setEndTime(Long.parseLong(time));
+
+        return report;
+    }
+
+    /**
+     * Represents a report on an SPI log file.
+     */
+    public static final class Report {
+
+        /**
+         * Maps method name strings to a <code>Set</code> of
+         * {@link LogAnalyzer.Timing}.
+         */
+        private final Map methodsToTimings = new HashMap();
+
+        /**
+         * The timestamp of the first log entry.
+         */
+        private long startTime = 0;
+
+        /**
+         * The timestamp of the last log entry.
+         */
+        private long endTime = 0;
+
+        private Report() {
+        }
+
+        /**
+         * Adds a method call to the report.
+         *
+         * @param methodSignature the method signature.
+         * @param nanos the time spent in this method in nanoseconds.
+         */
+        private void addMethodCall(String methodSignature, long nanos) {
+            Set timings = (Set) methodsToTimings.get(methodSignature);
+            if (timings == null) {
+                timings = new TreeSet();
+                methodsToTimings.put(methodSignature, timings);
+            }
+            timings.add(new Timing(nanos));
+        }
+
+        /**
+         * Sets the time of the first log entry.
+         *
+         * @param time the time of the first log entry.
+         */
+        private void setStartTime(long time) {
+            this.startTime = time;
+        }
+
+        /**
+         * Sets the time of the last log entry.
+         *
+         * @param time the time of the last log entry.
+         */
+        private void setEndTime(long time) {
+            this.endTime = time;
+        }
+
+        /**
+         * Prints this report to the passed <code>writer</code>.
+         *
+         * @param writer where the report is written to.
+         */
+        public void print(PrintWriter writer) {
+            List methods = new ArrayList();
+            methods.addAll(methodsToTimings.keySet());
+            long totalNanos = 0;
+            final Map accumulatedTime = new HashMap();
+            for (Iterator it = methodsToTimings.keySet().iterator(); it.hasNext(); ) {
+                String method = (String) it.next();
+                Set timings = (Set) methodsToTimings.get(method);
+                long methodTotal = 0;
+                for (Iterator iter = timings.iterator(); iter.hasNext(); ) {
+                    Timing t = (Timing) iter.next();
+                    methodTotal += t.nanos;
+                }
+                accumulatedTime.put(method, new Long(methodTotal));
+                totalNanos += methodTotal;
+            }
+            // sort by accumulated time
+            Collections.sort(methods, new Comparator() {
+                public int compare(Object o1, Object o2) {
+                    Long t1 = (Long) accumulatedTime.get(o1);
+                    Long t2 = (Long) accumulatedTime.get(o2);
+                    return t2.compareTo(t1);
+                }
+            });
+            writer.println();
+            long timespan = (endTime - startTime) / 1000;
+            long totalSeconds = (totalNanos / (1000 * 1000 * 1000));
+            writer.println("Logged timespan:                  " +
+                    timespan + "s");
+            writer.println("Time spent in SPI implementation: " +
+                    totalSeconds + "s (" + 100 * totalSeconds / timespan + "%)");
+            writer.println();
+            writer.println("         #calls   mean(ms)  method");
+            NumberFormat percentFormat = NumberFormat.getPercentInstance();
+            percentFormat.setMaximumFractionDigits(1);
+            percentFormat.setMinimumFractionDigits(1);
+            NumberFormat nFormat = NumberFormat.getNumberInstance();
+            nFormat.setMaximumFractionDigits(1);
+            nFormat.setMinimumFractionDigits(1);
+            for (Iterator it = methods.iterator(); it.hasNext(); ) {
+                String methodName = (String) it.next();
+                StringBuffer tmp = new StringBuffer();
+                long methodTotal = ((Long) accumulatedTime.get(methodName)).longValue();
+                String percent = percentFormat.format((double) methodTotal / totalNanos);
+                while (percent.length() < 6) {
+                    percent = " " + percent;
+                }
+                tmp.append(percent);
+                Set timings = (Set) methodsToTimings.get(methodName);
+                String nCalls = String.valueOf(timings.size());
+                while (nCalls.length() < 9) {
+                    nCalls = " " + nCalls;
+                }
+                tmp.append(nCalls);
+                String mean = nFormat.format((double) methodTotal / (1000 * 1000) / timings.size());
+                while (mean.length() < 9) {
+                    mean = " " + mean;
+                }
+                tmp.append(mean);
+                tmp.append("    " + methodName);
+                writer.println(tmp.toString());
+            }
+            writer.flush();
+        }
+    }
+
+    /**
+     * Helper class that contains the method timing in nanoseconds and a
+     * sequence number, which allows a well-order on the timing objects.
+     */
+    private static final class Timing implements Comparable {
+
+        /**
+         * Sequence counter.
+         */
+        private static int SEQUENCE_NUMBER = 0;
+
+        /**
+         * Sequence number
+         */
+        private final int seq;
+
+        /**
+         * Time in nanoseconds
+         */
+        private final long nanos;
+
+        Timing(long nanos) {
+            synchronized (Timing.class) {
+                this.seq = SEQUENCE_NUMBER++;
+            }
+            this.nanos = nanos;
+        }
+
+        public int hashCode() {
+            return new Long(nanos).hashCode() ^ new Integer(seq).hashCode();
+        }
+
+        public boolean equals(Object obj) {
+            if (obj instanceof Timing) {
+                Timing other = (Timing) obj;
+                return this.nanos == other.nanos && this.seq == other.seq;
+            }
+            return false;
+        }
+
+        public int compareTo(Object o) {
+            Timing other = (Timing) o;
+            if (this.nanos < other.nanos) {
+                return -1;
+            } else if (this.nanos == other.nanos) {
+                return this.seq < other.seq ? -1 : (this.seq == other.seq ? 0 : -1);
+            } else {
+                return 1;
+            }
+        }
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/LogAnalyzer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/RepositoryServiceLogger.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/RepositoryServiceLogger.java?view=auto&rev=554909
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/RepositoryServiceLogger.java (added)
+++ jackrabbit/trunk/contrib/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/RepositoryServiceLogger.java Tue Jul 10 04:31:47 2007
@@ -0,0 +1,674 @@
+/*
+ * 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.spi.logger;
+
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.spi.SessionInfo;
+import org.apache.jackrabbit.spi.ItemId;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.NodeInfo;
+import org.apache.jackrabbit.spi.PropertyInfo;
+import org.apache.jackrabbit.spi.Batch;
+import org.apache.jackrabbit.spi.LockInfo;
+import org.apache.jackrabbit.spi.QueryInfo;
+import org.apache.jackrabbit.spi.EventFilter;
+import org.apache.jackrabbit.spi.EventBundle;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.name.Path;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Credentials;
+import javax.jcr.LoginException;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.ValueFormatException;
+import javax.jcr.AccessDeniedException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.ItemExistsException;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.ReferentialIntegrityException;
+import javax.jcr.MergeException;
+import javax.jcr.NamespaceException;
+import javax.jcr.query.InvalidQueryException;
+import javax.jcr.lock.LockException;
+import javax.jcr.version.VersionException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import java.util.Map;
+import java.util.Iterator;
+import java.io.InputStream;
+import java.io.Writer;
+import java.io.IOException;
+
+/**
+ * <code>RepositoryServiceLogger</code> implements the repository service
+ * interface and logs each call to a <code>Writer</code>.
+ */
+public class RepositoryServiceLogger implements RepositoryService {
+
+    private final RepositoryService service;
+
+    private final Writer log;
+
+    public RepositoryServiceLogger(RepositoryService rs, Writer log) {
+        this.service = rs;
+        this.log = log;
+    }
+
+    public IdFactory getIdFactory() {
+        try {
+            return (IdFactory) execute(new Callable() {
+                public Object call() {
+                    return service.getIdFactory();
+                }
+            }, "getIdFactory()", new Object[]{});
+        } catch (RepositoryException e) {
+            throw new InternalError();
+        }
+    }
+
+    public QValueFactory getQValueFactory() {
+        try {
+            return (QValueFactory) execute(new Callable() {
+                public Object call() {
+                    return service.getQValueFactory();
+                }
+            }, "getQValueFactory()", new Object[]{});
+        } catch (RepositoryException e) {
+            throw new InternalError();
+        }
+    }
+
+    public Map getRepositoryDescriptors() throws RepositoryException {
+        return (Map) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getRepositoryDescriptors();
+            }
+        }, "getRepositoryDescriptors()", new Object[]{});
+    }
+
+    public SessionInfo obtain(final Credentials credentials, final String s)
+            throws LoginException, NoSuchWorkspaceException, RepositoryException {
+        return (SessionInfo) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.obtain(credentials, s);
+            }
+        }, "obtain(Credentials,String)", new Object[]{s});
+    }
+
+    public SessionInfo obtain(final SessionInfo sessionInfo, final String s)
+            throws LoginException, NoSuchWorkspaceException, RepositoryException {
+        return (SessionInfo) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.obtain(sessionInfo, s);
+            }
+        }, "obtain(SessionInfo,String)", new Object[]{s});
+    }
+
+    public SessionInfo impersonate(final SessionInfo sessionInfo,
+                                   final Credentials credentials)
+            throws LoginException, RepositoryException {
+        return (SessionInfo) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.impersonate(sessionInfo, credentials);
+            }
+        }, "impersonate(SessionInfo,Credentials)", new Object[]{});
+    }
+
+    public void dispose(final SessionInfo sessionInfo) throws RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.dispose(sessionInfo);
+                return null;
+            }
+        }, "dispose(SessionInfo)", new Object[]{});
+    }
+
+    public String[] getWorkspaceNames(final SessionInfo sessionInfo)
+            throws RepositoryException {
+        return (String[]) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getWorkspaceNames(sessionInfo);
+            }
+        }, "getWorkspaceNames(SessionInfo)", new Object[]{});
+    }
+
+    public boolean isGranted(final SessionInfo sessionInfo,
+                             final ItemId itemId,
+                             final String[] strings) throws RepositoryException {
+        return ((Boolean) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return new Boolean(service.isGranted(sessionInfo, itemId, strings));
+            }
+        }, "isGranted(SessionInfo,ItemId,String[])", new Object[]{itemId})).booleanValue();
+    }
+
+    public NodeId getRootId(final SessionInfo sessionInfo)
+            throws RepositoryException {
+        return (NodeId) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getRootId(sessionInfo);
+            }
+        }, "getRootId(SessionInfo)", new Object[]{});
+    }
+
+    public QNodeDefinition getNodeDefinition(final SessionInfo sessionInfo,
+                                             final NodeId nodeId)
+            throws RepositoryException {
+        return (QNodeDefinition) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getNodeDefinition(sessionInfo, nodeId);
+            }
+        }, "getNodeDefinition(SessionInfo,NodeId)", new Object[]{nodeId});
+    }
+
+    public QPropertyDefinition getPropertyDefinition(final SessionInfo sessionInfo,
+                                                     final PropertyId propertyId)
+            throws RepositoryException {
+        return (QPropertyDefinition) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getPropertyDefinition(sessionInfo, propertyId);
+            }
+        }, "getPropertyDefinition(SessionInfo,PropertyId)", new Object[]{propertyId});
+    }
+
+    public boolean exists(final SessionInfo sessionInfo, final ItemId itemId)
+            throws RepositoryException {
+        return ((Boolean) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return new Boolean(service.exists(sessionInfo, itemId));
+            }
+        }, "exists(SessionInfo,ItemId)", new Object[]{itemId})).booleanValue();
+    }
+
+    public NodeInfo getNodeInfo(final SessionInfo sessionInfo,
+                                final NodeId nodeId)
+            throws ItemNotFoundException, RepositoryException {
+        return (NodeInfo) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getNodeInfo(sessionInfo, nodeId);
+            }
+        }, "getNodeInfo(SessionInfo,NodeId)", new Object[]{nodeId});
+    }
+
+    public Iterator getItemInfos(final SessionInfo sessionInfo,
+                                 final NodeId nodeId)
+            throws ItemNotFoundException, RepositoryException {
+        return (Iterator) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getItemInfos(sessionInfo, nodeId);
+            }
+        }, "getItemInfos(SessionInfo,NodeId)", new Object[]{nodeId});
+    }
+
+    public Iterator getChildInfos(final SessionInfo sessionInfo,
+                                  final NodeId nodeId)
+            throws ItemNotFoundException, RepositoryException {
+        return (Iterator) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getChildInfos(sessionInfo, nodeId);
+            }
+        }, "getChildInfos(SessionInfo,NodeId)", new Object[]{nodeId});
+    }
+
+    public PropertyInfo getPropertyInfo(final SessionInfo sessionInfo,
+                                        final PropertyId propertyId)
+            throws ItemNotFoundException, RepositoryException {
+        return (PropertyInfo) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getPropertyInfo(sessionInfo, propertyId);
+            }
+        }, "getPropertyInfo(SessionInfo,PropertyId)", new Object[]{propertyId});
+    }
+
+    public Batch createBatch(final ItemId itemId, final SessionInfo sessionInfo)
+            throws RepositoryException {
+        return (Batch) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.createBatch(itemId, sessionInfo);
+            }
+        }, "createBatch(ItemId,SessionInfo)", new Object[]{itemId});
+    }
+
+    public void submit(final Batch batch) throws PathNotFoundException, ItemNotFoundException, NoSuchNodeTypeException, ValueFormatException, VersionException, LockException, ConstraintViolationException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.submit(batch);
+                return null;
+            }
+        }, "submit(Batch)", new Object[]{});
+    }
+
+    public void importXml(final SessionInfo sessionInfo,
+                          final NodeId nodeId,
+                          final InputStream inputStream,
+                          final int i) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.importXml(sessionInfo, nodeId, inputStream, i);
+                return null;
+            }
+        }, "importXml(SessionInfo,NodeId,InputStream,int)",
+                new Object[]{nodeId});
+    }
+
+    public void move(final SessionInfo sessionInfo,
+                     final NodeId nodeId,
+                     final NodeId nodeId1,
+                     final QName name) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.move(sessionInfo, nodeId, nodeId1, name);
+                return null;
+            }
+        }, "move(SessionInfo,NodeId,NodeId,QName)",
+                new Object[]{nodeId, nodeId1, name});
+    }
+
+    public void copy(final SessionInfo sessionInfo,
+                     final String s,
+                     final NodeId nodeId,
+                     final NodeId nodeId1,
+                     final QName name) throws NoSuchWorkspaceException, ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, UnsupportedRepositoryOperationException, RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.copy(sessionInfo, s, nodeId, nodeId1, name);
+                return null;
+            }
+        }, "copy(SessionInfo,String,NodeId,NodeId,QName)",
+                new Object[]{s, nodeId, nodeId1, name});
+    }
+
+    public void update(final SessionInfo sessionInfo,
+                       final NodeId nodeId,
+                       final String s)
+            throws NoSuchWorkspaceException, AccessDeniedException, LockException, InvalidItemStateException, RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.update(sessionInfo, nodeId, s);
+                return null;
+            }
+        }, "update(SessionInfo,NodeId,String)", new Object[]{nodeId, s});
+    }
+
+    public void clone(final SessionInfo sessionInfo,
+                      final String s,
+                      final NodeId nodeId,
+                      final NodeId nodeId1,
+                      final QName name,
+                      final boolean b) throws NoSuchWorkspaceException, ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, UnsupportedRepositoryOperationException, RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.clone(sessionInfo, s, nodeId, nodeId1, name, b);
+                return null;
+            }
+        }, "clone(SessionInfo,String,NodeId,NodeId,QName,boolean)",
+                new Object[]{s, nodeId, nodeId1, name, new Boolean(b)});
+    }
+
+    public LockInfo getLockInfo(final SessionInfo sessionInfo,
+                                final NodeId nodeId)
+            throws LockException, RepositoryException {
+        return (LockInfo) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getLockInfo(sessionInfo, nodeId);
+            }
+        }, "getLockInfo(SessionInfo,NodeId)", new Object[]{nodeId});
+    }
+
+    public LockInfo lock(final SessionInfo sessionInfo,
+                         final NodeId nodeId,
+                         final boolean b,
+                         final boolean b1)
+            throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, InvalidItemStateException, RepositoryException {
+        return (LockInfo) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.lock(sessionInfo, nodeId, b, b1);
+            }
+        }, "lock(SessionInfo,NodeId,boolean,boolean)",
+                new Object[]{nodeId, new Boolean(b), new Boolean(b1)});
+    }
+
+    public void refreshLock(final SessionInfo sessionInfo, final NodeId nodeId)
+            throws LockException, RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.refreshLock(sessionInfo, nodeId);
+                return null;
+            }
+        }, "refreshLock(SessionInfo,NodeId)", new Object[]{nodeId});
+    }
+
+    public void unlock(final SessionInfo sessionInfo, final NodeId nodeId)
+            throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, InvalidItemStateException, RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.unlock(sessionInfo, nodeId);
+                return null;
+            }
+        }, "unlock(SessionInfo,NodeId)", new Object[]{nodeId});
+    }
+
+    public void checkin(final SessionInfo sessionInfo, final NodeId nodeId)
+            throws VersionException, UnsupportedRepositoryOperationException, InvalidItemStateException, LockException, RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.checkin(sessionInfo, nodeId);
+                return null;
+            }
+        }, "checkin(SessionInfo,NodeId)", new Object[]{nodeId});
+    }
+
+    public void checkout(final SessionInfo sessionInfo, final NodeId nodeId)
+            throws UnsupportedRepositoryOperationException, LockException, RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.checkout(sessionInfo, nodeId);
+                return null;
+            }
+        }, "checkout(SessionInfo,NodeId)", new Object[]{nodeId});
+    }
+
+    public void removeVersion(final SessionInfo sessionInfo,
+                              final NodeId nodeId,
+                              final NodeId nodeId1)
+            throws ReferentialIntegrityException, AccessDeniedException, UnsupportedRepositoryOperationException, VersionException, RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.removeVersion(sessionInfo, nodeId, nodeId1);
+                return null;
+            }
+        }, "removeVersion(SessionInfo,NodeId,NodeId)",
+                new Object[]{nodeId, nodeId1});
+    }
+
+    public void restore(final SessionInfo sessionInfo,
+                        final NodeId nodeId,
+                        final NodeId nodeId1,
+                        final boolean b) throws VersionException, PathNotFoundException, ItemExistsException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.restore(sessionInfo, nodeId, nodeId1, b);
+                return null;
+            }
+        }, "restore(SessionInfo,NodeId,NodeId,boolean)",
+                new Object[]{nodeId, nodeId1, new Boolean(b)});
+    }
+
+    public void restore(final SessionInfo sessionInfo,
+                        final NodeId[] nodeIds,
+                        final boolean b)
+            throws ItemExistsException, UnsupportedRepositoryOperationException, VersionException, LockException, InvalidItemStateException, RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.restore(sessionInfo, nodeIds, b);
+                return null;
+            }
+        }, "restore(SessionInfo,NodeId[],boolean)",
+                new Object[]{nodeIds, new Boolean(b)});
+    }
+
+    public Iterator merge(final SessionInfo sessionInfo,
+                          final NodeId nodeId,
+                          final String s,
+                          final boolean b) throws NoSuchWorkspaceException, AccessDeniedException, MergeException, LockException, InvalidItemStateException, RepositoryException {
+        return (Iterator) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.merge(sessionInfo, nodeId, s, b);
+            }
+        }, "merge(SessionInfo,NodeId,String,boolean)",
+                new Object[]{nodeId, s, new Boolean(b)});
+    }
+
+    public void resolveMergeConflict(final SessionInfo sessionInfo,
+                                     final NodeId nodeId,
+                                     final NodeId[] nodeIds,
+                                     final NodeId[] nodeIds1)
+            throws VersionException, InvalidItemStateException, UnsupportedRepositoryOperationException, RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.resolveMergeConflict(sessionInfo, nodeId, nodeIds, nodeIds1);
+                return null;
+            }
+        }, "resolveMergeConflict(SessionInfo,NodeId,NodeId[],NodeId[])",
+                new Object[]{nodeId, nodeIds, nodeIds1});
+    }
+
+    public void addVersionLabel(final SessionInfo sessionInfo,
+                                final NodeId nodeId,
+                                final NodeId nodeId1,
+                                final QName name,
+                                final boolean b) throws VersionException, RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.addVersionLabel(sessionInfo, nodeId, nodeId1, name, b);
+                return null;
+            }
+        }, "addVersionLabel(SessionInfo,NodeId,NodeId,QName,boolean)",
+                new Object[]{nodeId, nodeId1, name, new Boolean(b)});
+    }
+
+    public void removeVersionLabel(final SessionInfo sessionInfo,
+                                   final NodeId nodeId,
+                                   final NodeId nodeId1,
+                                   final QName name) throws VersionException, RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.removeVersionLabel(sessionInfo, nodeId, nodeId1, name);
+                return null;
+            }
+        }, "removeVersionLabel(SessionInfo,NodeId,NodeId,QName)",
+                new Object[]{nodeId, nodeId1, name});
+    }
+
+    public String[] getSupportedQueryLanguages(final SessionInfo sessionInfo)
+            throws RepositoryException {
+        return (String[]) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getSupportedQueryLanguages(sessionInfo);
+            }
+        }, "getSupportedQueryLanguages(SessionInfo)", new Object[]{});
+    }
+
+    public void checkQueryStatement(final SessionInfo sessionInfo,
+                                    final String s,
+                                    final String s1,
+                                    final Map map) throws InvalidQueryException, RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.checkQueryStatement(sessionInfo, s, s1, map);
+                return null;
+            }
+        }, "checkQueryStatement(SessionInfo,String,String,Map)",
+                new Object[]{s, s1});
+    }
+
+    public QueryInfo executeQuery(final SessionInfo sessionInfo,
+                                  final String s,
+                                  final String s1,
+                                  final Map map) throws RepositoryException {
+        return (QueryInfo) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.executeQuery(sessionInfo, s, s1, map);
+            }
+        }, "executeQuery(SessionInfo,String,String,Map)",
+                new Object[]{s, s1});
+    }
+
+    public EventFilter createEventFilter(final SessionInfo sessionInfo,
+                                         final int i,
+                                         final Path path,
+                                         final boolean b,
+                                         final String[] strings,
+                                         final QName[] qNames,
+                                         final boolean b1)
+            throws UnsupportedRepositoryOperationException, RepositoryException {
+        return (EventFilter) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.createEventFilter(sessionInfo, i, path, b, strings, qNames, b1);
+            }
+        }, "createEventFilter(SessionInfo,int,Path,boolean,String[],QName[],boolean)",
+                new Object[]{new Integer(i), path, new Boolean(b), strings, qNames, new Boolean(b1)});
+    }
+
+    public EventBundle[] getEvents(final SessionInfo sessionInfo,
+                                   final long l,
+                                   final EventFilter[] eventFilters)
+            throws RepositoryException, UnsupportedRepositoryOperationException, InterruptedException {
+        final InterruptedException[] ex = new InterruptedException[1];
+        EventBundle[] bundles = (EventBundle[]) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                try {
+                    return service.getEvents(sessionInfo, l, eventFilters);
+                } catch (InterruptedException e) {
+                    ex[0] = e;
+                    return null;
+                }
+            }
+        }, "getEvents(SessionInfo,long,EventFilter[])", new Object[]{new Long(l)});
+        if (ex[0] != null) {
+            throw ex[0];
+        }
+        return bundles;
+    }
+
+    public Map getRegisteredNamespaces(final SessionInfo sessionInfo)
+            throws RepositoryException {
+        return (Map) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getRegisteredNamespaces(sessionInfo);
+            }
+        }, "getRegisteredNamespaces(SessionInfo)", new Object[]{});
+    }
+
+    public String getNamespaceURI(final SessionInfo sessionInfo,
+                                  final String s)
+            throws NamespaceException, RepositoryException {
+        return (String) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getNamespaceURI(sessionInfo, s);
+            }
+        }, "getNamespaceURI(SessionInfo,String)", new Object[]{s});
+    }
+
+    public String getNamespacePrefix(final SessionInfo sessionInfo,
+                                     final String s)
+            throws NamespaceException, RepositoryException {
+        return (String) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getNamespacePrefix(sessionInfo, s);
+            }
+        }, "getNamespacePrefix(SessionInfo,String)", new Object[]{s});
+    }
+
+    public void registerNamespace(final SessionInfo sessionInfo,
+                                  final String s,
+                                  final String s1) throws NamespaceException, UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.registerNamespace(sessionInfo, s, s1);
+                return null;
+            }
+        }, "registerNamespace(SessionInfo,String,String)", new Object[]{s, s1});
+    }
+
+    public void unregisterNamespace(final SessionInfo sessionInfo,
+                                    final String s)
+            throws NamespaceException, UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.unregisterNamespace(sessionInfo, s);
+                return null;
+            }
+        }, "unregisterNamespace(SessionInfo,String)", new Object[]{s});
+    }
+
+    public Iterator getQNodeTypeDefinitions(final SessionInfo sessionInfo)
+            throws RepositoryException {
+        return (Iterator) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getQNodeTypeDefinitions(sessionInfo);
+            }
+        }, "getQNodeTypeDefinitions(SessionInfo)", new Object[]{});
+    }
+
+    public QNodeTypeDefinition getQNodeTypeDefinition(
+            final SessionInfo sessionInfo,final QName name)
+            throws RepositoryException {
+        return (QNodeTypeDefinition) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getQNodeTypeDefinition(sessionInfo, name);
+            }
+        }, "getQNodeTypeDefinition(SessionInfo,QName)", new Object[]{name});
+    }
+
+    private Object execute(Callable callable, String methodName, Object[] args)
+            throws RepositoryException {
+        boolean success = false;
+        long time = System.nanoTime();
+        try {
+            Object obj = callable.call();
+            success = true;
+            return obj;
+        } finally {
+            time = System.nanoTime() - time;
+            try {
+                StringBuffer b = new StringBuffer();
+                b.append(String.valueOf(System.currentTimeMillis()));
+                b.append("|").append(methodName);
+                b.append("|").append(time).append("|");
+                if (success) {
+                    b.append("succeeded");
+                } else {
+                    b.append("failed");
+                }
+                b.append("|");
+                String separator = "";
+                for (int i = 0; i < args.length; i++) {
+                    if (args[i] instanceof Object[]) {
+                        Object[] nested = (Object[]) args[i];
+                        for (int j = 0; j < nested.length; j++) {
+                            b.append(separator);
+                            b.append(nested[j]);
+                            separator = ",";
+                        }
+                    } else {
+                        b.append(separator);
+                        b.append(args[i]);
+                    }
+                    separator = ",";
+                }
+                b.append("\r\n");
+                log.write(b.toString());
+            } catch (IOException e) {
+                // ignore
+            }
+        }
+    }
+
+    public interface Callable {
+
+        public Object call() throws RepositoryException;
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/RepositoryServiceLogger.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message