/** * If the new slice is a LoadServiceSlice notify it about the current state. * * @param cmd the VerticalCommand */ private void handleNewSlice(VerticalCommand cmd) { if (cmd.getService().equals(NAME)) { // --- We ARE in the Main-Container !!! ---------------------------------------- Object[] params = cmd.getParams(); String newSliceName = (String) params[0]; try { // --- Is this the slice, we have waited for? ------------------------------ loadInfo.setNewContainerStarted(newSliceName); // --- Be sure to get the new (fresh) slice --> Bypass the service cache --- LoadServiceSlice newSlice = (LoadServiceSlice) getFreshSlice(newSliceName); // --- Set the local ThresholdLevels to the new container ------------------ newSlice.setThresholdLevels(LoadMeasureThread.getThresholdLevels()); } catch (ServiceException | IMTPException t) { logger.error( "Error notifying new slice " + newSliceName + " about current LoadService-State", t); } } }
/** * Broadcast the set of threshold levels to all container. * * @param slices the slices * @param thresholdLevels the threshold levels * @throws ServiceException the service exception */ private void broadcastThresholdLevels(Service.Slice[] slices, LoadThresholdLevels thresholdLevels) throws ServiceException { loadInfo.containerLoads.clear(); logger.debug("Try to set threshold level to all Containers !"); for (int i = 0; i < slices.length; i++) { String sliceName = null; try { LoadServiceSlice slice = (LoadServiceSlice) slices[i]; sliceName = slice.getNode().getName(); logger.debug("Try to set threshold level to " + sliceName); slice.setThresholdLevels(thresholdLevels); } catch (ServiceException | IMTPException t) { // NOTE that slices are always retrieved from the main and not from the cache --> No need to // retry in case of failure logger.warn("Error while try to set threshold level to slice " + sliceName, t); } } }