@Override public void destroyKnownAgentClient(Agent agent) { AgentClient agent_client; // first see if its already cached, if not we need to create one synchronized (m_knownAgentClients) { String agent_address = agent.getAddress(); int agent_port = agent.getPort(); agent_client = m_knownAgentClients.remove(getEndpointKey(agent_address, agent_port)); if (agent_client != null) { agent_client.stopSending(); } // purge the spool file, if it exists File spool_file = null; try { ClientCommandSenderConfiguration sender_config = getSenderConfiguration(agent); if (sender_config.commandSpoolFileName != null) { spool_file = new File(sender_config.dataDirectory, sender_config.commandSpoolFileName); if (spool_file.exists()) { // first truncate it, in case Windows is locking it; then try to delete new FileOutputStream(spool_file, false).close(); spool_file.delete(); } } } catch (Exception e) { LOG.warn("Failed to truncate/delete spool for deleted agent [" + agent + "]" + " please manually remove the file: " + spool_file, e); } } return; }
int agent_port = agent.getPort();