Search in sources :

Example 26 with User

use of com.xrtb.db.User in project XRTB by benmfaul.

the class JunkDomainUser method run.

public void run() {
    try {
        flag.await();
        System.out.println("User " + name + " running.");
        TestDatabaseObject.db.put(u);
        User x = TestDatabaseObject.db.get(name);
        if (x == null) {
            System.err.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
        }
        latch.countDown();
        System.out.println("User " + name + " complete");
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : User(com.xrtb.db.User)

Example 27 with User

use of com.xrtb.db.User in project XRTB by benmfaul.

the class Configuration method readDatabaseIntoCache.

/**
	 * Used to load ./database.json into Cache2k. This is used when aerospike is
	 * not present. This instance will handle its own cache, and do its own win
	 * processing.
	 * 
	 * @param fname
	 *            String. The file name of the database.
	 * @throws Exception
	 *             on file or cache2k errors.
	 */
private static void readDatabaseIntoCache(String fname) throws Exception {
    String content = new String(Files.readAllBytes(Paths.get(fname)), StandardCharsets.UTF_8);
    System.out.println(content);
    Database db = Database.getInstance();
    List<User> users = DbTools.mapper.readValue(content, DbTools.mapper.getTypeFactory().constructCollectionType(List.class, User.class));
    for (User u : users) {
        db.addUser(u);
    }
}
Also used : User(com.xrtb.db.User) Database(com.xrtb.db.Database) List(java.util.List) ArrayList(java.util.ArrayList)

Example 28 with User

use of com.xrtb.db.User in project XRTB by benmfaul.

the class Config method setup.

public static void setup(String configFile) throws Exception {
    try {
        DbTools tools = new DbTools("localhost:3000");
        tools.clear();
        tools.loadDatabase("database.json");
        if (server == null) {
            server = new RTBServer(configFile);
            int wait = 0;
            while (!server.isReady() && wait < 10) {
                Thread.sleep(1000);
                wait++;
            }
            if (wait == 10) {
                fail("Server never started");
            }
            Thread.sleep(1000);
        } else {
            Configuration c = Configuration.getInstance();
            c.campaignsList.clear();
            User u = DataBaseObject.getInstance().get("ben");
            for (Campaign camp : u.campaigns) {
                c.addCampaign("ben", camp.adId);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.toString());
    }
}
Also used : RTBServer(com.xrtb.bidder.RTBServer) User(com.xrtb.db.User) Campaign(com.xrtb.common.Campaign) Configuration(com.xrtb.common.Configuration) DbTools(com.xrtb.tools.DbTools)

Aggregations

User (com.xrtb.db.User)28 Campaign (com.xrtb.common.Campaign)13 ArrayList (java.util.ArrayList)11 HashMap (java.util.HashMap)9 Map (java.util.Map)9 List (java.util.List)7 RTBServer (com.xrtb.bidder.RTBServer)5 Configuration (com.xrtb.common.Configuration)5 DbTools (com.xrtb.tools.DbTools)5 Test (org.junit.Test)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 Node (com.xrtb.common.Node)3 BidRequest (com.xrtb.pojo.BidRequest)3 File (java.io.File)2 Set (java.util.Set)2 HttpSession (javax.servlet.http.HttpSession)2 BeforeClass (org.junit.BeforeClass)2 AddCampaign (com.xrtb.commands.AddCampaign)1 DeleteCampaign (com.xrtb.commands.DeleteCampaign)1 DataBaseObject (com.xrtb.db.DataBaseObject)1