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();
}
}
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);
}
}
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());
}
}
Aggregations