Client that executes actions on the local node.
| 32 | * Client that executes actions on the local node. |
| 33 | */ |
| 34 | public class NodeClient implements Client { |
| 35 | |
| 36 | @SuppressWarnings("rawtypes") |
| 37 | private Map<ActionType, TransportAction> actions; |
| 38 | |
| 39 | public NodeClient() { |
| 40 | } |
| 41 | |
| 42 | @SuppressWarnings("rawtypes") |
| 43 | public void initialize(Map<ActionType, TransportAction> actions) { |
| 44 | this.actions = actions; |
| 45 | } |
| 46 | |
| 47 | @Override |
| 48 | public void close() { |
| 49 | // nothing really to do |
| 50 | } |
| 51 | |
| 52 | @Override |
| 53 | @SuppressWarnings("unchecked") |
| 54 | public <Req extends TransportRequest, Resp extends TransportResponse> CompletableFuture<Resp> execute(ActionType<Resp> action, Req request) { |
| 55 | if (actions == null) { |
| 56 | throw new IllegalStateException("NodeClient has not been initialized"); |
| 57 | } |
| 58 | TransportAction<Req, Resp> transportAction = actions.get(action); |
| 59 | if (transportAction == null) { |
| 60 | throw new IllegalStateException("failed to find action [" + action + "] to execute"); |
| 61 | } |
| 62 | return transportAction.execute(request); |
| 63 | } |
| 64 | } |
nothing calls this directly
no outgoing calls
no test coverage detected