11package redis .clients .jedis .tests ;
22
3- import java .util .List ;
4- import java .util .concurrent .ExecutorService ;
5- import java .util .concurrent .Executors ;
6- import java .util .concurrent .ThreadPoolExecutor ;
7- import java .util .concurrent .TimeUnit ;
8- import java .util .concurrent .atomic .AtomicBoolean ;
9-
103import org .junit .After ;
114import org .junit .Assert ;
125import org .junit .Before ;
136import org .junit .Test ;
147
158import redis .clients .jedis .Connection ;
16- import redis .clients .jedis .Jedis ;
17- import redis .clients .jedis .JedisPool ;
18- import redis .clients .jedis .SortingParams ;
199import redis .clients .jedis .exceptions .JedisConnectionException ;
2010
2111public class ConnectionTest extends Assert {
@@ -51,51 +41,4 @@ public void connectIfNotConnectedWhenSettingTimeoutInfinite() {
5141 client .setTimeoutInfinite ();
5242 }
5343
54- @ Test
55- public void lala () throws InterruptedException {
56- final JedisPool jedisPool = new JedisPool ("localhost" );
57- ExecutorService executor = Executors .newFixedThreadPool (10 );
58- final AtomicBoolean ended = new AtomicBoolean (false );
59-
60- for (int n = 0 ; n < 10 ; n ++) {
61- executor .execute (new Runnable () {
62- @ Override
63- public void run () {
64- while (!ended .get ()) {
65- Jedis jedis = jedisPool .getResource ();
66- SortingParams sortingParameters = new SortingParams ();
67- String sortBy = "1:2:*->status" ;// assume key is 1:2:
68- String filterSetName = "1:2:jobIds" ;
69- sortingParameters .get ("a" , "b" , "c" );// assume that
70- // col1,
71- // col2, col3 are
72- // defined
73- sortingParameters .by (sortBy );
74- List <String > filteredAndsortedList = null ;
75- try {
76- filteredAndsortedList = jedis .sort (filterSetName ,
77- sortingParameters );
78- System .out .println ("Sorted List size "
79- + filteredAndsortedList .size ());
80- for (String str : filteredAndsortedList ) {
81- // System.out.println(str);
82- }
83- } catch (Exception e ) {
84- System .out .println ("-----Exception thrown-----" );
85- System .out .println (e );
86- System .out .println (" returned value is "
87- + filteredAndsortedList );
88- e .printStackTrace ();
89- } finally {
90- jedisPool .returnResource (jedis );
91- }
92- }
93- }
94- });
95- }
96- Thread .sleep (10000 );
97- ended .set (true );
98- executor .shutdown ();
99- executor .awaitTermination (10 , TimeUnit .SECONDS );
100- }
10144}
0 commit comments