serverExec.shutdown();
}
private static void invokeClient01(String groupId, int serverPort, boolean denseModel)
throws InterruptedException {
PredictionModel model = denseModel ? new DenseModel(100, false)
: new SparseModel(100, false);
model.configureClock();
MixClient client = null;
try {
client = new MixClient(MixEventName.average, groupId, "localhost:" + serverPort, false, 3, model);
model.setUpdateHandler(client);
final Random rand = new Random(43);
for(int i = 0; i < 1000000; i++) {
Integer feature = Integer.valueOf(rand.nextInt(100));
float weight = rand.nextFloat() >= 0.5f ? 1.f : 0.f;
model.set(feature, new WeightValue(weight));
}
waitForMixed(model, 100000, 10000L);
int numMixed = model.getNumMixed();
//System.out.println("number of mix events: " + numMixed);
Assert.assertTrue("number of mix events: " + numMixed, numMixed > 0);
for(int i = 0; i < 100; i++) {
float w = model.getWeight(i);
Assert.assertEquals(0.5f, w, 0.1f);
}
} finally {
IOUtils.closeQuietly(client);
}