Open Kilda Java Documentation
FeatureTogglesServiceImpl.java
Go to the documentation of this file.
1 /* Copyright 2017 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.northbound.service.impl;
17 
30 
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
33 import org.springframework.beans.factory.annotation.Autowired;
34 import org.springframework.beans.factory.annotation.Value;
35 import org.springframework.stereotype.Service;
36 
37 @Service
39 
40  private final Logger logger = LoggerFactory.getLogger(FeatureTogglesServiceImpl.class);
41 
42  @Value("#{kafkaTopicsConfig.getTopoEngTopic()}")
43  private String topoEngTopic;
44 
45  @Autowired
46  private MessageProducer messageProducer;
47 
48  @Autowired
49  private MessageConsumer<Message> messageConsumer;
50 
51  @Autowired
52  private FeatureTogglesMapper mapper;
53 
54  @Override
56  String correlationId = RequestCorrelationId.getId();
57  logger.debug("Processing request to toggle features, new properties are {}", dto);
58  FeatureToggleRequest request = mapper.toRequest(dto);
59  CommandMessage message = new CommandMessage(request, System.currentTimeMillis(), correlationId,
61  messageProducer.send(topoEngTopic, message);
62  }
63 
64  @Override
66  String correlationId = RequestCorrelationId.getId();
68  CommandMessage requestMessage = new CommandMessage(teRequest, System.currentTimeMillis(),
69  correlationId, Destination.TOPOLOGY_ENGINE);
70  messageProducer.send(topoEngTopic, requestMessage);
71 
72  Message result = messageConsumer.poll(correlationId);
73  FeatureTogglesResponse response =
74  (FeatureTogglesResponse) validateInfoMessage(requestMessage, result, correlationId);
75 
76  return mapper.toDto(response);
77  }
78 }
default InfoData validateInfoMessage(final Message requestMessage, final Message responseMessage, final String correlationId)
list result
Definition: plan-d.py:72