@@ -0,0 +1,3147 @@
+package org.apache.helix.model;%0A%0A/*%0A * Licensed to the Apache Software Foundation (ASF) under one%0A * or more contributor license agreements.  See the NOTICE file%0A * distributed with this work for additional information%0A * regarding copyright ownership.  The ASF licenses this file%0A * to you under the Apache License, Version 2.0 (the%0A * %22License%22); you may not use this file except in compliance%0A * with the License.  You may obtain a copy of the License at%0A *%0A *   http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing,%0A * software distributed under the License is distributed on an%0A * %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY%0A * KIND, either express or implied.  See the License for the%0A * specific language governing permissions and limitations%0A * under the License.%0A */%0A%0Aimport java.util.Map;%0Aimport java.util.Set;%0Aimport java.util.TreeMap;%0A%0Aimport org.apache.helix.HelixProperty;%0Aimport org.apache.helix.ZNRecord;%0A%0A/**%0A * Customized view is an aggregation (across all instances)%0A * of customized states for the resource%0A */%0Apublic class CustomizedView extends HelixProperty %7B%0A%0A  /**%0A   * Instantiate a customized view with the resource it corresponds to%0A   * @param resource the name of the resource%0A   */%0A  public CustomizedView(String resource) %7B%0A    super(new ZNRecord(resource));%0A  %7D%0A%0A  /**%0A   * Instantiate a customized view with a pre-populated record%0A   * @param record ZNRecord corresponding to a customized view%0A   */%0A  public CustomizedView(ZNRecord record) %7B%0A    super(record);%0A  %7D%0A%0A  /**%0A   * For a given replica, specify which partition it corresponds to, where it is served, and its%0A   * current state%0A   * @param partition the partition of the replica being served%0A   * @param instance the instance serving the replica%0A   * @param customState the customized state the replica is in%0A   */%0A  public void setState(String partition, String instance, String customState) %7B%0A    if (_record.getMapField(partition) == null) %7B%0A      _record.setMapField(partition, new TreeMap%3CString, String%3E());%0A    %7D%0A    _record.getMapField(partition).put(instance, customState);%0A  %7D%0A%0A  /**%0A   * For a given partition, indicate where and in what customized state each of its replicas is in%0A   * @param partitionName the partition to set%0A   * @param customizedStateMap (instance, state) pairs%0A   */%0A  public void setStateMap(String partitionName, Map%3CString, String%3E customizedStateMap) %7B%0A    _record.setMapField(partitionName, customizedStateMap);%0A  %7D%0A%0A  /**%0A   * Get all the partitions of the resource%0A   * @return a set of partition names%0A   */%0A  public Set%3CString%3E getPartitionSet() %7B%0A    return _record.getMapFields().keySet();%0A  %7D%0A%0A  /**%0A   * Get the instance and the state for each partition replica%0A   * @param partitionName the partition to look up%0A   * @return (instance, state) pairs%0A   */%0A  public Map%3CString, String%3E getStateMap(String partitionName) %7B%0A    return _record.getMapField(partitionName);%0A  %7D%0A%0A  /**%0A   * Get the resource represented by this view%0A   * @return the name of the resource%0A   */%0A  public String getResourceName() %7B%0A    return _record.getId();%0A  %7D%0A%7D%0A

Add the CustomizedView Helix property (#723)