You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2014/07/01 14:27:32 UTC
git commit: STRATOS-676: Added missing file MemberIpHostnameMap.java
Repository: stratos
Updated Branches:
refs/heads/master 5e548002d -> 4a2c5b5f7
STRATOS-676: Added missing file MemberIpHostnameMap.java
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/4a2c5b5f
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/4a2c5b5f
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/4a2c5b5f
Branch: refs/heads/master
Commit: 4a2c5b5f755686d938e87b0f72af6ddc8e4f28e0
Parents: 5e54800
Author: Imesh Gunaratne <im...@apache.org>
Authored: Tue Jul 1 08:26:48 2014 -0400
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Tue Jul 1 08:26:48 2014 -0400
----------------------------------------------------------------------
.../context/map/MemberIpHostnameMap.java | 63 ++++++++++++++++++++
1 file changed, 63 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/4a2c5b5f/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/map/MemberIpHostnameMap.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/map/MemberIpHostnameMap.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/map/MemberIpHostnameMap.java
new file mode 100644
index 0000000..715f3ce
--- /dev/null
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/map/MemberIpHostnameMap.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.stratos.load.balancer.context.map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Member-ip -> hostname map for maintaining cluster hostnames of all members against their ip addresses.
+ */
+public class MemberIpHostnameMap {
+ private static final Log log = LogFactory.getLog(MemberIpHostnameMap.class);
+
+ private ConcurrentHashMap<String, String> concurrentHashMap;
+
+ public MemberIpHostnameMap() {
+ concurrentHashMap = new ConcurrentHashMap<String, String>();
+ }
+
+ public void put(String ip, String hostname) {
+ concurrentHashMap.put(ip, hostname);
+ }
+
+ public boolean contains(String ip) {
+ return concurrentHashMap.containsKey(ip);
+ }
+
+ public String get(String ip) {
+ if(contains(ip)) {
+ return concurrentHashMap.get(ip);
+ }
+ return null;
+ }
+
+ public void remove(String ip) {
+ if(contains(ip)) {
+ concurrentHashMap.remove(ip);
+ }
+ }
+
+ public void clear() {
+ concurrentHashMap.clear();
+ }
+}