Examples of CuratorEntry


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

    @ThriftMethod
    public NodeCacheProjection startNodeCache(CuratorProjection projection, final String path, boolean dataIsCompressed, boolean buildInitial) throws RpcException
    {
        try
        {
            final CuratorEntry entry = CuratorEntry.mustGetEntry(connectionManager, projection);

            final NodeCache cache = new NodeCache(entry.getClient(), path, dataIsCompressed);
            cache.start(buildInitial);

            Closer closer = new Closer()
            {
                @Override
                public void close()
                {
                    try
                    {
                        cache.close();
                    }
                    catch ( IOException e )
                    {
                        log.error("Could not close left-over NodeCache for path: " + path, e);
                    }
                }
            };
            String id = entry.addThing(cache, closer);

            NodeCacheListener listener = new NodeCacheListener()
            {
                @Override
                public void nodeChanged()
                {
                    entry.addEvent(new RpcCuratorEvent(RpcCuratorEventType.NODE_CACHE, path));
                }
            };
            cache.getListenable().addListener(listener);

            return new NodeCacheProjection(id);
View Full Code Here

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

    @ThriftMethod
    public RpcChildData getNodeCacheData(CuratorProjection projection, NodeCacheProjection cacheProjection) throws RpcException
    {
        try
        {
            CuratorEntry entry = CuratorEntry.mustGetEntry(connectionManager, projection);

            NodeCache nodeCache = CuratorEntry.mustGetThing(entry, cacheProjection.id, NodeCache.class);
            return new RpcChildData(nodeCache.getCurrentData());
        }
        catch ( Exception e )
View Full Code Here

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

    @ThriftMethod
    public PersistentEphemeralNodeProjection startPersistentEphemeralNode(CuratorProjection projection, final String path, byte[] data, RpcPersistentEphemeralNodeMode mode) throws RpcException
    {
        try
        {
            CuratorEntry entry = CuratorEntry.mustGetEntry(connectionManager, projection);

            final PersistentEphemeralNode node = new PersistentEphemeralNode(entry.getClient(), PersistentEphemeralNode.Mode.valueOf(mode.name()), path, data);
            node.start();

            Closer closer = new Closer()
            {
                @Override
                public void close()
                {
                    try
                    {
                        node.close();
                    }
                    catch ( Exception e )
                    {
                        log.error("Could not release left-over persistent ephemeral node for path: " + path, e);
                    }
                }
            };
            String id = entry.addThing(node, closer);
            return new PersistentEphemeralNodeProjection(id);
        }
        catch ( Exception e )
        {
            throw new RpcException(e);
View Full Code Here

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

    @ThriftMethod
    public List<LeaseProjection> acquireSemaphore(CuratorProjection projection, final String path, int acquireQty, int maxWaitMs, int maxLeases) throws RpcException
    {
        try
        {
            CuratorEntry entry = CuratorEntry.mustGetEntry(connectionManager, projection);

            final InterProcessSemaphoreV2 semaphore = new InterProcessSemaphoreV2(entry.getClient(), path, maxLeases);
            final Collection<Lease> leases = semaphore.acquire(acquireQty, maxWaitMs, TimeUnit.MILLISECONDS);
            if ( leases == null )
            {
                return Lists.newArrayList();
            }

            List<LeaseProjection> leaseProjections = Lists.newArrayList();
            for ( final Lease lease : leases )
            {
                Closer closer = new Closer()
                {
                    @Override
                    public void close()
                    {
                        try
                        {
                            semaphore.returnLease(lease);
                        }
                        catch ( Exception e )
                        {
                            log.error("Could not release semaphore leases for path: " + path, e);
                        }
                    }
                };
                leaseProjections.add(new LeaseProjection(entry.addThing(lease, closer)));
            }
            return leaseProjections;
        }
        catch ( Exception e )
        {
View Full Code Here

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

        }
    }

    public void addEvent(CuratorProjection projection, RpcCuratorEvent event)
    {
        CuratorEntry entry = connectionManager.get(projection.id);
        if ( entry != null )
        {
            entry.addEvent(event);
        }
    }
View Full Code Here

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

    }

    @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

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

    @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

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

    @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

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

    @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

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

    }

    @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
TOP
Copyright © 2018 www.massapi.com. 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.