Repository: karaf-cellar Updated Branches: refs/heads/master 6f4a1f0b2 -> faa015365
[KARAF-2648] Rename features config category to feature (in order to be aligned with config, bundle categories) Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/faa01536 Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/faa01536 Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/faa01536 Branch: refs/heads/master Commit: faa015365cc843c4dd9272bc13ad3f4cc820ed5e Parents: 6f4a1f0 Author: Jean-Baptiste Onofré <[email protected]> Authored: Mon Jun 16 21:58:59 2014 +0200 Committer: Jean-Baptiste Onofré <[email protected]> Committed: Mon Jun 16 21:58:59 2014 +0200 ---------------------------------------------------------------------- assembly/src/main/resources/groups.cfg | 12 +- assembly/src/main/resources/hazelcast.xml | 10 +- .../apache/karaf/cellar/features/Constants.java | 5 +- .../hazelcast/merge/CellarMergePolicy.java | 160 ------------------- 4 files changed, 10 insertions(+), 177 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/faa01536/assembly/src/main/resources/groups.cfg ---------------------------------------------------------------------- diff --git a/assembly/src/main/resources/groups.cfg b/assembly/src/main/resources/groups.cfg index 7d4d642..b550a79 100644 --- a/assembly/src/main/resources/groups.cfg +++ b/assembly/src/main/resources/groups.cfg @@ -16,12 +16,12 @@ default.config.blacklist.outbound = org.apache.felix.fileinstall*, \ org.ops4j.pax.web default.config.sync = true -default.features.whitelist.inbound = * -default.features.whitelist.outbound = * -default.features.blacklist.inbound = config,management,hazelcast,cellar* -default.features.blacklist.outbound = config,management,hazelcast,cellar* -default.features.sync = true -default.features.repositories.sync = true +default.feature.whitelist.inbound = * +default.feature.whitelist.outbound = * +default.feature.blacklist.inbound = config,management,hazelcast,cellar* +default.feature.blacklist.outbound = config,management,hazelcast,cellar* +default.feature.sync = true +default.feature.repositories.sync = true default.bundle.whitelist.inbound = * default.bundle.whitelist.outbound = * http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/faa01536/assembly/src/main/resources/hazelcast.xml ---------------------------------------------------------------------- diff --git a/assembly/src/main/resources/hazelcast.xml b/assembly/src/main/resources/hazelcast.xml index 8466cca..979b375 100644 --- a/assembly/src/main/resources/hazelcast.xml +++ b/assembly/src/main/resources/hazelcast.xml @@ -21,7 +21,7 @@ <multicast-group>224.2.2.3</multicast-group> <multicast-port>54327</multicast-port> </multicast> - <tcp-ip enabled="false"> + <tcp-ip enabled="true"> <interface>127.0.0.1</interface> </tcp-ip> <aws enabled="false"> @@ -158,12 +158,4 @@ <merge-policy>hz.ADD_NEW_ENTRY</merge-policy> <!-- <merge-policy>CELLAR_MERGE_POLICY</merge-policy> --> </map> - <!-- Cellar MERGE POLICY --> - <!-- - <merge-policies> - <map-merge-policy name="CELLAR_MERGE_POLICY"> - <class-name>org.apache.karaf.cellar.hazelcast.merge.CellarMergePolicy</class-name> - </map-merge-policy> - </merge-policies> - --> </hazelcast> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/faa01536/features/src/main/java/org/apache/karaf/cellar/features/Constants.java ---------------------------------------------------------------------- diff --git a/features/src/main/java/org/apache/karaf/cellar/features/Constants.java b/features/src/main/java/org/apache/karaf/cellar/features/Constants.java index 8ee51bd..6cad2c8 100644 --- a/features/src/main/java/org/apache/karaf/cellar/features/Constants.java +++ b/features/src/main/java/org/apache/karaf/cellar/features/Constants.java @@ -18,10 +18,11 @@ package org.apache.karaf.cellar.features; */ public class Constants { + // hazelcast map name public static final String REPOSITORIES = "org.apache.karaf.cellar.repositories"; public static final String FEATURES = "org.apache.karaf.cellar.features"; - public static final String REPOSITORIES_CATEGORY = "features.repositories"; - public static final String FEATURES_CATEGORY = "features"; + // configuration category + public static final String FEATURES_CATEGORY = "feature"; } http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/faa01536/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/merge/CellarMergePolicy.java ---------------------------------------------------------------------- diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/merge/CellarMergePolicy.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/merge/CellarMergePolicy.java deleted file mode 100644 index 6af9043..0000000 --- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/merge/CellarMergePolicy.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * 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.hazelcast.merge; - -import java.util.LinkedHashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import com.hazelcast.core.MapEntry; -import com.hazelcast.merge.MergePolicy; -import org.apache.karaf.cellar.core.MultiNode; -import org.apache.karaf.cellar.core.utils.CellarUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A Cellar custom Hazelcast merge policy. - */ -public class CellarMergePolicy implements MergePolicy { - - private static final transient Logger LOGGER = LoggerFactory.getLogger(CellarMergePolicy.class); - - /** - * Returns the value of the entry after the merge - * of entries with the same key. Returning value can be - * You should consider the case where existingEntry is null. - * - * @param mapName name of the map - * @param mergingEntry entry merging into the destination cluster - * @param existingEntry existing entry in the destination cluster - * @return final value of the entry. If returns null then no change on the entry. - */ - @Override - public Object merge(String mapName, MapEntry mergingEntry, MapEntry existingEntry) { - LOGGER.debug("Cellar merge policy triggered merging entry {}, existing entry {}",mergingEntry,existingEntry); - Object mergingDataValue = mergingEntry != null ? mergingEntry.getValue() : null; - Object existingDataValue = existingEntry != null ? existingEntry.getValue() : null; - - if (existingDataValue == null && mergingDataValue != null) { - return mergingDataValue; - } - - else if (mergingDataValue == null && existingDataValue != null) { - return existingDataValue; - } - - // merge MultiNodes by merging their members. - else if(MultiNode.class.isAssignableFrom(mergingDataValue.getClass()) - && MultiNode.class.isAssignableFrom(existingDataValue.getClass())) { - - MultiNode existingMultiNode = (MultiNode) existingDataValue; - MultiNode mergingMultiNode = (MultiNode) mergingDataValue; - - existingMultiNode.setNodes(merge(mergingMultiNode.getNodes(), existingMultiNode.getNodes())); - return existingMultiNode; - } - - else if(Set.class.isAssignableFrom(mergingDataValue.getClass()) - && Set.class.isAssignableFrom(existingDataValue.getClass())) { - return merge((Set)mergingDataValue,(Set) existingDataValue); - } - - else if(List.class.isAssignableFrom(mergingDataValue.getClass()) - && List.class.isAssignableFrom(existingDataValue.getClass())) { - return merge((List)mergingDataValue,(List) existingDataValue); - } - - else if (String.class.isAssignableFrom(mergingDataValue.getClass()) - && String.class.isAssignableFrom(existingDataValue.getClass()) - && (CellarUtils.isMergable((String) mergingDataValue) || CellarUtils.isMergable((String) existingDataValue))) { - return merge((String) mergingDataValue, (String) existingDataValue); - } - - return existingDataValue; - } - - /** - * Merges sets. - * - * @param mergingSet the first set to merge. - * @param existingSet the second set to merge. - * @return a set resulting of the merge of the two others. - */ - public <T> Set<T> merge(Set<T> mergingSet, Set<T> existingSet) { - Set<T> result = new LinkedHashSet<T>(); - - // copy new Set - if(mergingSet != null && !mergingSet.isEmpty()) { - for(T obj:mergingSet) { - result.add(obj); - } - } - - // copy existing Set - if(existingSet != null && !existingSet.isEmpty()) { - for(T obj:existingSet) { - result.add(obj); - } - } - - return result; - } - - /** - * Merge lists. - * - * @param mergingList the first list to merge. - * @param existingList the second list to merge. - * @return a list resulting of the merge of the two others. - */ - public <T> List<T> merge(List<T> mergingList, List<T> existingList) { - List<T> result = new LinkedList<T>(); - - // copy existing List - if(existingList != null && !existingList.isEmpty()) { - for(T obj:existingList) { - result.add(obj); - } - } - - // copy new List - if(mergingList != null && !mergingList.isEmpty()) { - for(T obj:mergingList) { - result.add(obj); - } - } - - return result; - } - - /** - * Merge Strings. - * - * @param mergingString the first String to merge. - * @param existingString the second String to merge. - * @return a String resulting of the merge of the two others. - */ - public String merge(String mergingString, String existingString) { - String result = existingString; - Set<String> items = new LinkedHashSet<String>(); - items.addAll(CellarUtils.createSetFromString(mergingString)); - items.addAll(CellarUtils.createSetFromString(existingString)); - if (!items.isEmpty()) { - result = CellarUtils.createStringFromSet(items,true); - } - return result; - } - -}
