InternalConfigurationPersistenceService implements ConfigurationPersistenceService { boolean removeInvalidGatewayReceivers(Document document) throws TransformerException { boolean modified = false; NodeList receiverNodes = document.getElementsByTagName("gateway-receiver"); for (int i = receiverNodes.getLength() - 1; i >= 0; i--) { Element receiverElement = (Element) receiverNodes.item(i); String hostNameForSenders = receiverElement.getAttribute("hostname-for-senders"); if (StringUtils.isNotBlank(hostNameForSenders)) { receiverElement.getParentNode().removeChild(receiverElement); logger.info("Removed invalid cluster configuration gateway-receiver element=" + XmlUtils.prettyXml(receiverElement)); modified = true; } String bindAddress = receiverElement.getAttribute("bind-address"); if (StringUtils.isNotBlank(bindAddress) && !bindAddress.equals("0.0.0.0")) { receiverElement.getParentNode().removeChild(receiverElement); logger.info("Removed invalid cluster configuration gateway-receiver element=" + XmlUtils.prettyXml(receiverElement)); modified = true; } } return modified; } InternalConfigurationPersistenceService(InternalCache cache, Path workingDirectory,
      JAXBService jaxbService); @VisibleForTesting  InternalConfigurationPersistenceService(JAXBService jaxbService); @VisibleForTesting  InternalConfigurationPersistenceService(InternalCache cache,
      DistributedLockService sharedConfigLockingService, JAXBService jaxbService,
      Path configDirPath, Path configDiskDirPath); JAXBService getJaxbService(); void addXmlEntity(XmlEntity xmlEntity, String[] groups); void deleteXmlEntity(XmlEntity xmlEntity, String[] groups); void modifyXmlAndProperties(Properties properties, XmlEntity xmlEntity, String[] groups); void addJarsToThisLocator(List<String> jarFullPaths, String[] groups); boolean removeJars(String[] jarNames, String[] groups); void downloadJarFromOtherLocators(String groupName, String jarName); void downloadJarFromLocator(String groupName, String jarName,
      DistributedMember sourceLocator); File downloadJar(DistributedMember locator, String groupName, String jarName); ConfigurationResponse createConfigurationResponse(Set<String> groups); void destroySharedConfiguration(); Path getPathToJarOnThisLocator(String groupName, String jarName); Configuration getConfiguration(String groupName); void setConfiguration(String groupName, Configuration configuration); boolean hasXmlConfiguration(); Map<String, Configuration> getEntireConfiguration(); Set<String> getGroups(); Path getClusterConfigDirPath(); SharedConfigurationStatus getStatus(); void loadSharedConfigurationFromDir(File configDir); void writeConfigToFile(Configuration configuration, File rootDir); boolean lockSharedConfiguration(); void unlockSharedConfiguration(); Region<String, Configuration> getConfigurationRegion(); @Override CacheConfig getCacheConfig(String group); @Override CacheConfig getCacheConfig(String group, boolean createNew); @Override void updateCacheConfig(String group, UnaryOperator<CacheConfig> mutator); static final String CLUSTER_CONFIG_ARTIFACTS_DIR_NAME; static final String CLUSTER_CONFIG_DISK_DIR_PREFIX; static final String CONFIG_REGION_NAME; }
@Test public void removeInvalidGatewayReceiversWithDifferentHostNameForSenders() throws Exception { Document document = XmlUtils.createDocumentFromXml(getDuplicateReceiversWithDifferentHostNameForSendersXml()); System.out .println("Initial document:" + System.lineSeparator() + "" + XmlUtils.prettyXml(document)); assertThat(document.getElementsByTagName("gateway-receiver").getLength()).isEqualTo(2); service.removeInvalidGatewayReceivers(document); System.out.println( "Processed document:" + System.lineSeparator() + "" + XmlUtils.prettyXml(document)); assertThat(document.getElementsByTagName("gateway-receiver").getLength()).isEqualTo(0); }
@Test public void removeInvalidGatewayReceiversWithDifferentBindAddresses() throws Exception { Document document = XmlUtils.createDocumentFromXml(getDuplicateReceiversWithDifferentBindAddressesXml()); System.out .println("Initial document:" + System.lineSeparator() + "" + XmlUtils.prettyXml(document)); assertThat(document.getElementsByTagName("gateway-receiver").getLength()).isEqualTo(2); service.removeInvalidGatewayReceivers(document); System.out.println( "Processed document:" + System.lineSeparator() + "" + XmlUtils.prettyXml(document)); assertThat(document.getElementsByTagName("gateway-receiver").getLength()).isEqualTo(0); }
@Test public void keepValidGatewayReceiversWithDefaultBindAddress() throws Exception { Document document = XmlUtils.createDocumentFromXml(getSingleReceiverWithDefaultBindAddressXml()); System.out .println("Initial document:" + System.lineSeparator() + "" + XmlUtils.prettyXml(document)); assertThat(document.getElementsByTagName("gateway-receiver").getLength()).isEqualTo(1); service.removeInvalidGatewayReceivers(document); System.out.println( "Processed document:" + System.lineSeparator() + "" + XmlUtils.prettyXml(document)); assertThat(document.getElementsByTagName("gateway-receiver").getLength()).isEqualTo(1); }