Open Kilda Java Documentation
CtrlAction.java
Go to the documentation of this file.
1 package org.openkilda.wfm.ctrl;
2 
3 import org.apache.storm.tuple.Tuple;
9 
10 public class CtrlAction extends AbstractAction {
11  private Boolean isHandled = false;
12  private final ICtrlBolt bolt;
13 
14  public CtrlAction(ICtrlBolt bolt, Tuple tuple) {
15  super(bolt, tuple);
16  this.bolt = bolt;
17  }
18 
19  @Override
20  protected void handle()
22  String source = getTuple().getSourceComponent();
23 
25  return;
26  }
27 
28  isHandled = true;
29 
30  AbstractAction action;
31  RouteMessage message = new RouteMessage(getTuple());
32  RequestData payload = message.getPayload();
33  switch (payload.getAction()) {
34  case "list":
35  action = new ListAction(this, message);
36  break;
37  case "dump":
38  action = new DumpStateAction(this, message);
39  break;
40  case "clearState":
41  action = new ClearStateAction(this, message);
42  break;
43  case "dumpBySwitch":
44  action = new DumpBySwitchStateAction(this, message);
45  break;
46  case "dumpResorceCache":
47  action = new DumpByResorceCacheAction(this, message);
48  break;
49  default:
50  throw new UnsupportedActionException(payload.getAction());
51  }
52 
53  action.run();
54  }
55 
56  @Override
57  protected void commit() {
58  if (! isHandled) {
59  return;
60  }
61  super.commit();
62  }
63 
64  public Boolean getHandled() {
65  return isHandled;
66  }
67 
68  public String getStreamId() {
69  return getBolt().getCtrlStreamId();
70  }
71 
72  @Override
73  public ICtrlBolt getBolt() {
74  return bolt;
75  }
76 
77 
78  public static boolean boltHandlerEntrance(ICtrlBolt bolt, Tuple tuple)
79  {
80  CtrlAction ctrl = new CtrlAction(bolt, tuple);
81  ctrl.run();
82  return ctrl.getHandled();
83  }
84 }
CtrlAction(ICtrlBolt bolt, Tuple tuple)
Definition: CtrlAction.java:14
source
Definition: nodes.py:53
static boolean boltHandlerEntrance(ICtrlBolt bolt, Tuple tuple)
Definition: CtrlAction.java:78