Open Kilda Java Documentation
AbstractVerificationCommand.java
Go to the documentation of this file.
1 /* Copyright 2018 Telstra Open Source
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 package org.openkilda.floodlight.command.flow;
17 
26 
27 abstract class AbstractVerificationCommand extends Command {
28  private final KafkaMessageProducer kafkaProducer;
29  private final UniFlowVerificationRequest verificationRequest;
30 
31  AbstractVerificationCommand(CommandContext context, UniFlowVerificationRequest verificationRequest) {
32  super(context);
33 
34  this.verificationRequest = verificationRequest;
35  kafkaProducer = getContext().getModuleContext().getServiceImpl(KafkaMessageProducer.class);
36  }
37 
38  protected void sendResponse(UniFlowVerificationResponse response) {
39  InfoMessage message = new InfoMessage(response, System.currentTimeMillis(), getContext().getCorrelationId());
40  kafkaProducer.postMessage(Topic.FLOW, message);
41  }
42 
43  protected void sendErrorResponse(FlowVerificationErrorCode errorCode) {
44  UniFlowVerificationResponse response = new UniFlowVerificationResponse(verificationRequest, errorCode);
45  sendResponse(response);
46  }
47 
48  protected UniFlowVerificationRequest getVerificationRequest() {
49  return verificationRequest;
50  }
51 }
void postMessage(final String topic, final Message message)
static final String FLOW
Definition: Topic.java:25