From 11859d9a6e466bab4ab73e1e46d092c6052acf68 Mon Sep 17 00:00:00 2001
From: coulbeck <coulbeck@localhost>
Date: Fri, 02 Feb 2007 21:50:10 +0000
Subject: [PATCH] These changes are for issue 787: LDAP server need to detect failure of changelog servers
---
opendj-sdk/opends/src/server/org/opends/server/synchronization/protocol/SocketSession.java | 38 ++++++++++++++++++++++++++++++++++++++
1 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/synchronization/protocol/SocketSession.java b/opendj-sdk/opends/src/server/org/opends/server/synchronization/protocol/SocketSession.java
index 08f8285..3b1185f 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/synchronization/protocol/SocketSession.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/synchronization/protocol/SocketSession.java
@@ -50,6 +50,18 @@
byte[] rcvLengthBuf = new byte[8];
/**
+ * The time the last message published to this session.
+ */
+ private long lastPublishTime = 0;
+
+
+ /**
+ * The time the last message was received on this session.
+ */
+ private long lastReceiveTime = 0;
+
+
+ /**
* Creates a new SocketSession based on the provided socket.
*
* @param socket The Socket on which the SocketSession will be based.
@@ -87,6 +99,8 @@
output.write(sendLengthBuf);
output.write(buffer);
output.flush();
+
+ lastPublishTime = System.currentTimeMillis();
}
/**
@@ -102,9 +116,13 @@
{
int read = input.read(rcvLengthBuf, length, 8-length);
if (read == -1)
+ {
throw new IOException("no more data");
+ }
else
+ {
length += read;
+ }
}
int totalLength = Integer.parseInt(new String(rcvLengthBuf), 16);
@@ -114,7 +132,11 @@
length = 0;
byte[] buffer = new byte[totalLength];
while (length < totalLength)
+ {
length += input.read(buffer, length, totalLength - length);
+ }
+
+ lastReceiveTime = System.currentTimeMillis();
return SynchronizationMessage.generateMsg(buffer);
}
catch (OutOfMemoryError e)
@@ -127,6 +149,22 @@
/**
* {@inheritDoc}
*/
+ public long getLastPublishTime()
+ {
+ return lastPublishTime;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public long getLastReceiveTime()
+ {
+ return lastReceiveTime;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public String getRemoteAddress()
{
return socket.getInetAddress().getHostAddress();
--
Gitblit v1.10.0