Package gov.nasa.arc.mct.gui.FeedView

Examples of gov.nasa.arc.mct.gui.FeedView.SynchronizationControl


        activeFeedViews.remove(manifestation);
    }
   
    public SynchronizationControl synchronizeTime(final long syncTime) {
        final Set<FeedView> syncedManifestations = new HashSet<FeedView>();
         SynchronizationControl sc = new SynchronizationControl() {
             @Override
            public void update(long syncTime) {
                 /* Assume the "time" is uniform across all providers, this is a limitation that needs to
                  * removed when feeds (non ISP) are added. One way to do this is to pass the time
                  * service along with the time to get offsets between the various time services. For
                  * example, TimeServiceA - 4, TimeServiceB - 2, then if time 3 was passed along with
                  * TimeServiceA then the offset to TimeServiceB would be (2 - 4) = -2 + time to get the
                  * time from TimeServiceB.
                  */
                 Map<FeedProvider, Long[]> times = new HashMap<FeedProvider,Long[]>();
                 for (FeedView manifestation:activeFeedViews) {
                     for (FeedProvider provider:manifestation.getVisibleFeedProviders()) {
                         times.put(provider, new Long[]{syncTime-2000, syncTime});
                     }
                 }
                 FeedCycleRenderer renderer = createSyncWorker(syncTime, times, activeFeedViews, syncedManifestations);

                 try {
                     renderer.execute();
                 } catch (Exception e) {
                     LOGGER.error(e);
                 }
            }

            @Override
            public void synchronizationDone() {
                 activeSyncControl.set(null);
                 for(FeedView m : syncedManifestations) {
                    m.synchronizationDone();
                }
            }
         };
       
         if (!activeSyncControl.compareAndSet(null, sc)) {
             return null;
         }
        
        /* Assume the "time" is uniform across all providers, this is a limitation that needs to
         * removed when feeds (non ISP) are added. One way to do this is to pass the time
         * service along with the time to get offsets between the various time services. For
         * example, TimeServiceA - 4, TimeServiceB - 2, then if time 3 was passed along with
         * TimeServiceA then the offset to TimeServiceB would be (2 - 4) = -2 + time to get the
         * time from TimeServiceB.
         */
        Map<FeedProvider, Long[]> times = new HashMap<FeedProvider,Long[]>();
        for (FeedView manifestation:activeFeedViews) {
            for (FeedProvider provider:manifestation.getVisibleFeedProviders()) {
                times.put(provider, new Long[]{syncTime-2000, syncTime});
            }
        }
        FeedCycleRenderer renderer = createSyncWorker(syncTime, times, activeFeedViews, syncedManifestations);
       
        try {
            renderer.execute();
        } catch (Exception e) {
            LOGGER.error(e);
            sc.synchronizationDone();
            sc = null;
        }
       
        return sc;
    }
View Full Code Here


    }
   
    @Test
    public void testSynchronizeTime() {
        pool.addFeedView(fv1);
        SynchronizationControl sc =
            pool.synchronizeTime(System.currentTimeMillis() - 2);
        Assert.assertNotNull(sc);
        Assert.assertNull(pool.synchronizeTime(System.currentTimeMillis()));
        sc.synchronizationDone();
        Assert.assertNotNull(pool.synchronizeTime(System.currentTimeMillis()));
    }
View Full Code Here

TOP

Related Classes of gov.nasa.arc.mct.gui.FeedView.SynchronizationControl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.