Project

General

Profile

« Previous | Next » 

Revision 10164

Added by Jing Tao about 7 years ago

The indexall action will be run on another thread.

View differences:

src/edu/ucsb/nceas/metacat/MetacatHandler.java
2827 2827
           // Process all of the documents
2828 2828
           logMetacat.info("queueing doc index for all documents");
2829 2829
           try {
2830
                    List<String> allIdentifiers = IdentifierManager.getInstance().getAllSystemMetadataGUIDs();
2831
                    Iterator<String> it = allIdentifiers.iterator();
2830
                    Runnable indexAll = new Runnable () {
2831
                       public void run() {
2832
                           List<String> allIdentifiers = IdentifierManager.getInstance().getAllSystemMetadataGUIDs();
2833
                           Iterator<String> it = allIdentifiers.iterator();
2834
                           while (it.hasNext()) {
2835
                               String id = it.next();
2836
                               Identifier identifier = new Identifier();
2837
                               identifier.setValue(id);
2838
                               SystemMetadata sysMeta = HazelcastService.getInstance().getSystemMetadataMap().get(identifier);
2839
                               if (sysMeta != null) {
2840
                                   
2841
                                   // submit for indexing
2842
                                   Map<String, List<Object>> fields = EventLog.getInstance().getIndexFields(identifier, Event.READ.xmlValue());
2843
                                   try {
2844
                                        MetacatSolrIndex.getInstance().submit(identifier, sysMeta, fields, false);
2845
                                   } catch (Exception e) {
2846
                                       System.out.println("we can't submit the id "+id+" to the index queue since "+e.getMessage());
2847
                                   }
2848
                                   //results.append("<pid>" + id + "</pid>\n");
2849
                                   System.out.println("queued SystemMetadata for index on pid: " + id);
2850
                               }
2851
                               
2852
                           }
2853
                       }
2854
                    };
2855
                    Thread thread = new Thread(indexAll);
2856
                    thread.start();
2832 2857
                    results.append("<success>");
2833
                    while (it.hasNext()) {
2834
                        String id = it.next();
2835
                        Identifier identifier = new Identifier();
2836
                        identifier.setValue(id);
2837
                        SystemMetadata sysMeta = HazelcastService.getInstance().getSystemMetadataMap().get(identifier);
2838
                        if (sysMeta != null) {
2839
                        	
2840
                            // submit for indexing
2841
    					    Map<String, List<Object>> fields = EventLog.getInstance().getIndexFields(identifier, Event.READ.xmlValue());
2842
                            MetacatSolrIndex.getInstance().submit(identifier, sysMeta, fields, false);
2843

  
2844
    					    results.append("<pid>" + id + "</pid>\n");
2845
                            logMetacat.debug("queued SystemMetadata for index on pid: " + id);
2846
                        }
2847
                        
2848
                    }
2858
                    results.append("The indexall action was accepted by Metacat and it is working on the background right now. It doesn't guarantee all the object will be reindexed successfully. You may monitor the process in the Metacat log.");
2849 2859
                    results.append("</success>");
2850 2860
                    logMetacat.info("done queueing index for all documents");
2851 2861
           } catch (Exception e) {

Also available in: Unified diff