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 9FE81DD8A for ; Wed, 7 Nov 2012 05:13:01 +0000 (UTC) Received: (qmail 85375 invoked by uid 500); 7 Nov 2012 05:13:01 -0000 Delivered-To: apmail-helix-commits-archive@helix.apache.org Received: (qmail 85354 invoked by uid 500); 7 Nov 2012 05:13:01 -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 85346 invoked by uid 99); 7 Nov 2012 05:13:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Nov 2012 05:13:01 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Nov 2012 05:12:53 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id ABAB62388C7B; Wed, 7 Nov 2012 05:11:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1406467 [19/19] - in /incubator/helix/site-content: ./ apidocs/assets/ apidocs/reference/ apidocs/reference/org/apache/helix/ apidocs/reference/org/apache/helix/examples/ apidocs/reference/org/apache/helix/manager/file/ apidocs/reference/o... Date: Wed, 07 Nov 2012 05:11:34 -0000 To: commits@helix.incubator.apache.org From: olamy@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121107051145.ABAB62388C7B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: incubator/helix/site-content/xref/org/apache/helix/model/StateModelDefinition.html URL: http://svn.apache.org/viewvc/incubator/helix/site-content/xref/org/apache/helix/model/StateModelDefinition.html?rev=1406467&r1=1406466&r2=1406467&view=diff ============================================================================== --- incubator/helix/site-content/xref/org/apache/helix/model/StateModelDefinition.html (original) +++ incubator/helix/site-content/xref/org/apache/helix/model/StateModelDefinition.html Wed Nov 7 05:11:27 2012 @@ -185,10 +185,10 @@ 175 * 176 * @param state 177 */ -178 public void initialState(String initialState) +178 public Builder initialState(String initialState) 179 { 180 this.initialState = initialState; -181 +181 return this; 182 } 183 184 /** @@ -200,111 +200,142 @@ 190 * 191 * @param states 192 */ -193 public void addState(String state, int priority) +193 public Builder addState(String state, int priority) 194 { 195 statesMap.put(state, priority); -196 } -197 -198 /** -199 * Define all legal transitions between states using this method. Priority -200 * is used to order the transitions. Helix tries to maximize the number of -201 * transitions that can be fired in parallel without violating the -202 * constraint. The transitions are first sorted based on priority and -203 * transitions are selected in a greedy way until the constriants are not -204 * violated. -205 * -206 * @param fromState -207 * @param toState -208 * @param priority -209 */ -210 public void addTransition(String fromState, String toState, int priority) -211 { -212 transitionMap.put(new Transition(fromState, toState), priority); -213 } -214 -215 public void upperBound(String state, int upperBound) -216 { -217 stateConstraintMap.put(state, String.valueOf(upperBound)); -218 } -219 -220 /** -221 * You can use this to have the bounds dynamically change based on other -222 * parameters. Currently support 2 values R --> Refers to the number of -223 * replicas specified during resource creation. This allows having different -224 * replication factor for each resource without having to create a different -225 * state machine. N --> Refers to all nodes in the cluster. Useful for -226 * resources that need to exist on all nodes. This way one can add/remove -227 * nodes without having the change the bounds. -228 * -229 * @param state -230 * @param bound -231 */ -232 public void dynamicUpperBound(String state, String bound) -233 { -234 stateConstraintMap.put(state, bound); -235 } -236 -237 public StateModelDefinition build() -238 { -239 ZNRecord record = new ZNRecord(_statemodelName); -240 ArrayList<String> statePriorityList = new ArrayList<String>( -241 statesMap.keySet()); -242 Comparator<? super String> c1 = new Comparator<String>() -243 { -244 -245 @Override -246 public int compare(String o1, String o2) -247 { -248 return statesMap.get(o1).compareTo(statesMap.get(o2)); -249 } -250 }; -251 Collections.sort(statePriorityList, c1); -252 ArrayList<String> transitionPriorityList = new ArrayList<String>( -253 transitionMap.size()); -254 for (Transition t : transitionMap.keySet()) -255 { -256 transitionPriorityList.add(t.toString()); -257 } -258 Comparator<? super String> c2 = new Comparator<String>() -259 { -260 -261 @Override -262 public int compare(String o1, String o2) -263 { -264 return statesMap.get(o1).compareTo(statesMap.get(o2)); -265 } -266 }; -267 Collections.sort(transitionPriorityList, c2); -268 -269 record.setSimpleField( -270 StateModelDefinitionProperty.INITIAL_STATE.toString(), initialState); -271 record.setListField( -272 StateModelDefinitionProperty.STATE_PRIORITY_LIST.toString(), -273 statePriorityList); -274 record -275 .setListField( -276 StateModelDefinitionProperty.STATE_TRANSITION_PRIORITYLIST -277 .toString(), transitionPriorityList); -278 StateTransitionTableBuilder stateTransitionTableBuilder = new StateTransitionTableBuilder(); -279 Map<String, Map<String, String>> transitionTable = stateTransitionTableBuilder -280 .buildTransitionTable(statePriorityList, new ArrayList<Transition>( -281 transitionMap.keySet())); -282 for (String state : transitionTable.keySet()) -283 { -284 record.setMapField(state + ".next", transitionTable.get(state)); -285 } -286 for (String state : stateConstraintMap.keySet()) -287 { -288 HashMap<String, String> metadata = new HashMap<String, String>(); -289 metadata.put("count", stateConstraintMap.get(state)); -290 record.setMapField(state + ".meta", metadata); -291 } -292 return new StateModelDefinition(record); -293 } -294 -295 } -296 -297 } +196 return this; +197 } +198 +199 /** +200 * Sets the priority to Integer.MAX_VALUE +201 * +202 * @param state +203 */ +204 public Builder addState(String state) +205 { +206 addState(state, Integer.MAX_VALUE); +207 return this; +208 } +209 +210 /** +211 * Define all legal transitions between states using this method. Priority +212 * is used to order the transitions. Helix tries to maximize the number of +213 * transitions that can be fired in parallel without violating the +214 * constraint. The transitions are first sorted based on priority and +215 * transitions are selected in a greedy way until the constriants are not +216 * violated. +217 * +218 * @param fromState +219 * @param toState +220 * @param priority +221 */ +222 public Builder addTransition(String fromState, String toState, int priority) +223 { +224 transitionMap.put(new Transition(fromState, toState), priority); +225 return this; +226 } +227 +228 public Builder addTransition(String fromState, String toState) +229 { +230 addTransition(fromState, toState, Integer.MAX_VALUE); +231 return this; +232 } +233 +234 public Builder upperBound(String state, int upperBound) +235 { +236 stateConstraintMap.put(state, String.valueOf(upperBound)); +237 return this; +238 } +239 +240 /** +241 * You can use this to have the bounds dynamically change based on other +242 * parameters. <br/> +243 * Currently support 2 values <br/> +244 * R --> Refers to the number of replicas specified during resource +245 * creation. This allows having different replication factor for each +246 * resource without having to create a different state machine. <br/> +247 * N --> Refers to all nodes in the cluster. Useful for resources that need +248 * to exist on all nodes. This way one can add/remove nodes without having +249 * the change the bounds. +250 * +251 * @param state +252 * @param bound +253 */ +254 public Builder dynamicUpperBound(String state, String bound) +255 { +256 stateConstraintMap.put(state, bound); +257 return this; +258 } +259 +260 public StateModelDefinition build() +261 { +262 ZNRecord record = new ZNRecord(_statemodelName); +263 ArrayList<String> statePriorityList = new ArrayList<String>( +264 statesMap.keySet()); +265 Comparator<? super String> c1 = new Comparator<String>() +266 { +267 +268 @Override +269 public int compare(String o1, String o2) +270 { +271 return statesMap.get(o1).compareTo(statesMap.get(o2)); +272 } +273 }; +274 Collections.sort(statePriorityList, c1); +275 ArrayList<Transition> transitionList = new ArrayList<Transition>( +276 transitionMap.keySet()); +277 +278 Comparator<? super Transition> c2 = new Comparator<Transition>() +279 { +280 @Override +281 public int compare(Transition o1, Transition o2) +282 { +283 return transitionMap.get(o1).compareTo(transitionMap.get(o2)); +284 } +285 }; +286 Collections.sort(transitionList, c2); +287 List<String> transitionPriorityList = new ArrayList<String>( +288 transitionList.size()); +289 for (Transition t : transitionList) +290 { +291 transitionPriorityList.add(t.toString()); +292 } +293 +294 record.setSimpleField( +295 StateModelDefinitionProperty.INITIAL_STATE.toString(), initialState); +296 record.setListField( +297 StateModelDefinitionProperty.STATE_PRIORITY_LIST.toString(), +298 statePriorityList); +299 record +300 .setListField( +301 StateModelDefinitionProperty.STATE_TRANSITION_PRIORITYLIST +302 .toString(), transitionPriorityList); +303 StateTransitionTableBuilder stateTransitionTableBuilder = new StateTransitionTableBuilder(); +304 Map<String, Map<String, String>> transitionTable = stateTransitionTableBuilder +305 .buildTransitionTable(statePriorityList, new ArrayList<Transition>( +306 transitionMap.keySet())); +307 for (String state : transitionTable.keySet()) +308 { +309 record.setMapField(state + ".next", transitionTable.get(state)); +310 } +311 for (String state : statePriorityList) +312 { +313 HashMap<String, String> metadata = new HashMap<String, String>(); +314 if (stateConstraintMap.get(state) != null) +315 { +316 metadata.put("count", stateConstraintMap.get(state)); +317 } else +318 { +319 metadata.put("count", "-1"); +320 } +321 record.setMapField(state + ".meta", metadata); +322 } +323 return new StateModelDefinition(record); +324 } +325 +326 } +327 +328 }
Modified: incubator/helix/site-content/xref/org/apache/helix/model/package-frame.html URL: http://svn.apache.org/viewvc/incubator/helix/site-content/xref/org/apache/helix/model/package-frame.html?rev=1406467&r1=1406466&r2=1406467&view=diff ============================================================================== --- incubator/helix/site-content/xref/org/apache/helix/model/package-frame.html (original) +++ incubator/helix/site-content/xref/org/apache/helix/model/package-frame.html Wed Nov 7 05:11:27 2012 @@ -31,6 +31,9 @@ Attributes
  • + AutoModeBuilder +
  • +
  • Builder
  • @@ -55,6 +58,9 @@ CurrentStateProperty
  • + CustomBuilder +
  • +
  • Error
  • @@ -118,6 +124,9 @@ ResourceAssignment
  • + SemiAutoBuilder +
  • +
  • StateModelDefinition
  • Modified: incubator/helix/site-content/xref/org/apache/helix/model/package-summary.html URL: http://svn.apache.org/viewvc/incubator/helix/site-content/xref/org/apache/helix/model/package-summary.html?rev=1406467&r1=1406466&r2=1406467&view=diff ============================================================================== --- incubator/helix/site-content/xref/org/apache/helix/model/package-summary.html (original) +++ incubator/helix/site-content/xref/org/apache/helix/model/package-summary.html Wed Nov 7 05:11:27 2012 @@ -62,6 +62,11 @@ + AutoModeBuilder + + + + Builder @@ -102,6 +107,11 @@ + CustomBuilder + + + + Error @@ -207,6 +217,11 @@ + SemiAutoBuilder + + + + StateModelDefinition Modified: incubator/helix/site-content/xref/org/apache/helix/package-frame.html URL: http://svn.apache.org/viewvc/incubator/helix/site-content/xref/org/apache/helix/package-frame.html?rev=1406467&r1=1406466&r2=1406467&view=diff ============================================================================== --- incubator/helix/site-content/xref/org/apache/helix/package-frame.html (original) +++ incubator/helix/site-content/xref/org/apache/helix/package-frame.html Wed Nov 7 05:11:27 2012 @@ -187,7 +187,7 @@ StopThread
  • - Type + Type
  • ZNRecord Modified: incubator/helix/site-content/xref/org/apache/helix/package-summary.html URL: http://svn.apache.org/viewvc/incubator/helix/site-content/xref/org/apache/helix/package-summary.html?rev=1406467&r1=1406466&r2=1406467&view=diff ============================================================================== --- incubator/helix/site-content/xref/org/apache/helix/package-summary.html (original) +++ incubator/helix/site-content/xref/org/apache/helix/package-summary.html Wed Nov 7 05:11:27 2012 @@ -322,7 +322,7 @@ - Type + Type Modified: incubator/helix/site-content/xref/org/apache/helix/participant/statemachine/StateTransitionTableBuilder.html URL: http://svn.apache.org/viewvc/incubator/helix/site-content/xref/org/apache/helix/participant/statemachine/StateTransitionTableBuilder.html?rev=1406467&r1=1406466&r2=1406467&view=diff ============================================================================== --- incubator/helix/site-content/xref/org/apache/helix/participant/statemachine/StateTransitionTableBuilder.html (original) +++ incubator/helix/site-content/xref/org/apache/helix/participant/statemachine/StateTransitionTableBuilder.html Wed Nov 7 05:11:27 2012 @@ -161,32 +161,38 @@ 151 && (pathVal1 + pathVal2) < pathValCur) 152 { 153 setPathVal(path, fromState, toState, pathVal1 + pathVal2); -154 setNext(next, fromState, toState, intermediateState); +154 setNext(next, fromState, toState, getNext(next, fromState, intermediateState)); 155 } 156 } 157 } 158 } -159 -160 return next; -161 } -162 -163 public static void main(String[] args) -164 { -165 List<String> states = new ArrayList<String>(); -166 states.add("OFFLINE"); -167 states.add("SLAVE"); -168 states.add("MASTER"); -169 -170 List<Transition> transitions = new ArrayList<Transition>(); -171 transitions.add(new Transition("OFFLINE", "SLAVE")); -172 transitions.add(new Transition("SLAVE", "MASTER")); -173 transitions.add(new Transition("MASTER", "SLAVE")); +159 return next; +160 } +161 +162 public static void main(String[] args) +163 { +164 List<String> states = new ArrayList<String>(); +165 //[MASTER, SLAVE, DROPPED, OFFLINE] +166 //[SLAVE-OFFLINE, OFFLINE-SLAVE, SLAVE-MASTER, OFFLINE-DROPPED, MASTER-SLAVE] +167 states.add("MASTER"); +168 states.add("SLAVE"); +169 states.add("DROPPED"); +170 states.add("OFFLINE"); +171 +172 +173 List<Transition> transitions = new ArrayList<Transition>(); 174 transitions.add(new Transition("SLAVE", "OFFLINE")); -175 StateTransitionTableBuilder builder = new StateTransitionTableBuilder(); -176 Map<String, Map<String, String>> next = builder.buildTransitionTable(states, transitions); -177 printPath(states, next); -178 } -179 } +175 transitions.add(new Transition("OFFLINE", "SLAVE")); +176 transitions.add(new Transition("SLAVE", "MASTER")); +177 transitions.add(new Transition("OFFLINE", "DROPPED")); +178 transitions.add(new Transition("MASTER", "SLAVE")); +179 +180 StateTransitionTableBuilder builder = new StateTransitionTableBuilder(); +181 Map<String, Map<String, String>> next = builder.buildTransitionTable(states, transitions); +182 System.out.println(next); +183 printPath(states, next); +184 } +185 }
    Modified: incubator/helix/site-content/xref/org/apache/helix/tools/ZKDumper.html URL: http://svn.apache.org/viewvc/incubator/helix/site-content/xref/org/apache/helix/tools/ZKDumper.html?rev=1406467&r1=1406466&r2=1406467&view=diff ============================================================================== --- incubator/helix/site-content/xref/org/apache/helix/tools/ZKDumper.html (original) +++ incubator/helix/site-content/xref/org/apache/helix/tools/ZKDumper.html Wed Nov 7 05:11:27 2012 @@ -64,7 +64,7 @@ 54 static Options options; 55 private String suffix = ""; 56 //enable by default -57 private boolean removeSuffix=true; +57 private boolean removeSuffix=false; 58 59 public String getSuffix() 60 {