@Test public void testTcpTcMaxRate() throws ConfigurationException, InterruptedException, IOException { int ncommands = 20; int tcMaxRate = 2; Map<String, Object> config = new HashMap<>(); config.put("tcMaxRate", tcMaxRate); config.put("tcQueueSize", ncommands); config.put("tcHost", "localhost"); config.put("tcPort", mtc.port); config.put("commandPostprocessorClassName", GenericCommandPostprocessor.class.getName()); TcpTcDataLink dataLink = new TcpTcDataLink(); dataLink.init("testinst", "test1", YConfiguration.wrap(config)); Semaphore semaphore = new Semaphore(0); MyPublisher mypub = new MyPublisher(semaphore); dataLink.setCommandHistoryPublisher(mypub); dataLink.startAsync(); dataLink.awaitRunning(); for (int i = 1; i <= ncommands; i++) { dataLink.sendTc(getCommand(i)); } assertTrue(semaphore.tryAcquire(ncommands, 10, TimeUnit.SECONDS)); assertTrue("Number of commands sent is smaller than queue size: ", mypub.successful.size() >= ncommands); for (int i = 5; i < mypub.successful.size() - tcMaxRate; i++) { int seq1 = mypub.successful.get(i); int seq2 = mypub.successful.get(i + tcMaxRate); long gap = mypub.sentTime.get(seq2) - mypub.sentTime.get(seq1); assertTrue("gap is not right: " + gap, gap >= 850 && gap < 1150); } dataLink.stopAsync(); }
public void init(String yamcsInstance, String name, YConfiguration config) throws ConfigurationException { super.init(yamcsInstance, name, config); configure(yamcsInstance, config); timeService = YamcsServer.getTimeService(yamcsInstance); }
TcpTcDataLink extends AbstractThreadedTcDataLink { public void init(String yamcsInstance, String name, YConfiguration config) throws ConfigurationException { super.init(yamcsInstance, name, config); configure(yamcsInstance, config); timeService = YamcsServer.getTimeService(yamcsInstance); } }
TcpTcDataLink extends AbstractThreadedTcDataLink { public void init(String yamcsInstance, String name, YConfiguration config) throws ConfigurationException { super.init(yamcsInstance, name, config); configure(yamcsInstance, config); timeService = YamcsServer.getTimeService(yamcsInstance); }  }
TcpTcDataLink extends AbstractThreadedTcDataLink { public void init(String yamcsInstance, String name, YConfiguration config) throws ConfigurationException { super.init(yamcsInstance, name, config); configure(yamcsInstance, config); timeService = YamcsServer.getTimeService(yamcsInstance); }  void init(String yamcsInstance, String name, YConfiguration config); @Override String getDetailedStatus(); @Override void shutDown(); @Override void uplinkCommand(PreparedCommand pc); }
TcpTcDataLink extends AbstractThreadedTcDataLink { public void init(String yamcsInstance, String name, YConfiguration config) throws ConfigurationException { super.init(yamcsInstance, name, config); configure(yamcsInstance, config); timeService = YamcsServer.getTimeService(yamcsInstance); }  void init(String yamcsInstance, String name, YConfiguration config); @Override String getDetailedStatus(); @Override void shutDown(); @Override void uplinkCommand(PreparedCommand pc);  }