startMessage = null;
m_connectionPort = 0;
m_state = AgentControllerState.UPDATING;
final AgentUpdateGrinderMessage message = m_agentControllerServerListener.getLastAgentUpdateGrinderMessage();
m_agentControllerServerListener.discardMessages(AgentControllerServerListener.AGENT_UPDATE);
AgentDownloadGrinderMessage agentDownloadGrinderMessage = new AgentDownloadGrinderMessage(message.getVersion());
try {
// If it's initial message
if (agentUpdateHandler == null && message.getNext() == 0) {
IOUtils.closeQuietly(agentUpdateHandler);
agentUpdateHandler = new AgentUpdateHandler(agentConfig, message);
} else if (agentUpdateHandler != null) {
if (message.isValid()) {
retryCount = 0;
agentUpdateHandler.update(message);
agentDownloadGrinderMessage.setNext(message.getNext());
} else if (retryCount <= AgentDownloadGrinderMessage.MAX_RETRY_COUNT) {
retryCount++;
agentDownloadGrinderMessage.setNext(message.getOffset());
} else {
throw new CommunicationException("Error while getting the agent package from " +
"controller");
}
} else {