Repository: ignite Updated Branches: refs/heads/ignite-ssl-hotfix [created] b43bb6f6d
IGNITE-3998: IGFS: Enabled IgfsAbstractSelfTest.testCreateConsistencyMultithreaded. This closes #1129. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a4c63ae1 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a4c63ae1 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a4c63ae1 Branch: refs/heads/ignite-ssl-hotfix Commit: a4c63ae113931615e940ada2411ebce32dba5db8 Parents: f447559 Author: iveselovskiy <iveselovs...@gridgain.com> Authored: Fri Sep 30 10:45:13 2016 +0300 Committer: vozerov-gridgain <voze...@gridgain.com> Committed: Fri Sep 30 10:45:13 2016 +0300 ---------------------------------------------------------------------- .../processors/igfs/IgfsAbstractSelfTest.java | 141 +++++++++---------- 1 file changed, 70 insertions(+), 71 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/a4c63ae1/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java index e8d65f1..7058954 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java @@ -1310,77 +1310,76 @@ public abstract class IgfsAbstractSelfTest extends IgfsAbstractBaseSelfTest { * @throws Exception If failed. */ public void testCreateConsistencyMultithreaded() throws Exception { - // TODO: Enable -// final AtomicBoolean stop = new AtomicBoolean(); -// -// final AtomicInteger createCtr = new AtomicInteger(); // How many times the file was re-created. -// final AtomicReference<Exception> err = new AtomicReference<>(); -// -// igfs.create(FILE, false).close(); -// -// int threadCnt = 50; -// -// IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() { -// @SuppressWarnings("ThrowFromFinallyBlock") -// @Override public void run() { -// while (!stop.get() && err.get() == null) { -// IgfsOutputStream os = null; -// -// try { -// os = igfs.create(FILE, true); -// -// os.write(chunk); -// -// os.close(); -// -// createCtr.incrementAndGet(); -// } -// catch (IgniteException e) { -// // No-op. -// } -// catch (IOException e) { -// err.compareAndSet(null, e); -// -// Throwable[] chain = X.getThrowables(e); -// -// Throwable cause = chain[chain.length - 1]; -// -// System.out.println("Failed due to IOException exception. Cause:"); -// cause.printStackTrace(System.out); -// } -// finally { -// if (os != null) -// try { -// os.close(); -// } -// catch (IOException ioe) { -// throw new IgniteException(ioe); -// } -// } -// } -// } -// }, threadCnt); -// -// long startTime = U.currentTimeMillis(); -// -// while (err.get() == null -// && createCtr.get() < 500 -// && U.currentTimeMillis() - startTime < 60 * 1000) -// U.sleep(100); -// -// stop.set(true); -// -// fut.get(); -// -// awaitFileClose(igfs.asSecondary(), FILE); -// -// if (err.get() != null) { -// X.println("Test failed: rethrowing first error: " + err.get()); -// -// throw err.get(); -// } -// -// checkFileContent(igfs, FILE, chunk); + final AtomicBoolean stop = new AtomicBoolean(); + + final AtomicInteger createCtr = new AtomicInteger(); // How many times the file was re-created. + final AtomicReference<Exception> err = new AtomicReference<>(); + + igfs.create(FILE, false).close(); + + int threadCnt = 50; + + IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() { + @SuppressWarnings("ThrowFromFinallyBlock") + @Override public void run() { + while (!stop.get() && err.get() == null) { + IgfsOutputStream os = null; + + try { + os = igfs.create(FILE, true); + + os.write(chunk); + + os.close(); + + createCtr.incrementAndGet(); + } + catch (IgniteException e) { + // No-op. + } + catch (IOException e) { + err.compareAndSet(null, e); + + Throwable[] chain = X.getThrowables(e); + + Throwable cause = chain[chain.length - 1]; + + System.out.println("Failed due to IOException exception. Cause:"); + cause.printStackTrace(System.out); + } + finally { + if (os != null) + try { + os.close(); + } + catch (IOException ioe) { + throw new IgniteException(ioe); + } + } + } + } + }, threadCnt); + + long startTime = U.currentTimeMillis(); + + while (err.get() == null + && createCtr.get() < 500 + && U.currentTimeMillis() - startTime < 60 * 1000) + U.sleep(100); + + stop.set(true); + + fut.get(); + + awaitFileClose(igfs.asSecondary(), FILE); + + if (err.get() != null) { + X.println("Test failed: rethrowing first error: " + err.get()); + + throw err.get(); + } + + checkFileContent(igfs, FILE, chunk); } /**