/** * Returns the preferred host type for this forest. If * getAlternateHost() is not null, return ALTERNATE_HOST. Otherwise, if * getOpenReplicaHost() is not null, return OPEN_REPLICA_HOST. Otherwise, * if getRequestHost() is not null, return REQUEST_HOST. * Otherwise, return FOREST_HOST. * * @return the host type of the forest */ public default HostType getPreferredHostType() { if ( getAlternateHost() != null ) { return HostType.ALTERNATE_HOST; } else if ( getOpenReplicaHost() != null ) { return HostType.OPEN_REPLICA_HOST; } else if ( getRequestHost() != null ) { return HostType.REQUEST_HOST; } else { return HostType.FOREST_HOST; } } }
/** * Returns the host your application should talk to for this forest. If * getAlternateHost() is not null, return it. Otherwise, if * getOpenReplicaHost() is not null, return it. Otherwise, if * getRequestHost() is not null, return it. Otherwise, return getHost(). * * @return the preferred host for this forest */ public default String getPreferredHost() { if ( getAlternateHost() != null ) { return getAlternateHost(); } else if ( getOpenReplicaHost() != null ) { return getOpenReplicaHost(); } else if ( getRequestHost() != null ) { return getRequestHost(); } else { return getHost(); } }
for( Forest forest : existingFilteredForestConfiguration.listForests()) { if(forest.getPreferredHostType() == HostType.REQUEST_HOST && !forest.getHost().toLowerCase().equals(forest.getRequestHost().toLowerCase())) { if(preferredHostsList.contains(forest.getHost())) { preferredHostsList.remove(forest.getHost());
openReplicaHost = renames.get(openReplicaHost); String requestHost = forest.getRequestHost(); if ( requestHost != null ) requestHost = requestHost.toLowerCase(); if ( renames.containsKey(requestHost) ) { hostArray = new String[] {forest.getOpenReplicaHost(), forest.getAlternateHost()}; } else { hostArray = new String[] {forest.getHost(), forest.getOpenReplicaHost(), forest.getAlternateHost(), forest.getRequestHost()}; openReplicaHost = replaceHost(openReplicaHost, validHosts); String requestHost = forest.getRequestHost(); String host = forest.getHost(); if ( blackList.contains(requestHost) ) { openReplicaHost = replaceHost(openReplicaHost, validHosts); String requestHost = forest.getRequestHost(); if ( ! whiteList.contains(requestHost) ) { requestHost = replaceHost(requestHost, validHosts);
!forest.getHost().toLowerCase().equals(forest.getRequestHost().toLowerCase())) { if(hosts.containsKey(forest.getHost())) hosts.remove(forest.getHost());
assertEquals("alternatehost1", filteredForests[0].getPreferredHost()); assertEquals("openreplicahost1", filteredForests[0].getOpenReplicaHost()); assertEquals("requesthost1", filteredForests[0].getRequestHost()); assertEquals("alternatehost1", filteredForests[0].getAlternateHost()); assertEquals("forestId1", filteredForests[0].getForestId()); assertFalse("openreplicahost2".equals(filteredForests[1].getPreferredHost())); assertEquals("host2", filteredForests[1].getHost()); assertEquals(null, filteredForests[1].getRequestHost()); assertEquals(null, filteredForests[1].getAlternateHost()); assertEquals("forestId2", filteredForests[1].getForestId()); assertEquals("host3", filteredForests[2].getHost()); assertEquals(null, filteredForests[2].getOpenReplicaHost()); assertEquals(null, filteredForests[2].getRequestHost()); assertEquals("forestId3", filteredForests[2].getForestId()); assertFalse("requestHost4".equals(filteredForests[3].getRequestHost())); assertFalse("requestHost4".equals(filteredForests[3].getPreferredHost())); assertFalse("host4".equals(filteredForests[3].getHost()));
assertFalse("alternatehost1".equals(filteredForests[0].getPreferredHost())); assertFalse("openreplicahost1".equals(filteredForests[0].getOpenReplicaHost())); assertFalse("requesthost1".equals(filteredForests[0].getRequestHost())); assertEquals("forestId1", filteredForests[0].getForestId()); assertEquals(null, filteredForests[1].getRequestHost()); assertEquals("forestId2", filteredForests[1].getForestId()); assertEquals(null, filteredForests[1].getRequestHost()); assertEquals("forestId3", filteredForests[2].getForestId()); assertEquals("requesthost4", filteredForests[3].getRequestHost()); assertEquals("requesthost4", filteredForests[3].getPreferredHost());
assertEquals("openreplicahost1", filteredForests[0].getOpenReplicaHost()); assertEquals("alternatehost1", filteredForests[0].getAlternateHost()); assertEquals("requesthost1", filteredForests[0].getRequestHost()); assertEquals("forestId1", filteredForests[0].getForestId()); assertEquals("openreplicahost1a", filteredForests[0].getOpenReplicaHost()); assertEquals("alternatehost1", filteredForests[0].getAlternateHost()); assertEquals("requesthost1", filteredForests[0].getRequestHost()); assertEquals("forestId1", filteredForests[0].getForestId()); assertEquals("openreplicahost1a", filteredForests[0].getOpenReplicaHost()); assertEquals("alternatehost1a", filteredForests[0].getAlternateHost()); assertEquals("requesthost1", filteredForests[0].getRequestHost()); assertEquals("forestId1", filteredForests[0].getForestId()); assertEquals("openreplicahost1a", filteredForests[0].getOpenReplicaHost()); assertEquals("alternatehost1a", filteredForests[0].getAlternateHost()); assertEquals("requesthost1a", filteredForests[0].getRequestHost()); assertEquals("forestId1", filteredForests[0].getForestId());