Permalink
Browse files

Minor changes to demo classes.

  • Loading branch information...
1 parent b406e75 commit eb87827aa2747a60b518ea044d6a74f3a3acc592 Karthik Ranganathan committed Aug 31, 2012
View
8 eureka-core/src/main/java/com/netflix/eureka/EurekaBootStrap.java
@@ -65,6 +65,7 @@
private static final String EUREKA_ENVIRONMENT = "eureka.environment";
private static final String CLOUD = "cloud";
+ private static final String DEFAULT = "default";
private static final String ARCHAIUS_DEPLOYMENT_DATACENTER = "archaius.deployment.datacenter";
@@ -114,6 +115,7 @@ public void contextInitialized(ServletContextEvent event) {
}
} catch (Throwable e) {
+ logger.error("Cannot bootstrap eureka server :", e);
throw new RuntimeException("Cannot bootstrap eureka server :", e);
}
}
@@ -130,9 +132,9 @@ protected void initEurekaEnvironment() {
String dataCenter = ConfigurationManager.getConfigInstance()
.getString(EUREKA_DATACENTER);
if (dataCenter == null) {
- logger.info("Eureka data center value eureka.datacenter is not set, defaulting to cloud");
+ logger.info("Eureka data center value eureka.datacenter is not set, defaulting to default");
ConfigurationManager.getConfigInstance().setProperty(
- ARCHAIUS_DEPLOYMENT_DATACENTER, CLOUD);
+ ARCHAIUS_DEPLOYMENT_DATACENTER, DEFAULT);
} else {
ConfigurationManager.getConfigInstance().setProperty(
ARCHAIUS_DEPLOYMENT_DATACENTER, dataCenter);
@@ -166,7 +168,7 @@ protected void initEurekaEnvironment() {
public void contextDestroyed(ServletContextEvent event) {
try {
logger.info(new Date().toString()
- + " Shutting down Discovery service...");
+ + " Shutting down Eureka Server..");
InstanceInfo info = ApplicationInfoManager.getInstance().getInfo();
// Unregister all MBeans associated w/ DSCounters
EurekaMonitors.shutdown();
View
6 eureka-core/src/main/java/com/netflix/eureka/PeerAwareInstanceRegistry.java
@@ -466,7 +466,7 @@ public void statusUpdate(final String asgName, final ASGStatus newStatus,
if (!isPeerAlive(serviceUrl)
&& eurekaServerConfig.shouldReplicateOnlyIfUP()) {
logger.warn(
- "The discovery node {} seems to be down and hence not replicating it there",
+ "The eureka peer node {} seems to be down and hence not replicating it there",
serviceUrl);
}
@@ -766,7 +766,7 @@ private void replicateInstanceActionsToPeers(final Action action,
// Do not retry
retryCounter = 0;
logger.warn(
- "The discovery node {} seems to be down and hence not replicating it there",
+ "The peer eureka node {} seems to be down and hence not replicating it there",
serviceUrl);
// Clear the queue so that back log does not build up.
node.disableStatusReplication();
@@ -870,7 +870,7 @@ private void replicateASGInfoToReplicaNodes(final String asgName,
* @return - true if alive, false otherwise.
*/
private boolean isPeerAlive(String serviceUrl) {
- Stopwatch t = Monitors.newTimer("DISCOVERY:checkReplicaAlive").start();
+ Stopwatch t = Monitors.newTimer("Eureka-checkReplicaAlive").start();
boolean isReplicaAlive = peerEurekaStatusMap.get(serviceUrl);
try {
if (!isReplicaAlive) {
View
4 eureka-core/src/main/java/com/netflix/eureka/util/AwsAsgUtil.java
@@ -197,13 +197,13 @@ private AutoScalingGroup retrieveAutoScalingGroup(String asgName) {
*
* @param key
* - The name of the ASG for which the flag needs to be checked.
- * @return - true, if the load balancer falg is not suspended, false
+ * @return - true, if the load balancer flag is not suspended, false
* otherwise.
*/
private Boolean isASGEnabledinAWS(Object key) {
String myKey = (String) key;
try {
- Stopwatch t = Monitors.newTimer("Discovery:loadASGInfo").start();
+ Stopwatch t = Monitors.newTimer("Eureka-loadASGInfo").start();
boolean returnValue = !isAddToLoadBalancerSuspended(myKey);
t.stop();
return returnValue;
View
1 eureka-core/src/main/java/com/netflix/eureka/util/EIPManager.java
@@ -65,7 +65,6 @@
*/
public class EIPManager {
private static final String US_EAST_1 = "us-east-1";
- // private static final String PROP_EIP = "netflix.discovery.eip.";
private static final Logger logger = LoggerFactory
.getLogger(EIPManager.class);
private EurekaServerConfig eurekaConfig = EurekaServerConfigurationManager
View
18 eureka-server/test/java/com/netflix/eureka/SampleEurekaClient.java
@@ -33,10 +33,11 @@
import com.netflix.discovery.DiscoveryManager;
/**
- * Sample Eureka client that discovers the service using Eureka and sends requests.
+ * Sample Eureka client that discovers the service using Eureka and sends
+ * requests.
*
* @author Karthik Ranganathan
- *
+ *
*/
public class SampleEurekaClient {
private static final DynamicPropertyFactory configInstance = com.netflix.config.DynamicPropertyFactory
@@ -65,14 +66,19 @@ public void sendRequestToServiceUsingEureka() {
+ nextServerInfo.getHostName() + " at port " + serverPort);
}
try {
+ System.out.println("Connected to server. Sending a sample request");
PrintStream out = new PrintStream(s.getOutputStream());
- out.println("The client trying to send request at " + new Date());
- String str;
+ out.println("Sample request " + new Date());
+ String str = null;
+ System.out.println("Waiting for server response..");
BufferedReader rd = new BufferedReader(new InputStreamReader(
s.getInputStream()));
str = rd.readLine();
- System.out.println("The client received the response :" + str);
- System.out.println("Closing the channel");
+ if (str != null) {
+ System.out
+ .println("Received response from server. Communication all fine using Eureka :");
+ System.out.println("Exiting the client. Demo over..");
+ }
rd.close();
} catch (IOException e) {
e.printStackTrace();
View
33 eureka-server/test/java/com/netflix/eureka/SampleEurekaService.java
@@ -36,19 +36,24 @@
import com.netflix.discovery.DiscoveryManager;
/**
- * Sample Eureka service that registers with Eureka to receive and process requests.
+ * Sample Eureka service that registers with Eureka to receive and process
+ * requests.
*
- * <p>This example just receives one request and exits once it receives the request after processing it.</p>
+ * <p>
+ * This example just receives one request and exits once it receives the request
+ * after processing it.
+ * </p>
*
* @author Karthik Ranganathan
- *
+ *
*/
public class SampleEurekaService {
private static final DynamicPropertyFactory configInstance = com.netflix.config.DynamicPropertyFactory
.getInstance();
- private static final Logger logger = LoggerFactory.getLogger(SampleEurekaService.class);
-
+ private static final Logger logger = LoggerFactory
+ .getLogger(SampleEurekaService.class);
+
public void registerWithEureka() {
// Register with Eureka
DiscoveryManager.getInstance().initComponent(
@@ -77,19 +82,22 @@ public void registerWithEureka() {
}
}
- logger.info("Service started and ready to process requests..");
+ System.out.println("Service started and ready to process requests..");
try {
ServerSocket serverSocket = new ServerSocket(configInstance
.getIntProperty("eureka.port", 8010).get());
final Socket s = serverSocket.accept();
- logger.info("HANDLING CONNECTION FROM CLIENT");
+ System.out
+ .println("Client got connected..Processing request from the client");
processRequest(s);
} catch (IOException e) {
e.printStackTrace();
}
this.unRegisterWithEureka();
+ System.out.println("Shutting down server.Demo over.");
+
}
public void unRegisterWithEureka() {
@@ -101,11 +109,14 @@ private void processRequest(final Socket s) {
try {
BufferedReader rd = new BufferedReader(new InputStreamReader(
s.getInputStream()));
- PrintStream out = new PrintStream(s.getOutputStream());
String line = rd.readLine();
- logger.info("SERVER RECEIVED LINE:" + line);
- out.println("I received the line from the client:" + line + " at "
- + new Date());
+ if (line != null) {
+ System.out.println("Received the request from the client.");
+ }
+ PrintStream out = new PrintStream(s.getOutputStream());
+ System.out.println("Sending the response to the client...");
+
+ out.println("Reponse at " + new Date());
} catch (Throwable e) {
System.err.println("Error processing requests");

0 comments on commit eb87827

Please sign in to comment.