From 48163d1cd9f19542413eef554511ed1618d5bc8b Mon Sep 17 00:00:00 2001 From: Hariharan Anantharaman Date: Wed, 27 Jun 2018 17:48:07 +0530 Subject: [PATCH] CHanges for monitoring cesc data --- .../service/ConnectionStatisticsService.java | 2 + .../src/main/resources/application-cesc.yml | 44 ++++ .../com/m2mci/mqttKafkaBridge/Bridge.java | 100 +++++++++ .../mqttKafkaBridge/CommandLineParser.java | 61 ++++++ .../adapter/MqttkafkaadapterApplication.java | 10 +- .../callback/AbstractMqttCallBack.java | 104 +++++++++ .../adapter/callback/DefaultMqttCallBack.java | 26 +++ .../src/main/resources/application-cesc.yml | 30 +++ .../PlatformkafkabrokerApplication.java | 201 +++++++++++++++++- .../src/main/resources/application-cesc.yml | 23 ++ .../gateway/ZuulgatewayApplication.java | 14 ++ .../gateway/ZuulgatewayApplicationTests.java | 16 ++ 12 files changed, 628 insertions(+), 3 deletions(-) create mode 100644 connectionstatistics/src/main/resources/application-cesc.yml create mode 100644 mqttKafkaBridge/src/main/java/com/m2mci/mqttKafkaBridge/Bridge.java create mode 100644 mqttKafkaBridge/src/main/java/com/m2mci/mqttKafkaBridge/CommandLineParser.java create mode 100644 mqttkafkaadapter/src/main/java/com/techolution/smartoffice/adapter/callback/AbstractMqttCallBack.java create mode 100644 mqttkafkaadapter/src/main/java/com/techolution/smartoffice/adapter/callback/DefaultMqttCallBack.java create mode 100644 mqttkafkaadapter/src/main/resources/application-cesc.yml create mode 100644 platformkafkabroker/src/main/resources/application-cesc.yml create mode 100644 zuulgateway/src/main/java/com/techolution/mauritius/smartwater/gateway/ZuulgatewayApplication.java create mode 100644 zuulgateway/src/test/java/com/techolution/mauritius/smartwater/gateway/ZuulgatewayApplicationTests.java diff --git a/connectionstatistics/src/main/java/com/techolution/mauritius/smartwater/connection/service/ConnectionStatisticsService.java b/connectionstatistics/src/main/java/com/techolution/mauritius/smartwater/connection/service/ConnectionStatisticsService.java index 6805115..23369f6 100644 --- a/connectionstatistics/src/main/java/com/techolution/mauritius/smartwater/connection/service/ConnectionStatisticsService.java +++ b/connectionstatistics/src/main/java/com/techolution/mauritius/smartwater/connection/service/ConnectionStatisticsService.java @@ -934,6 +934,8 @@ else if("roomambience".equalsIgnoreCase(metrics)){ } else if("batteryhealth".equalsIgnoreCase(metrics)){ returnVal="battery_health"; + }else if ("transformer".equalsIgnoreCase(metrics)){ + returnVal="transformer_telemetry"; } return returnVal; } diff --git a/connectionstatistics/src/main/resources/application-cesc.yml b/connectionstatistics/src/main/resources/application-cesc.yml new file mode 100644 index 0000000..61d3552 --- /dev/null +++ b/connectionstatistics/src/main/resources/application-cesc.yml @@ -0,0 +1,44 @@ +server: + port: 8100 + + + +logging: + level: + org.springframework.security: DEBUG + log4j.logger.org.hibernate.SQL: DEBUG + com.techolution: DEBUG + +spring: + jpa: + show-sql: true + hibernate: + ddl-auto: update + properties: + hibernate: + dialect: org.hibernate.dialect.MySQL5Dialect + datasource: + url: jdbc:mysql://localhost:3306/mauritius_smartwater + username: admin + password: admin123 + driver-class-name: com.mysql.jdbc.Driver + tomcat: + max-active: 5 + hikari: + maximum-pool-size: 5 + application: + name: connectionstatisticsservice + + + + +influx: + url: http://52.170.92.62:8086 + username: root + password: root + dbname: cesc_qa + datatimezone: Asia/Calcutta + retentionpolicy: aRetentionPolicy2 + + + \ No newline at end of file diff --git a/mqttKafkaBridge/src/main/java/com/m2mci/mqttKafkaBridge/Bridge.java b/mqttKafkaBridge/src/main/java/com/m2mci/mqttKafkaBridge/Bridge.java new file mode 100644 index 0000000..99fd17e --- /dev/null +++ b/mqttKafkaBridge/src/main/java/com/m2mci/mqttKafkaBridge/Bridge.java @@ -0,0 +1,100 @@ +package com.m2mci.mqttKafkaBridge; + +import java.util.Properties; + +import kafka.javaapi.producer.Producer; +import kafka.javaapi.producer.ProducerData; +import kafka.message.Message; +import kafka.producer.ProducerConfig; + +import org.apache.log4j.Logger; +import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; +import org.eclipse.paho.client.mqttv3.IMqttToken; +import org.eclipse.paho.client.mqttv3.MqttAsyncClient; +import org.eclipse.paho.client.mqttv3.MqttCallback; +import org.eclipse.paho.client.mqttv3.MqttException; +import org.eclipse.paho.client.mqttv3.MqttMessage; +import org.kohsuke.args4j.CmdLineException; + +public class Bridge implements MqttCallback { + private Logger logger = Logger.getLogger(this.getClass().getName()); + private MqttAsyncClient mqtt; + private Producer kafkaProducer; + + private void connect(String serverURI, String clientId, String zkConnect) throws MqttException { + mqtt = new MqttAsyncClient(serverURI, clientId); + mqtt.setCallback(this); + IMqttToken token = mqtt.connect(); + Properties props = new Properties(); + props.put("zk.connect", zkConnect); + props.put("serializer.class", "kafka.serializer.DefaultEncoder"); + ProducerConfig config = new ProducerConfig(props); + kafkaProducer = new Producer(config); + token.waitForCompletion(); + logger.info("Connected to MQTT and Kafka"); + } + + private void reconnect() throws MqttException { + IMqttToken token = mqtt.connect(); + token.waitForCompletion(); + } + + private void subscribe(String[] mqttTopicFilters) throws MqttException { + int[] qos = new int[mqttTopicFilters.length]; + for (int i = 0; i < qos.length; ++i) { + qos[i] = 0; + } + mqtt.subscribe(mqttTopicFilters, qos); + } + + @Override + public void connectionLost(Throwable cause) { + logger.warn("Lost connection to MQTT server", cause); + while (true) { + try { + logger.info("Attempting to reconnect to MQTT server"); + reconnect(); + logger.info("Reconnected to MQTT server, resuming"); + return; + } catch (MqttException e) { + logger.warn("Reconnect failed, retrying in 10 seconds", e); + } + try { + Thread.sleep(10000); + } catch (InterruptedException e) { + } + } + } + + @Override + public void deliveryComplete(IMqttDeliveryToken token) { + // TODO Auto-generated method stub + + } + + @Override + public void messageArrived(String topic, MqttMessage message) throws Exception { + byte[] payload = message.getPayload(); + ProducerData data = new ProducerData(topic, new Message(payload)); + kafkaProducer.send(data); + } + + /** + * @param args + */ + public static void main(String[] args) { + CommandLineParser parser = null; + try { + parser = new CommandLineParser(); + parser.parse(args); + Bridge bridge = new Bridge(); + bridge.connect(parser.getServerURI(), parser.getClientId(), parser.getZkConnect()); + bridge.subscribe(parser.getMqttTopicFilters()); + } catch (MqttException e) { + e.printStackTrace(System.err); + } catch (CmdLineException e) { + System.err.println(e.getMessage()); + parser.printUsage(System.err); + } + } +} diff --git a/mqttKafkaBridge/src/main/java/com/m2mci/mqttKafkaBridge/CommandLineParser.java b/mqttKafkaBridge/src/main/java/com/m2mci/mqttKafkaBridge/CommandLineParser.java new file mode 100644 index 0000000..cbba6db --- /dev/null +++ b/mqttKafkaBridge/src/main/java/com/m2mci/mqttKafkaBridge/CommandLineParser.java @@ -0,0 +1,61 @@ +package com.m2mci.mqttKafkaBridge; + +import java.io.OutputStream; +import java.io.PrintStream; + +import org.kohsuke.args4j.CmdLineException; +import org.kohsuke.args4j.CmdLineParser; +import org.kohsuke.args4j.Option; + +public class CommandLineParser { + private static final String ALL_MQTT_TOPICS = "#"; + private static final String DEFAULT_ZOOKEEPER_CONNECT = "localhost:2181"; + private static final String DEFAULT_MQTT_SERVER_URI = "tcp://localhost:1883"; + + @Option(name="--id", usage="MQTT Client ID") + private String clientId = "mqttKafkaBridge"; + + @Option(name="--uri", usage="MQTT Server URI") + private String serverURI = DEFAULT_MQTT_SERVER_URI; + + @Option(name="--zk", usage="Zookeeper connect string") + private String zkConnect = DEFAULT_ZOOKEEPER_CONNECT; + + @Option(name="--topics", usage="MQTT topic filters (comma-separated)") + private String mqttTopicFilters = ALL_MQTT_TOPICS; + + @Option(name="--help", aliases="-h", usage="Show help") + private boolean showHelp = false; + + private CmdLineParser parser = new CmdLineParser(this); + + public String getClientId() { + return clientId; + } + + public String getServerURI() { + return serverURI; + } + + public String getZkConnect() { + return zkConnect; + } + + public String[] getMqttTopicFilters() { + return mqttTopicFilters.split(","); + } + + public void parse(String[] args) throws CmdLineException { + parser.parseArgument(args); + if (showHelp) { + printUsage(System.out); + System.exit(0); + } + } + + public void printUsage(OutputStream out) { + PrintStream stream = new PrintStream(out); + stream.println("java " + Bridge.class.getName() + " [options...]"); + parser.printUsage(out); + } +} diff --git a/mqttkafkaadapter/src/main/java/com/techolution/smartoffice/adapter/MqttkafkaadapterApplication.java b/mqttkafkaadapter/src/main/java/com/techolution/smartoffice/adapter/MqttkafkaadapterApplication.java index c8bae49..e65c82c 100644 --- a/mqttkafkaadapter/src/main/java/com/techolution/smartoffice/adapter/MqttkafkaadapterApplication.java +++ b/mqttkafkaadapter/src/main/java/com/techolution/smartoffice/adapter/MqttkafkaadapterApplication.java @@ -9,6 +9,7 @@ import org.springframework.core.env.Environment; import com.techolution.smartoffice.adapter.callback.BMSMqttCallBack; +import com.techolution.smartoffice.adapter.callback.DefaultMqttCallBack; import com.techolution.smartoffice.adapter.callback.SmartOfficeMqttCallBack; @@ -28,6 +29,9 @@ public class MqttkafkaadapterApplication implements CommandLineRunner{ @Autowired BMSMqttCallBack bmsMqttCallBack; + @Autowired + DefaultMqttCallBack cescMqttCallBack; + @Autowired private Environment environment; @@ -45,7 +49,11 @@ public void run(String... args) throws Exception { if((environment.getActiveProfiles())[0].contains("bms")){ bmsMqttCallBack.connect(); logger.debug("Registed BMS callback"); - }else{ + } else if((environment.getActiveProfiles())[0].contains("cesc")){ + cescMqttCallBack.connect(); + logger.debug("Registed cescMqttCallBack callback"); + } + else{ smartOfficeMqttCallBack.connect(); logger.debug("Registed smartoffice callback"); } diff --git a/mqttkafkaadapter/src/main/java/com/techolution/smartoffice/adapter/callback/AbstractMqttCallBack.java b/mqttkafkaadapter/src/main/java/com/techolution/smartoffice/adapter/callback/AbstractMqttCallBack.java new file mode 100644 index 0000000..6834488 --- /dev/null +++ b/mqttkafkaadapter/src/main/java/com/techolution/smartoffice/adapter/callback/AbstractMqttCallBack.java @@ -0,0 +1,104 @@ +package com.techolution.smartoffice.adapter.callback; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; +import org.eclipse.paho.client.mqttv3.IMqttToken; +import org.eclipse.paho.client.mqttv3.MqttAsyncClient; +import org.eclipse.paho.client.mqttv3.MqttCallback; +import org.eclipse.paho.client.mqttv3.MqttException; +import org.eclipse.paho.client.mqttv3.MqttMessage; +import org.json.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.kafka.core.KafkaTemplate; +import org.springframework.stereotype.Component; + + +import com.techolution.smartoffice.adapter.CustomProperties; + + + + +public abstract class AbstractMqttCallBack implements MqttCallback { + + private Log log = LogFactory.getLog(AbstractMqttCallBack.class); + + @Autowired + CustomProperties customProperties; + + protected MqttAsyncClient mqtt; + + + @Autowired + protected KafkaTemplate template; + + + @Override + public void connectionLost(Throwable arg0) { + // TODO Auto-generated method stub + try { + connect(); + } catch (MqttException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + @Override + public void deliveryComplete(IMqttDeliveryToken arg0) { + // TODO Auto-generated method stub + + } + + public void subscribe() throws MqttException { + //int[] qos = new int[mqttTopicFilters.length]; + /*for (int i = 0; i < qos.length; ++i) { + qos[i] = 0; + }*/ + if(mqtt == null) + { + this.connect(); + } + if(!mqtt.isConnected()){ + mqtt.connect(); + } + mqtt.subscribe(customProperties.getMqtttopic(), 0); + } + + + public void connect() throws MqttException { + log.debug("Broker is"+customProperties.getMqttbroker()); + if(customProperties!=null){ + mqtt = new MqttAsyncClient(customProperties.getMqttbroker(),customProperties.getMqttclientid()); + mqtt.setCallback(this); + IMqttToken token=mqtt.connect(); + //log.debug("Connection to "+customProperties.getMqttbroker()+" completed successfully"); + mqtt.setCallback(this); + while(!token.isComplete()){ + // log.debug("Waiting for connection to complete"); + } + mqtt.subscribe(customProperties.getMqtttopic(), 0); + + //token. + // log.info("MQTT CLIENT HAS BEEN CONNECTED"); + }else{ + log.warn("Properties is null"); + } + + + + } + + /*public SmartOfficeMqttCallBack() { + super(); + try { + this.connect(); + this.subscribe(); + } catch (MqttException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }*/ + +} diff --git a/mqttkafkaadapter/src/main/java/com/techolution/smartoffice/adapter/callback/DefaultMqttCallBack.java b/mqttkafkaadapter/src/main/java/com/techolution/smartoffice/adapter/callback/DefaultMqttCallBack.java new file mode 100644 index 0000000..5a28a23 --- /dev/null +++ b/mqttkafkaadapter/src/main/java/com/techolution/smartoffice/adapter/callback/DefaultMqttCallBack.java @@ -0,0 +1,26 @@ +package com.techolution.smartoffice.adapter.callback; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.eclipse.paho.client.mqttv3.MqttMessage; +import org.springframework.stereotype.Component; + +@Component +public class DefaultMqttCallBack extends AbstractMqttCallBack { + + private Log log = LogFactory.getLog(DefaultMqttCallBack.class); + @Override + public void messageArrived(String topic, MqttMessage message) throws Exception { + // TODO Auto-generated method stub + + + + byte[] payload = message.getPayload(); + String messageReceived=new String(payload); + log.debug("Before sending message:"+messageReceived); + //log.debug("Before sending message:"+object.toString()); + this.template.send(this.customProperties.getKafkatopic(),messageReceived); + + } + +} diff --git a/mqttkafkaadapter/src/main/resources/application-cesc.yml b/mqttkafkaadapter/src/main/resources/application-cesc.yml new file mode 100644 index 0000000..a2b20be --- /dev/null +++ b/mqttkafkaadapter/src/main/resources/application-cesc.yml @@ -0,0 +1,30 @@ +#server: +# port: 8090 + + + +logging: + level: + org.springframework.security: DEBUG + log4j.logger.org.hibernate.SQL: DEBUG + com.techolution: DEBUG + +spring: + kafka: + + producer: + bootstrap-servers: + - localhost:9092 + + +custom: + # mqttbroker: tcp://192.168.2.81:1883 + #mqttbroker: tcp://localhost:1883 + mqttbroker: tcp://52.170.92.62:1883 + # mqtttopic: techo/smartoffice/1 + mqtttopic: transmon + roomid: room2 + kafkatopic: transmon + mqttclientid: client2 + + \ No newline at end of file diff --git a/platformkafkabroker/src/main/java/com/techolution/smartoffice/kafka/consumer/PlatformkafkabrokerApplication.java b/platformkafkabroker/src/main/java/com/techolution/smartoffice/kafka/consumer/PlatformkafkabrokerApplication.java index 52606a9..0c7af29 100644 --- a/platformkafkabroker/src/main/java/com/techolution/smartoffice/kafka/consumer/PlatformkafkabrokerApplication.java +++ b/platformkafkabroker/src/main/java/com/techolution/smartoffice/kafka/consumer/PlatformkafkabrokerApplication.java @@ -3,8 +3,11 @@ import java.io.IOException; -import java.math.BigDecimal; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.time.Instant; import java.util.ArrayList; +import java.util.Date; import java.util.List; import org.apache.http.client.methods.HttpPost; @@ -12,6 +15,7 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.kafka.clients.consumer.ConsumerRecord; +import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.slf4j.Logger; @@ -20,6 +24,7 @@ import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.core.env.Environment; import org.springframework.kafka.annotation.KafkaListener; import com.techolution.smartoffice.kafka.consumer.data.KeyValue; @@ -32,6 +37,9 @@ public class PlatformkafkabrokerApplication implements CommandLineRunner { @Autowired CustomProperties customProperties; + + @Autowired + Environment environment; public static Logger logger = LoggerFactory.getLogger(PlatformkafkabrokerApplication.class); @@ -39,9 +47,16 @@ public static void main(String[] args) { SpringApplication.run(PlatformkafkabrokerApplication.class, args); } - @KafkaListener(topics = "smartoffice") + @KafkaListener(topics = "smartoffice" ) public void listen(ConsumerRecord cr) throws Exception { //logger.info(cr.toString()); + + String[] profiles=environment.getActiveProfiles(); + + if(!profiles[0].equalsIgnoreCase("default")){ + return; + } + String msgvalue=(String)cr.value(); logger.info("Value is:"+msgvalue); @@ -83,6 +98,11 @@ public void listen(ConsumerRecord cr) throws Exception { @KafkaListener(topics = "bmstest") public void listenBMS(ConsumerRecord cr) throws Exception { //logger.info(cr.toString()); + String[] profiles=environment.getActiveProfiles(); + + if(!profiles[0].contains("bms")){ + return; + } String msgvalue=(String)cr.value(); logger.info("Value is:"+msgvalue); @@ -122,6 +142,148 @@ public void listenBMS(ConsumerRecord cr) throws Exception { } + + @KafkaListener(topics = "transmon") + public void listenCESC(ConsumerRecord cr) throws Exception { + //logger.info(cr.toString()); + String[] profiles=environment.getActiveProfiles(); + + if(!profiles[0].contains("cesc")){ + return; + } + DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); + String msgvalue=(String)cr.value(); + logger.info("Value is:"+msgvalue); + + JSONObject object=new JSONObject(msgvalue); + + JSONObject sensorData=object.getJSONObject("sensorData"); + + JSONObject vibrationData=object.getJSONObject("vibData"); + + String timestamp=object.getString("timeStamp"); + //Instant instant=Instant.parse(timestamp); + Date date = formatter.parse(timestamp.split("\\+")[0]); + + + + SimpleDateFormat myFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); + String dateVal=myFormat.format(date); + logger.info("dateVal is:"+dateVal); + + SeriesPointData seriesPointData=new SeriesPointData(); + + seriesPointData.setTimestamp(date); + seriesPointData.setName("transformer"); + + KeyValue tag=new KeyValue(); + tag.setKey("devID"); + tag.setValue((String)object.get("devID")); + + + KeyValue tag2=new KeyValue(); + tag2.setKey("transID"); + tag2.setValue((String)object.get("transID")); + + + List tagList=new ArrayList(); + tagList.add(tag); + tagList.add(tag2); + + + List valuelist=new ArrayList(); + + KeyValue dataType=new KeyValue(); + dataType.setKey("data_type"); + // BigDecimal temp = new BigDecimal(object.getDouble("Temperature")); + //Float tempval=new Float(object.getDouble("Temperature")); + dataType.setValue(object.getString("dataType")); + valuelist.add(dataType); + + KeyValue oiltemperature=null; + if(sensorData.has("oilTemp")){ + + oiltemperature=new KeyValue(); + oiltemperature.setKey("oil_temperature"); + oiltemperature.setValue(Float.valueOf(sensorData.getString("oilTemp"))); + valuelist.add(oiltemperature); + } + KeyValue moisture=null; + if(sensorData.has("moisture")){ + + moisture=new KeyValue(); + moisture.setKey("moisture"); + moisture.setValue(Float.valueOf(sensorData.getString("moisture"))); + valuelist.add(moisture); + } + + KeyValue lt1=null; + KeyValue lt2=null; + KeyValue lt3=null; + + if(sensorData.has("LT")){ + + JSONArray array=sensorData.getJSONArray("LT"); + lt1=new KeyValue(); + lt1.setKey("lt_temperature_1"); + lt1.setValue(Float.valueOf(array.getString(0))); + + + lt2=new KeyValue(); + lt2.setKey("lt_temperature_2"); + lt2.setValue(Float.valueOf(array.getString(1))); + + + lt3=new KeyValue(); + lt3.setKey("lt_temperature_3"); + lt3.setValue(Float.valueOf(array.getString(2))); + + valuelist.add(lt1); + valuelist.add(lt2); + valuelist.add(lt3); + + + } + + if(vibrationData != null){ + + KeyValue gavlue=null; + KeyValue freq_1=null; + KeyValue freq_2=null; + KeyValue freq_3=null; + + if(vibrationData.has("gValue")){ + gavlue=new KeyValue(); + gavlue.setKey("g_value"); + gavlue.setValue(Float.valueOf(vibrationData.getString("gValue"))); + valuelist.add(gavlue); + JSONArray array=vibrationData.getJSONArray("freq"); + + freq_1=new KeyValue(); + freq_1.setKey("vibration_primiary_freq"); + freq_1.setValue(Float.valueOf(array.getString(0))); + + freq_2=new KeyValue(); + freq_2.setKey("vibration_secondry_freq"); + freq_2.setValue(Float.valueOf(array.getString(1))); + + freq_3=new KeyValue(); + freq_3.setKey("vibration_tertiary_freq"); + freq_3.setValue(Float.valueOf(array.getString(2))); + valuelist.add(gavlue); + valuelist.add(freq_1); + valuelist.add(freq_2); + valuelist.add(freq_3); + } + + } + + + sendData("transformer", tagList, valuelist,dateVal); + // latch.countDown(); + } + + protected void sendData(String name,List tags,List values) throws JSONException{ JSONObject json = new JSONObject(); @@ -131,6 +293,41 @@ protected void sendData(String name,List tags,List values) t + json.put("tags", tags); + json.put("values", values); + + System.out.println("JSON is:"+json.toString()); + + CloseableHttpClient httpClient = HttpClientBuilder.create().build(); + + try { + HttpPost request = new HttpPost(customProperties.getServiceurl()); + StringEntity params = new StringEntity(json.toString()); + request.addHeader("content-type", "application/json"); + request.setEntity(params); + httpClient.execute(request); + // handle response here... + } catch (Exception ex) { + // handle exception here + } finally { + try { + httpClient.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + } + protected void sendData(String name,List tags,List values,String timeStamp) throws JSONException{ + + JSONObject json = new JSONObject(); + + + json.put("name", name); + json.put("timestamp", timeStamp); + + json.put("tags", tags); json.put("values", values); diff --git a/platformkafkabroker/src/main/resources/application-cesc.yml b/platformkafkabroker/src/main/resources/application-cesc.yml new file mode 100644 index 0000000..5b1188e --- /dev/null +++ b/platformkafkabroker/src/main/resources/application-cesc.yml @@ -0,0 +1,23 @@ +#server: +# port: 8090 + + + +logging: + level: + org.springframework.security: DEBUG + log4j.logger.org.hibernate.SQL: DEBUG + com.techolution: DEBUG + +spring: + kafka: + consumer: + group-id: consumer1 + auto-offset-reset: earliest + bootstrap-servers: + - localhost:9092 + +custom: + serviceurl: http://localhost:8100/telemetry/insert/data + + \ No newline at end of file diff --git a/zuulgateway/src/main/java/com/techolution/mauritius/smartwater/gateway/ZuulgatewayApplication.java b/zuulgateway/src/main/java/com/techolution/mauritius/smartwater/gateway/ZuulgatewayApplication.java new file mode 100644 index 0000000..ffedb7a --- /dev/null +++ b/zuulgateway/src/main/java/com/techolution/mauritius/smartwater/gateway/ZuulgatewayApplication.java @@ -0,0 +1,14 @@ +package com.techolution.mauritius.smartwater.gateway; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.netflix.zuul.EnableZuulProxy; + +@EnableZuulProxy +@SpringBootApplication +public class ZuulgatewayApplication { + + public static void main(String[] args) { + SpringApplication.run(ZuulgatewayApplication.class, args); + } +} diff --git a/zuulgateway/src/test/java/com/techolution/mauritius/smartwater/gateway/ZuulgatewayApplicationTests.java b/zuulgateway/src/test/java/com/techolution/mauritius/smartwater/gateway/ZuulgatewayApplicationTests.java new file mode 100644 index 0000000..c7b6fd3 --- /dev/null +++ b/zuulgateway/src/test/java/com/techolution/mauritius/smartwater/gateway/ZuulgatewayApplicationTests.java @@ -0,0 +1,16 @@ +package com.techolution.mauritius.smartwater.gateway; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class ZuulgatewayApplicationTests { + + @Test + public void contextLoads() { + } + +}