latch.await();
System.out.println("D2 client is sending traffic.");
System.out.println("Note that traffic for 'member' will go mostly to ProfileService 1,3,5 servers.");
System.out.println("Because we make ProfileService 2,4,6 servers respond slowly \n");
ScheduledFuture task = executorService.scheduleAtFixedRate(new Runnable()
{
@Override
public void run ()
{
try
{
sendTraffic(trafficProportion, d2Client, null);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}, 0, 1000, TimeUnit.MILLISECONDS);
System.out.println("Press enter to restore the health of all the servers\n\n\n");
System.out.println("After this line you will see d2 client will start logging warning"
+ " message because server 2,4,6's latencies are higher than" +
"the threshold (high water mark).");
System.out.println("===========================================================");
System.in.read();
task.cancel(false);
task = executorService.scheduleAtFixedRate(new Runnable()
{
@Override
public void run ()
{
try
{
sendTraffic(trafficProportion, d2Client, 0l);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}, 0, 1000, TimeUnit.MILLISECONDS);
System.out.println("=========================================================\n\n\n");
System.out.println("Now all servers are healthy. Traffic for 'member' " +
"will be balanced between profile service 1,2,3,4,5,6.");
System.out.println("Press enter to shut down\n\n");
System.in.read();
task.cancel(false);
System.out.println("Shutting down...");
shutdown(d2Client, executorService, clientShutdownTimeout);
}