ManagedApplication { public void acknowledgeHeartBeat( Instance scopedInstance ) { String count = scopedInstance.data.get( MISSED_HEARTBEATS ); if( count != null && Integer.parseInt( count ) > THRESHOLD ) this.logger.info( "Agent " + InstanceHelpers.computeInstancePath( scopedInstance ) + " is alive and reachable again." ); if( scopedInstance.getStatus() != InstanceStatus.DEPLOYED_STARTED || ! scopedInstance.data.containsKey( Instance.RUNNING_FROM )) scopedInstance.data.put( Instance.RUNNING_FROM, String.valueOf( new Date().getTime())); scopedInstance.setStatus( InstanceStatus.DEPLOYED_STARTED ); scopedInstance.data.remove( MISSED_HEARTBEATS ); } ManagedApplication( Application application ); Map<Instance,List<Message>> getScopedInstanceToAwaitingMessages(); Application getApplication(); File getDirectory(); String getName(); Graphs getGraphs(); File getTemplateDirectory(); @Override String toString(); void storeAwaitingMessage( Instance instance, Message msg ); List<Message> removeAwaitingMessages( Instance instance ); void acknowledgeHeartBeat( Instance scopedInstance ); void checkStates( INotificationMngr notificationMngr );  }
@Test public void testAcknowledgeHeartBeat() { Assert.assertNull( this.app.getMySqlVm().data.get( Instance.RUNNING_FROM )); Assert.assertNull( this.app.getMySqlVm().data.get( ManagedApplication.MISSED_HEARTBEATS )); this.ma.acknowledgeHeartBeat( this.app.getMySqlVm()); Assert.assertNull( this.app.getMySqlVm().data.get( ManagedApplication.MISSED_HEARTBEATS )); String time = this.app.getMySqlVm().data.get( Instance.RUNNING_FROM ); Assert.assertNotNull( time ); this.app.getMySqlVm().setStatus( InstanceStatus.DEPLOYED_STARTED ); this.ma.acknowledgeHeartBeat( this.app.getMySqlVm()); Assert.assertEquals( InstanceStatus.DEPLOYED_STARTED, this.app.getMySqlVm().getStatus()); Assert.assertNull( this.app.getMySqlVm().data.get( ManagedApplication.MISSED_HEARTBEATS )); String otherTime = this.app.getMySqlVm().data.get( Instance.RUNNING_FROM ); Assert.assertNotNull( otherTime ); Assert.assertEquals( time, otherTime ); this.app.getMySqlVm().setStatus( InstanceStatus.PROBLEM ); this.ma.acknowledgeHeartBeat( this.app.getMySqlVm()); Assert.assertEquals( InstanceStatus.DEPLOYED_STARTED, this.app.getMySqlVm().getStatus()); Assert.assertNull( this.app.getMySqlVm().data.get( ManagedApplication.MISSED_HEARTBEATS )); this.app.getMySqlVm().setStatus( InstanceStatus.PROBLEM ); this.app.getMySqlVm().data.put( ManagedApplication.MISSED_HEARTBEATS, "5" ); this.ma.acknowledgeHeartBeat( this.app.getMySqlVm()); Assert.assertEquals( InstanceStatus.DEPLOYED_STARTED, this.app.getMySqlVm().getStatus()); Assert.assertNull( this.app.getMySqlVm().data.get( ManagedApplication.MISSED_HEARTBEATS )); }