Return-Path: X-Original-To: apmail-helix-commits-archive@minotaur.apache.org Delivered-To: apmail-helix-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EAE2810C9B for ; Wed, 2 Oct 2013 00:44:57 +0000 (UTC) Received: (qmail 74989 invoked by uid 500); 2 Oct 2013 00:44:57 -0000 Delivered-To: apmail-helix-commits-archive@helix.apache.org Received: (qmail 74963 invoked by uid 500); 2 Oct 2013 00:44:57 -0000 Mailing-List: contact commits-help@helix.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@helix.incubator.apache.org Delivered-To: mailing list commits@helix.incubator.apache.org Received: (qmail 74956 invoked by uid 99); 2 Oct 2013 00:44:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Oct 2013 00:44:57 +0000 X-ASF-Spam-Status: No, hits=-2000.7 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 02 Oct 2013 00:44:56 +0000 Received: (qmail 73983 invoked by uid 99); 2 Oct 2013 00:44:36 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Oct 2013 00:44:36 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 28EFD8AD5BF; Wed, 2 Oct 2013 00:44:36 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kanak@apache.org To: commits@helix.incubator.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: [HELIX-100] Clean up immutable return values Date: Wed, 2 Oct 2013 00:44:36 +0000 (UTC) X-Virus-Checked: Checked by ClamAV on apache.org Updated Branches: refs/heads/helix-logical-model 73db45011 -> 45af07c85 [HELIX-100] Clean up immutable return values Project: http://git-wip-us.apache.org/repos/asf/incubator-helix/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-helix/commit/45af07c8 Tree: http://git-wip-us.apache.org/repos/asf/incubator-helix/tree/45af07c8 Diff: http://git-wip-us.apache.org/repos/asf/incubator-helix/diff/45af07c8 Branch: refs/heads/helix-logical-model Commit: 45af07c85d3dd45887aa4c83d871572fdb05ac24 Parents: 73db450 Author: Kanak Biscuitwala Authored: Tue Oct 1 17:43:49 2013 -0700 Committer: Kanak Biscuitwala Committed: Tue Oct 1 17:43:49 2013 -0700 ---------------------------------------------------------------------- .../org/apache/helix/model/ExternalView.java | 19 +++++------ .../java/org/apache/helix/model/IdealState.java | 36 +++++++++----------- .../java/org/apache/helix/model/Message.java | 8 ++--- .../apache/helix/model/ResourceAssignment.java | 4 +-- .../helix/model/StateModelDefinition.java | 4 +-- 5 files changed, 34 insertions(+), 37 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/45af07c8/helix-core/src/main/java/org/apache/helix/model/ExternalView.java ---------------------------------------------------------------------- diff --git a/helix-core/src/main/java/org/apache/helix/model/ExternalView.java b/helix-core/src/main/java/org/apache/helix/model/ExternalView.java index 77df3cf..15a22ca 100644 --- a/helix-core/src/main/java/org/apache/helix/model/ExternalView.java +++ b/helix-core/src/main/java/org/apache/helix/model/ExternalView.java @@ -30,8 +30,8 @@ import org.apache.helix.api.id.ParticipantId; import org.apache.helix.api.id.PartitionId; import org.apache.helix.api.id.ResourceId; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; /** * External view is an aggregation (across all instances) @@ -123,11 +123,11 @@ public class ExternalView extends HelixProperty { * @return a set of partition ids */ public Set getPartitionSet() { - ImmutableSet.Builder builder = new ImmutableSet.Builder(); + Set partitionSet = Sets.newHashSet(); for (String partitionName : getPartitionStringSet()) { - builder.add(PartitionId.from(partitionName)); + partitionSet.add(PartitionId.from(partitionName)); } - return builder.build(); + return partitionSet; } /** @@ -149,13 +149,12 @@ public class ExternalView extends HelixProperty { if (rawStateMap == null) { return null; } - ImmutableMap.Builder builder = - new ImmutableMap.Builder(); + Map stateMap = Maps.newHashMap(); for (String participantName : rawStateMap.keySet()) { - builder - .put(ParticipantId.from(participantName), State.from(rawStateMap.get(participantName))); + stateMap.put(ParticipantId.from(participantName), + State.from(rawStateMap.get(participantName))); } - return builder.build(); + return stateMap; } /** http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/45af07c8/helix-core/src/main/java/org/apache/helix/model/IdealState.java ---------------------------------------------------------------------- diff --git a/helix-core/src/main/java/org/apache/helix/model/IdealState.java b/helix-core/src/main/java/org/apache/helix/model/IdealState.java index 5996391..8f579ec 100644 --- a/helix-core/src/main/java/org/apache/helix/model/IdealState.java +++ b/helix-core/src/main/java/org/apache/helix/model/IdealState.java @@ -43,12 +43,11 @@ import org.apache.log4j.Logger; import com.google.common.base.Function; import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.ListMultimap; import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import com.google.common.collect.Multimaps; +import com.google.common.collect.Sets; /** * The ideal states of all partitions in a resource @@ -294,14 +293,14 @@ public class IdealState extends HelixProperty { /** * Get all of the partitions - * @return an immutable set of partitions + * @return a set of partitions */ public Set getPartitionSet() { - ImmutableSet.Builder partitionSetBuilder = new ImmutableSet.Builder(); + Set partitionSet = Sets.newHashSet(); for (String partitionName : getPartitionStringSet()) { - partitionSetBuilder.add(PartitionId.from(partitionName)); + partitionSet.add(PartitionId.from(partitionName)); } - return partitionSetBuilder.build(); + return partitionSet; } /** @@ -331,18 +330,17 @@ public class IdealState extends HelixProperty { /** * Get the current mapping of a partition * @param partitionId the name of the partition - * @return the instances where the replicas live and the state of each (immutable) + * @return the instances where the replicas live and the state of each */ public Map getParticipantStateMap(PartitionId partitionId) { Map instanceStateMap = getInstanceStateMap(partitionId.stringify()); - ImmutableMap.Builder builder = - new ImmutableMap.Builder(); + Map participantStateMap = Maps.newHashMap(); if (instanceStateMap != null) { for (String participantId : instanceStateMap.keySet()) { - builder.put(ParticipantId.from(participantId), + participantStateMap.put(ParticipantId.from(participantId), State.from(instanceStateMap.get(participantId))); } - return builder.build(); + return participantStateMap; } return null; } @@ -381,14 +379,14 @@ public class IdealState extends HelixProperty { /** * Get the participants who host replicas of a partition * @param partitionId the partition to look up - * @return immutable set of participant ids + * @return set of participant ids */ public Set getParticipantSet(PartitionId partitionId) { - ImmutableSet.Builder builder = new ImmutableSet.Builder(); + Set participantSet = Sets.newHashSet(); for (String participantName : getInstanceSet(partitionId.stringify())) { - builder.add(ParticipantId.from(participantName)); + participantSet.add(ParticipantId.from(participantName)); } - return builder.build(); + return participantSet; } /** @@ -426,13 +424,13 @@ public class IdealState extends HelixProperty { * @return an ordered list of participants that can serve replicas of the partition */ public List getPreferenceList(PartitionId partitionId) { - ImmutableList.Builder builder = new ImmutableList.Builder(); + List preferenceList = Lists.newArrayList(); List preferenceStringList = getPreferenceList(partitionId.stringify()); if (preferenceStringList != null) { for (String participantName : preferenceStringList) { - builder.add(ParticipantId.from(participantName)); + preferenceList.add(ParticipantId.from(participantName)); } - return builder.build(); + return preferenceList; } return null; } http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/45af07c8/helix-core/src/main/java/org/apache/helix/model/Message.java ---------------------------------------------------------------------- diff --git a/helix-core/src/main/java/org/apache/helix/model/Message.java b/helix-core/src/main/java/org/apache/helix/model/Message.java index 71e9696..86319e3 100644 --- a/helix-core/src/main/java/org/apache/helix/model/Message.java +++ b/helix-core/src/main/java/org/apache/helix/model/Message.java @@ -44,7 +44,7 @@ import org.apache.helix.api.id.StateModelFactoryId; import org.apache.helix.controller.stages.ClusterEvent; import org.apache.helix.manager.zk.DefaultSchedulerMessageHandlerFactory; -import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; /** * Messages sent internally among nodes in the system to respond to changes in state. @@ -671,11 +671,11 @@ public class Message extends HelixProperty { if (partitionNames == null) { return Collections.emptyList(); } - ImmutableList.Builder builder = new ImmutableList.Builder(); + List partitionIds = Lists.newArrayList(); for (String partitionName : partitionNames) { - builder.add(PartitionId.from(partitionName)); + partitionIds.add(PartitionId.from(partitionName)); } - return builder.build(); + return partitionIds; } /** http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/45af07c8/helix-core/src/main/java/org/apache/helix/model/ResourceAssignment.java ---------------------------------------------------------------------- diff --git a/helix-core/src/main/java/org/apache/helix/model/ResourceAssignment.java b/helix-core/src/main/java/org/apache/helix/model/ResourceAssignment.java index c478e13..c91a655 100644 --- a/helix-core/src/main/java/org/apache/helix/model/ResourceAssignment.java +++ b/helix-core/src/main/java/org/apache/helix/model/ResourceAssignment.java @@ -73,7 +73,7 @@ public class ResourceAssignment extends HelixProperty { /** * Get the currently mapped partitions - * @return list of Partition objects + * @return list of Partition objects (immutable) */ public List getMappedPartitions() { ImmutableList.Builder builder = new ImmutableList.Builder(); @@ -94,7 +94,7 @@ public class ResourceAssignment extends HelixProperty { /** * Get the participant, state pairs for a partition * @param partition the Partition to look up - * @return map of (participant id, state) + * @return immutable map of (participant id, state) */ public Map getReplicaMap(PartitionId partitionId) { Map rawReplicaMap = _record.getMapField(partitionId.stringify()); http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/45af07c8/helix-core/src/main/java/org/apache/helix/model/StateModelDefinition.java ---------------------------------------------------------------------- diff --git a/helix-core/src/main/java/org/apache/helix/model/StateModelDefinition.java b/helix-core/src/main/java/org/apache/helix/model/StateModelDefinition.java index 32ee2c7..af06ecc 100644 --- a/helix-core/src/main/java/org/apache/helix/model/StateModelDefinition.java +++ b/helix-core/src/main/java/org/apache/helix/model/StateModelDefinition.java @@ -159,7 +159,7 @@ public class StateModelDefinition extends HelixProperty { /** * Get an ordered priority list of transitions - * @return Transition objects, the first of which is highest priority + * @return Transition objects, the first of which is highest priority (immutable) */ public List getStateTransitionPriorityList() { ImmutableList.Builder builder = new ImmutableList.Builder(); @@ -179,7 +179,7 @@ public class StateModelDefinition extends HelixProperty { /** * Get an ordered priority list of states - * @return immutable list of states, the first of which is highest priority + * @return immutable list of states, the first of which is highest priority (immutable) */ public List getStatesPriorityList() { ImmutableList.Builder builder = new ImmutableList.Builder();