1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-03 23:25:26 +02:00

[222448] [dstore] update DownloadListener to handle timeouts and nudge

This commit is contained in:
David McKnight 2008-03-12 17:31:09 +00:00
parent f5ec51e020
commit db6618a76f
2 changed files with 62 additions and 11 deletions

View file

@ -287,7 +287,10 @@ public class StatusMonitor implements IDomainListener, ICommunicationsListener
WaitThreshold = wait*10; // 1 second means 10 sleep(100ms)
else if ( wait == -1 ) // force a diagnostic
WaitThreshold = -1;
int nudges = 0; // nudges used for waking up server with slow connections
// nudge up to 12 times before giving up
if (display != null)
{
// Current thread is UI thread
@ -319,8 +322,13 @@ public class StatusMonitor implements IDomainListener, ICommunicationsListener
if (WaitThreshold == 0)
{
// no diagnostic factory but there is a timeout
return status; // returning the undone status object
wakeupServer(status);
// no diagnostic factory but there is a timeout
if (nudges >= 12)
return status; // returning the undone status object
nudges++;
}
else if (_networkDown)
{
@ -359,8 +367,13 @@ public class StatusMonitor implements IDomainListener, ICommunicationsListener
if (WaitThreshold == 0)
{
wakeupServer(status);
// no diagnostic factory but there is a timeout
return status; // returning the undone status object
if (nudges >= 12)
return status; // returning the undone status object
nudges++;
}
else if (_networkDown)
{
@ -375,6 +388,19 @@ public class StatusMonitor implements IDomainListener, ICommunicationsListener
return status;
}
private void wakeupServer(DataElement status)
{
if (status != null)
{
// token command to wake up update handler
DataElement cmdDescriptor = _dataStore.findCommandDescriptor("C_REFRESH"); //$NON-NLS-1$
DataElement subject = status.getParent().get(0);
if (cmdDescriptor != null)
{
_dataStore.command(cmdDescriptor, subject);
}
}
}
/**
* Start diagnostic

View file

@ -16,6 +16,7 @@
* David McKnight (IBM) - [197480] eliminating UI dependencies
* David McKnight (IBM) - [216252] MessageFormat.format -> NLS.bind
* Martin Oberhuber (Wind River) - [219952] Use MessageFormat for download progress message
* David McKnight (IBM) - [222448] [dstore] update DownloadListener to handle timeouts and nudge
********************************************************************************/
package org.eclipse.rse.services.dstore.util;
@ -230,14 +231,13 @@ public class DownloadListener implements IDomainListener
*/
public DataElement waitForUpdate(int wait) throws InterruptedException
{
// Prevent infinite looping by introducing a threshold for wait
int WaitThreshold = 50; //default. sleep(100ms) for 150 times
if (wait > 0)
{
}
else if (wait == -1)
{
}
WaitThreshold = wait * 10; // 1 second means 10 sleep(100ms)
else if (wait == -1) // force a diagnostic
WaitThreshold = -1;
{
// Current thread is not UI thread
@ -263,11 +263,36 @@ public class DownloadListener implements IDomainListener
{
Thread.sleep(100);
updateDownloadState();
if (WaitThreshold > 0) // update timer count if
{
// threshold not reached
--WaitThreshold; // decrement the timer count
}
else if (WaitThreshold == 0)
{
// try to wake up the server
wakeupServer(_status);
}
}
}
}
return _status;
}
private void wakeupServer(DataElement status)
{
if (status != null)
{
// token command to wake up update handler
DataElement cmdDescriptor = _dataStore.findCommandDescriptor("C_REFRESH"); //$NON-NLS-1$
DataElement subject = status.getParent().get(0);
if (cmdDescriptor != null)
{
_dataStore.command(cmdDescriptor, subject);
}
}
}
public void cancelDownload()
{