Package org.apache.curator.x.rpc.connections

Examples of org.apache.curator.x.rpc.connections.CuratorEntry$Entry


    }

    @ThriftMethod
    public void noteError(CuratorProjection projection, DiscoveryProviderProjection providerProjection, String instanceId) throws RpcException
    {
        CuratorEntry entry = CuratorEntry.mustGetEntry(connectionManager, projection);
        @SuppressWarnings("unchecked")
        ServiceProvider<byte[]> serviceProvider = CuratorEntry.mustGetThing(entry, providerProjection.id, ServiceProvider.class);
        try
        {
            for ( ServiceInstance<byte[]> instance : serviceProvider.getAllInstances() )
View Full Code Here


    @ThriftMethod
    public void registerInstance(CuratorProjection projection, DiscoveryProjection discoveryProjection, DiscoveryInstance instance) throws RpcException
    {
        try
        {
            CuratorEntry entry = CuratorEntry.mustGetEntry(connectionManager, projection);
            @SuppressWarnings("unchecked")
            ServiceDiscovery<byte[]> serviceDiscovery = CuratorEntry.mustGetThing(entry, discoveryProjection.id, ServiceDiscovery.class);
            serviceDiscovery.registerService(instance.toReal());
        }
        catch ( Exception e )
View Full Code Here

    @ThriftMethod
    public void updateInstance(CuratorProjection projection, DiscoveryProjection discoveryProjection, DiscoveryInstance instance) throws RpcException
    {
        try
        {
            CuratorEntry entry = CuratorEntry.mustGetEntry(connectionManager, projection);
            @SuppressWarnings("unchecked")
            ServiceDiscovery<byte[]> serviceDiscovery = CuratorEntry.mustGetThing(entry, discoveryProjection.id, ServiceDiscovery.class);
            serviceDiscovery.updateService(instance.toReal());
        }
        catch ( Exception e )
View Full Code Here

    @ThriftMethod
    public void unregisterInstance(CuratorProjection projection, DiscoveryProjection discoveryProjection, DiscoveryInstance instance) throws RpcException
    {
        try
        {
            CuratorEntry entry = CuratorEntry.mustGetEntry(connectionManager, projection);
            @SuppressWarnings("unchecked")
            ServiceDiscovery<byte[]> serviceDiscovery = CuratorEntry.mustGetThing(entry, discoveryProjection.id, ServiceDiscovery.class);
            serviceDiscovery.unregisterService(instance.toReal());
        }
        catch ( Exception e )
View Full Code Here

    }

    @ThriftMethod
    public Collection<String> queryForNames(CuratorProjection projection, DiscoveryProjection discoveryProjection) throws RpcException
    {
        CuratorEntry entry = CuratorEntry.mustGetEntry(connectionManager, projection);
        @SuppressWarnings("unchecked")
        ServiceDiscovery<byte[]> serviceDiscovery = CuratorEntry.mustGetThing(entry, discoveryProjection.id, ServiceDiscovery.class);
        try
        {
            return serviceDiscovery.queryForNames();
View Full Code Here

    }

    @ThriftMethod
    public DiscoveryInstance queryForInstance(CuratorProjection projection, DiscoveryProjection discoveryProjection, String name, String id) throws RpcException
    {
        CuratorEntry entry = CuratorEntry.mustGetEntry(connectionManager, projection);
        @SuppressWarnings("unchecked")
        ServiceDiscovery<byte[]> serviceDiscovery = CuratorEntry.mustGetThing(entry, discoveryProjection.id, ServiceDiscovery.class);
        try
        {
            return new DiscoveryInstance(serviceDiscovery.queryForInstance(name, id));
View Full Code Here

    }

    @ThriftMethod
    public Collection<DiscoveryInstance> queryForInstances(CuratorProjection projection, DiscoveryProjection discoveryProjection, String name) throws RpcException
    {
        CuratorEntry entry = CuratorEntry.mustGetEntry(connectionManager, projection);
        @SuppressWarnings("unchecked")
        ServiceDiscovery<byte[]> serviceDiscovery = CuratorEntry.mustGetThing(entry, discoveryProjection.id, ServiceDiscovery.class);
        try
        {
            Collection<ServiceInstance<byte[]>> instances = serviceDiscovery.queryForInstances(name);
View Full Code Here

    @ThriftMethod
    public RpcCuratorEvent getNextEvent(CuratorProjection projection) throws RpcException
    {
        try
        {
            CuratorEntry entry = CuratorEntry.mustGetEntry(connectionManager, projection);
            RpcCuratorEvent event = entry.pollForEvent(pingTimeMs);
            return (event != null) ? event : new RpcCuratorEvent();
        }
        catch ( InterruptedException e )
        {
            throw new RpcException(e);
View Full Code Here

    @ThriftMethod
    public DiscoveryProjection startDiscovery(CuratorProjection projection, final String basePath, DiscoveryInstance yourInstance) throws RpcException
    {
        try
        {
            CuratorEntry entry = CuratorEntry.mustGetEntry(connectionManager, projection);
            final ServiceDiscovery<byte[]> serviceDiscovery = ServiceDiscoveryBuilder
                .builder(byte[].class)
                .basePath(basePath)
                .client(entry.getClient())
                .thisInstance((yourInstance != null) ? yourInstance.toReal() : null)
                .build();
            serviceDiscovery.start();

            Closer closer = new Closer()
            {
                @Override
                public void close()
                {
                    try
                    {
                        serviceDiscovery.close();
                    }
                    catch ( IOException e )
                    {
                        log.error("Could not close ServiceDiscovery with basePath: " + basePath, e);
                    }
                }
            };
            String id = entry.addThing(serviceDiscovery, closer);

            return new DiscoveryProjection(id);
        }
        catch ( Exception e )
        {
View Full Code Here

                strategy = new RoundRobinStrategy<byte[]>();
                break;
            }
        }

        CuratorEntry entry = CuratorEntry.mustGetEntry(connectionManager, projection);
        @SuppressWarnings("unchecked")
        ServiceDiscovery<byte[]> serviceDiscovery = CuratorEntry.mustGetThing(entry, discoveryProjection.id, ServiceDiscovery.class);
        final ServiceProvider<byte[]> serviceProvider = serviceDiscovery
            .serviceProviderBuilder()
            .downInstancePolicy(new DownInstancePolicy(downTimeoutMs, TimeUnit.MILLISECONDS, downErrorThreshold))
            .providerStrategy(strategy)
            .serviceName(serviceName)
            .build();
        try
        {
            serviceProvider.start();
            Closer closer = new Closer()
            {
                @Override
                public void close()
                {
                    try
                    {
                        serviceProvider.close();
                    }
                    catch ( IOException e )
                    {
                        log.error("Could not close ServiceProvider with serviceName: " + serviceName, e);
                    }
                }
            };
            String id = entry.addThing(serviceProvider, closer);
            return new DiscoveryProviderProjection(id);
        }
        catch ( Exception e )
        {
            throw new RpcException(e);
View Full Code Here

TOP

Related Classes of org.apache.curator.x.rpc.connections.CuratorEntry$Entry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.