@Override public void removeManagerEndpoint(String endpoint_json) { VnfmManagerEndpoint endpoint = gson.fromJson(endpoint_json, VnfmManagerEndpoint.class); log.debug("Unregistering: " + endpoint); // TODO double check that the equals is done on all parameters.. for (VnfmManagerEndpoint vnfmManagerEndpoint : vnfmEndpointRepository.findAll()) if (vnfmManagerEndpoint.getEndpoint().equals(endpoint.getEndpoint())) { this.unregister(vnfmManagerEndpoint); break; } }
@Override public void register(VnfmManagerEndpoint endpoint) throws AlreadyExistingException { log.debug("Persisting: " + endpoint); for (VnfmManagerEndpoint endpointExisting : vnfmEndpointRepository.findAll()) { // TODO: decide whether the type or the endpoint (or both) is the unique identifier. strategy // here is different than in unregister function if (endpointExisting.getEndpoint().equals(endpoint.getEndpoint()) && endpointExisting.getType().equals(endpoint.getType()) && endpointExisting.getEndpointType().equals(endpoint.getEndpointType())) throw new AlreadyExistingException( "VnfmManagerEndpoint " + endpoint + " already exists in the DB"); } endpoint.setActive(true); this.vnfmEndpointRepository.save(endpoint); }
@Scheduled(initialDelay = 30000, fixedDelay = 20000) public void checkHeartBeat() { for (VnfmManagerEndpoint endpoint : vnfmEndpointRepository.findAll()) { if (endpoint.getEndpointType().ordinal() == EndpointType.RABBIT.ordinal()) { if (endpoint.isEnabled()) { try { if (!RabbitManager.getQueues( brokerIp.trim(), username, password, virtualHost, managementPort) .contains(endpoint.getEndpoint())) { if (endpoint.isActive()) { log.info("Set endpoint " + endpoint.getType() + " to unactive"); endpoint.setActive(false); vnfmEndpointRepository.save(endpoint); } } else { if (!endpoint.isActive()) { log.info("Set endpoint " + endpoint.getType() + " to active"); endpoint.setActive(true); vnfmEndpointRepository.save(endpoint); } } } catch (IOException ignored) { log.warn("Not able to list queues, probably " + brokerIp.trim() + " is not reachable."); } } } } } }
if (endpoint.isEnabled()) { try { URL url = new URL(endpoint.getEndpoint()); if (!pingHost(url.getHost(), url.getPort(), 2)) { if (endpoint.isActive()) { log.warn("Not able to check endpoint: " + endpoint.getEndpoint()); endpoint.setActive(false); vnfmEndpointRepository.save(endpoint);