(final PigContext pigContext)
| 490 | } |
| 491 | |
| 492 | private static synchronized ContainerDescriptor getTempContainer(final PigContext pigContext) |
| 493 | throws DataStorageException { |
| 494 | ContainerDescriptor tempContainer = null; |
| 495 | String tdir= Utils.substituteVars(pigContext.getProperties().getProperty(PigConfiguration.PIG_TEMP_DIR, "/tmp")); |
| 496 | try { |
| 497 | do { |
| 498 | tempContainer = pigContext.getDfs().asContainer(tdir + "/temp" + r.nextInt()); |
| 499 | } while (tempContainer.exists()); |
| 500 | createContainer(tempContainer); |
| 501 | } |
| 502 | catch (IOException e) { |
| 503 | // try one last time in case this was due IO Exception caused by dir |
| 504 | // operations on directory created by another JVM at the same instant |
| 505 | tempContainer = pigContext.getDfs().asContainer(tdir + "/temp" + r.nextInt()); |
| 506 | try { |
| 507 | createContainer(tempContainer); |
| 508 | } |
| 509 | catch (IOException e1) { |
| 510 | throw new DataStorageException(e1); |
| 511 | } |
| 512 | } |
| 513 | return tempContainer; |
| 514 | } |
| 515 | |
| 516 | private static void createContainer(ContainerDescriptor container) throws IOException { |
| 517 | container.create(); |
no test coverage detected