Author: anierbeck
Date: Tue Apr 9 15:38:17 2013
New Revision: 1466083
URL: http://svn.apache.org/r1466083
Log:
[KARAF-2262] - cellar-cloud: The IP is not enough, sometimes the IP is hidden
but a valid dns name is available
Added:
karaf/cellar/branches/cellar-2.2.x/cloud/src/main/java/org/apache/karaf/cellar/cloud/ServiceContainer.java
(with props)
Modified:
karaf/cellar/branches/cellar-2.2.x/cloud/src/main/java/org/apache/karaf/cellar/cloud/BlobStoreDiscoveryService.java
Modified:
karaf/cellar/branches/cellar-2.2.x/cloud/src/main/java/org/apache/karaf/cellar/cloud/BlobStoreDiscoveryService.java
URL:
http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/cloud/src/main/java/org/apache/karaf/cellar/cloud/BlobStoreDiscoveryService.java?rev=1466083&r1=1466082&r2=1466083&view=diff
==============================================================================
---
karaf/cellar/branches/cellar-2.2.x/cloud/src/main/java/org/apache/karaf/cellar/cloud/BlobStoreDiscoveryService.java
(original)
+++
karaf/cellar/branches/cellar-2.2.x/cloud/src/main/java/org/apache/karaf/cellar/cloud/BlobStoreDiscoveryService.java
Tue Apr 9 15:38:17 2013
@@ -102,6 +102,14 @@ public class BlobStoreDiscoveryService i
} else {
blobStore.removeBlob(container, ip);
}
+ } else if (obj instanceof ServiceContainer) {
+ ServiceContainer serviceContainer = (ServiceContainer) obj;
+ DateTime registeredTime = serviceContainer.getRegisteredTime();
+ if (registeredTime != null &&
registeredTime.plusSeconds(validityPeriod).isAfterNow()) {
+ members.add(serviceContainer.getHostName());
+ } else {
+ blobStore.removeBlob(container, ip);
+ }
}
}
return members;
@@ -112,7 +120,7 @@ public class BlobStoreDiscoveryService i
*/
public void signIn() {
DateTime now = new DateTime();
- createBlob(container, ipAddress, now);
+ createBlob(container, ipAddress, new
ServiceContainer(getHostAdress(),now));
}
/**
@@ -226,6 +234,15 @@ public class BlobStoreDiscoveryService i
return null;
}
}
+
+ protected String getHostAdress() {
+ try {
+ return InetAddress.getLocalHost().getHostName();
+ } catch (UnknownHostException ex) {
+ LOGGER.error("CELLAR CLOUD: unable to determine host
address for current node", ex);
+ return null;
+ }
+ }
public String getProvider() {
return provider;
Added:
karaf/cellar/branches/cellar-2.2.x/cloud/src/main/java/org/apache/karaf/cellar/cloud/ServiceContainer.java
URL:
http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/cloud/src/main/java/org/apache/karaf/cellar/cloud/ServiceContainer.java?rev=1466083&view=auto
==============================================================================
---
karaf/cellar/branches/cellar-2.2.x/cloud/src/main/java/org/apache/karaf/cellar/cloud/ServiceContainer.java
(added)
+++
karaf/cellar/branches/cellar-2.2.x/cloud/src/main/java/org/apache/karaf/cellar/cloud/ServiceContainer.java
Tue Apr 9 15:38:17 2013
@@ -0,0 +1,35 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.cellar.cloud;
+
+import org.joda.time.DateTime;
+
+public class ServiceContainer {
+
+ private DateTime registeredTime;
+ private String hostName;
+
+ public DateTime getRegisteredTime() {
+ return registeredTime;
+ }
+
+ public String getHostName() {
+ return hostName;
+ }
+
+ public ServiceContainer(String hostName, DateTime registeredTime) {
+ this.registeredTime = registeredTime;
+ this.hostName = hostName;
+ }
+}
Propchange:
karaf/cellar/branches/cellar-2.2.x/cloud/src/main/java/org/apache/karaf/cellar/cloud/ServiceContainer.java
------------------------------------------------------------------------------
svn:mime-type = text/plain