package yami;

import static com.google.common.collect.Lists.*;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import yami.configuration.Peer;
import yami.model.Constants;
import yami.model.DataStoreRetriever;
import yami.model.Result;
import yami.utils.ProcessExecuter;

public class AllPeersRestartServlet extends HttpServlet
{
	private static final Logger log = Logger.getLogger(AllPeersRestartServlet.class);
	private static final long serialVersionUID = 1L;
	private PrintWriter writer;
	
	@Override
	public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
	{
		log.info("ClientRestartServlet started");
		writer = res.getWriter();
		writer.println("Recived restart request");
		List<String> command = newArrayList(Constants.getInstallDir() + "/bin/restartAllPeers");
		for (Peer peer : DataStoreRetriever.getD().peers())
		{
			command.add(peer.name);
		}
		Result r = ProcessExecuter.execute(command);
		writer.println("executing " + command);
		writer.println(r.output);
		writer.println("finished!");
	}
	
}

@@ -962,16 +962,75 @@
 uest%22);%0A
+%09%09for (Peer peer : DataStoreRetriever.getD().peers())%0A%09%09%7B%0A%09
 %09%09List%3CS
@@ -1116,66 +1116,8 @@
 %22);%0A
-%09%09for (Peer peer : DataStoreRetriever.getD().peers())%0A%09%09%7B%0A
 %09%09%09c
@@ -1140,19 +1140,16 @@
 name);%0A%09
-%09%7D%0A
 %09%09Result
@@ -1181,32 +1181,33 @@
 ute(command);%0A%09%09
+%09
 writer.println(%22
@@ -1206,16 +1206,95 @@
 rintln(%22
+===================================================== peer %22 + peer.name + %22 ; 
 executin
@@ -1307,24 +1307,25 @@
 command);%0A%09%09
+%09
 writer.print
@@ -1338,16 +1338,39 @@
 utput);%0A
+%09%09%09writer.flush();%0A%09%09%7D%0A
 %09%09writer

restart should print output