Created
November 5, 2012 19:10
-
-
Save ypujante/4019665 to your computer and use it in GitHub Desktop.
Example of a glu plugin to handle custom plan type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (c) 2012 Yan Pujante | |
* | |
* 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.acme.plugins | |
/** | |
* Example of a plugin which handles a "Refresh" plan type which does the following: for all entries | |
* that are in "stopped" state, undeploy and redeploy them (but until the "stopped" state). | |
* | |
* | |
* Configured in glu-console-webapp.groovy this way: | |
* | |
* // define the plugins as a Map, or a class name or an array of class names | |
* orchestration.engine.plugins = [ | |
* 'org.linkedin.glu.orchestration.engine.plugins.builtin.StreamFileContentPlugin', | |
* 'org.acme.plugins.RefreshPlanPlugin' | |
* ] | |
* | |
* plans: [ | |
* [planType: "deploy"], | |
* [planType: "bounce"], | |
* [planType: "redeploy"], | |
* [planType: "undeploy"], | |
* [planType: "transition", displayName: "Stop", state: "stopped"], | |
* [planType: "refresh", displayName: "Refresh"] | |
* ], | |
* | |
* | |
* @author [email protected] */ | |
public class RefreshPlanPlugin | |
{ | |
def plannerService | |
/** | |
* Called on initialization | |
*/ | |
def PluginService_initialize = { args -> | |
plannerService = args.applicationContext['plannerService'] | |
} | |
/** | |
* Called before computing any plans which allows you to tweak the creation of the plan including | |
* the ability to create your own actions. | |
* | |
* @param args.params.planType the type of plan to create (ex: bounce, deploy, transition, etc...) | |
* @param args.params.stepType the type of steps to create (ex: sequential or parallel) | |
* @param args.params.name (optional) the name of the plan if provided | |
* @param args.params.* any other params needed by the plan creation (provided in the "plans" | |
* and "mountPointActions" configuration parameters) | |
* @param args.metadata metadata to use for the plan | |
* @return a collection of plans (depending on <code>args.params.stepType</code>) | |
*/ | |
def PlannerService_pre_computePlans = { args -> | |
switch(args.params.planType) | |
{ | |
case "refresh": | |
return plannerService.computeDeploymentPlans(args.params, | |
args.metadata, | |
null, | |
"entryState='stopped'", | |
null, | |
[null, 'stopped']) // undeploy, deploy until "stopped" | |
break | |
default: | |
return null | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment