private InstanceState checkIn(){
  final InstanceState state;
  try {
    logger.debug("Getting instance state for {}",instanceId);
    state=getInstanceState(instanceId);
  }
 catch (  ResourceException e) {
    logger.info("Error retrieving instance state for {}",instanceId);
    return null;
  }
  try {
    if (firstCheckin) {
      state.updateStartup();
      state.clearShutdown();
      firstCheckin=false;
    }
switch (state.getState()) {
case InstanceState.STATE_RUNNING:
      state.updateTimestamp();
    break;
case InstanceState.STATE_DOWN:
  state.setState(InstanceState.STATE_RUNNING);
logger.debug("Instance {} state changing from {} to {}",instanceId,InstanceState.STATE_DOWN,InstanceState.STATE_RUNNING);
state.updateTimestamp();
break;
case InstanceState.STATE_PROCESSING_DOWN:
logger.debug("Instance {} is in state {}, waiting for recovery attempt to finish",instanceId,state.getState());
return state;
}
updateInstanceState(instanceId,state);
logger.debug("Instance {} state updated successfully",instanceId);
}
 catch (ResourceException e) {
if (e.getCode() != ResourceException.CONFLICT) {
logger.warn("Error updating instance timestamp",e);
}
 else {
logger.info("Failed to set this instance state to {}",state.getState());
return null;
}
}
return state;
}

private InstanceState checkIn ( ) { final InstanceState state ; try { logger . debug ( "Getting instance state for {}" , instanceId ) ; state = getInstanceState ( instanceId ) ; } catch ( ResourceException e ) { logger . info ( "Error retrieving instance state for {}" , instanceId ) ; return null ; } try { if ( firstCheckin ) { state . updateStartup ( ) ; state . clearShutdown ( ) ; firstCheckin = false ; } switch ( state . getState ( ) ) { case InstanceState . STATE_RUNNING : state . updateTimestamp ( ) ; break ; case InstanceState . STATE_DOWN : state . setState ( InstanceState . STATE_RUNNING ) ; logger . debug ( "Instance {} state changing from {} to {}" , instanceId , InstanceState . STATE_DOWN , InstanceState . STATE_RUNNING ) ; state . updateTimestamp ( ) ; break ; case InstanceState . STATE_PROCESSING_DOWN : logger . debug ( "Instance {} is in state {}, waiting for recovery attempt to finish" , instanceId , state . getState ( ) ) ; return state ; } updateInstanceState ( instanceId , state ) ; logger . debug ( "Instance {} state updated successfully" , instanceId ) ; } catch ( ResourceException e ) { if ( e . getCode ( ) != ResourceException . CONFLICT ) { logger . warn ( "Error updating instance timestamp" , e ) ; } else { logger . info ( "Failed to set this instance state to {}" , state . getState ( ) ) ; return null ; } } return state ; }
updates the timestamp for this instance in the instance check - in map .
