Project

General

Profile

« Previous | Next » 

Revision 7143

use a shared ExecutorService for replicate() calls.
https://redmine.dataone.org/issues/2623

View differences:

src/edu/ucsb/nceas/metacat/restservice/MNResourceHandler.java
132 132
    protected static final String RESOURCE_NODE = "node";
133 133
    protected static final String RESOURCE_ERROR = "error";
134 134
    protected static final String RESOURCE_META_CHANGED = "dirtySystemMetadata";
135
    
136
    // shared executor
137
	private static ExecutorService executor = null;
135 138

  
139
	static {
140
		// use a shared executor service with nThreads == one less than available processors
141
    	int availableProcessors = Runtime.getRuntime().availableProcessors();
142
        int nThreads = availableProcessors * 1;
143
        nThreads--;
144
    	executor = Executors.newFixedThreadPool(nThreads);	
145
	}
146
	
136 147
    /**
137 148
     * Initializes new instance by setting servlet context,request and response
138 149
     * */
......
675 686
				}
676 687
			}
677 688
    	};
678
    	ExecutorService executor = Executors.newSingleThreadExecutor();
679
    	executor.execute(runner);
680
    	executor.shutdown();
689
    	// submit the task, and that's it
690
    	executor.submit(runner);
681 691
        
682 692
    	// thread was started, so we return success
683 693
        response.setStatus(200);

Also available in: Unified diff