diff --git a/cavis-nd4j/cavis-nd4j-aeron/src/main/java/org/nd4j/aeron/ipc/AeronNDArraySubscriber.java b/cavis-nd4j/cavis-nd4j-aeron/src/main/java/org/nd4j/aeron/ipc/AeronNDArraySubscriber.java index 204893e97..0b554093a 100644 --- a/cavis-nd4j/cavis-nd4j-aeron/src/main/java/org/nd4j/aeron/ipc/AeronNDArraySubscriber.java +++ b/cavis-nd4j/cavis-nd4j-aeron/src/main/java/org/nd4j/aeron/ipc/AeronNDArraySubscriber.java @@ -51,7 +51,7 @@ public class AeronNDArraySubscriber implements AutoCloseable { // Create a context, needed for client connection to media driver // A separate media driver process need to run prior to running this application private Aeron.Context ctx; - private AtomicBoolean running = new AtomicBoolean(true); + private AtomicBoolean running; private final AtomicBoolean init = new AtomicBoolean(false); private NDArrayCallback ndArrayCallback; diff --git a/cavis-nd4j/cavis-nd4j-aeron/src/test/java/org/nd4j/aeron/ipc/LargeNdArrayIpcTest.java b/cavis-nd4j/cavis-nd4j-aeron/src/test/java/org/nd4j/aeron/ipc/LargeNdArrayIpcTest.java index 85ec9f01b..de0f74356 100644 --- a/cavis-nd4j/cavis-nd4j-aeron/src/test/java/org/nd4j/aeron/ipc/LargeNdArrayIpcTest.java +++ b/cavis-nd4j/cavis-nd4j-aeron/src/test/java/org/nd4j/aeron/ipc/LargeNdArrayIpcTest.java @@ -72,18 +72,23 @@ public class LargeNdArrayIpcTest extends BaseND4JTest { INDArray arr = Nd4j.ones(length); AeronNDArrayPublisher publisher; ctx = new Aeron.Context() - .driverTimeoutMs(10000).availableImageHandler(AeronUtil::printAvailableImage) - .unavailableImageHandler(AeronUtil::printUnavailableImage) - .aeronDirectoryName(mediaDriver.aeronDirectoryName()) - .errorHandler(err -> err.printStackTrace()); + .driverTimeoutMs(10000) + .availableImageHandler(AeronUtil::printAvailableImage) + .unavailableImageHandler(AeronUtil::printUnavailableImage) + .aeronDirectoryName(mediaDriver.aeronDirectoryName()) + .errorHandler(err -> err.printStackTrace()); final AtomicBoolean running = new AtomicBoolean(true); Aeron aeron = Aeron.connect(ctx); int numSubscribers = 1; AeronNDArraySubscriber[] subscribers = new AeronNDArraySubscriber[numSubscribers]; for (int i = 0; i < numSubscribers; i++) { - AeronNDArraySubscriber subscriber = AeronNDArraySubscriber.builder().streamId(streamId).ctx(getContext()) - .channel(channel).aeron(aeron).running(running).ndArrayCallback(new NDArrayCallback() { + AeronNDArraySubscriber subscriber = AeronNDArraySubscriber.builder() + .streamId(streamId).ctx(getContext()) + .channel(channel) + .aeron(aeron) + .running(running) + .ndArrayCallback(new NDArrayCallback() { /** * A listener for ndarray message * @@ -110,7 +115,8 @@ public class LargeNdArrayIpcTest extends BaseND4JTest { try { subscriber.launch(); } catch (Exception e) { - log.error("",e); + System.out.println(e.getMessage()); + e.printStackTrace(); } }); @@ -122,17 +128,23 @@ public class LargeNdArrayIpcTest extends BaseND4JTest { Thread.sleep(1000); - publisher = AeronNDArrayPublisher.builder().publishRetryTimeOut(3000).streamId(streamId).channel(channel) - .aeron(aeron).build(); + publisher = AeronNDArrayPublisher.builder() + .publishRetryTimeOut(3000) + .streamId(streamId) + .channel(channel) + .aeron(aeron) + .build(); - for (int i = 0; i < 1 && running.get(); i++) { - log.info("About to send array."); + for (int i = 0; i < 1; i++) { + System.out.println("About to send array."); publisher.publish(arr); - log.info("Sent array"); + System.out.println("Sent array"); } + Thread.sleep( 5000); + for (int i = 0; i < numSubscribers; i++) CloseHelper.close(subscribers[i]); CloseHelper.close(aeron); diff --git a/cavis-nd4j/cavis-nd4j-common/build.gradle b/cavis-nd4j/cavis-nd4j-common/build.gradle index e801f3b5c..b58257047 100644 --- a/cavis-nd4j/cavis-nd4j-common/build.gradle +++ b/cavis-nd4j/cavis-nd4j-common/build.gradle @@ -18,6 +18,7 @@ * ***************************************************************************** * */ +apply from: "${project.rootProject.projectDir}/createTestBackends.gradle" dependencies { implementation "com.fasterxml.jackson.core:jackson-databind" @@ -29,4 +30,5 @@ dependencies { implementation "org.apache.commons:commons-compress" implementation "commons-codec:commons-codec" testImplementation projects.cavisNd4j.cavisNd4jCommonTests + testRuntimeOnly "net.brutex.ai:dl4j-test-resources:1.0.1-SNAPSHOT" } \ No newline at end of file diff --git a/cavis-nd4j/cavis-nd4j-common/src/test/java/org/nd4j/common/io/ClassPathResourceTest.java b/cavis-nd4j/cavis-nd4j-common/src/test/java/org/nd4j/common/io/ClassPathResourceTest.java index 9e1591f82..3e5f8bf72 100644 --- a/cavis-nd4j/cavis-nd4j-common/src/test/java/org/nd4j/common/io/ClassPathResourceTest.java +++ b/cavis-nd4j/cavis-nd4j-common/src/test/java/org/nd4j/common/io/ClassPathResourceTest.java @@ -24,9 +24,11 @@ package org.nd4j.common.io; import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import org.nd4j.common.io.ClassPathResource; import java.io.File; +import java.nio.file.Path; import java.util.UUID; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -36,13 +38,12 @@ public class ClassPathResourceTest { @Test - public void testDirExtractingIntelliJ() throws Exception { + public void testDirExtractingIntelliJ(@TempDir Path tempDir) throws Exception { //https://github.com/deeplearning4j/deeplearning4j/issues/6483 ClassPathResource cpr = new ClassPathResource("somedir"); - File f = new File(FileUtils.getTempDirectoryPath()+File.separatorChar+ UUID.randomUUID().toString()); - FileUtils.forceMkdir(f); + File f = tempDir.toFile(); cpr.copyDirectory(f); File[] files = f.listFiles(); diff --git a/cavis-nd4j/cavis-nd4j-parameter-server/cavis-nd4j-parameter-server-core/src/main/java/org/nd4j/parameterserver/ParameterServerSubscriber.java b/cavis-nd4j/cavis-nd4j-parameter-server/cavis-nd4j-parameter-server-core/src/main/java/org/nd4j/parameterserver/ParameterServerSubscriber.java index 6aaca2e49..b32e97147 100644 --- a/cavis-nd4j/cavis-nd4j-parameter-server/cavis-nd4j-parameter-server-core/src/main/java/org/nd4j/parameterserver/ParameterServerSubscriber.java +++ b/cavis-nd4j/cavis-nd4j-parameter-server/cavis-nd4j-parameter-server-core/src/main/java/org/nd4j/parameterserver/ParameterServerSubscriber.java @@ -325,7 +325,7 @@ public class ParameterServerSubscriber implements AutoCloseable { int tries=0; while (!subscriber.launched() && tries<12) { tries++; - LockSupport.parkNanos(100000); + Thread.sleep(1000); } if(!subscriber.launched()) { throw new Exception("Subscriber did not start in time."); diff --git a/nd4j/pom.xml b/nd4j/pom.xml index 8dfe09d06..33f87c4b3 100644 --- a/nd4j/pom.xml +++ b/nd4j/pom.xml @@ -1,22 +1,23 @@