All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.zeroc.IceInternal.ConnectionFlushBatch Maven / Gradle / Ivy

Go to download

Ice is a comprehensive RPC framework that helps you build distributed applications with minimal effort using familiar object-oriented idioms

There is a newer version: 3.7.10
Show newest version
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//

package com.zeroc.IceInternal;

import java.util.concurrent.Callable;

public class ConnectionFlushBatch extends OutgoingAsyncBaseI
{
    public ConnectionFlushBatch(com.zeroc.Ice.ConnectionI con, com.zeroc.Ice.Communicator communicator,
                                Instance instance)
    {
        super(communicator, instance, "flushBatchRequests");
        _connection = con;
    }

    @Override
    public com.zeroc.Ice.Connection getConnection()
    {
        return _connection;
    }

    @Override
    protected void markCompleted()
    {
        complete(null);
    }

    public void invoke(com.zeroc.Ice.CompressBatch compressBatch)
    {
        _observer = ObserverHelper.get(_instance, "flushBatchRequests");
        try
        {
            final BatchRequestQueue.SwapResult r = _connection.getBatchRequestQueue().swap(_os);
            int status;
            if(r == null)
            {
                status = AsyncStatus.Sent;
                if(sent())
                {
                    status |= AsyncStatus.InvokeSentCallback;
                }
            }
            else if(_instance.queueRequests())
            {
                status = _instance.getQueueExecutor().execute(new Callable()
                {
                    @Override
                    public Integer call()
                        throws RetryException
                    {
                        boolean comp = false;
                        if(compressBatch == com.zeroc.Ice.CompressBatch.Yes)
                        {
                            comp = true;
                        }
                        else if(compressBatch == com.zeroc.Ice.CompressBatch.No)
                        {
                            comp = false;
                        }
                        else
                        {
                            comp = r.compress;
                        }
                        return _connection.sendAsyncRequest(ConnectionFlushBatch.this, comp, false, r.batchRequestNum);
                    }
                });
            }
            else
            {
                boolean comp = false;
                if(compressBatch == com.zeroc.Ice.CompressBatch.Yes)
                {
                    comp = true;
                }
                else if(compressBatch == com.zeroc.Ice.CompressBatch.No)
                {
                    comp = false;
                }
                else
                {
                    comp = r.compress;
                }
                status = _connection.sendAsyncRequest(this, comp, false, r.batchRequestNum);
            }

            if((status & AsyncStatus.Sent) > 0)
            {
                _sentSynchronously = true;
                if((status & AsyncStatus.InvokeSentCallback) > 0)
                {
                    invokeSent();
                }
            }
        }
        catch(RetryException ex)
        {
            if(completed(ex.get()))
            {
                invokeCompletedAsync();
            }
        }
        catch(com.zeroc.Ice.Exception ex)
        {
            if(completed(ex))
            {
                invokeCompletedAsync();
            }
        }
    }

    private com.zeroc.Ice.ConnectionI _connection;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy