Revision 6679
Added by ben leinfelder about 13 years ago
src/edu/ucsb/nceas/metacat/restservice/MNResourceHandler.java | ||
---|---|---|
35 | 35 |
import java.util.Enumeration; |
36 | 36 |
import java.util.Map; |
37 | 37 |
import java.util.TimeZone; |
38 |
import java.util.concurrent.ExecutorService; |
|
39 |
import java.util.concurrent.Executors; |
|
38 | 40 |
|
39 | 41 |
import javax.servlet.ServletContext; |
40 | 42 |
import javax.servlet.http.HttpServletRequest; |
... | ... | |
619 | 621 |
logMetacat.debug("in POST replicate()"); |
620 | 622 |
|
621 | 623 |
//parse the systemMetadata |
622 |
SystemMetadata sysmeta = collectSystemMetadata(); |
|
624 |
final SystemMetadata sysmeta = collectSystemMetadata();
|
|
623 | 625 |
|
624 | 626 |
String sn = multipartparams.get("sourceNode").get(0); |
625 | 627 |
logMetacat.debug("sourceNode: " + sn); |
626 |
NodeReference sourceNode = new NodeReference(); |
|
628 |
final NodeReference sourceNode = new NodeReference();
|
|
627 | 629 |
sourceNode.setValue(sn); |
630 |
|
|
631 |
// run it in a thread to avoid connection timeout |
|
632 |
Runnable runner = new Runnable() { |
|
633 |
@Override |
|
634 |
public void run() { |
|
635 |
try { |
|
636 |
MNodeService.getInstance(request).replicate(session, sysmeta, sourceNode); |
|
637 |
} catch (Exception e) { |
|
638 |
throw new RuntimeException(e.getMessage(), e); |
|
639 |
} |
|
640 |
} |
|
641 |
}; |
|
642 |
ExecutorService executor = Executors.newSingleThreadExecutor(); |
|
643 |
executor.execute(runner); |
|
644 |
executor.shutdown(); |
|
645 |
|
|
646 |
// thread was started, so we return success |
|
628 | 647 |
response.setStatus(200); |
629 |
OutputStream out = response.getOutputStream(); |
|
630 |
IOUtils.write("OKAY", out, "UTF-8"); |
|
631 |
MNodeService.getInstance(request).replicate(session, sysmeta, sourceNode); |
|
632 |
|
|
648 |
|
|
633 | 649 |
} |
634 | 650 |
|
635 | 651 |
/** |
Also available in: Unified diff
run replicate() in a separate thread so that we don't wait for potentially large data objects to be moved around the system.