Search in sources :

Example 1 with RedissonClient

use of com.aerospike.redisson.RedissonClient in project XRTB by benmfaul.

the class TestFreqCapLogc method test1M.

@Test
public void test1M() throws Exception {
    AerospikeHandler client = AerospikeHandler.getInstance("localhost", 3000, 300);
    RedissonClient redisson = new RedissonClient(client);
    Set<String> set = new HashSet();
    for (int i = 0; i < 1000; i++) {
        String key = "JUNK" + i;
        System.out.println(key);
        set.add(key);
        redisson.set(key, key, 120);
    }
    System.out.println("Assignment complete");
    for (String s : set) {
        assertNotNull(redisson.get(s));
    }
    System.out.println("Test 1 complete");
    Thread.sleep(125000);
    for (String s : set) {
        assertNull(redisson.get(s));
    }
}
Also used : RedissonClient(com.aerospike.redisson.RedissonClient) AerospikeHandler(com.aerospike.redisson.AerospikeHandler) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with RedissonClient

use of com.aerospike.redisson.RedissonClient in project XRTB by benmfaul.

the class AeroConfiguration method main.

/**
 * The application. -set key filename, or -get key
 * @param args String[]. The arguments.
 * @throws Exception on errors.
 */
public static void main(String[] args) throws Exception {
    String name = null;
    String cmd = null;
    String contents = null;
    String spike = "localhost";
    int i = 0;
    if (args.length > 0) {
        while (i < args.length) {
            switch(args[i]) {
                case "-h":
                    System.out.println("-aero <host:port>       [Sets the host:port string of the cache        ]");
                    System.out.println("-set  <name> <filename> [Set <name> to contents of <filename> contents ]");
                    System.out.println("-get  <name>            [Print the contents of name                   ]");
                    System.exit(0);
                case "-aero":
                    spike = args[i + 1];
                    i += 2;
                    break;
                case "-set":
                    cmd = args[i];
                    name = args[i + 1];
                    contents = new String(Files.readAllBytes(Paths.get(args[i + 2])), StandardCharsets.UTF_8);
                    i += 3;
                    break;
                case "-get":
                    cmd = args[i];
                    name = args[i + 1];
                    i += 2;
                    break;
            }
        }
    }
    if (cmd == null) {
        System.out.println("Please use either -get or -set");
        System.exit(0);
        ;
    }
    AerospikeHandler ae = AerospikeHandler.getInstance(spike, 3000, 300);
    RedissonClient redisson = new RedissonClient(ae);
    if (cmd.equals("-get")) {
        contents = redisson.get(name);
        System.out.println(contents);
    }
    if (cmd.equals("-set")) {
        redisson.set(name, contents);
    }
    System.exit(0);
}
Also used : RedissonClient(com.aerospike.redisson.RedissonClient) AerospikeHandler(com.aerospike.redisson.AerospikeHandler)

Example 3 with RedissonClient

use of com.aerospike.redisson.RedissonClient in project XRTB by benmfaul.

the class TestWinProcessing method setup.

@BeforeClass
public static void setup() {
    try {
        AerospikeHandler spike = AerospikeHandler.getInstance("localhost", 3000, 300);
        redisson = new RedissonClient(spike);
        Config.setup();
        System.out.println("******************  TestWinProcessing");
        password = Configuration.getInstance().password;
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : RedissonClient(com.aerospike.redisson.RedissonClient) AerospikeHandler(com.aerospike.redisson.AerospikeHandler) BeforeClass(org.junit.BeforeClass)

Example 4 with RedissonClient

use of com.aerospike.redisson.RedissonClient in project XRTB by benmfaul.

the class TestDeadmanSwitch method testSwitch.

/**
 * @throws Exception
 */
@Test
public void testSwitch() throws Exception {
    AerospikeHandler spike = AerospikeHandler.getInstance("localhost", 3000, 300);
    RedissonClient redisson = new RedissonClient(spike);
    DeadmanSwitch.testmode = true;
    redisson.del("deadmanswitch");
    DeadmanSwitch d = new DeadmanSwitch(redisson, "deadmanswitch");
    Thread.sleep(1000);
    assertFalse(d.canRun());
    redisson.set("deadmanswitch", "ready", 5);
    assertTrue(d.canRun());
    Thread.sleep(10000);
    assertFalse(d.canRun());
}
Also used : RedissonClient(com.aerospike.redisson.RedissonClient) DeadmanSwitch(com.xrtb.bidder.DeadmanSwitch) AerospikeHandler(com.aerospike.redisson.AerospikeHandler) Test(org.junit.Test)

Example 5 with RedissonClient

use of com.aerospike.redisson.RedissonClient in project XRTB by benmfaul.

the class TestDeadmanSwitch method testDelayedExpire.

@Test
public void testDelayedExpire() throws Exception {
    AerospikeHandler spike = AerospikeHandler.getInstance("localhost", 3000, 300);
    RedissonClient redisson = new RedissonClient(spike);
    redisson.del("xxx");
    Map m = new HashMap();
    m.put("Ben", 1);
    m.put("Peter", 2);
    redisson.hmset("xxx", m);
    m = redisson.hgetAll("xxx");
    assertNotNull(m);
    Long n = (Long) m.get("Ben");
    assertNotNull(n);
    redisson.expire("xxx", 2);
    m = redisson.hgetAll("xxx");
    assertNotNull(m);
    n = (Long) m.get("Ben");
    assertNotNull(n);
    Thread.sleep(5000);
    m = redisson.hgetAll("xxx");
    assertNull(m);
}
Also used : RedissonClient(com.aerospike.redisson.RedissonClient) HashMap(java.util.HashMap) AerospikeHandler(com.aerospike.redisson.AerospikeHandler) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

AerospikeHandler (com.aerospike.redisson.AerospikeHandler)9 RedissonClient (com.aerospike.redisson.RedissonClient)9 Test (org.junit.Test)4 DeadmanSwitch (com.xrtb.bidder.DeadmanSwitch)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)1 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)1 ListObjectsRequest (com.amazonaws.services.s3.model.ListObjectsRequest)1 ObjectListing (com.amazonaws.services.s3.model.ObjectListing)1 S3Object (com.amazonaws.services.s3.model.S3Object)1 NavMap (com.xrtb.blocks.NavMap)1 DataBaseObject (com.xrtb.db.DataBaseObject)1 Database (com.xrtb.db.Database)1 Appnexus (com.xrtb.exchanges.appnexus.Appnexus)1 ForensiqClient (com.xrtb.fraud.ForensiqClient)1 MMDBClient (com.xrtb.fraud.MMDBClient)1 BidRequest (com.xrtb.pojo.BidRequest)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1