Quantcast

Removing filters (plans) or destroying jetty (Http) and restarting

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Removing filters (plans) or destroying jetty (Http) and restarting

devnewb
Hi guys.

I am building up a list of filters (plans) and then running a jetty (Http) instance.

Now I want to be able to either:

 - remove filters and add new ones
or
 - modify filters already added
or
 - stop, destroy, read a clean set of filters and then restart my Http instance

Has anyone done anything similar ?  It would be preferred if I could remove filters or modify them really.

Thanks for your help.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Removing filters (plans) or destroying jetty (Http) and restarting

soft_props
Do you mean while developing or doing so dynamically live as part of your deployment?

Under the covers we are building up one or more ServletContextHandlers [1] in the jetty filter code [2]. I don''t think we'd have a way to remove filters once added to the ContextHandler. You would basically have to create new new Http instance

Can you expand a little more what your app is trying to do at runtime?

[1]: http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/servlet/ServletContextHandler.html

[2]: https://github.com/n8han/Unfiltered/blob/master/jetty/src/main/scala/servers.scala#L29

-Doug Tangren
http://lessis.me


On Thu, Jun 23, 2011 at 3:45 PM, devnewb [via Databinder] <[hidden email]> wrote:
Hi guys.

I am building up a list of filters (plans) and then running a jetty (Http) instance.

Now I want to be able to either:

 - remove filters and add new ones
or
 - modify filters already added
or
 - stop, destroy, read a clean set of filters and then restart my Http instance

Has anyone done anything similar ?  It would be preferred if I could remove filters or modify them really.

Thanks for your help.


To start a new topic under Unfiltered, email [hidden email]
To unsubscribe from Unfiltered, click here.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Removing filters (plans) or destroying jetty (Http) and restarting

devnewb
Hi Doug.

I would be doing this dynamically once the app is up.  So it looks as though I would need to create a new Http instance ?

My experiments with stopping, destroying etc did not work from sbt console... my filters were always 'remembered' leading me to believe I was not destroying successfully :-)

Thanks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Removing filters (plans) or destroying jetty (Http) and restarting

soft_props
Dynamical modification of handlers may be doable in the impl of the netty-server. I do something like this (swapping items from netty's pipeline) in the websockets module [1]. If you aren't touching underlying ServletHttpRequest in your Plans, it isn't that hard to switch over the the equivalent netty Plans [2].

Let me know if this is something you would like to see supported or drop us a gh issue [3]

In general we'd like to promote immutable servers but I can see how something like this would be useful. It brings to mind akka's hotswap

[1]: https://github.com/n8han/Unfiltered/blob/master/websockets/src/main/scala/plans.scala#L112
[2]: https://github.com/n8han/Unfiltered/blob/master/netty/src/main/scala/cycle/plans.scala
[3]: https://github.com/n8han/unfiltered/issues
[4]: https://profiles.google.com/vasil.remeniuk/posts/RjANYXqCMbV/Akka-Scala-framework-HotSwap-is-a-real-state-of#vasil.remeniuk/posts/RjANYXqCMbV

-Doug Tangren
http://lessis.me


On Thu, Jun 23, 2011 at 4:08 PM, devnewb [via Databinder] <[hidden email]> wrote:
Hi Doug.

I would be doing this dynamically once the app is up.  So it looks as though I would need to create a new Http instance ?

My experiments with stopping, destroying etc did not work from sbt console... my filters were always 'remembered' leading me to believe I was not destroying successfully :-)

Thanks.


To start a new topic under Unfiltered, email [hidden email]
To unsubscribe from Unfiltered, click here.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Removing filters (plans) or destroying jetty (Http) and restarting

devnewb
Hi.

I suppose the choice depends on the performance characteristics of doing it either way.  Keeping a cache to enable modification dynamically is more efficient.. but more complicated to code ?

Just using an immutable server is a brute force approach.. but those filters once recreated would certainly have no performance problems... and lets face it.. our machines could handle this kind of brute force... but then.. how much inefficiency is tolerable.. what if we want to rebuild just one filter in one hundred ?

Sorry.. thinking while writing.  Perhaps I will just brute force it for now, but if I find it is counter productive I will explore the idea again.  Thanks for your pointers.

Do you have sample code for killing and remaking the Jetty Http instance ?  On a separate note.. are there any limitations on the number of plans you can insert as filters on the instance ?

Thanks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Removing filters (plans) or destroying jetty (Http) and restarting

n8han
Administrator
I think you will have better luck by working with PartialFunction intents than full Filter plans. You can maintain some mutable collection of intents and handle them all in one Filter plan; just iterate over it while calling orElse (there may be something in scala-lib that does this already).

If it isn't clear what I mean by that, please take a read through this page which discusses how you can translate between plans and intents, tho it is to solve a different problem:
http://unfiltered.databinder.net/Pattern+Matching+Pitfalls.html

Nathan

On 06/23/2011 04:50 PM, devnewb [via Databinder] wrote:
Hi.

I suppose the choice depends on the performance characteristics of doing it either way.  Keeping a cache to enable modification dynamically is more efficient.. but more complicated to code ?

Just using an immutable server is a brute force approach.. but those filters once recreated would certainly have no performance problems... and lets face it.. our machines could handle this kind of brute force... but then.. how much inefficiency is tolerable.. what if we want to rebuild just one filter in one hundred ?

Sorry.. thinking while writing.  Perhaps I will just brute force it for now, but if I find it is counter productive I will explore the idea again.  Thanks for your pointers.

Do you have sample code for killing and remaking the Jetty Http instance ?  On a separate note.. are there any limitations on the number of plans you can insert as filters on the instance ?

Thanks.


To start a new topic under Unfiltered, email [hidden email]
To unsubscribe from Unfiltered, click here.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Removing filters (plans) or destroying jetty (Http) and restarting

devnewb
Hi Nathan.

Tried to assimilate that but it is late and I am tired.  Is there not still the problem that no matter what you do with the intents mutable structure or otherwise you still need to place them into a filter at some point, so it would be back to the original position, needing to spawn a new Jetty Http instance or figure out how to modify the existing one ?

Sorry if I did not get it.

Thanks.
Loading...