Mailing List Archive

cvs commit: jakarta-lucene-sandbox/contributions/webcrawler-LARM/src/de/lanlab/larm/net HostInfo.java
cmarschner 2002/10/22 08:22:59

Modified: contributions/webcrawler-LARM/src/de/lanlab/larm/net
HostInfo.java
Log:
added host semaphores

Revision Changes Path
1.3 +59 -2 jakarta-lucene-sandbox/contributions/webcrawler-LARM/src/de/lanlab/larm/net/HostInfo.java

Index: HostInfo.java
===================================================================
RCS file: /home/cvs/jakarta-lucene-sandbox/contributions/webcrawler-LARM/src/de/lanlab/larm/net/HostInfo.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HostInfo.java 15 Sep 2002 19:30:40 -0000 1.2
+++ HostInfo.java 22 Oct 2002 15:22:59 -0000 1.3
@@ -79,7 +79,62 @@

private int id;

- private int healthyCount = 5;
+ int healthyCount = 8;
+
+ int locks = 2; // max. concurrent requests
+ int lockObtained = 0; // for debugging
+
+ Object lockMonitor = new Object();
+ public Object getLockMonitor()
+ {
+ return lockMonitor;
+ }
+ public void releaseLock()
+ {
+ synchronized(lockMonitor)
+ {
+ if(lockObtained>=0)
+ {
+ locks++;
+ lockObtained--;
+// try
+// {
+// throw new Exception();
+//
+// }
+// catch(Exception e)
+// {
+// System.out.println("HostInfo: release called at: " + e.getStackTrace()[1]);
+// }
+// System.out.println("HostInfo " + hostName + ": releaseing Lock. now " + lockObtained + " locks obtained, " + locks + " available");
+ }
+// else
+// {
+// System.out.println("HostInfo: lock released although no lock acquired!?");
+// }
+ }
+ }
+ // must be synchronized
+ public void obtainLock()
+ {
+ locks--;
+ lockObtained++;
+// try
+// {
+// throw new Exception();
+//
+// }
+// catch(Exception e)
+// {
+// System.out.println("obtain called at: " + e.getStackTrace()[1]);
+// }
+// System.out.println("HostInfo " + hostName + ": obtaining Lock. now " + lockObtained + " locks obtained, " + locks + " available");
+ }
+ // must be synchronized
+ public boolean isBusy()
+ {
+ return locks<=0;
+ }

// five strikes, and you're out
private boolean isReachable = true;
@@ -194,6 +249,7 @@
public void badRequest()
{
healthyCount--;
+ System.out.println("HostInfo: " + this.hostName + ": badRequest. " + healthyCount + " left");
}


@@ -205,6 +261,7 @@
public void setReachable(boolean reachable)
{
isReachable = reachable;
+ System.out.println("HostInfo: " + this.hostName + ": setting to " + (reachable ? "reachable" : "unreachable"));
}






--
To unsubscribe, e-mail: <mailto:lucene-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-dev-help@jakarta.apache.org>