HTTPServer and SwazooServer servers

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

HTTPServer and SwazooServer servers

Stefan Schmiedl
Greetings.

I've started looking at the inner workings of Swazoo and came upon my first
questions while stepping through SwazooServer demoStart :-)

The short question: The handling of the servers set is somewhat inconsistent.
Looking at the start method quoted below, the "collection nature" of servers
is exposed by "(swazoo servers includes: httpServer)", then it is not used
by "swazoo addServer: httpServer" or (corresponding removals in stop).
Is there a specific reason for this?

Now for the long question:

I'm guessing that the "canonical" way to access the HTTPServer for a site
is

        SwazooServer singleton serverFor: aSite

SwazooServer>>start (in 2.2.beta1) is implemented as:

        SwazooServer>>start
                | swazoo |
                swazoo := SwazooServer singleton.
                [self aliases do: [:each | | httpServer |
                        httpServer := swazoo serverFor: each.
                        httpServer addSite: self.
                        (swazoo servers includes: httpServer)
                                ifFalse:
                                        [swazoo addServer: httpServer.
                                        httpServer isServing ifFalse: [httpServer start] ] ].
                ] ifCurtailed: [self stop].
                self serving: true.

where

        SwazooServer>>serverFor: aSiteIdentifier
                ^self servers
                        detect: [:each | (each ip = aSiteIdentifier ip) & (each port = aSiteIdentifier port)]
                        ifNone: [self newServerFor: aSiteIdentifier]


How much harm would be caused by the following approach:

        SwazooServer>>serverFor:
                ^self servers
                        detect: [:each | (each ip = aSiteIdentifier ip) & (each port = aSiteIdentifier port)]
                        ifNone: [self addServer: (self newServerFor: aSiteIdentifier)]

and

        SwazooServer>>start
                | swazoo |
                swazoo := SwazooServer singleton.
                [self aliases do: [:each | | httpServer |
                        httpServer := swazoo serverFor: each.
                        httpServer addSite: self.
                        httpServer isServing ifFalse: [httpServer start] ].
                ] ifCurtailed: [self stop].
                self serving: true.

If I understand the code correctly, an "unknown" server is added to the servers set,
however, the server in question already comes from the set or has just been created
and is definitely not in the set. Resolving this difference earlier shortens the start method.

The original approach would only start new httpServers, while the latter would start
servers for all known aliases. So you could theoretically end up with an alias hooked up
to a non-running httpServer. When is this useful?


Just making Smalltalk,
s.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Swazoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swazoo-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: HTTPServer and SwazooServer servers

Janko Mivšek
Hi Stefan, welcome to the Swazoo list!

For your suggested change, it seems it should work, so I propose that
you just implement and test it, then let us know. I can also start
testing by myself. Well, let me start then ...

Janko


Stefan Schmiedl wrote:

> Greetings.
>
> I've started looking at the inner workings of Swazoo and came upon my first
> questions while stepping through SwazooServer demoStart :-)
>
> The short question: The handling of the servers set is somewhat inconsistent.
> Looking at the start method quoted below, the "collection nature" of servers
> is exposed by "(swazoo servers includes: httpServer)", then it is not used
> by "swazoo addServer: httpServer" or (corresponding removals in stop).
> Is there a specific reason for this?
>
> Now for the long question:
>
> I'm guessing that the "canonical" way to access the HTTPServer for a site
> is
>
> SwazooServer singleton serverFor: aSite
>
> SwazooServer>>start (in 2.2.beta1) is implemented as:
>
> SwazooServer>>start
> | swazoo |
> swazoo := SwazooServer singleton.
> [self aliases do: [:each | | httpServer |
> httpServer := swazoo serverFor: each.
> httpServer addSite: self.
> (swazoo servers includes: httpServer)
> ifFalse:
> [swazoo addServer: httpServer.
> httpServer isServing ifFalse: [httpServer start] ] ].
> ] ifCurtailed: [self stop].
> self serving: true.
>
> where
>
> SwazooServer>>serverFor: aSiteIdentifier
> ^self servers
> detect: [:each | (each ip = aSiteIdentifier ip) & (each port = aSiteIdentifier port)]
> ifNone: [self newServerFor: aSiteIdentifier]
>
>
> How much harm would be caused by the following approach:
>
> SwazooServer>>serverFor:
> ^self servers
> detect: [:each | (each ip = aSiteIdentifier ip) & (each port = aSiteIdentifier port)]
> ifNone: [self addServer: (self newServerFor: aSiteIdentifier)]
>
> and
>
> SwazooServer>>start
> | swazoo |
> swazoo := SwazooServer singleton.
> [self aliases do: [:each | | httpServer |
> httpServer := swazoo serverFor: each.
> httpServer addSite: self.
> httpServer isServing ifFalse: [httpServer start] ].
> ] ifCurtailed: [self stop].
> self serving: true.
>
> If I understand the code correctly, an "unknown" server is added to the servers set,
> however, the server in question already comes from the set or has just been created
> and is definitely not in the set. Resolving this difference earlier shortens the start method.
>
> The original approach would only start new httpServers, while the latter would start
> servers for all known aliases. So you could theoretically end up with an alias hooked up
> to a non-running httpServer. When is this useful?
>
>
> Just making Smalltalk,
> s.
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Swazoo-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/swazoo-devel
>

--
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Swazoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swazoo-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: HTTPServer and SwazooServer servers

Janko Mivšek
Stefan,

I just implemented your patch and extended it to be even more simple and
understandable IMHO:

Site>>start
   | swazoo |
   swazoo := SwazooServer singleton.
   [self aliases do: [:each | | httpServer |
       httpServer := swazoo serverFor: each. "it will also create
                                            and start it if needed"
       httpServer addSite: self].
   ] ifCurtailed: [self stop].
   self serving: true.


SwazooServer>>serverFor: aSiteIdentifier
   | httpServer |
   ^self servers
      detect: [:each | (each ip = aSiteIdentifier ip) &
                          (each port = aSiteIdentifier port)]
      ifNone: [
        httpServer := self newServerFor: aSiteIdentifier.
        self addServer: httpServer.
        httpServer start.
        ^httpServer]

SwazooServer>>addServer: aHTTPServer
    ^self servers add: aHTTPServer "^ missing!"


Janko

Janko Mivšek wrote:

> Hi Stefan, welcome to the Swazoo list!
>
> For your suggested change, it seems it should work, so I propose that
> you just implement and test it, then let us know. I can also start
> testing by myself. Well, let me start then ...
>
> Janko
>
>
> Stefan Schmiedl wrote:
>> Greetings.
>>
>> I've started looking at the inner workings of Swazoo and came upon my first
>> questions while stepping through SwazooServer demoStart :-)
>>
>> The short question: The handling of the servers set is somewhat inconsistent.
>> Looking at the start method quoted below, the "collection nature" of servers
>> is exposed by "(swazoo servers includes: httpServer)", then it is not used
>> by "swazoo addServer: httpServer" or (corresponding removals in stop).
>> Is there a specific reason for this?
>>
>> Now for the long question:
>>
>> I'm guessing that the "canonical" way to access the HTTPServer for a site
>> is
>>
>> SwazooServer singleton serverFor: aSite
>>
>> SwazooServer>>start (in 2.2.beta1) is implemented as:
>>
>> SwazooServer>>start
>> | swazoo |
>> swazoo := SwazooServer singleton.
>> [self aliases do: [:each | | httpServer |
>> httpServer := swazoo serverFor: each.
>> httpServer addSite: self.
>> (swazoo servers includes: httpServer)
>> ifFalse:
>> [swazoo addServer: httpServer.
>> httpServer isServing ifFalse: [httpServer start] ] ].
>> ] ifCurtailed: [self stop].
>> self serving: true.
>>
>> where
>>
>> SwazooServer>>serverFor: aSiteIdentifier
>> ^self servers
>> detect: [:each | (each ip = aSiteIdentifier ip) & (each port = aSiteIdentifier port)]
>> ifNone: [self newServerFor: aSiteIdentifier]
>>
>>
>> How much harm would be caused by the following approach:
>>
>> SwazooServer>>serverFor:
>> ^self servers
>> detect: [:each | (each ip = aSiteIdentifier ip) & (each port = aSiteIdentifier port)]
>> ifNone: [self addServer: (self newServerFor: aSiteIdentifier)]
>>
>> and
>>
>> SwazooServer>>start
>> | swazoo |
>> swazoo := SwazooServer singleton.
>> [self aliases do: [:each | | httpServer |
>> httpServer := swazoo serverFor: each.
>> httpServer addSite: self.
>> httpServer isServing ifFalse: [httpServer start] ].
>> ] ifCurtailed: [self stop].
>> self serving: true.
>>
>> If I understand the code correctly, an "unknown" server is added to the servers set,
>> however, the server in question already comes from the set or has just been created
>> and is definitely not in the set. Resolving this difference earlier shortens the start method.
>>
>> The original approach would only start new httpServers, while the latter would start
>> servers for all known aliases. So you could theoretically end up with an alias hooked up
>> to a non-running httpServer. When is this useful?
>>
>>
>> Just making Smalltalk,
>> s.
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
>> Build the coolest Linux based applications with Moblin SDK & win great prizes
>> Grand prize is a trip for two to an Open Source event anywhere in the world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> _______________________________________________
>> Swazoo-devel mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/swazoo-devel
>>
>

--
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Swazoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swazoo-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: HTTPServer and SwazooServer servers

Stefan Schmiedl
On Sat, 22 Nov 2008 20:06:58 +0100
Janko Mivšek <[hidden email]> wrote:

> I just implemented your patch and extended it to be even more simple
> and understandable IMHO:

Thanks for the quick update, Janko.

s.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Swazoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swazoo-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: HTTPServer and SwazooServer servers

Stefan Schmiedl
In reply to this post by Janko Mivšek
On Sat, 22 Nov 2008 20:06:58 +0100
Janko Mivšek <[hidden email]> wrote:

> Stefan,
>
> I just implemented your patch and extended it to be even more simple
> and understandable IMHO:
>

I think the changes below should preserver behavior and look clean. I'll take another
look tomorrow.

Site>>start
       
        | swazoo |
        swazoo := SwazooServer singleton.
        [ self aliases do: [ :each | swazoo startServerFor: each on: self ] ]
                ifCurtailed: [ self stop ].
        self serving: true


SwazooServer>>startServerFor: aSiteIdentifier on: aSite
       
        (self serverFor: aSiteIdentifier) startOn: aSite


SwazooServer>>serverFor: aSiteIdentifier

        ^self servers
                detect: [:each | (each ip = aSiteIdentifier ip) & (each port = aSiteIdentifier port)]
                ifNone: [self addServer: (self newServerFor: aSiteIdentifier)]


HTTPServer>>startOn: aSite
       
        self addSite: aSite.
        self isServing ifFalse: [ self start ]

s.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Swazoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swazoo-devel
Loading...