Search in sources :

Example 1 with SbeStorageMetaData

use of org.deeplearning4j.ui.storage.impl.SbeStorageMetaData in project deeplearning4j by deeplearning4j.

the class TestRemoteReceiver method testRemoteBasic.

@Test
@Ignore
public void testRemoteBasic() throws Exception {
    List<Persistable> updates = new ArrayList<>();
    List<Persistable> staticInfo = new ArrayList<>();
    List<StorageMetaData> metaData = new ArrayList<>();
    CollectionStatsStorageRouter collectionRouter = new CollectionStatsStorageRouter(metaData, staticInfo, updates);
    UIServer s = UIServer.getInstance();
    s.enableRemoteListener(collectionRouter, false);
    RemoteUIStatsStorageRouter remoteRouter = new RemoteUIStatsStorageRouter("http://localhost:9000");
    SbeStatsReport update1 = new SbeStatsReport();
    update1.setDeviceCurrentBytes(new long[] { 1, 2 });
    update1.reportIterationCount(10);
    update1.reportIDs("sid", "tid", "wid", 123456);
    update1.reportPerformance(10, 20, 30, 40, 50);
    SbeStatsReport update2 = new SbeStatsReport();
    update2.setDeviceCurrentBytes(new long[] { 3, 4 });
    update2.reportIterationCount(20);
    update2.reportIDs("sid2", "tid2", "wid2", 123456);
    update2.reportPerformance(11, 21, 31, 40, 50);
    StorageMetaData smd1 = new SbeStorageMetaData(123, "sid", "typeid", "wid", "initTypeClass", "updaterTypeClass");
    StorageMetaData smd2 = new SbeStorageMetaData(456, "sid2", "typeid2", "wid2", "initTypeClass2", "updaterTypeClass2");
    SbeStatsInitializationReport init1 = new SbeStatsInitializationReport();
    init1.reportIDs("sid", "wid", "tid", 3145253452L);
    init1.reportHardwareInfo(1, 2, 3, 4, null, null, "2344253");
    remoteRouter.putUpdate(update1);
    Thread.sleep(100);
    remoteRouter.putStorageMetaData(smd1);
    Thread.sleep(100);
    remoteRouter.putStaticInfo(init1);
    Thread.sleep(100);
    remoteRouter.putUpdate(update2);
    Thread.sleep(100);
    remoteRouter.putStorageMetaData(smd2);
    Thread.sleep(2000);
    assertEquals(2, metaData.size());
    assertEquals(2, updates.size());
    assertEquals(1, staticInfo.size());
    assertEquals(Arrays.asList(update1, update2), updates);
    assertEquals(Arrays.asList(smd1, smd2), metaData);
    assertEquals(Collections.singletonList(init1), staticInfo);
}
Also used : StorageMetaData(org.deeplearning4j.api.storage.StorageMetaData) SbeStorageMetaData(org.deeplearning4j.ui.storage.impl.SbeStorageMetaData) Persistable(org.deeplearning4j.api.storage.Persistable) SbeStatsInitializationReport(org.deeplearning4j.ui.stats.impl.SbeStatsInitializationReport) SbeStatsReport(org.deeplearning4j.ui.stats.impl.SbeStatsReport) UIServer(org.deeplearning4j.ui.api.UIServer) ArrayList(java.util.ArrayList) CollectionStatsStorageRouter(org.deeplearning4j.api.storage.impl.CollectionStatsStorageRouter) RemoteUIStatsStorageRouter(org.deeplearning4j.api.storage.impl.RemoteUIStatsStorageRouter) SbeStorageMetaData(org.deeplearning4j.ui.storage.impl.SbeStorageMetaData) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with SbeStorageMetaData

use of org.deeplearning4j.ui.storage.impl.SbeStorageMetaData in project deeplearning4j by deeplearning4j.

the class TestStorageMetaData method testStorageMetaData.

@Test
public void testStorageMetaData() {
    Serializable extraMeta = "ExtraMetaData";
    long timeStamp = 123456;
    StorageMetaData m = new SbeStorageMetaData(timeStamp, "sessionID", "typeID", "workerID", "org.some.class.InitType", "org.some.class.UpdateType", extraMeta);
    byte[] bytes = m.encode();
    StorageMetaData m2 = new SbeStorageMetaData();
    m2.decode(bytes);
    assertEquals(m, m2);
    assertArrayEquals(bytes, m2.encode());
    //Sanity check: null values
    m = new SbeStorageMetaData(0, null, null, null, null, (String) null);
    bytes = m.encode();
    m2 = new SbeStorageMetaData();
    m2.decode(bytes);
    //In practice, we don't want these things to ever be null anyway...
    assertNullOrZeroLength(m2.getSessionID());
    assertNullOrZeroLength(m2.getTypeID());
    assertNullOrZeroLength(m2.getWorkerID());
    assertNullOrZeroLength(m2.getInitTypeClass());
    assertNullOrZeroLength(m2.getUpdateTypeClass());
    assertArrayEquals(bytes, m2.encode());
}
Also used : StorageMetaData(org.deeplearning4j.api.storage.StorageMetaData) SbeStorageMetaData(org.deeplearning4j.ui.storage.impl.SbeStorageMetaData) Serializable(java.io.Serializable) SbeStorageMetaData(org.deeplearning4j.ui.storage.impl.SbeStorageMetaData) Test(org.junit.Test)

Aggregations

StorageMetaData (org.deeplearning4j.api.storage.StorageMetaData)2 SbeStorageMetaData (org.deeplearning4j.ui.storage.impl.SbeStorageMetaData)2 Test (org.junit.Test)2 Serializable (java.io.Serializable)1 ArrayList (java.util.ArrayList)1 Persistable (org.deeplearning4j.api.storage.Persistable)1 CollectionStatsStorageRouter (org.deeplearning4j.api.storage.impl.CollectionStatsStorageRouter)1 RemoteUIStatsStorageRouter (org.deeplearning4j.api.storage.impl.RemoteUIStatsStorageRouter)1 UIServer (org.deeplearning4j.ui.api.UIServer)1 SbeStatsInitializationReport (org.deeplearning4j.ui.stats.impl.SbeStatsInitializationReport)1 SbeStatsReport (org.deeplearning4j.ui.stats.impl.SbeStatsReport)1 Ignore (org.junit.Ignore)1