summaryrefslogtreecommitdiff
path: root/matlab/test/Ice/operations/BatchOneways.m
blob: 38f5591aabc66ef303abe4e04c9caf4613aecc63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
%
% Copyright (c) ZeroC, Inc. All rights reserved.
%

classdef BatchOneways
    methods(Static)
        function batchOneways(helper, p)
            import Test.*;

            communicator = helper.communicator();
            properties = communicator.getProperties();
            bs1 = zeros(1, 10  * 1024);

            batch = p.ice_batchOneway();
            batch.ice_flushBatchRequests(); % Empty flush

            if ~isempty(batch.ice_getConnection())
                batch.ice_getConnection().flushBatchRequests(Ice.CompressBatch.BasedOnProxy);
            end
            communicator.flushBatchRequests(Ice.CompressBatch.BasedOnProxy);

            p.opByteSOnewayCallCount(); % Reset the call count

            for i = 1:30
                try
                    batch.opByteSOneway(bs1);
                catch ex
                    if isa(ex, 'Ice.MemoryLimitException')
                        assert(false);
                    else
                        rethrow(ex);
                    end
                end
            end

            count = 0;
            while count < 27 % 3 * 9 requests auto-flushed.
                count = count + p.opByteSOnewayCallCount();
                pause(0.1);
            end

            if ~isempty(batch.ice_getConnection())
                batch1 = p.ice_batchOneway();
                batch2 = p.ice_batchOneway();

                batch1.ice_ping();
                batch2.ice_ping();
                batch1.ice_flushBatchRequests();
                batch1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait);
                batch1.ice_ping();
                batch2.ice_ping();

                batch1.ice_getConnection();
                batch2.ice_getConnection();

                batch1.ice_ping();
                batch1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait);
                batch1.ice_ping();
                batch2.ice_ping();
            end

            identity = Ice.Identity();
            identity.name = 'invalid';
            batch3 = batch.ice_identity(identity);
            batch3.ice_ping();
            batch3.ice_flushBatchRequests();

            % Make sure that a bogus batch request doesn't cause troubles to other ones.
            batch3.ice_ping();
            batch.ice_ping();
            batch.ice_flushBatchRequests();
            batch.ice_ping();

            p.ice_ping();
            if ~isempty(p.ice_getConnection()) && isempty(properties.getProperty('Ice.Override.Compress'))
                prx = p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway();

                batchC1 = MyClassPrx.uncheckedCast(prx.ice_compress(false));
                batchC2 = MyClassPrx.uncheckedCast(prx.ice_compress(true));
                batchC3 = MyClassPrx.uncheckedCast(prx.ice_identity(identity));

                batchC1.opByteSOneway(bs1);
                batchC1.opByteSOneway(bs1);
                batchC1.opByteSOneway(bs1);
                batchC1.ice_getConnection().flushBatchRequests(Ice.CompressBatch.Yes);

                batchC2.opByteSOneway(bs1);
                batchC2.opByteSOneway(bs1);
                batchC2.opByteSOneway(bs1);
                batchC1.ice_getConnection().flushBatchRequests(Ice.CompressBatch.No);

                batchC1.opByteSOneway(bs1);
                batchC1.opByteSOneway(bs1);
                batchC1.opByteSOneway(bs1);
                batchC1.ice_getConnection().flushBatchRequests(Ice.CompressBatch.BasedOnProxy);

                batchC1.opByteSOneway(bs1);
                batchC2.opByteSOneway(bs1);
                batchC1.opByteSOneway(bs1);
                batchC1.ice_getConnection().flushBatchRequests(Ice.CompressBatch.BasedOnProxy);

                batchC1.opByteSOneway(bs1);
                batchC3.opByteSOneway(bs1);
                batchC1.opByteSOneway(bs1);
                batchC1.ice_getConnection().flushBatchRequests(Ice.CompressBatch.BasedOnProxy);
            end
        end
    end
end