Search in sources :

Example 1 with Storage

use of org.nd4j.parameterserver.distributed.logic.Storage in project nd4j by deeplearning4j.

the class FrameTest method testFrame1.

/**
 * Simple test for Frame functionality
 */
@Test
public void testFrame1() {
    final AtomicInteger count = new AtomicInteger(0);
    Frame<TrainingMessage> frame = new Frame<>();
    for (int i = 0; i < 10; i++) {
        frame.stackMessage(new TrainingMessage() {

            @Override
            public byte getCounter() {
                return 2;
            }

            @Override
            public void setTargetId(short id) {
            }

            @Override
            public int getRetransmitCount() {
                return 0;
            }

            @Override
            public void incrementRetransmitCount() {
            }

            @Override
            public long getFrameId() {
                return 0;
            }

            @Override
            public void setFrameId(long frameId) {
            }

            @Override
            public long getOriginatorId() {
                return 0;
            }

            @Override
            public void setOriginatorId(long id) {
            }

            @Override
            public short getTargetId() {
                return 0;
            }

            @Override
            public long getTaskId() {
                return 0;
            }

            @Override
            public int getMessageType() {
                return 0;
            }

            @Override
            public byte[] asBytes() {
                return new byte[0];
            }

            @Override
            public UnsafeBuffer asUnsafeBuffer() {
                return null;
            }

            @Override
            public void attachContext(VoidConfiguration voidConfiguration, TrainingDriver<? extends TrainingMessage> trainer, Clipboard clipboard, Transport transport, Storage storage, NodeRole role, short shardIndex) {
            // no-op intentionally
            }

            @Override
            public void extractContext(BaseVoidMessage message) {
            // no-op intentionally
            }

            @Override
            public void processMessage() {
                count.incrementAndGet();
            }

            @Override
            public boolean isJoinSupported() {
                return false;
            }

            @Override
            public void joinMessage(VoidMessage message) {
            // no-op
            }

            @Override
            public boolean isBlockingMessage() {
                return false;
            }
        });
    }
    assertEquals(10, frame.size());
    frame.processMessage();
    assertEquals(20, count.get());
}
Also used : VoidConfiguration(org.nd4j.parameterserver.distributed.conf.VoidConfiguration) NodeRole(org.nd4j.parameterserver.distributed.enums.NodeRole) Storage(org.nd4j.parameterserver.distributed.logic.Storage) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Clipboard(org.nd4j.parameterserver.distributed.logic.completion.Clipboard) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) Transport(org.nd4j.parameterserver.distributed.transport.Transport) Test(org.junit.Test)

Aggregations

AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 UnsafeBuffer (org.agrona.concurrent.UnsafeBuffer)1 Test (org.junit.Test)1 VoidConfiguration (org.nd4j.parameterserver.distributed.conf.VoidConfiguration)1 NodeRole (org.nd4j.parameterserver.distributed.enums.NodeRole)1 Storage (org.nd4j.parameterserver.distributed.logic.Storage)1 Clipboard (org.nd4j.parameterserver.distributed.logic.completion.Clipboard)1 Transport (org.nd4j.parameterserver.distributed.transport.Transport)1