Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.apache.helix.model;
  
  /*
   * 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.
  */
 
 import java.util.List;
 
config-scope that replaces

Link:
ConfigScope
 
 public class HelixConfigScope {
  
Defines the various scopes of configs, and how they are represented on Zookeeper
 
   public enum ConfigScopeProperty {
     CLUSTER(2, 0),
     PARTICIPANT(2, 0),
     RESOURCE(2, 0),
     PARTITION(2, 1),
     CONSTRAINT(2, 0);
 
     final int _zkPathArgNum;
     final int _mapKeyArgNum;
 
     private ConfigScopeProperty(int zkPathArgNumint mapKeyArgNum) {
        = zkPathArgNum;
        = mapKeyArgNum;
     }

    
Get the number of template arguments required to generate a full path

Returns:
number of template arguments in the path
 
     public int getZkPathArgNum() {
       return ;
     }

    
Get the number of arguments corresponding to a lookup key

Returns:
number of map key arguments
 
     public int getMapKeyArgNum() {
       return ;
     }
   }

  
string templates to generate znode path
 
   private static final StringTemplate template = new StringTemplate();
   static {
     // get the znode
         "/{clusterName}/CONFIGS/CLUSTER/{clusterName}");
 
         "/{clusterName}/CONFIGS/PARTICIPANT/{participantName}");
         "/{clusterName}/CONFIGS/RESOURCE/{resourceName}");
         "/{clusterName}/CONFIGS/RESOURCE/{resourceName}");
 
     // get children
     .addEntry(., 1, "/{clusterName}/CONFIGS/CLUSTER");
     .addEntry(., 1, "/{clusterName}/CONFIGS/PARTICIPANT");
     .addEntry(., 1, "/{clusterName}/CONFIGS/RESOURCE");
   }
 
   final String _clusterName;

  
this is participantName if type is PARTICIPANT or null otherwise
 
   final String _participantName;
 
   final String _resourceName;
 
   final String _zkPath;
   final String _mapKey;

  
use full-key to get config, use non-full-key to get config-keys
  final boolean _isFullKey;

  
Initialize with a type of scope and unique identifiers

Parameters:
type the scope
zkPathKeys keys identifying a ZNode location
mapKey a key for an additional lookup within a ZNode
  public HelixConfigScope(ConfigScopeProperty typeList<StringzkPathKeysString mapKey) {
    if (zkPathKeys.size() != type.getZkPathArgNum()
        && zkPathKeys.size() != (type.getZkPathArgNum() - 1)) {
      throw new IllegalArgumentException(type + " requires " + type.getZkPathArgNum()
          + " arguments to get znode or " + (type.getZkPathArgNum() - 1)
          + " arguments to get children, but was: " + zkPathKeys);
    }
    if (type == .) {
       = (zkPathKeys.size() == type.getZkPathArgNum()) && (mapKey != null);
    } else {
       = (zkPathKeys.size() == type.getZkPathArgNum());
    }
     = type;
     = zkPathKeys.get(0);
    // init participantName
    if (type == . && ) {
       = zkPathKeys.get(1);
    } else {
       = null;
    }
    // init resourceName
    if (type == . && ) {
       = zkPathKeys.get(1);
    } else {
       = null;
    }
     = .instantiate(typezkPathKeys.toArray(new String[0]));
     = mapKey;
  }

  
Get the scope

Returns:
the type of scope
    return ;
  }

  
Get the cluster name

Returns:
the name of the associated cluster
  public String getClusterName() {
    return ;
  }

  
Get the participant name if it exists

Returns:
the participant name if the type is PARTICIPANT, or null
  public String getParticipantName() {
    return ;
  }

  
Get the resource name if it exists

Returns:
the resource name if the type is RESOURCE, or null
  public String getResourceName() {
    return ;
  }

  
Get the path to the corresponding ZNode

Returns:
a Zookeeper path
  public String getZkPath() {
    return ;
  }

  
Get the lookup key within the ZNode if it exists

Returns:
the lookup key, or null
  public String getMapKey() {
    return ;
  }

  
Determine if the key gets a config key or the actual config

Returns:
true if the key corresponds to a config, false if it corresponds to a config key
  public boolean isFullKey() {
    return ;
  }
New to GrepCode? Check out our FAQ X