Author: jflesch
Date: 2006-07-20 01:52:32 +0000 (Thu, 20 Jul 2006)
New Revision: 9669
Modified:
trunk/apps/Thaw/src/thaw/core/Logger.java
trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java
trunk/apps/Thaw/src/thaw/fcp/FCPMessage.java
trunk/apps/Thaw/src/thaw/fcp/FCPQueueLoader.java
trunk/apps/Thaw/src/thaw/fcp/FCPQueueManager.java
trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
Log:
Try to reduce the deadlock problem
Modified: trunk/apps/Thaw/src/thaw/core/Logger.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Logger.java 2006-07-20 00:00:43 UTC (rev
9668)
+++ trunk/apps/Thaw/src/thaw/core/Logger.java 2006-07-20 01:52:32 UTC (rev
9669)
@@ -21,7 +21,7 @@
* 2 or more is recommanded.
* 5 is never logged in a file, only on stdout.
*/
- private final static int LOG_LEVEL = 2;
+ public final static int LOG_LEVEL = 2;
private static Vector logListeners = null;
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2006-07-20 00:00:43 UTC
(rev 9668)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2006-07-20 01:52:32 UTC
(rev 9669)
@@ -39,8 +39,9 @@
private boolean running = false;
private boolean successful = false;
+ private boolean isLockOwner = false;
+
-
/**
* See setParameters().
*/
@@ -249,16 +250,24 @@
}
*/
+ Logger.error(this, "=== PROTOCOL ERROR ===
\n"+message.toString());
+
status = "Protocol Error
("+message.getValue("CodeDescription")+")";
progress = 100;
running = false;
- successful = false;
+ successful = false;
if(message.getValue("Fatal") != null &&
message.getValue("Fatal").equals("false")) {
status = status + " (non-fatal)";
}
+ if(isLockOwner) {
+
queueManager.getQueryManager().getConnection().unlockReading();
+
queueManager.getQueryManager().getConnection().unlockWriting();
+ isLockOwner= false;
+ }
+
queueManager.getQueryManager().deleteObserver(this);
setChanged();
@@ -335,7 +344,7 @@
fileSize = message.getAmountOfDataWaiting();
status = "Writing to disk";
- Logger.notice(this, "Receiving file ...");
+ Logger.info(this, "Receiving file ...");
setChanged();
notifyObservers();
@@ -348,10 +357,11 @@
Logger.warning(this, "Unable to fetch correctly
the file. This may create problems on socket");
}
- Logger.notice(this, "Done");
+ Logger.info(this, "File received");
queueManager.getQueryManager().getConnection().unlockReading();
queueManager.getQueryManager().getConnection().unlockWriting();
+ isLockOwner= false;
running = false;
progress = 100;
@@ -407,14 +417,18 @@
if(!connection.lockReading()) {
/* Ah ben ou? mais non */
run();
+ return;
}
if(!connection.lockWriting()) {
/* Ah ben ou? mais non */
connection.unlockReading();
run();
+ return;
}
+ isLockOwner = true;
+
Logger.debug(this, "I take the reading lock !");
if(dir == null) {
@@ -461,7 +475,7 @@
}
public synchronized boolean continueSaveFileTo(String dir) {
- Logger.notice(this, "Asking file to the node...");
+ Logger.debug(this, "Asking file to the node...");
destinationDir = dir;
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java 2006-07-20 00:00:43 UTC
(rev 9668)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java 2006-07-20 01:52:32 UTC
(rev 9669)
@@ -40,6 +40,7 @@
private boolean sending = false;
private FCPGenerateSSK sskGenerator = null;
+ private boolean lockOwner = false;
private final static int PACKET_SIZE = 1024;
@@ -221,8 +222,11 @@
if(!connection.lockWriting()) {
/* Ah ben ou? mais non ... */
run();
+ return;
}
+ lockOwner = true;
+
clientPut.continueInsert();
return;
}
@@ -291,9 +295,10 @@
Logger.info(this, "Sending file to the node");
boolean ret = sendFile();
- Logger.info(this, "File sent (or not)");
+ Logger.info(this, "File sent (or not :p)");
connection.unlockWriting();
+ lockOwner = false;
sending = false;
if(ret == true) {
@@ -502,6 +507,11 @@
running = false;
finished = true;
+ if(lockOwner) {
+ lockOwner = false;
+
queueManager.getQueryManager().getConnection().unlockWriting();
+ }
+
status = "Protocol error
("+msg.getValue("CodeDescription")+")";
if(msg.getValue("Fatal") != null &&
msg.getValue("Fatal").equals("false"))
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPMessage.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPMessage.java 2006-07-20 00:00:43 UTC
(rev 9668)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPMessage.java 2006-07-20 01:52:32 UTC
(rev 9669)
@@ -63,6 +63,10 @@
setValue(affectation[0], affectation[1]);
}
+ if(getMessageName().equals("ProtocolError")) {
+ Logger.notice(this, "PROTOCOL ERROR:"+toString());
+ }
+
return true;
}
@@ -71,7 +75,7 @@
return messageName;
}
- public void setMessageName(String name) {
+ public void setMessageName(String name) {
if(name == null || name.equals("")) {
Logger.notice(this, "Setting name to empty ? weird");
}
@@ -80,6 +84,8 @@
Logger.notice(this, "Name shouldn't contain '\n'");
}
+ Logger.notice(this, "Message: "+name);
+
messageName = name;
}
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPQueueLoader.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPQueueLoader.java 2006-07-20 00:00:43 UTC
(rev 9668)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPQueueLoader.java 2006-07-20 01:52:32 UTC
(rev 9669)
@@ -26,7 +26,12 @@
FCPListPersistentRequests listPersistent = new
FCPListPersistentRequests();
- return listPersistent.start(queueManager);
+ boolean ret = listPersistent.start(queueManager);
+
+ if(ret)
+
queueManager.getQueryManager().getConnection().lockWriting();
+
+ return ret;
}
@@ -121,6 +126,8 @@
if(msg.getMessageName().equals("EndListPersistentRequests")) {
Logger.info(this, "End Of ListPersistentRequests.");
+
queueManager.getQueryManager().getConnection().unlockWriting();
+
return;
}
}
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPQueueManager.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPQueueManager.java 2006-07-20 00:00:43 UTC
(rev 9668)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPQueueManager.java 2006-07-20 01:52:32 UTC
(rev 9669)
@@ -270,7 +270,7 @@
}
- public void ordonnance() {
+ public void schedule() {
/* We count the running query to see if there is an
empty slot */
@@ -359,7 +359,7 @@
return;
try {
- ordonnance();
+ schedule();
} catch(java.util.ConcurrentModificationException e) {
Logger.notice(this, "Ordonnancor: Collision !");
} catch(Exception e) {
Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
2006-07-20 00:00:43 UTC (rev 9668)
+++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
2006-07-20 01:52:32 UTC (rev 9669)
@@ -164,8 +164,7 @@
return null;
- if( (insertionQueue && column == 3)
- || (!insertionQueue && column == 4) ) {
+ if(value instanceof Integer) {
Integer progress = (Integer)value;
JProgressBar bar = new JProgressBar(0, 100);