Skip to content

Commit

Permalink
#63: rewired console
Browse files Browse the repository at this point in the history
use new classes for computing / executing plan (not working)
  • Loading branch information
ypujante committed Jun 12, 2011
1 parent 17a9ff9 commit b42d4f8
Show file tree
Hide file tree
Showing 12 changed files with 177 additions and 331 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class UrlMappings

// agents
"/agents"(controller: 'agents', action: 'list') { __nvbe = 'Dashboard' }
"/agents/list"(controller: 'agents', action: 'list') { __nvbe = 'Dashboard' }
"/agents/view/$id"(controller: 'agents', action: 'view') { __nvbe = 'System' }
"/agents/ps/$id"(controller: 'agents', action: 'ps') { __nvbe = 'System' }
"/agents/fullStackTrace/$id"(controller: 'agents', action: 'fullStackTrace') { __nvbe = 'System' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,18 @@
</constructor-arg>
</bean>

<bean id="actionFactory" class="org.linkedin.glu.provisioner.core.touchpoint.TouchpointActionFactory">
<constructor-arg>
<list>
<bean class="org.linkedin.glu.provisioner.impl.agent.AgentTouchpoint">
<constructor-arg ref="agentFactory"/>
<constructor-arg ref="encryptionKeysProvider"/>
</bean>
<bean class="org.linkedin.glu.provisioner.impl.agent.AgentUpgradeTouchpoint">
<constructor-arg ref="agentFactory"/>
<constructor-arg ref="encryptionKeysProvider"/>
</bean>
</list>
</constructor-arg>
<bean id="actionExecutionFactory"
class="org.linkedin.glu.orchestration.engine.core.action.execution.ActionExecutionFactoryImpl">
<property name="agentFactory" ref="agentFactory"/>
<property name="agentURIProvider" ref="_agentsServiceImpl"/>
<property name="encryptionKeysProvider" ref="encryptionKeysProvider"/>
</bean>

<bean id="executor" class="java.util.concurrent.Executors" factory-method="newCachedThreadPool"/>

<bean id="leafExecutor" class="org.linkedin.glu.provisioner.deployment.impl.ActionDescriptorStepExecutor">
<property name="actionFactory" ref="actionFactory"/>
<bean id="leafExecutor"
class="org.linkedin.glu.orchestration.engine.action.execution.ActionDescriptorStepExecutor">
<property name="actionExecutionFactory" ref="actionExecutionFactory"/>
</bean>

<bean id="planExecutor" class="org.linkedin.glu.provisioner.plan.impl.PlanExecutor">
Expand All @@ -77,20 +70,14 @@
<property name="leafStepExecutor" ref="leafExecutor"/>
</bean>

<bean id="simplePlanner" class="org.linkedin.glu.provisioner.impl.planner.SimplePlanner">
<property name="propsExcludes">
<set>
<value>skeleton</value>
<value>metadata</value>
<value>tags</value>
</set>
</property>
<property name="fieldExcludes"><set><value>gluScript</value></set></property>
<bean id="deployer" class="org.linkedin.glu.orchestration.engine.deployment.DeployerImpl">
<property name="planExecutor" ref="planExecutor"/>
</bean>

<bean id="deploymentMgr" class="org.linkedin.glu.provisioner.deployment.impl.DeploymentManager">
<property name="planExecutor" ref="planExecutor"/>
<property name="planner" ref="simplePlanner"/>
<bean id="deltaMgr" class="org.linkedin.glu.orchestration.engine.delta.DeltaMgrImpl"/>

<bean id="planner" class="org.linkedin.glu.orchestration.engine.planner.PlannerImpl">
<property name="agentURIProvider" ref="_agentsServiceImpl"/>
</bean>

<bean id="agentPlanner" class="org.linkedin.glu.provisioner.impl.planner.AgentPlanner"/>
Expand Down Expand Up @@ -189,7 +176,9 @@
class="org.linkedin.glu.orchestration.engine.deployment.DeploymentServiceImpl">
<property name="agentsService" ref="agentsService"/>
<property name="authorizationService" ref="authorizationService"/>
<property name="deploymentMgr" ref="deploymentMgr"/>
<property name="deployer" ref="deployer"/>
<property name="deltaMgr" ref="deltaMgr"/>
<property name="planner" ref="planner"/>
<property name="fabricService" ref="fabricService"/>
<property name="deploymentStorage">
<bean class="org.linkedin.glu.console.provisioner.services.storage.DeploymentStorageImpl"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,6 @@ class AgentsController extends ControllerBase
return ensureCurrentFabric()
}

/**
* List all the agents (in the current fabric)
*/
def list = {
def agents = new TreeMap(agentsService.getAgentInfos(request.fabric))

def mountPoints = [:]

def model = [:]

def hosts = deploymentService.getHostsWithDeltas(fabric: request.fabric.name)

agents.values().each { agent ->
model[agent.agentName] = computeAgentModel(request.fabric, agent, null, hosts.contains(agent.agentName))
}

return [model: model, count: model.size(), instances: model.values().sum { it.mountPoints?.size() }]
}

/**
* List all the agents (in the current fabric) with their version (in preparation to upgrade)
*/
Expand Down Expand Up @@ -147,37 +128,36 @@ class AgentsController extends ControllerBase
request.system = system
params.system = system

Plan plan = deploymentService.computeDeploymentPlan(params) { true }

session.delta = []

plans = deploymentService.groupByInstance(plan, [type: 'deploy', agent: params.id])
plans = deploymentService.computeDeploymentPlans(params, [type: 'deploy', agent: params.id])

session.delta.addAll(plans)

def bouncePlan = deploymentService.computeBouncePlan(params) { true }
if(bouncePlan)
{
bouncePlan.name = "Bounce: ${title}"
bouncePlans = deploymentService.groupByInstance(bouncePlan, [type: 'bounce', agent: params.id])
session.delta.addAll(bouncePlans)
}

def redeployPlan = deploymentService.computeRedeployPlan(params) { true }
if(redeployPlan)
{
redeployPlan.name = "Redeploy: ${title}"
redeployPlans = deploymentService.groupByInstance(redeployPlan, [type: 'redeploy', agent: params.id])
session.delta.addAll(redeployPlans)
}
// TODO HIGH YP: add this back
// def bouncePlan = deploymentService.computeBouncePlan(params) { true }
// if(bouncePlan)
// {
// bouncePlan.name = "Bounce: ${title}"
// bouncePlans = deploymentService.groupByInstance(bouncePlan, [type: 'bounce', agent: params.id])
// session.delta.addAll(bouncePlans)
// }
//
// def redeployPlan = deploymentService.computeRedeployPlan(params) { true }
// if(redeployPlan)
// {
// redeployPlan.name = "Redeploy: ${title}"
// redeployPlans = deploymentService.groupByInstance(redeployPlan, [type: 'redeploy', agent: params.id])
// session.delta.addAll(redeployPlans)
// }

def mountPoints = [] as Set
system.each { mountPoints << it.mountPoint }

model = computeAgentModel(request.fabric,
agent,
mountPoints,
plan?.hasLeafSteps())
plans && plans[0]?.hasLeafSteps())
}

return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,55 +127,53 @@ class SystemController extends ControllerBase

def missingAgents = systemService.getMissingAgents(request.fabric, request.system)

Plan plan = deploymentService.computeDeploymentPlan(params)

def plans =
deploymentService.groupByInstance(plan,
[type: 'deploy',
fabric: request.fabric.name])
deploymentService.computeDeploymentPlans(params,
[type: 'deploy',
fabric: request.fabric.name])

session.delta = []

session.delta.addAll(plans)

def bouncePlans

def bouncePlan = deploymentService.computeBouncePlan(params) { true }
if(bouncePlan)
{
bouncePlan.name = "Bounce: ${title}"
bouncePlans =
deploymentService.groupByInstance(bouncePlan,
[type: 'bounce',
fabric: request.fabric.name])
session.delta.addAll(bouncePlans)
}

def redeployPlans

def redeployPlan = deploymentService.computeRedeployPlan(params) { true }
if(redeployPlan)
{
redeployPlan.name = "Redeploy: ${title}"
redeployPlans =
deploymentService.groupByInstance(redeployPlan,
[type: 'redeploy',
fabric: request.fabric.name])
session.delta.addAll(redeployPlans)
}

def undeployPlans

def undeployPlan = deploymentService.computeUndeployPlan(params) { true }
if(undeployPlan)
{
undeployPlan.name = "Undeploy: ${title}"
undeployPlans =
deploymentService.groupByInstance(undeployPlan,
[type: 'undeploy',
fabric: request.fabric.name])
session.delta.addAll(undeployPlans)
}
def bouncePlans = null

// def bouncePlan = deploymentService.computeBouncePlan(params) { true }
// if(bouncePlan)
// {
// bouncePlan.name = "Bounce: ${title}"
// bouncePlans =
// deploymentService.groupByInstance(bouncePlan,
// [type: 'bounce',
// fabric: request.fabric.name])
// session.delta.addAll(bouncePlans)
// }

def redeployPlans = null

// def redeployPlan = deploymentService.computeRedeployPlan(params) { true }
// if(redeployPlan)
// {
// redeployPlan.name = "Redeploy: ${title}"
// redeployPlans =
// deploymentService.groupByInstance(redeployPlan,
// [type: 'redeploy',
// fabric: request.fabric.name])
// session.delta.addAll(redeployPlans)
// }

def undeployPlans = null

// def undeployPlan = deploymentService.computeUndeployPlan(params) { true }
// if(undeployPlan)
// {
// undeployPlan.name = "Undeploy: ${title}"
// undeployPlans =
// deploymentService.groupByInstance(undeployPlan,
// [type: 'undeploy',
// fabric: request.fabric.name])
// session.delta.addAll(undeployPlans)
// }

[
delta: plans,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ dependencies {
testCompile spec.external.junit
testRuntime spec.external.slf4jLog4j
}

sourceSets.main.java.srcDirs = []
sourceSets.main.groovy.srcDir 'src/main/java'
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class ActionExecutionFactoryImpl implements ActionExecutionFactory
public static final String ENCRYPTION_KEYS = 'encryptionKeys'

@Initializable(required = true)
AgentFactory factory
AgentFactory agentFactory

@Initializable(required = true)
AgentURIProvider agentURIProvider
Expand Down Expand Up @@ -146,7 +146,7 @@ public class ActionExecutionFactoryImpl implements ActionExecutionFactory
*/
private def withAgent(AgentActionDescriptor ad, Closure closure)
{
factory.withRemoteAgent(agentURIProvider.getAgentURI(ad.fabric, ad.agent), closure)
agentFactory.withRemoteAgent(agentURIProvider.getAgentURI(ad.fabric, ad.agent), closure)
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,23 @@ import org.linkedin.glu.provisioner.core.model.SystemModel
import org.linkedin.glu.provisioner.plan.api.IPlanExecutionProgressTracker
import org.linkedin.glu.provisioner.plan.api.IStep
import org.linkedin.glu.provisioner.plan.api.Plan
import org.linkedin.glu.orchestration.engine.action.descriptor.ActionDescriptor

/**
* System service.
*
* @author ypujante@linkedin.com */
interface DeploymentService
{
Collection<String> getHostsWithDeltas(params)

Plan computeDeploymentPlan(params)

/**
* @param params.system the 'expected' system (with filters)
* @param params.fabric the fabric (object)
* @param params.name name of the plan created
* @param closure to filter the plan
* @return the plan or <code>null</code> if no current or expected environments
* @param params.type plan types (<code>null</code> means both types, otherwise the type you want)
* @param metadata any metadata to add to the plan(s)
* @return the plans (0, 1 or 2) depending on whether there is a plan at all or if more than 1 type
*/
Plan computeDeploymentPlan(params, Closure closure)
Collection<Plan<ActionDescriptor>> computeDeploymentPlans(params, def metadata)

/**
* Computes a transition plan. The closure is meant to
Expand Down Expand Up @@ -75,18 +73,6 @@ interface DeploymentService
Environment expectedEnvironment,
Closure closure)

/**
* Shortcut to group the plan by hostname first, then mountpoint in both sequential and parallel
* types.
*/
Map<IStep.Type, Plan> groupByHostnameAndMountPoint(Plan plan)

/**
* Create a new plan of the given type where the entries are grouped by hostname first, then
* mountpoint and call the closure to filter all leaves.
*/
Plan groupByHostnameAndMountPoint(Plan plan, IStep.Type type)

/**
* Shortcut to group the plan by instance in both sequential and parallel types.
*/
Expand Down
Loading

0 comments on commit b42d4f8

Please sign in to comment.