Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Detecting port and context path
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Morten Kjetland  
View profile  
 More options Nov 9 2012, 7:41 pm
From: Morten Kjetland <morten.kjetl...@gmail.com>
Date: Fri, 9 Nov 2012 16:41:48 -0800 (PST)
Local: Fri, Nov 9 2012 7:41 pm
Subject: Detecting port and context path

Hi,

I am the author of DDSL - Dynamic Distributed Service Locator
- https://github.com/mbknor/ddsl

DDSL makes it really easy for services to discover/connect to each other in
a distributed way without any single point of failure using Apache
Zookeeper.

DDSL enables an applications/services to register its pressens on the
"network" when it starts up, and when it quits or it crashes etc, it will
automatically be deregistered.

DDSL handles multiple instances of the same app, even with different
versions at the same time.

When a service/app needs to connect to a different service/app, it can just
query DDSL for one or all pressent instances of that specific service (with
specific version).

DDSL has a built in distributed load balancer, but you can also set up
auto-configuration of nginx, apache, ELB etc by
using https://github.com/mbknor/ddslConfigWriter

I have already created a Play Framework plugin that makes it really easy to
register with / using DDSL: https://github.com/mbknor/ddsl-play2-module

I am now looking into creating a similar plugin/module for dropwizard. To
do this, I have to resolve which URL the app/service is available on.

So my question to this group is therefor:

* How can I resolve the http port used.

* Where/how should I hook in to get a callback when the service goes online
and offline.

Best regards,
Morten Kjetland


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Fairley  
View profile  
 More options Nov 9 2012, 10:56 pm
From: Michael Fairley <michaelfair...@gmail.com>
Date: Fri, 9 Nov 2012 21:56:24 -0600
Local: Fri, Nov 9 2012 10:56 pm
Subject: Re: Detecting port and context path

The Configuration object that gets passed to the Service's initialize
method contains an HttpConfiguration, which contains the port that the
service will start on.

Managed objects (http://dropwizard.codahale.com/manual/core/#managed-objects)
are bound to the lifecycle of the service, and can be added to the
Environment with Environment#manage(Managed managed).

On Fri, Nov 9, 2012 at 6:41 PM, Morten Kjetland
<morten.kjetl...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Morten Kjetland  
View profile  
 More options Jan 21, 3:38 am
From: Morten Kjetland <m...@kjetland.com>
Date: Mon, 21 Jan 2013 09:38:54 +0100
Local: Mon, Jan 21 2013 3:38 am
Subject: Re: Detecting port and context path

Hi,

If configuring http.port = 0, Dropwizard will automatically pick a random
port.
How can I resolve which port was chosen?

I'm creating a DDSL plugin for Dropwizard (
https://github.com/mbknor/ddsl-dropwizard) which makes it easy to enable
Service Discovery to Dropwizard apps.

The plugin will resolve the URL your service is currently running on and
announce it to DDSL along with service name and version.

Other apps / nginx'es etc can then automatically discover it.

This plugin is still work-in-progress.

Best regards,
Morten Kjetland

On Sat, Nov 10, 2012 at 4:56 AM, Michael Fairley
<michaelfair...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Olve Hansen  
View profile  
 More options Jan 21, 7:58 am
From: Olve Hansen <o...@vimond.com>
Date: Mon, 21 Jan 2013 04:58:26 -0800 (PST)
Local: Mon, Jan 21 2013 7:58 am
Subject: Re: Detecting port and context path

Hi Morten.

Got the answer - basically you have to implement ServerLifecycleListener
and via environment object available in the service run-method you add your
implementation to enviornment:
ServerLifecycleListener:

*environment.addServerLifecycleListener(yourHandler);*

In the event you can query the *Server* object given through * public void
serverStarted(Server server) *

There are two connectors, one name "*internal*", and one named "*main*".

Regards,
Olve


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Morten Kjetland  
View profile  
 More options Jan 22, 5:58 am
From: Morten Kjetland <morten.kjetl...@gmail.com>
Date: Tue, 22 Jan 2013 02:58:19 -0800 (PST)
Local: Tues, Jan 22 2013 5:58 am
Subject: Re: Detecting port and context path

Thanks Olve,

The following code works for both configured and auto-configured ports:

    @Override
    public void serverStarted(Server server) {
        // Detect the port jetty is listening on - works with configured-
and random-port
        for (Connector connector : server.getConnectors()) {
            if ( "main".equals( connector.getName() )) {
                this.httpPort = connector.getLocalPort();
                executeServiceUp();
            }
        }
    }

-Morten


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »