Thread.sleep((long) (Math.log(NB_PEERS) * 1000));
System.out.println("\nTurn around after second stabilization");
turnAround(tracker.getRandomPeer());
// A GuideMichelin is created. It will use the Chord network
GuideMichelin guideMichelin = new GuideMichelinImpl(tracker);
// Some data are added to the {@link GuideMichelin}
DataGenerator dataGenerator = new DataGenerator(10);
Map<String, String> newData;
for(int i = 0 ; i < 10 ; i++)
{
newData = dataGenerator.getNewData();
for(Map.Entry<String, String> entry : newData.entrySet())
{
guideMichelin.put(entry.getKey(), entry.getValue(), 5);
}
}
// The peers are listed again with the data they store
Thread.sleep(2000);
System.out.println("\nTurn around after adding data");
turnAround(tracker.getRandomPeer());
// Some data are requested from the GuideMichelin
String[] restaurants = {"Le Bistrot Gourmand" , "Auberge de la Madone" , "toto"};
for(String restaurant : restaurants)
{
System.out.println("\nRestaurant '" + restaurant + "' - Daily special: '" + guideMichelin.get(restaurant)
+ "'");
}
System.out.println("TEST\n");
String str = "";
Map<String, String> restaurantsTest2 = new HashMap<String, String>();
restaurantsTest2.put("Le Bistrot Gourmand", "Allouette");
restaurantsTest2.put("Jean-Francois Issautier", "Poirreaux en sauce");
restaurantsTest2.put("Le Mas Candille", "Candide sur pavé de saumon");
restaurantsTest2.put("Le Park 45", "Le 45eme menu");
System.out.println("Ancien Menus");
str += "\n" + "/Ajoute des anciens menus\\";
for(Map.Entry<String, String> restaurant : restaurantsTest2.entrySet())
{
System.out.println("Le restaurant : " + restaurant.getKey() + " a pour plat : " + guideMichelin.get
(restaurant.getKey()));
}
restaurantsTest2 = new HashMap<String, String>();
restaurantsTest2.put("Chez Lulu", "Courgette crues");
restaurantsTest2.put("Tata martine", "Potiron aux endives");
restaurantsTest2.put("La grande gerbe", "Hamberger sauce ketchup");
restaurantsTest2.put("Tata", "Yoyo");
System.out.println("\n/***Ajouts des nouveaux menus***\\");
for(Map.Entry<String, String> restaurant : restaurantsTest2.entrySet())
{
guideMichelin.put(restaurant.getKey(), restaurant.getValue());
}
System.out.println("\n/***Nouveaux menus stockés dans les pairs***\\");
for(Map.Entry<String, String> restaurant : restaurantsTest2.entrySet())
{
System.out.println("Le restaurant de ma liste " + restaurant.getKey() + " a pour plat dans la guide " +
"Michelin : " + guideMichelin.get(restaurant.getKey()));
}
System.out.println();