private void registerForDiscovery() {
		logger.info("Registering for discovery server!");

		JSONObject registerInfo = new JSONObject();
		registerInfo.put("ipAddrs", serverIpAddrs);
		registerInfo.put("portNum", serverPort);
		try {
			Socket registerSocket = new Socket(discovery_ipAddrs,
					discovery_portNum);

			BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(
					registerSocket.getOutputStream()));

			String path = "/register";
			wr.write("POST " + path + " HTTP/1.1\r\n");
			wr.write("Content-Length: " + registerInfo.toString().length()
					+ "\r\n");
			wr.write("Content-Type: application/json\r\n");
			wr.write("\r\n");
			wr.write(registerInfo.toString());
			wr.flush();

			BufferedReader recerive_br = new BufferedReader(
					new InputStreamReader(registerSocket.getInputStream()));

			String receive_line = null;
			ArrayList<String> receive_Hearder = new ArrayList<String>();

			while (!(receive_line = recerive_br.readLine().trim()).equals("")) {
				receive_Hearder.add(receive_line);
			}

			char[] bodyChars = new char[1000];
			recerive_br.read(bodyChars);
			StringBuffer sb = new StringBuffer();
			sb.append(bodyChars);
			String receive_body = sb.toString().trim();

			JSONParser jp = new JSONParser();
			JSONObject requestBody = null;
			try {
				requestBody = (JSONObject) jp.parse(receive_body);
			} catch (ParseException e) {
				logger.debug(e.getMessage(), e);
			}
			dataserverID = Integer.valueOf(requestBody.get("dataserverID")
					.toString());
			currentPrimary = (JSONObject) requestBody.get("currentPrimary");
			backEndsArray = (JSONArray) requestBody.get("currentBackEndsArray");

			registerSocket.close();
			if (dataserverID == 1) {
				dataServerRole = DataServerRole.PRIMARY;
				logger.info("############ I'm  " + dataServerRole);
				logger.info("Register finish, I'm primary data server, my server ID is: "
						+ dataserverID);
				logger.info("Current primary server is: "
						+ currentPrimary.toString());
			} else {
				dataServerRole = DataServerRole.SECONDARY;
				logger.info("############ I'm  " + dataServerRole);
				logger.info("Register finish, I'm secondary data server, my server ID is: "
						+ dataserverID);
				logger.info("Current primary server is: "
						+ currentPrimary.toString());
			}
		} catch (IOException e) {
			logger.debug(e.getMessage(), e);
		}
	}