Re: Processing multiple objects w/NSTasks efficiently?
Re: Processing multiple objects w/NSTasks efficiently?
- Subject: Re: Processing multiple objects w/NSTasks efficiently?
- From: Kaelin Colclasure <email@hidden>
- Date: Mon, 7 Nov 2005 16:56:52 -0800
On Nov 7, 2005, at 4:01 PM, Michael Carter wrote:
Hello all.
I could use some advise on a project I'm working on.
I need to query information from a couple hundred servers in an
efficient manner using a central application. My initial approach
is to create an array of objects which each contain an NSTask. This
task pulls information from a remote host using an ssh call in
order to display key info in an NSTableView. The columns of the
tableview are bound to the parameters needing display.
What I'd like to do is write the app so that this is all done
asynchronously so that the user needn't sit there and watch the
ball spin. What would be the best practice for such an approach?
I've tried creating a single thread that iterates the objects and
tells them to start their tasks. I currently use
makeObjectsPerformSelector: but only one server at a time is
polled. The whole operation isn't really asynchronous since I found
I had to use NSTask's waitUntilExit to process each task.
Is there a better way to do this?
If perchance there is a Web server running on the hosts you need to
poll, and you can install a trivial CGI script on them, you can
greatly simplify matters by using HTTP instead of SSH across the
network.
OTOH, if SSH is a hard requirement, you might look around for a
library that lets you open multiple SSH sessions from a single
process. (I'm pretty sure I've heard of one, but it was probably for
Linux [or perhaps Java], and in any case I can't recall where I came
across it off the top of my head.)
If you absolutely must resort to using NSTasks, I'd suggest starting
a small pool of worker tasks (maybe 10 or so) and distributing the
poll requests among them. 200 worker tasks are just going to be
contending with each other for network bandwidth anyway...
HTH,
-- Kaelin
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden