You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@curator.apache.org by "Huang, Ying-Yi" <yh...@etrade.com> on 2014/02/07 00:33:00 UTC

Static/Permanent service type

When I use service discovery Java API to register a service instance, the service type default is dynamic.  The service instance node is ephemeral in ZooKeeper so the node is deleted when the program exits.  However, if I set the service type to static or permanent, the node is still deleted when the program exits. At ZooKeeper, the node created is not ephemeral though.   I am wondering if this is by design.  Is there any way to create static/permanent service with Java API? Or they can only be created with RESTFul API though x-discover-server.

Thanks,
Ying-Yi

Re: Static/Permanent service type

Posted by Jordan Zimmerman <jo...@jordanzimmerman.com>.
Hmm - that’s a good point. I wonder if PERMANENT should be excluded. The idea here is that the instance is going down so any services that it registered should go down too. But, I can see an argument that PERMANENT should not. However, this implementation has been released for a long time so I’d be concerned about breaking existing code. Maybe a method could be added to designate which service types are unregistered when the ServiceDiscovery instance is closed.

-JZ

From: Huang, Ying-Yi Huang, Ying-Yi
Reply: Huang, Ying-Yi yhuang@etrade.com
Date: February 10, 2014 at 7:43:59 PM
To: Jordan Zimmerman jordan@jordanzimmerman.com
Subject:  Re: Static/Permanent service type  
Services registered with service discovery would get unregistered when close() is called. This will remove all services including static and permanent. Is this the designed behavior?  

public class ServiceDiscoveryImpl<T> implements ServiceDiscovery<T>  
{  
@Override  
public void close() throws IOException  
{  
for ( ServiceCache<T> cache : Lists.newArrayList(caches) )  
{  
Closeables.closeQuietly(cache);  
}  
for ( ServiceProvider<T> provider : Lists.newArrayList(providers) )  
{  
Closeables.closeQuietly(provider);  
}  

for ( ServiceInstance<T> service : services.values() )  
{  
try  
{  
unregisterService(service);  
}  
catch ( Exception e )  
{  
log.error("Could not unregister instance: " + service.getName(), e);  
}  
}  

client.getConnectionStateListenable().removeListener(connectionStateListener);  
}  
}  

Thanks,  
Ying-Yi  
On Feb 7, 2014, at 6:24 PM, Jordan Zimmerman <jo...@jordanzimmerman.com>>  
wrote:  

ServiceType.DYNAMIC is not supported. It makes sense because there is no session for the REST API.  

-JZ  

________________________________  
From: Huang, Ying-Yi Huang, Ying-Yi<ma...@etrade.com>  
Reply: Huang, Ying-Yi yhuang@etrade.com<ma...@etrade.com>  
Date: February 7, 2014 at 1:29:12 PM  
To: Jordan Zimmerman jordan@jordanzimmerman.com<ma...@jordanzimmerman.com>  
Subject: Re: Static/Permanent service type  
A general question is that are all three types of services supported in Java API and RESTFul API?  


Re: Static/Permanent service type

Posted by "Huang, Ying-Yi" <yh...@etrade.com>.
Services registered with service discovery would get unregistered when  close() is called.  This will remove all services including static and permanent. Is this the designed behavior?

public class ServiceDiscoveryImpl<T> implements ServiceDiscovery<T>
{
        @Override
    public void close() throws IOException
    {
        for ( ServiceCache<T> cache : Lists.newArrayList(caches) )
        {
            Closeables.closeQuietly(cache);
        }
        for ( ServiceProvider<T> provider : Lists.newArrayList(providers) )
        {
            Closeables.closeQuietly(provider);
        }

        for ( ServiceInstance<T> service : services.values() )
        {
            try
            {
                unregisterService(service);
            }
            catch ( Exception e )
            {
                log.error("Could not unregister instance: " + service.getName(), e);
            }
        }

        client.getConnectionStateListenable().removeListener(connectionStateListener);
    }
}

Thanks,
Ying-Yi
On Feb 7, 2014, at 6:24 PM, Jordan Zimmerman <jo...@jordanzimmerman.com>>
 wrote:

ServiceType.DYNAMIC is not supported. It makes sense because there is no session for the REST API.

-JZ

________________________________
From: Huang, Ying-Yi Huang, Ying-Yi<ma...@etrade.com>
Reply: Huang, Ying-Yi yhuang@etrade.com<ma...@etrade.com>
Date: February 7, 2014 at 1:29:12 PM
To: Jordan Zimmerman jordan@jordanzimmerman.com<ma...@jordanzimmerman.com>
Subject:  Re: Static/Permanent service type
A general question is that are all three types of services supported in Java API and RESTFul API?


Re: Static/Permanent service type

Posted by Jordan Zimmerman <jo...@jordanzimmerman.com>.
ServiceType.DYNAMIC is not supported. It makes sense because there is no session for the REST API.

-JZ

From: Huang, Ying-Yi Huang, Ying-Yi
Reply: Huang, Ying-Yi yhuang@etrade.com
Date: February 7, 2014 at 1:29:12 PM
To: Jordan Zimmerman jordan@jordanzimmerman.com
Subject:  Re: Static/Permanent service type  
A general question is that are all three types of services supported in Java API and RESTFul API?

Re: Static/Permanent service type

Posted by "Huang, Ying-Yi" <yh...@etrade.com>.
Not really. Instance cleanup is part of x-discovery-server.  When create a service node of static from Java API, there is no parameter for refreshing time. Nor there is cleanup object.  A general question is that are all three types of services supported in Java API and RESTFul API? Here is the summary from my tests:

Java API,
-  Dynamic service works.  An ephemeral node is created at ZK.
- Static/Permanent service doesn't work.  Normal node is created at ZK but get deleted when program exits.

RESTFul API,
- Not able to create dynamic service node. Got error

Caused by: com.sun.jersey.api.client.UniformInterfaceException: PUT http://localhost:51234/v1/service/staticSvc/8193610a-bdd6-4c2f-a9ec-6dc7c89b8679 returned a response status of 400 Bad Request

- Static and permanent work fine.

Thanks,
Ying-Yi

On Feb 6, 2014, at 6:38 PM, Jordan Zimmerman <jo...@jordanzimmerman.com>>
 wrote:

This sounds like https://issues.apache.org/jira/browse/CURATOR-81 which is fixed in 2.4.1 which will be released any day now. Let me know if it’s something different.

-JZ

________________________________
From: Huang, Ying-Yi Huang, Ying-Yi<ma...@etrade.com>
Reply: user@curator.apache.org<ma...@curator.apache.org> user@curator.apache.org<ma...@curator.apache.org>
Date: February 6, 2014 at 6:33:47 PM
To: user@curator.apache.org<ma...@curator.apache.org> user@curator.apache.org<ma...@curator.apache.org>
Subject:  Static/Permanent service type
When I use service discovery Java API to register a service instance, the service type default is dynamic. The service instance node is ephemeral in ZooKeeper so the node is deleted when the program exits. However, if I set the service type to static or permanent, the node is still deleted when the program exits. At ZooKeeper, the node created is not ephemeral though. I am wondering if this is by design. Is there any way to create static/permanent service with Java API? Or they can only be created with RESTFul API though x-discover-server.

Thanks,
Ying-Yi


Re: Static/Permanent service type

Posted by Jordan Zimmerman <jo...@jordanzimmerman.com>.
This sounds like https://issues.apache.org/jira/browse/CURATOR-81 which is fixed in 2.4.1 which will be released any day now. Let me know if it’s something different.

-JZ

From: Huang, Ying-Yi Huang, Ying-Yi
Reply: user@curator.apache.org user@curator.apache.org
Date: February 6, 2014 at 6:33:47 PM
To: user@curator.apache.org user@curator.apache.org
Subject:  Static/Permanent service type  
When I use service discovery Java API to register a service instance, the service type default is dynamic. The service instance node is ephemeral in ZooKeeper so the node is deleted when the program exits. However, if I set the service type to static or permanent, the node is still deleted when the program exits. At ZooKeeper, the node created is not ephemeral though. I am wondering if this is by design. Is there any way to create static/permanent service with Java API? Or they can only be created with RESTFul API though x-discover-server.  

Thanks,  
Ying-Yi