01 /*
02 * Created on Aug 29, 2007
03 */
04 package com.x8ing.mc.bp.operation;
05
06 import java.util.List;
07
08 import com.x8ing.lsm4j.Condition;
09 import com.x8ing.lsm4j.state.ProcessableState;
10 import com.x8ing.mc.bp.AbstractBusinessAction;
11 import com.x8ing.mc.bp.BalanceAccount;
12 import com.x8ing.mc.bp.BusinessContext;
13 import com.x8ing.mc.distribution.RandomDistribution;
14 import com.x8ing.mc.distribution.RandomDistributionConstant;
15
16 /**
17 * @author Patrick Heusser
18 */
19 public class OperationDownAction extends AbstractBusinessAction {
20
21 private RandomDistribution failureResolveChance = new RandomDistributionConstant(0, 100);
22
23 /**
24 * @see com.x8ing.mc.bp.AbstractBusinessAction#execute(com.x8ing.lsm4j.state.ProcessableState,
25 * com.x8ing.mc.bp.BusinessContext, com.x8ing.lsm4j.Condition, java.util.List)
26 */
27 public void execute(ProcessableState currentState, BusinessContext businessContext, Condition previousCondition,
28 List lastVisitedStatesHistory) {
29
30 // book money
31 addBalanceSheetTransaction("Production down: Outage costs.", -businessContext.getConfiguration()
32 .getOperationCostForOutagePerDay(), BalanceAccount.PRODUCTION);
33
34 // log info
35 addLogBookEntry("Production system is down.");
36
37 // check if we can fix the fug
38 if (failureResolveChance.getNextRandomNumber() < businessContext.getConfiguration()
39 .getChanceOperationDownResolvingWithSuccess()) {
40
41 // we have a problem
42 businessContext.setProductionSystemRunning(true);
43
44 addLogBookEntry("production failure resolved.");
45
46 } else {
47 addLogBookEntry("production failure not yet resolved.");
48
49 }
50
51 }
52
53 protected void lazyInit() {
54 // empty
55 }
56
57 }
|