1919
2020import java .util .Collection ;
2121import java .util .Collections ;
22+ import java .util .EnumSet ;
2223import java .util .HashMap ;
2324import java .util .UUID ;
2425import java .util .concurrent .atomic .AtomicInteger ;
25- import java .util .function .Consumer ;
2626import org .apache .ignite .Ignition ;
27+ import org .apache .ignite .cache .CacheAtomicityMode ;
2728import org .apache .ignite .client .ClientCache ;
29+ import org .apache .ignite .client .ClientCacheConfiguration ;
2830import org .apache .ignite .client .ClientTransaction ;
2931import org .apache .ignite .client .Config ;
3032import org .apache .ignite .client .IgniteClient ;
3335import org .apache .ignite .configuration .IgniteConfiguration ;
3436import org .apache .ignite .configuration .ThinClientConfiguration ;
3537import org .apache .ignite .internal .IgniteEx ;
38+ import org .apache .ignite .internal .client .thin .TcpClientCache ;
3639import org .apache .ignite .internal .client .thin .TestTask ;
40+ import org .apache .ignite .internal .processors .cache .version .GridCacheVersion ;
3741import org .apache .ignite .internal .util .GridIntList ;
42+ import org .apache .ignite .internal .util .lang .ConsumerX ;
3843import org .apache .ignite .internal .util .typedef .F ;
44+ import org .apache .ignite .internal .util .typedef .T3 ;
3945import org .apache .ignite .internal .util .typedef .internal .CU ;
4046import org .apache .ignite .internal .util .typedef .internal .U ;
4147import org .apache .ignite .lang .IgniteUuid ;
4248import org .junit .Test ;
49+ import org .junit .runner .RunWith ;
50+ import org .junit .runners .Parameterized ;
4351
52+ import static org .apache .ignite .cache .CacheAtomicityMode .ATOMIC ;
53+ import static org .apache .ignite .cache .CacheAtomicityMode .TRANSACTIONAL ;
4454import static org .apache .ignite .internal .processors .performancestatistics .OperationType .CACHE_GET ;
4555import static org .apache .ignite .internal .processors .performancestatistics .OperationType .CACHE_GET_ALL ;
4656import static org .apache .ignite .internal .processors .performancestatistics .OperationType .CACHE_GET_AND_PUT ;
4757import static org .apache .ignite .internal .processors .performancestatistics .OperationType .CACHE_GET_AND_REMOVE ;
4858import static org .apache .ignite .internal .processors .performancestatistics .OperationType .CACHE_PUT ;
4959import static org .apache .ignite .internal .processors .performancestatistics .OperationType .CACHE_PUT_ALL ;
60+ import static org .apache .ignite .internal .processors .performancestatistics .OperationType .CACHE_PUT_ALL_CONFLICT ;
5061import static org .apache .ignite .internal .processors .performancestatistics .OperationType .CACHE_REMOVE ;
5162import static org .apache .ignite .internal .processors .performancestatistics .OperationType .CACHE_REMOVE_ALL ;
63+ import static org .apache .ignite .internal .processors .performancestatistics .OperationType .CACHE_REMOVE_ALL_CONFLICT ;
64+ import static org .junit .Assume .assumeTrue ;
5265
5366/**
5467 * Tests thin client performance statistics.
5568 */
69+ @ RunWith (Parameterized .class )
5670public class PerformanceStatisticsThinClientTest extends AbstractPerformanceStatisticsTest {
5771 /** Test task name. */
5872 public static final String TEST_TASK_NAME = "TestTask" ;
@@ -66,12 +80,20 @@ public class PerformanceStatisticsThinClientTest extends AbstractPerformanceStat
6680 /** Thin client. */
6781 private static IgniteClient thinClient ;
6882
83+ /** */
84+ @ Parameterized .Parameter
85+ public CacheAtomicityMode atomicityMode ;
86+
87+ /** */
88+ @ Parameterized .Parameters (name = "atomicityMode={0}" )
89+ public static Collection <?> parameters () {
90+ return EnumSet .of (ATOMIC , TRANSACTIONAL );
91+ }
92+
6993 /** {@inheritDoc} */
7094 @ Override protected IgniteConfiguration getConfiguration (String igniteInstanceName ) throws Exception {
7195 IgniteConfiguration cfg = super .getConfiguration (igniteInstanceName );
7296
73- cfg .setCacheConfiguration (defaultCacheConfiguration ());
74-
7597 cfg .setClientConnectorConfiguration (
7698 new ClientConnectorConfiguration ().setThinClientConfiguration (
7799 new ThinClientConfiguration ().setMaxActiveComputeTasksPerConnection (ACTIVE_TASKS_LIMIT )));
@@ -96,9 +118,22 @@ public class PerformanceStatisticsThinClientTest extends AbstractPerformanceStat
96118 @ Override protected void afterTestsStopped () throws Exception {
97119 super .afterTestsStopped ();
98120
121+ stopAllGrids ();
99122 thinClient .close ();
100123 }
101124
125+ /** {@inheritDoc} */
126+ @ Override protected void beforeTest () throws Exception {
127+ thinClient .createCache (new ClientCacheConfiguration ()
128+ .setName (DEFAULT_CACHE_NAME )
129+ .setAtomicityMode (atomicityMode ));
130+ }
131+
132+ /** {@inheritDoc} */
133+ @ Override protected void afterTest () throws Exception {
134+ thinClient .destroyCache (DEFAULT_CACHE_NAME );
135+ }
136+
102137 /** @throws Exception If failed. */
103138 @ Test
104139 public void testCompute () throws Exception {
@@ -169,10 +204,24 @@ public void testCacheOperation() throws Exception {
169204 checkCacheOperation (CACHE_REMOVE_ALL , cache -> cache .removeAll (Collections .singleton (3 )));
170205
171206 checkCacheOperation (CACHE_GET_AND_REMOVE , cache -> cache .getAndRemove (5 ));
207+
208+ GridCacheVersion confl = new GridCacheVersion (1 , 0 , 1 , (byte )2 );
209+
210+ checkCacheOperation (CACHE_PUT_ALL_CONFLICT , cache -> ((TcpClientCache <Object , Object >)cache )
211+ .putAllConflict (F .asMap (6 , new T3 <>(1 , confl , CU .EXPIRE_TIME_ETERNAL ))));
212+
213+ checkCacheOperation (CACHE_REMOVE_ALL_CONFLICT , cache -> ((TcpClientCache <Object , Object >)cache )
214+ .removeAllConflict (F .asMap (6 , confl )));
215+
216+ checkCacheOperation (CACHE_PUT_ALL_CONFLICT , cache -> ((TcpClientCache <Object , Object >)cache )
217+ .putAllConflictAsync (F .asMap (7 , new T3 <>(2 , confl , CU .EXPIRE_TIME_ETERNAL ))).get ());
218+
219+ checkCacheOperation (CACHE_REMOVE_ALL_CONFLICT , cache -> ((TcpClientCache <Object , Object >)cache )
220+ .removeAllConflictAsync (F .asMap (7 , confl )).get ());
172221 }
173222
174223 /** Checks cache operation. */
175- private void checkCacheOperation (OperationType op , Consumer <ClientCache <Object , Object >> clo ) throws Exception {
224+ private void checkCacheOperation (OperationType op , ConsumerX <ClientCache <Object , Object >> clo ) throws Exception {
176225 long startTime = U .currentTimeMillis ();
177226
178227 cleanPerformanceStatisticsDir ();
@@ -202,6 +251,8 @@ private void checkCacheOperation(OperationType op, Consumer<ClientCache<Object,
202251 /** @throws Exception If failed. */
203252 @ Test
204253 public void testTransaction () throws Exception {
254+ assumeTrue (atomicityMode == TRANSACTIONAL );
255+
205256 checkTx (true );
206257
207258 checkTx (false );
0 commit comments