/** * Gets the name of this member (this Server) in the GemFire distributed system as determined by * the 'name' GemFire property. * * @return a String indicating the name of the member (this Server) in the GemFire distributed * system. */ @Override public String getMemberName() { return defaultIfBlank(this.memberName, super.getMemberName()); }
/** * Gets the name of this member (this Locator) in the GemFire distributed system and determined by * the 'name' GemFire property. * * @return a String indicating the name of the member (this Locator) in the GemFire distributed * system. */ @Override public String getMemberName() { return defaultIfBlank(this.memberName, super.getMemberName()); }
/** * Creates a Properties object with configuration settings that the launcher has that should take * precedence over anything the user has defined in their gemfire properties file. * * @param defaults default GemFire Distributed System properties as configured in the Builder. * @return a Properties object with GemFire properties that the launcher has defined. * @see java.util.Properties */ protected Properties getDistributedSystemProperties(final Properties defaults) { final Properties distributedSystemProperties = new Properties(); if (defaults != null) { distributedSystemProperties.putAll(defaults); } if (isNotBlank(getMemberName())) { distributedSystemProperties.setProperty(NAME, getMemberName()); } return distributedSystemProperties; }
/** * Gets the name or ID of the member in the GemFire distributed system. This method prefers name * if specified, otherwise the ID is returned. If name was not specified to the Builder that * created this Launcher and this call is not in-process, then null is returned. * * @return a String value indicating the member's name if specified, otherwise the member's ID is * returned if this call is made in-process, or finally, null is returned if neither name * name was specified or the call is out-of-process. * @see #getMemberName() * @see #getMemberId() */ public String getMember() { if (isNotBlank(getMemberName())) { return getMemberName(); } if (isNotBlank(getMemberId())) { return getMemberId(); } return null; }
@Test public void getDistributedSystemPropertiesIncludesDefaults() throws Exception { AbstractLauncher<?> launcher = createAbstractLauncher("TestMember", "123"); Properties defaults = new Properties(); defaults.setProperty("testKey", "testValue"); Properties properties = launcher.getDistributedSystemProperties(defaults); assertThat(properties.getProperty(NAME)).isEqualTo(launcher.getMemberName()); assertThat(properties.getProperty("testKey")).isEqualTo("testValue"); }
@Test public void getMemberNameReturnsEmptyIfEmpty() throws Exception { AbstractLauncher<?> launcher = createAbstractLauncher(StringUtils.EMPTY, null); assertThat(launcher.getMemberName()).isEqualTo(StringUtils.EMPTY); }
@Test public void getMemberNameReturnsValue() throws Exception { AbstractLauncher<?> launcher = createAbstractLauncher("memberOne", null); assertThat(launcher.getMemberName()).isEqualTo("memberOne"); }
@Test public void getMemberNameReturnsBlankIfBlank() throws Exception { AbstractLauncher<?> launcher = createAbstractLauncher(" ", null); assertThat(launcher.getMemberName()).isEqualTo(" "); }
@Test public void getMemberNameReturnsSameNumberOfBlanks() throws Exception { AbstractLauncher<?> launcher = createAbstractLauncher(" ", null); assertThat(launcher.getMemberName()).isEqualTo(" "); }
@Test public void getMemberPrefersMemberNameOverMemberId() throws Exception { AbstractLauncher<?> launcher = createAbstractLauncher("memberOne", "123"); assertThat(launcher.getMember()).isEqualTo("memberOne").isEqualTo(launcher.getMemberName()); }