@Override public void updateTimetolive(QName serviceName, String endpoint, int timetolive) throws ServiceLocatorException, InterruptedException { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Updating expiring time to happen in " + timetolive + " seconds on endpoint " + endpoint + " for service " + serviceName + "..."); } if (timetolive < 0) { throw new WrongArgumentException("Time-to-live cannot be negative."); } if (timetolive == 0) { throw new WrongArgumentException("Time-to-live cannot be zero."); } RootNode rootNode = getBackend().connect(); ServiceNode serviceNode = rootNode.getServiceNode(serviceName); EndpointNode endpointNode = serviceNode.getEndPoint(endpoint); if (endpointNode.exists()) { endpointNode.setLive(true); endpointNode.setExpiryTime(new Date(System.currentTimeMillis() + timetolive * 1000), true); } else { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Unable to update endpoint expiring time for endpoint " + endpoint + " for service " + serviceName + " because it does not exist."); } throw new EndpointNotFoundException("Endpoint " + endpoint + " for service " + serviceName + " does not exist."); } }
@Override public void updateTimetolive(QName serviceName, String endpoint, int timetolive) throws ServiceLocatorException, InterruptedException { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Updating expiring time to happen in " + timetolive + " seconds on endpoint " + endpoint + " for service " + serviceName + "..."); } if (timetolive < 0) { throw new WrongArgumentException("Time-to-live cannot be negative."); } if (timetolive == 0) { throw new WrongArgumentException("Time-to-live cannot be zero."); } RootNode rootNode = getBackend().connect(); ServiceNode serviceNode = rootNode.getServiceNode(serviceName); EndpointNode endpointNode = serviceNode.getEndPoint(endpoint); if (endpointNode.exists()) { endpointNode.setLive(true); endpointNode.setExpiryTime(new Date(System.currentTimeMillis() + timetolive * 1000), true); } else { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Unable to update endpoint expiring time for endpoint " + endpoint + " for service " + serviceName + " because it does not exist."); } throw new EndpointNotFoundException("Endpoint " + endpoint + " for service " + serviceName + " does not exist."); } }