 
					
				
		
12-03-2013 07:13 AM
12-03-2013 08:07 AM
 
					
				
		
12-05-2013 04:28 AM
   private  void start(String[] args) {
        try {
            preFolderName="D";
            sumFiles=0;
            sumFileSize=0;
            int start=1;
            int end=100;
            folderSize=2;
            if (args.length>0){
                start=Integer.parseInt(args[0]);
            }
            if (args.length>1){
                end = Integer.parseInt(args[1]);
            }
            if (args.length>2){
                folderSize = Integer.parseInt(args[2]);
            }
            if (args.length >3){
                fileNo=Integer.parseInt(args[3]);
            }
            writeFileContent=false;
            if (args.length >4){
                writeFileContent=true;
            }
            tmpFolder=new File("c:/tmp");
            NodeService nodeService= EcmService.me.getNodeService();
            NodeRef root = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
            ChildAssociationRef child = nodeService.getChildAssocs(root, ContentModel.ASSOC_CHILDREN,
                    QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "company_home")).get(0);
            NodeRef companyHome=child.getChildRef();
            File[] tmpFiles = tmpFolder.listFiles();
            files=new FileContent[tmpFiles.length];
            int k=0;
            for (File fi : tmpFiles){
                FileContent fc=new FileContent();
                fc.readFrom(fi);
                files[k++]=fc;
            }
            List<Thread> threads=new ArrayList<Thread>(end-start+1);
            sumFileSize=0;
            long  beginTime=System.currentTimeMillis();
            for  (int i=start;i<=end;i++){
                final int threadNo = i;
                final int finalEnd = end;
                final Folder folder=new Folder(companyHome,preFolderName + i);
                NodeRef folderNode=  GetFolderCommand.getOrCreateFolder(folder, true);
                folder.setNodeRef(folderNode);
                Thread thread  = new Thread(new Runnable() {
                        @Override
                        public void run() {
                            System.out.println(String.format("upload thread %d/%d start…", threadNo, finalEnd));
                            try {
                                AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork<Object>() {
                                    @Override
                                    public Object doWork() throws Exception {
                                        uploadFilesToFolder(threadNo, folder);
                                        return null;
                                    }
                                });
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    });
                threads.add(thread);
                thread.start();
            }
            for (Thread thread: threads){
                thread.join();
            }
            long endTime= System.currentTimeMillis();
            double  span = (endTime-beginTime)/1000.0;
            double sumSizeMB=sumFileSize / 1024 /1024.0;
            StringBuilder msg=new StringBuilder();
            msg.append("upload totalFiles=").append(sumFiles).append(",\t totalSize=");
            msg.append(sumSizeMB).append("MB");
            msg.append(",\tspent seconds=").append(span).append(",");
            System.out.println(msg);
            msg=new StringBuilder();
            msg.append(String.format("%1$.4f  MB/s , \t", sumSizeMB / span));
            msg.append(String.format("%1$.2f  Files/s , \t",sumFiles/span));
            System.out.println(msg);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
12-05-2013 05:41 AM
 
					
				
		
12-05-2013 06:01 AM
 
					
				
		
12-10-2013 08:44 PM
 
					
				
				
			
		
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.