chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r929423 - in /incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-util/src/main/java/org/apache/opencmis/util/repository: ObjGenApp.java ObjectGenerator.java TimeLogger.java
Date Wed, 31 Mar 2010 07:57:02 GMT
Author: jens
Date: Wed Mar 31 07:57:01 2010
New Revision: 929423

URL: http://svn.apache.org/viewvc?rev=929423&view=rev
Log:
CMIS-183: 
Add option to create folders in ObjectGenerator
Add option to execute commands multi-threaded

Modified:
    incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-util/src/main/java/org/apache/opencmis/util/repository/ObjGenApp.java
    incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-util/src/main/java/org/apache/opencmis/util/repository/ObjectGenerator.java
    incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-util/src/main/java/org/apache/opencmis/util/repository/TimeLogger.java

Modified: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-util/src/main/java/org/apache/opencmis/util/repository/ObjGenApp.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-util/src/main/java/org/apache/opencmis/util/repository/ObjGenApp.java?rev=929423&r1=929422&r2=929423&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-util/src/main/java/org/apache/opencmis/util/repository/ObjGenApp.java
(original)
+++ incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-util/src/main/java/org/apache/opencmis/util/repository/ObjGenApp.java
Wed Mar 31 07:57:01 2010
@@ -36,9 +36,6 @@ import org.apache.opencmis.commons.Sessi
 import org.apache.opencmis.commons.enums.BaseObjectTypeIds;
 import org.apache.opencmis.commons.exceptions.CmisBaseException;
 import org.apache.opencmis.commons.provider.CmisProvider;
-import org.apache.opencmis.commons.provider.NavigationService;
-import org.apache.opencmis.commons.provider.ObjectService;
-import org.apache.opencmis.commons.provider.ProviderObjectFactory;
 import org.apache.opencmis.commons.provider.RepositoryInfoData;
 import org.apache.opencmis.commons.provider.RepositoryService;
 
@@ -48,7 +45,7 @@ public class ObjGenApp {
   public static final String PROP_ATOMPUB_URL = "opencmis.test.atompub.url";
   public static final String PROP_URL = "url";
   public static final String PROP_WS_URL = "opencmis.test.webservices.url";
-  public static final String DEFAULT_ATOMPUB_URL = "http://localhost:8080/opencmis/atom";

+  public static final String DEFAULT_ATOMPUB_URL = "http://localhost:8080/opencmis/atom";
   public static final String DEFAULT_WS_URL = "http://localhost:8080/cmis/services/";
 
   private final static String CMD = "Command";
@@ -63,15 +60,15 @@ public class ObjGenApp {
   private final static String BINDING = "Binding";
   private final static String CLEANUP = "Cleanup";
   private final static String ROOTFOLDER = "RootFolder";
-  
+  private final static String THREADS = "Threads";
+
   private final static String BINDING_ATOM = "AtomPub";
   private final static String BINDING_WS = "WebService";
 
   private CmisProvider fProvider;
-  private boolean fUsingAtom; 
+  private boolean fUsingAtom;
   private String fUrlStr;
-  private boolean fDoCleanup;
-  
+
   OptionSpec<String> fCmd;
   OptionSpec<Integer> fDepth;
   OptionSpec<Integer> fContentSize;
@@ -84,8 +81,8 @@ public class ObjGenApp {
   OptionSpec<String> fBinding;
   OptionSpec<Boolean> fCleanup;
   OptionSpec<String> fRootFolder;
-  
-  
+  OptionSpec<Integer> fThreads;
+
   public static void main(String[] args) {
 
     ObjGenApp app = new ObjGenApp();
@@ -106,80 +103,83 @@ public class ObjGenApp {
   private void processCmdLine(String[] args) {
 
     OptionParser parser = new OptionParser();
-    fCmd = parser.accepts(CMD).withRequiredArg()
-      .describedAs("Command to perform (see below)");
-    fRepoId = parser.accepts(REPOSITORY_ID).withOptionalArg()
-      .describedAs("Repository used");
+    fCmd = parser.accepts(CMD).withRequiredArg().describedAs("Command to perform (see below)");
+    fRepoId = parser.accepts(REPOSITORY_ID).withOptionalArg().describedAs("Repository used");
     fDocType = parser.accepts(FILLER_DOCUMENT_TYPE_ID).withOptionalArg().defaultsTo(
-        BaseObjectTypeIds.CMIS_DOCUMENT.value())
-      .describedAs("Document type created");
+        BaseObjectTypeIds.CMIS_DOCUMENT.value()).describedAs("Document type created");
     fFolderType = parser.accepts(FILLER_FOLDER_TYPE_ID).withOptionalArg().defaultsTo(
-        BaseObjectTypeIds.CMIS_FOLDER.value())
-        .describedAs("Folder type created");
+        BaseObjectTypeIds.CMIS_FOLDER.value()).describedAs("Folder type created");
     fDocsPerFolder = parser.accepts(FILLER_DOCS_PER_FOLDER).withOptionalArg().ofType(Integer.class)
-      .describedAs("Documents on each level").defaultsTo(1);
+        .describedAs("Documents on each level").defaultsTo(1);
     fFolderPerFolder = parser.accepts(FILLER_FOLDERS_PER_FOLDER).withOptionalArg().ofType(
         Integer.class).describedAs(" Folders on each level").defaultsTo(0);
-    fDepth = parser.accepts(FILLER_DEPTH).withOptionalArg().ofType(Integer.class)
-      .describedAs("Levels of folders").defaultsTo(1);
+    fDepth = parser.accepts(FILLER_DEPTH).withOptionalArg().ofType(Integer.class).describedAs(
+        "Levels of folders").defaultsTo(1);
     fContentSize = parser.accepts(FILLER_CONTENT_SIZE).withOptionalArg().ofType(Integer.class)
-      .describedAs("Content size of each doc").defaultsTo(0);
+        .describedAs("Content size of each doc").defaultsTo(0);
     fCount = parser.accepts(COUNT).withOptionalArg().ofType(Integer.class).defaultsTo(1)
-        .describedAs("Repeat a command n times (not yet implemented)");
-    fBinding = parser.accepts(BINDING).withOptionalArg().ofType(String.class).defaultsTo(BINDING_ATOM)
-      .describedAs("Protocol Binding: " + BINDING_ATOM + " or " + BINDING_WS);
+        .describedAs("Repeat a command n times (partially implemented)");
+    fBinding = parser.accepts(BINDING).withOptionalArg().ofType(String.class).defaultsTo(
+        BINDING_ATOM).describedAs("Protocol Binding: " + BINDING_ATOM + " or " + BINDING_WS);
     fCleanup = parser.accepts(CLEANUP).withOptionalArg().ofType(Boolean.class).defaultsTo(false)
-    .describedAs("Clean all created objects at the end");
-    fRootFolder = parser.accepts(ROOTFOLDER).withOptionalArg().ofType(String.class)
-      .describedAs("folder id used as root to create objects (default repository root folder)");
-    
+        .describedAs("Clean all created objects at the end");
+    fRootFolder = parser.accepts(ROOTFOLDER).withOptionalArg().ofType(String.class).describedAs(
+        "folder id used as root to create objects (default repository root folder)");
+    fThreads = parser.accepts(THREADS).withOptionalArg().ofType(Integer.class).defaultsTo(1)
+        .describedAs("Number of threads to start in parallel");
+
     OptionSet options = parser.parse(args);
 
     if (options.valueOf(fCmd) == null || options.has("?"))
       usage(parser);
-    
+
     if (options.valueOf(fBinding).equals(BINDING_WS)) {
-      System.out.println("Using Web Service binding.");
       fUsingAtom = false;
-    } else if (options.valueOf(fBinding).equals(BINDING_ATOM)) {
-      System.out.println("Using AtomPub binding.");
+    }
+    else if (options.valueOf(fBinding).equals(BINDING_ATOM)) {
       fUsingAtom = true;
-    } else {
+    }
+    else {
       System.out.println("Unknown option <Binding>: " + options.valueOf(fBinding)
           + " allowed values: " + BINDING_WS + " or " + BINDING_ATOM);
       return;
     }
 
-    fDoCleanup = options.valueOf(fCleanup);
-    
     if (options.valueOf(fCmd).equals("FillRepository")) {
       fillRepository(options);
-    } else if (options.valueOf(fCmd).equals("CreateDocument")) {
+    }
+    else if (options.valueOf(fCmd).equals("CreateDocument")) {
       createSingleDocument(options);
-    } else if (options.valueOf(fCmd).equals("RepositoryInfo")) {
+    }
+    else if (options.valueOf(fCmd).equals("CreateFolder")) {
+      createFolders(options);
+    }
+    else if (options.valueOf(fCmd).equals("RepositoryInfo")) {
       repositoryInfo(options);
-    } else if (options.valueOf(fCmd).equals("GetUrl")) {
+    }
+    else if (options.valueOf(fCmd).equals("GetUrl")) {
       getUrl(getConfiguredUrl());
-    } else {
+    }
+    else {
       System.out.println("Unknown cmd: " + options.valueOf(fCmd));
       usage(parser);
     }
   }
 
-//  private void preInitExpensiveTasks() {
-//    // JAXB initialization is very expensive, count this separate:
-//    TimeLogger logger = new TimeLogger("Initialization");
-//    logger.start();
-//    try {
-//      JaxBHelper.createMarshaller();
-//    }
-//    catch (JAXBException e) {
-//      System.out.print("Failuer in JAXB init: " + e);
-//      e.printStackTrace();
-//    } // dummy call just to get initialized
-//    logger.stop();
-//    logger.printTimes();    
-//  }
+  // private void preInitExpensiveTasks() {
+  // // JAXB initialization is very expensive, count this separate:
+  // TimeLogger logger = new TimeLogger("Initialization");
+  // logger.start();
+  // try {
+  // JaxBHelper.createMarshaller();
+  // }
+  // catch (JAXBException e) {
+  // System.out.print("Failuer in JAXB init: " + e);
+  // e.printStackTrace();
+  // } // dummy call just to get initialized
+  // logger.stop();
+  // logger.printTimes();
+  // }
 
   private void usage(OptionParser parser) {
     try {
@@ -188,13 +188,17 @@ public class ObjGenApp {
       System.out.println("Usage:");
       parser.printHelpOn(System.out);
       System.out.println();
-      System.out.println("Command is one of [CreateDocument, FillRepository, RepositoryInfo]");
+      System.out
+          .println("Command is one of [CreateDocument, CreateFolder, FillRepository, RepositoryInfo]");
       System.out.println("JVM system properties: " + PROP_ATOMPUB_URL + ", " + PROP_WS_URL);
       System.out.println();
       System.out.println("Example: ");
-      System.out.println("java -D" + PROP_ATOMPUB_URL + "=http://localhost:8080/opencmis/atom
-cp ... " +
-          "org.apache.opencmis.util.repository.ObjGenApp --Binding=AtomPub --Command=CreateDocument
" +
-          "--RepositoryId=A1 --ContentSizeInKB=25");
+      System.out
+          .println("java -D"
+              + PROP_ATOMPUB_URL
+              + "=http://localhost:8080/opencmis/atom -cp ... "
+              + "org.apache.opencmis.util.repository.ObjGenApp --Binding=AtomPub --Command=CreateDocument
"
+              + "--RepositoryId=A1 --ContentSizeInKB=25");
       return;
     }
     catch (IOException e) {
@@ -202,33 +206,16 @@ public class ObjGenApp {
     }
   }
 
-
   private void fillRepository(String repoId, int docsPerFolder, int foldersPerFolders, int
depth,
-      String documentType, String folderType, int contentSizeInKB, String rootFolderId) {
-
-    ProviderObjectFactory objectFactory = getObjectFactory();
-    NavigationService navSvc = getProvider().getNavigationService();
-    ObjectService objSvc = getProvider().getObjectService();
-    RepositoryService repSvc = getProvider().getRepositoryService();
+      String documentType, String folderType, int contentSizeInKB, String rootFolderId,
+      boolean doCleanup) {
 
-    ObjectGenerator gen = new ObjectGenerator(objectFactory, navSvc, objSvc, repoId);
-    gen.setUseUuidsForNames(true);
-    gen.setNumberOfDocumentsToCreatePerFolder(docsPerFolder);
-    // Set the type id for all created documents:
-    gen.setDocumentTypeId(documentType);
-    // Set the type id for all created folders:
-    gen.setFolderTypeId(folderType);
-    // Set contentSize
-    gen.setContentSizeInKB(contentSizeInKB);
-    gen.setCleanUpAfterCreate(fDoCleanup);
-
-    // Build the tree
-    RepositoryInfoData rep = repSvc.getRepositoryInfo(repoId, null);
-    if (null == rootFolderId || rootFolderId.length() == 0)
-      rootFolderId = rep.getRootFolderId();
+    MultiThreadedObjectGenerator.ObjectGeneratorRunner runner = MultiThreadedObjectGenerator
+        .prepareForCreateTree(getProvider(), repoId, docsPerFolder, foldersPerFolders, depth,
+            documentType, folderType, contentSizeInKB, rootFolderId, doCleanup);
+    ObjectGenerator gen = runner.getObjectGenerator();
+    runner.doCreateTree();
 
-    gen.resetCounters();
-    gen.createFolderHierachy(depth, foldersPerFolders, rootFolderId);
     System.out.println();
     System.out.println("Result:");
     System.out.println("Filling repository succeeded.");
@@ -238,67 +225,151 @@ public class ObjGenApp {
     gen.printTimings();
   }
 
-  private void printParameters(OptionSet options) {    
+  private void fillRepositoryMT(int noThreads, String repoId, int docsPerFolder,
+      int foldersPerFolders, int depth, String documentType, String folderType,
+      int contentSizeInKB, String rootFolderId, boolean doCleanup) {
+
+    // Step 1: create a root folder for each thread
+    MultiThreadedObjectGenerator.ObjectGeneratorRunner runner = MultiThreadedObjectGenerator
+        .prepareForCreateFolder(getProvider(), repoId, folderType, rootFolderId, noThreads,
+            doCleanup);
+    String[] folderIds = runner.doCreateFolder();
+
+    // Step 2: fill each root folder with an object tree
+    MultiThreadedObjectGenerator.ObjectGeneratorRunner[] runners = MultiThreadedObjectGenerator
+        .prepareForCreateTreeMT(getProvider(), repoId, docsPerFolder, foldersPerFolders,
depth,
+            documentType, folderType, contentSizeInKB, folderIds, doCleanup);
+
+    MultiThreadedObjectGenerator.runMultiThreaded(runners);
+    System.out.println("Filling repository succeeded.");
+  }
+
+  private void printParameters(OptionSet options) {
     if (fUsingAtom)
-      System.out.println("Connecting to  " + getAtomPubUrl());
+      System.out.println("Using AtomPub, connecting to  " + getAtomPubUrl());
     else
-      System.out.println("Connecting to  " + getWsUrl());
-      
+      System.out.println("Using WebService, connecting to  " + getWsUrl());
+
     System.out.println("Repository id is: " + options.valueOf(fRepoId));
     System.out.println("Content size: " + options.valueOf(fContentSize));
     System.out.println("Document Type: " + options.valueOf(fDocType));
-    System.out.println("Folder used as root: " + options.valueOf(fRootFolder));
-    System.out.println("Delete all objects after creation: " + fDoCleanup);
+    System.out.println("Folder id used as root: " + options.valueOf(fRootFolder));
+    System.out.println("Delete all objects after creation: " + options.valueOf(fCleanup));
+    System.out.println("Number of threads to start: " + options.valueOf(fThreads));
   }
-  
+
   private void createSingleDocument(OptionSet options) {
     System.out.println();
     System.out.println("Creating document with parameters:");
     printParameters(options);
-    createSingleDocument(options.valueOf(fRepoId), options.valueOf(fContentSize), options.valueOf(fRootFolder));
+    int noThreads = options.valueOf(fThreads);
+    if (noThreads <= 1)
+      createSingleDocument(options.valueOf(fRepoId), options.valueOf(fDocType), options
+          .valueOf(fContentSize), options.valueOf(fRootFolder), options.valueOf(fCount),
options
+          .valueOf(fCleanup));
+    else
+      createSingleDocumentMT(noThreads, options.valueOf(fRepoId), options.valueOf(fDocType),
+          options.valueOf(fContentSize), options.valueOf(fRootFolder), options.valueOf(fCount),
+          options.valueOf(fCleanup));
   }
-  
+
   private void fillRepository(OptionSet options) {
     System.out.println();
+    printParameters(options);
     System.out.println("Creating object tree with folowing parameters: ");
     System.out.println("Documents per folder: " + options.valueOf(fDocsPerFolder));
     System.out.println("Folder per folder: " + options.valueOf(fFolderPerFolder));
     System.out.println("Depth: " + options.valueOf(fDepth));
     System.out.println("Folder Type: " + options.valueOf(fFolderType));
-    printParameters(options);
 
-    fillRepository(options.valueOf(fRepoId), options.valueOf(fDocsPerFolder), options
-        .valueOf(fFolderPerFolder), options.valueOf(fDepth), options.valueOf(fDocType), options
-        .valueOf(fFolderType), options.valueOf(fContentSize), options.valueOf(fRootFolder));
+    int noThreads = options.valueOf(fThreads);
+    if (noThreads <= 1)
+      fillRepository(options.valueOf(fRepoId), options.valueOf(fDocsPerFolder), options
+          .valueOf(fFolderPerFolder), options.valueOf(fDepth), options.valueOf(fDocType),
options
+          .valueOf(fFolderType), options.valueOf(fContentSize), options.valueOf(fRootFolder),
+          options.valueOf(fCleanup));
+    else
+      fillRepositoryMT(noThreads, options.valueOf(fRepoId), options.valueOf(fDocsPerFolder),
+          options.valueOf(fFolderPerFolder), options.valueOf(fDepth), options.valueOf(fDocType),
+          options.valueOf(fFolderType), options.valueOf(fContentSize),
+          options.valueOf(fRootFolder), options.valueOf(fCleanup));
+
   }
 
-  private void createSingleDocument(String repoId, int contentSizeInKB, String rootFolderId)
{
+  private void createFolders(OptionSet options) {
+    int noThreads = options.valueOf(fThreads);
+    if (noThreads <= 1)
+      createFolders(options.valueOf(fRepoId), options.valueOf(fFolderType), options
+          .valueOf(fRootFolder), options.valueOf(fCount), options.valueOf(fCleanup));
+    else
+      createFoldersMT(noThreads, options.valueOf(fRepoId), options.valueOf(fFolderType),
options
+          .valueOf(fRootFolder), options.valueOf(fCount), options.valueOf(fCleanup));
+  }
 
-    ProviderObjectFactory objectFactory = getObjectFactory();
-    NavigationService navSvc = getProvider().getNavigationService();
-    ObjectService objSvc = getProvider().getObjectService();
-    RepositoryService repSvc = getProvider().getRepositoryService();
-    ObjectGenerator gen = new ObjectGenerator(objectFactory, navSvc, objSvc, repoId);
-    TimeLogger timeLogger = new TimeLogger("Initialize");
-    timeLogger.start();
-    RepositoryInfoData rep = repSvc.getRepositoryInfo(repoId, null);
-    timeLogger.stop();
-    timeLogger.printTimes();
-    if (null == rootFolderId || rootFolderId.length() == 0)
-      rootFolderId = rep.getRootFolderId();
-    gen.setContentSizeInKB(contentSizeInKB);
-    gen.setUseUuidsForNames(true);
-    gen.setCleanUpAfterCreate(fDoCleanup);
-    String id = gen.createSingleDocument(rootFolderId);
+  private void createSingleDocument(String repoId, String documentType, int contentSizeInKB,
+      String rootFolderId, int docCount, boolean doCleanup) {
+
+    MultiThreadedObjectGenerator.ObjectGeneratorRunner runner = MultiThreadedObjectGenerator
+        .prepareForCreateDocument(getProvider(), repoId, documentType, contentSizeInKB,
+            rootFolderId, docCount, doCleanup);
+    ObjectGenerator gen = runner.getObjectGenerator();
+    String[] ids = runner.doCreateDocument();
     System.out.println();
     System.out.println("Result:");
     System.out.println("Document creation succeeded.");
     System.out.println("Folder used as root for creation: " + rootFolderId);
-    System.out.println("Id of created document: " + id);
+    System.out.println("Ids of created documents: ");
+    if (null == ids)
+      System.out.println("<none>");
+    else
+      for (int i = 0; i < ids.length; i++)
+        System.out.println(ids[i]);
     gen.printTimings();
     gen.resetCounters();
   }
 
+  private void createSingleDocumentMT(int noThreads, String repoId, String documentType,
+      int contentSizeInKB, String rootFolderId, int docCount, boolean doCleanup) {
+
+    MultiThreadedObjectGenerator.ObjectGeneratorRunner[] runners = MultiThreadedObjectGenerator
+        .prepareForCreateDocumentMT(noThreads, getProvider(), repoId, documentType,
+            contentSizeInKB, rootFolderId, docCount, doCleanup);
+
+    MultiThreadedObjectGenerator.runMultiThreaded(runners);
+    System.out.println("Document creation succeeded. All threads terminated.");
+  }
+
+  private void createFolders(String repoId, String folderType, String rootFolderId, int noFolders,
+      boolean doCleanup) {
+
+    MultiThreadedObjectGenerator.ObjectGeneratorRunner runner = MultiThreadedObjectGenerator
+        .prepareForCreateFolder(getProvider(), repoId, folderType, rootFolderId, noFolders,
+            doCleanup);
+    ObjectGenerator gen = runner.getObjectGenerator();
+    String[] ids = runner.doCreateFolder();
+    System.out.println();
+    System.out.println("Result:");
+    System.out.println("Folder creation succeeded.");
+    System.out.println("Ids of created folders: ");
+    if (null == ids)
+      System.out.println("<none>");
+    else
+      for (int i = 0; i < ids.length; i++)
+        System.out.println(ids[i]);
+    gen.printTimings();
+    gen.resetCounters();
+  }
+
+  private void createFoldersMT(int noThreads, String repoId, String folderType,
+      String rootFolderId, int noFolders, boolean doCleanup) {
+
+    MultiThreadedObjectGenerator.ObjectGeneratorRunner[] runners = MultiThreadedObjectGenerator
+        .prepareForCreateFolderMT(noThreads, getProvider(), repoId, folderType, rootFolderId,
+            noFolders, doCleanup);
+    MultiThreadedObjectGenerator.runMultiThreaded(runners);
+    System.out.println("Folder creation succeeded.");
+  }
+
   private void callRepoInfo(String repositoryId, int count) {
     RepositoryService repSvc = getProvider().getRepositoryService();
     TimeLogger timeLogger = new TimeLogger("RepoInfoTest");
@@ -309,7 +380,8 @@ public class ObjGenApp {
       repoInfo = repSvc.getRepositoryInfo(repositoryId, null);
       timeLogger.stop();
     }
-    System.out.println("Root Folder id is: " + (repoInfo==null ? "<unknown>" : repoInfo.getRootFolderId())
);
+    System.out.println("Root Folder id is: "
+        + (repoInfo == null ? "<unknown>" : repoInfo.getRootFolderId()));
     timeLogger.printTimes();
   }
 
@@ -317,10 +389,6 @@ public class ObjGenApp {
     callRepoInfo(options.valueOf(fRepoId), options.valueOf(fCount));
   }
 
-  private ProviderObjectFactory getObjectFactory() {
-    return getProvider().getObjectFactory();
-  }
-
   private CmisProvider getProvider() {
     if (fProvider == null) {
       if (fUsingAtom)
@@ -332,14 +400,14 @@ public class ObjGenApp {
   }
 
   private static void filLoginParams(Map<String, String> parameters, String user, String
password) {
-    if (user != null && !user.isEmpty())
+    if (user != null && user.length() > 0)
       parameters.put(SessionParameter.USER, user);
-    if (user != null && !user.isEmpty())
-      parameters.put(SessionParameter.PASSWORD, password);    
+    if (user != null && user.length() > 0)
+      parameters.put(SessionParameter.PASSWORD, password);
   }
-  
+
   private static CmisProvider createAtomProvider(String url, String user, String password)
{
-    
+
     // gather parameters
     Map<String, String> parameters = new HashMap<String, String>();
     filLoginParams(parameters, user, password);
@@ -410,7 +478,6 @@ public class ObjGenApp {
     return provider;
   }
 
-    
   private String getAtomPubUrl() {
     return System.getProperty(PROP_ATOMPUB_URL, DEFAULT_ATOMPUB_URL);
   }
@@ -450,5 +517,4 @@ public class ObjGenApp {
     }
   }
 
-  
 }

Modified: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-util/src/main/java/org/apache/opencmis/util/repository/ObjectGenerator.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-util/src/main/java/org/apache/opencmis/util/repository/ObjectGenerator.java?rev=929423&r1=929422&r2=929423&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-util/src/main/java/org/apache/opencmis/util/repository/ObjectGenerator.java
(original)
+++ incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-util/src/main/java/org/apache/opencmis/util/repository/ObjectGenerator.java
Wed Mar 31 07:57:01 2010
@@ -173,6 +173,18 @@ public class ObjectGenerator {
     fCleanup = doCleanup;
   }
   
+  public TimeLogger getCreateDocumentTimeLogger() {
+    return fTimeLoggerCreateDoc;
+  }
+  
+  public TimeLogger getCreateFolderTimeLogger() {
+    return fTimeLoggerCreateFolder;
+  }
+
+  public TimeLogger getDeleteTimeLogger() {
+    return fTimeLoggerDelete;
+  }
+  
   public void createFolderHierachy(int levels, int childrenPerLevel, String rootFolderId)
{
     resetCounters();
     fTimeLoggerCreateDoc.reset();
@@ -276,6 +288,45 @@ public class ObjectGenerator {
     return objectId;
   }
 	  
+  public String[] createDocuments(String folderId, int count) {
+    
+    String result[];
+    
+    fTimeLoggerCreateDoc.reset();
+    for (int i=0; i<count; i++) {
+      String id = createDocument(folderId, 0, 0);
+      fTopLevelDocsCreated.add(id);
+    }
+    if (fCleanup) {
+      deleteTree();
+      result = null;
+    } else {
+      result = new String[count];
+      for (int i=0; i<fTopLevelDocsCreated.size(); i++) 
+        result[i] = fTopLevelDocsCreated.get(i);
+    }
+    return result;
+  }
+
+  public String[] createFolders(String folderId, int count) {
+    
+    String result[];
+    
+    fTimeLoggerCreateFolder.reset();
+    for (int i=0; i<count; i++) {
+      createFolder(folderId);
+    }
+    if (fCleanup) {
+      deleteTree();
+      result = null;
+    } else {
+      result = new String[count];
+      for (int i=0; i<fTopLevelFoldersCreated.size(); i++) 
+        result[i] = fTopLevelFoldersCreated.get(i);
+    }
+    return result;
+  }
+    
   public void resetCounters() {
     fDocumentsInTotalCount = fFoldersInTotalCount = 0;
   }
@@ -326,6 +377,19 @@ public class ObjectGenerator {
     }
   }
 
+  private String createFolder(String parentId) {
+    PropertiesData props = createFolderProperties(0, 0);
+    String id = null;
+    try {
+      fTimeLoggerCreateFolder.start();
+      id = fObjSvc.createFolder(fRepositoryId, props, parentId, null, null, null, null);
+      fTopLevelFoldersCreated.add(id);
+    } finally {
+      fTimeLoggerCreateFolder.stop();
+    }
+    return id;
+  }
+
   private String createDocument(String folderId, int no, int level) {
     ContentStreamData contentStream = null;
     VersioningState versioningState = VersioningState.NONE;

Modified: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-util/src/main/java/org/apache/opencmis/util/repository/TimeLogger.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-util/src/main/java/org/apache/opencmis/util/repository/TimeLogger.java?rev=929423&r1=929422&r2=929423&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-util/src/main/java/org/apache/opencmis/util/repository/TimeLogger.java
(original)
+++ incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-util/src/main/java/org/apache/opencmis/util/repository/TimeLogger.java
Wed Mar 31 07:57:01 2010
@@ -161,4 +161,97 @@ public class TimeLogger {
     return sum; 
   }
 
+  ////////////////////////////////////////////////////////////////////////////////////
+  //
+  // Same methods used for multithreaded logging
+  
+  public static void logTimes(TimeLogger[] loggers) {
+    long size=0;    
+    if (null == loggers)
+      return;
+    
+    for (int i=0; i<loggers.length; i++)
+      size += loggers[i].fTimeRecs.size();
+    
+    LOG.info("Timings for " + size + " samples for action " + loggers[0].fAction + ": ");
+    LOG.info("  Average: " + getAverageTime(loggers) + "ms");
+    LOG.info("  Min    : " + getMinTime(loggers) + "ms");
+    LOG.info("  Max    : " + getMaxTime(loggers) + "ms");
+    LOG.info("  Total  : " + getTotalTime(loggers) + "ms");
+  }
+  
+  public static void printTimes(TimeLogger[] loggers) {
+    long size=0;    
+    if (null == loggers)
+      return;
+    
+    for (int i=0; i<loggers.length; i++)
+      size += loggers[i].fTimeRecs.size();
+    
+    System.out.println("Timings for " + size + " samples for action " + loggers[0].fAction
+ ": ");
+    System.out.println("  Average: " + getAverageTime(loggers) + "ms");
+    System.out.println("  Min    : " + getMinTime(loggers) + "ms");
+    System.out.println("  Max    : " + getMaxTime(loggers) + "ms");
+    System.out.println("  Total  : " + getTotalTime(loggers) + "ms");
+
+  }
+  
+  static private long getAverageTime(TimeLogger[] loggers) {
+    long sum = 0;
+    long size=0;
+    
+    for (int i=0; i<loggers.length; i++)
+      size += loggers[i].fTimeRecs.size();
+    
+    if (size==0)
+      return 0;
+    
+    for (int i=0; i<loggers.length; i++) {
+      if (0 == loggers[i].fTimeRecs.size())
+        continue;
+      
+      for (TimeRecord tm : loggers[i].fTimeRecs) {
+        sum += tm.fStop - tm.fStart;
+      }
+    }
+    
+    return (sum + size/2) / size; 
+  }
+  
+  static private long getMaxTime(TimeLogger[] loggers) {
+    long max = Long.MIN_VALUE;
+
+    for (int i=0; i<loggers.length; i++) {
+      long val = loggers[i].getMaxTime();
+      if (val > max)
+        max = val;
+    }
+
+    return max; 
+  }
+
+  static private long getMinTime(TimeLogger[] loggers) {
+    long min = Long.MAX_VALUE;
+    
+    for (int i=0; i<loggers.length; i++) {
+      long val = loggers[i].getMinTime();
+      if (val < min)
+        min = val;
+    }
+    
+    return min; 
+  }
+ 
+  static private long getTotalTime(TimeLogger[] loggers) {
+    long totalTime = Long.MIN_VALUE;
+
+    for (int i=0; i<loggers.length; i++) {
+      long val = loggers[i].getTotalTime();
+      if (val > totalTime)
+        totalTime = val;
+    }
+
+    return totalTime; 
+  }
+  
 }



Mime
View raw message