Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: What is supposed to happen when one of LoadupUtil's proxies fails?  (Read 7961 times)
jpwrunyan
Sr. Member
****
Posts: 84


View Profile WWW Email
« on: September 04, 2011, 06:21:02 »

I am not sure if this is the right forum to ask this in, but I am having trouble with LoadupUtil today.
I currently have two .cgi data services which are not ready yet though I have implemented their Proxies anyway.
This isn't a problem because it gives me a chance to test the application's fail state.

I am using LoadupUtil to sequence my initial proxies.  The flow is not that complicated, but I like Loadup anyway because it keeps things simple (although the boilerplate is non-trivial).

On Friday, the two requests to the yet-to-be-implemented server .cgi return a failed notification and then almost immediately after that LoadupMonitorProxy would send a LOADING_FINISHED_INCOMPLETE notification.  I thought that was good.  We know the 2 services failed immediately.

But now today it is acting differently.  The two .cgi proxies both return a failed notification immediately but LoadupMonitorProxy does not fire any notification at all.  If I wait for some minutes then finally it will send LOADING_FINISHED_INCOMPLETE as a result of LoadupMonitorProxy.timeoutTimer timedOut() handler.

Obviously, something is different (I think).  But it shouldn't be.  So first, before I can start debugging this, I need to know what exactly LoadupMonitorProxy is supposed to do.  Which of the two above behaviors is correct?  Should it be timing out or should it be finishing incomplete immediately?

Finally, could the response time of the successfully loaded resources affect this?  So far that is the only thing I can think of that might have changed... the server response times change daily.
Logged
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #1 on: September 05, 2011, 03:36:44 »

Yes, this question should probably be in the Loadup section of the forum.

I am assuming that we are not talking about loading assets via the assetloader sub-system of Loadup.

The LOADING_FINISHED_INCOMPLETE  notification is sent by Loadup when it has completely all attempts to load all the resources that it was asked to load, and one or more of the resources failed to load.  If there are more resources than the 2 that fail, then maybe there's a delay while those other ones are loaded; note that if the set of resources are independent as regards the order of loading, we can't predict the order in which the loads will occur.

Each attempted load has a timeout assigned (currently, default = 300secs). So, the load can effectively fail by timing out, if the load action itself is taking too long, regardless of the ultimate outcome of the load action; remember that Loadup is not the first to know of a load fail or a load success, it is the app itself that knows this first and the app then informs Loadup via notifications that trigger either LoadupResourceLoadedCommand or LoadupResourceLoadedCommand.  On the other hand, it is Loadup that informs the app about a timeout.

If you are getting a LOAD_RESOURCE_TIMED_OUT notification from Loadup, that means that some resource is taking too long to load, be that ultimately a successful load or a failed load.  The fact that Loadup issues the timeout notification does not kill the load action. The load action continues and the final outcome is a matter for the app, as it is with all loads.  At that stage, given the timeout, Loadup doesn't care; it has treated the resource load as a failed load.

If you are getting a LOAD_RESOURCE_TIMED_OUT notification from Loadup, that is probably the reason for the length of time until Loadup issues the LOADING_FINISHED_INCOMPLETE notification (300 secs is a long time). The 'timed out' notification identifies the failed resource in the body of the notification.

I am leaving aside the issue of retries. These would also delay the fiinsh of the loadup process.  You probably have retries =0.

You are probably aware of a lot of what I have stated above, but I hope that something there helps.

On the other hand, if you are saying that
- you send failed notifications and these trigger the relevant commands immediately (i.e. something else in you app doesn't handle these notifications such that the command invocation gets delayed)
- the timed out notification is received at a later time
- then we would need to look at the exact chronology of the notifications to understand what is going on.

----Philip
Logged
jpwrunyan
Sr. Member
****
Posts: 84


View Profile WWW Email
« Reply #2 on: September 05, 2011, 11:40:19 »

Philip, thanks for the reply.

I have to admit I am still pretty confused about everything.
First of all, I am not registering anything to respond to LOAD_RESOURCE_TIMED_OUT, so if that notification is firing, I am not aware of it.  I assume the monitor proxy however is aware of it.

Like I said, I am only responding to the failed/loaded notifications of individual proxies for debugging.  These are the same notifications registered with loadup's command structure:

command code (ApplicationStartupCommand):
:
...
facade.registerCommand(SystemConfigProxy.LOADED, LoadupResourceLoadedCommand);
facade.registerCommand(SystemConfigProxy.FAILED, LoadupResourceFailedCommand);
...

debug code (ApplicationMediator):
:
override public function listNotificationInterests():Array {
  return [
    SystemConfigProxy.LOADED,
    SystemConfigProxy.FAILED,
    ...
  ]
}
//and
override public function handleNotification(notification:INotification):void {
  var name:String = notification.getName();
  var body:Object = notification.getBody();
  var type:String = notification.getType();
  switch (name) {
    case SystemConfigProxy.LOADED: {
      startUpMessage += name + "\n";
      break;
    }
    case SystemConfigProxy.FAILED: {
      startUpMessage += name + "\n";
      break;
    }
    ...
    case LoadupMonitorProxy.LOADING_FINISHED_INCOMPLETE: {
      Alert.show("One or more necessary resources could not be loaded:\n" + startUpMessage, "Application Startup failure");
      break;
    }
    case LoadupMonitorProxy.LOADING_COMPLETE: {
      Alert.show("All necessary resources were loaded:\n" + startUpMessage, "Application Startup");
      break;
    }
  }
}

I have simplified the above as there are several proxies but they all follow the same basic idea.  The debug message collects the notification names and I use that information to find out which ones failed and which ones loaded.  The Alerts show this debug string.  As you can see, in the case of LOADING_COMPLETE the debug message contains XXX.LOADED notification names only.

Even if there is a FAILED notification from one of the proxies it comes in immediately.  The URLLoader requests are not hanging up indefinitely (ie not timing out--I get an immediate IOError because the resource does not yet exist on the server).  But the monitor proxy seems to respond either immediately or 300 seconds later for mysterious reasons.  When all the LOADED/FAILED notifications have come in, sometimes it sends LOADING_FINISHED_INCOMPLETE immediately, other times it waits 300 seconds before sending LOADING_FINISHED_INCOMPLETE.

I realize that Loadup doesn't know/cannot know how long it should take to load a resource, and that is why it uses its own timer.  However, and please correct me if I am wrong, but if all the proxies registered with the monitor have sent in their respective LOADED/FAILED notifications and thus triggered their LoadupResourceLoadedCommand/LoadupResourceFailedCommand then shouldn't Loadup know that it does not need to wait for a timeout?  Shouldn't it send a LOADING_FINISHED_INCOMPLETE notification immediately (if one of the responses was a failure)?  I believe that the retry count is 0.  It is the default setting.

I hope this has clarified my point of confusion.

Like I said, depending on the day, hour, and minute, the server response times may vary 500-3000 milliseconds.  But the responses generally come quickly.

Finally, I am not implying that I think something is wrong with Loadup.  I just want to confirm the expected behavior in the situation I described above.

(note: all LOADED/FAILED notifications' name values are unique to the Proxy that sends it--that's not the problem :-)

Thanks!

Note to moderator: can we move this thread to the correct forum?
Logged
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #3 on: September 06, 2011, 08:44:47 »

Two things occur to me.

1. It is absolutely critical that the loaded and failed notifications that you are sending have the correct proxy name in the notification body in each case. Otherwise Loadup will not know that a particular load has completed and will eventually timeout on that load. It would be helpful if you capture the notification body in each case in your debug code.

2. Your mediator should listen for Loadup.LOAD_RESOURCE_TIMED_OUT and capture the content of the notification body and that will show us the resource that is timing out within Loadup, and will confirm the reason for the delay.

Hope this helps. Good luck.
----Philip
Logged
Pages: [1]
Print