# Industry 4.0 towards Forestry 4.0: Fire Detection Use Case +
## 5 Methodology
### Dynamic Query Window-Based Selector for Stream Rate Change
#### 5.3.2 The Proposed Dynamic Window-Based Selector
```
1 Input:Workload_Requirements_List[] Output:New_Window_Type,New_Window_Size
2 FunctionNew_Window_Configuration()
3 Stream_Stat_Histo -Stat.getAllEntries_Histo(Stream_Rate_Last,Window_Size_Last);
4 Stream_Stat_Current -Stat.getAllEntries_Live(Stream_Rate_Current,Window_Size_Current);
5 Stream_Rate_Type -get_Stream_Type(Stream_Rate_Current);
6 New_Window_Type -Rnowledggebase(Workload_Requirements_List[ ], Stream_Rate_Type);
7 Recom_Window_Size -get_Window_Size -get_Window_Size_from_Knowledgebase(Workload_Requirements_List[ ], Stream_Rate_Type);
8//Large window size
9 ifRecom_Window_Size.equal('large')then
10\(New\_Window\_Size -Current\_Window\_Size+1\)
11 else
12//Small window size
13\(Stream\_Rate\_min\leftarrow\textbf{min}(Stream\_Rate\_Last,Stream\_Rate\_Current));
14\(Stream\_Rate\_max\leftarrow\textbf{max}(Stream\_Rate\_Last,Stream\_Rate\_Current));
15\(Stream\_Rate\_Change\_Ratio\gets Stream\_Rate\_max\)/Stream_Rate_min;
16 New_Window_Size -Window_Size_Current /Stream_Rate_Change_Ratio
17
18 end Function
```

**Algorithm 1**Dynamic Window Configuration Algorithm (Simplified)

**Deployment phase**

In the deployment phase, the new optimized stream query will be deployed using the selected window configuration based on the current stream job status, the stream rates, the application requirements, and resource constraints. In doing so, the new query will be deployed beside the current stream query (i.e., without killing the running query) and the current query still runs until the new one is warmed up. ## 6 Experimental Setup and Evaluation

The experiments have been conducted to perform data stream pipeline using Apache Kafka version 2.11-2.2.0, Apache Flink version 1.7, and MongoDB to consume data from data sources (i.e., sensor data generator), execute stream query and then store the reported data respectively. In the following subsections, the generation of forest fire dataset use case and the description of experiments and discussion are presented. ### Forest Fire Based on Climate Change Dataset

We build our use case called forest fire detection to continuously monitor climate change, i.e., weather conditions in real-time (see Figure 1). As technical level, Apache Kafka is used to consume weather streaming data from the deployed sensors within a forest. The collected data (i.e., potential fire events) is then sent to the query engine running on the top stream processing platform (i.e., Apache Flink). The number of possible fire events is varying drastically during the day. In the normal weather conditions, the weather sensors will send lower data frequencies, and no action will be taken from the forest department authority side. For the forest fire situation, the weather sensors start to send data in higher frequencies which causes event-loss due to the delay in consuming and processing such massive streaming data. Therefore, the delay will raise late alarms to the forest department authority to send its firefighters and drones to the burning forest. Consequently, the dynamic query window selector occurs due to the delay issues caused by the static window configuration for stream query engines. The adaptive query window selector adapts the window size (i.e., increasing and/or decreasing window size according to the fluctuating stream rates during day hours). To the best of our knowledge, there is no open dataset of forest fire detection IoT based use case. The authors in [27] have developed a system with secure communication which has been configured for monitoring different variables of environments including temperature, humidity, CO, CO\({}_{2}\) and wind speed. They have taken into account Rule of 30 that considers zones characterized by temperatures above 30 \({}^{\circ}\)C and humidity values below 30% as risk areas for forest fires. Authors in [25] have considered the probability of forest fire changing with temperature. Based on the proposed work in [25; 27], we prepare a dataset having five weather sensors including temperature, humidity, CO, CO\({}_{2}\), and wind speed.