private LocatorState(final LocatorLauncher launcher, final Status status, final LocatorStatusResponse response) { this(status, launcher.statusMessage, System.currentTimeMillis(), launcher.getId(), response.getPid(), response.getUptime(), response.getWorkingDirectory(), response.getJvmArgs(), response.getClasspath(), response.getGemFireVersion(), response.getJavaVersion(), response.getLogFile(), response.getHost(), String.valueOf(response.getPort()), response.getName()); }
@Override public String toString() { final StringBuilder buffer = new StringBuilder(getClass().getSimpleName()); buffer.append("{ pid = ").append(getPid()); buffer.append(", uptime = ").append(getUptime()); buffer.append(", workingDirectory = ").append(getWorkingDirectory()); buffer.append(", jvmArgs = ").append(ArgumentRedactor.redact(getJvmArgs())); buffer.append(", classpath = ").append(getClasspath()); buffer.append(", gemfireVersion = ").append(getGemFireVersion()); buffer.append(", javaVersion = ").append(getJavaVersion()); buffer.append("}"); return buffer.toString(); }
@Test public void testSerialize() throws IOException, ClassNotFoundException { final int locatorPort = 12345; final String locatorHost = "locatorHost"; final String locatorLogFile = "LocatorStatusResponseJUnitTest.log"; final String locatorName = "LocatorStatusResponseJUnitTest"; final ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); final LocatorStatusResponse expectedResponse = new LocatorStatusResponse() .initialize(locatorPort, locatorHost, locatorLogFile, locatorName); assertNotNull(expectedResponse); expectedResponse.toData(new DataOutputStream(byteStream)); final byte[] bytes = byteStream.toByteArray(); assertNotNull(bytes); assertFalse(bytes.length == 0); final LocatorStatusResponse actualResponse = new LocatorStatusResponse(); assertNotNull(actualResponse); assertNotSame(expectedResponse, actualResponse); assertFalse(actualResponse.equals(expectedResponse)); actualResponse.fromData(new DataInputStream(new ByteArrayInputStream(bytes))); assertEquals(expectedResponse, actualResponse); }
switch (id) { case DataSerializableFixedID.LOCATOR_STATUS_REQUEST: response = new LocatorStatusResponse().initialize(this.port, this.hostName, this.logFile, this.memberName); break;
protected void writeLogFile(final DataOutput out) throws IOException { String log = getLogFile(); out.writeUTF(log != null ? log : ""); }
protected void writeGemFireVersion(final DataOutput out) throws IOException { String version = getGemFireVersion(); out.writeUTF(version != null ? version : ""); }
protected void writeJavaVersion(final DataOutput out) throws IOException { String version = getJavaVersion(); out.writeUTF(version != null ? version : ""); }
protected void writeHost(final DataOutput out) throws IOException { String host = getHost(); out.writeUTF(host != null ? host : ""); }
protected void writeClasspath(final DataOutput out) throws IOException { String classpath = getClasspath(); out.writeUTF(classpath != null ? classpath : ""); }
protected void writeJvmArguments(final DataOutput out) throws IOException { final List<String> jvmArgs = getJvmArgs(); out.writeInt(jvmArgs.size()); for (final String jvmArg : jvmArgs) { out.writeUTF(jvmArg); } }
@Override public boolean equals(final Object obj) { if (obj == this) { return true; } if (!(obj instanceof LocatorStatusResponse)) { return false; } final LocatorStatusResponse that = (LocatorStatusResponse) obj; return ObjectUtils.equalsIgnoreNull(this.getPid(), that.getPid()) && ObjectUtils.equals(this.getUptime(), that.getUptime()) && ObjectUtils.equals(this.getWorkingDirectory(), that.getWorkingDirectory()) && ObjectUtils.equals(this.getJvmArgs(), that.getJvmArgs()) && ObjectUtils.equals(this.getClasspath(), that.getClasspath()) && ObjectUtils.equals(this.getGemFireVersion(), that.getGemFireVersion()) && ObjectUtils.equals(this.getJavaVersion(), that.getJavaVersion()); }
@Override public int hashCode() { int hashValue = 17; hashValue = 37 * hashValue + ObjectUtils.hashCode(getPid()); hashValue = 37 * hashValue + ObjectUtils.hashCode(getUptime()); hashValue = 37 * hashValue + ObjectUtils.hashCode(getWorkingDirectory()); hashValue = 37 * hashValue + ObjectUtils.hashCode(getJvmArgs()); hashValue = 37 * hashValue + ObjectUtils.hashCode(getClasspath()); hashValue = 37 * hashValue + ObjectUtils.hashCode(getGemFireVersion()); hashValue = 37 * hashValue + ObjectUtils.hashCode(getJavaVersion()); return hashValue; }