public static boolean checkRemoteLocatorsAndLocatorsMatch ( String remoteLocators , String locators ) { if ( remoteLocators == null || remoteLocators . length ( ) == 0 ) return false ; if ( remoteLocators . equalsIgnoreCase ( locators ) ) return true ; String [ ] remoteLocatorsArray = remoteLocators . split ( "," ) ; if ( locators == null || locators . length ( ) == 0 ) return false ; String [ ] locatorsArray = locators . split ( "," ) ; String remoteLocatorHost , locatorHost ; int remoteLocatorPort , locatorPort ; for ( String remoteLocator : remoteLocatorsArray ) { if ( remoteLocator == null || remoteLocator . length ( ) == 0 ) continue ; //parse host for ( String locator : locatorsArray ) { if ( locator == null || locator . length ( ) == 0 ) continue ; try { remoteLocatorHost = parseLocatorHost ( remoteLocator ) ; locatorHost = parseLocatorHost ( locator ) ; remoteLocatorPort = parseLocatorPort ( remoteLocator ) ; locatorPort = parseLocatorPort ( locator ) ; if ( Networking . hostEquals ( remoteLocatorHost , locatorHost ) && remoteLocatorPort == locatorPort ) { return true ; } else { //check if ip address match } } catch ( NumberFormatException e ) { //port parse exception return false ; } catch ( IllegalArgumentException e ) { throw new IllegalArgumentException ( "remoteLocator:" + remoteLocator + " locator:" + locator + " ERROR:" + e . getMessage ( ) , e ) ; } } } return false ; }
Parse the remote locators and locator and assert that they match