天气数据采集微服务的实现:数据采集组件、数据存储组件

Flume 数据采集组件 目录 1、数据收集工具/系统产生背景 2、专业的数据收集工具 2.1、Chukwa 2.2、Scribe 2.3、Fluentd 2.4、Logstash 2.5、Apache Flume 3、Flume概述 3.1、Flume概念 3.2、Flume版本介绍 3.3、Flume数据源和输出方式 4、Flume体系结构/核心组件 4.1、概述 4.2、Flume三大核心... 阅读详情

天气数据采集微服务的实现

天气数据采集服务包含数据采集组件、数据存储组件。其中,数据采集组件是通用的用于采集天气数据的组件,而数据存储组件是用于存储天气数据的组件。

在micro-weather-report应用的基础上,我们将对其进行逐步的拆分,形成一个新的微服务msa-weather-collection-server应用。

天气数据采集微服务的实现:数据采集组件、数据存储组件

 

所需环境

为了演示本例子,需要采用如下开发环境。

. JDK8。

. Gradle 4.0。

. Spring Boot Web Starter 2.0.0.M4。

.Apache HttpClient 4.5.3。

. Spring Boot Data Redis Starter 2.0.0.M4。

.Redis 3.2.100。

. Spring Boot Quartz Starter 2.0.0.M4。

. Quartz Scheduler 2.3.0。

新增天气数据采集服务接口及实现

在com.waylau.spring.cloud.weather.service包下,我们定义了该应用的天气数据采集服务接口WeatherDataCollectionService。

public interface WeatherDataCollectionService {
/**
*根据城市工D同步天气数据
*
*@param cityId
*@return
*/
void syncDataByCityId(String cityId);
}

WeatherDataCollectionService只有一个同步天气数据的方法。WeatherDataCollectionServicelmpl是对WeatherDataCollectionService接口的实现。

package com.waylau.spring.cloud.weather.service;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j-LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
/*★
*天气数据采集服务.
*
*@since 1.o.0 2017年10月29日
* @author <a href="/p/https://waylau.com">Way Lau</a>
*
FastAPI + Layui:打造企业级敏捷开发后台管理系统 本文详细介绍了如何使用FastAPI和Layui构建高效的企业级后台管理系统。FastAPI提供高性能的异步API支持,而Layui则简化了前端开发流程,两者结合可实现快速开发和部署。文章涵盖了从环境搭建、核心组件开发到性能优化的全流程,特别适合需要敏捷开发的企业项目。 阅读详情

相关推荐

Ubuntu 22.04 实战:为WIFI6网卡Realtek RTL8852BE手动编译驱动指南

本文详细介绍了在Ubuntu 22.04系统上为Realtek RTL8852BE WIFI6网卡手动编译驱动的完整指南。从问题诊断、环境准备到源码获取、编译安装,逐步解决驱动缺失问题,并提供常见问题排查和性能优化建议,帮助用户充分发挥WIFI6网卡性能。

weixin_30808693的博客 488

西门子博图指令(定时器操作三)

西门子博图定时器中复位定时器功能指令介绍

yue008的博客 8881

华为鸿蒙系统也能用!5分钟搞定谷歌三件套安装(附最新APK下载链接)

本文为华为鸿蒙系统用户提供了一份详尽的谷歌三件套(Google Play服务、商店及框架)手动安装指南。文章核心在于无需Root,通过ADB命令获取设备信息,并从可靠来源下载匹配版本的APK,按照正确顺序安装,从而解决海外应用依赖问题,实现5分钟快速部署。

c7d8e9的博客 6795

Unity URP项目里Post Processing死活没效果?别慌,这5个坑我帮你踩过了

本文详细解析了Unity URP项目中Post Processing效果失效的五大常见问题,包括渲染管线配置冲突、Volume作用域误判、摄像机参数漏配、Layer层级冲突和Profile引用异常。通过实际项目案例和代码示例,提供专业级解决方案,帮助开发者快速排查并修复后处理效果不生效的问题。

weixin_33721427的博客 339

保姆级教程:用TIA Portal V17给S7-1200 PLC和HMI做个联调仿真(附抢答器完整项目包)

本文提供了一份详细的TIA Portal V17教程,指导如何实现S7-1200 PLC与HMI的联合仿真开发。通过抢答器项目实例,涵盖从环境搭建、PLC编程到HMI设计的全流程,帮助工程师高效完成工业自动化系统的虚拟调试,显著提升开发效率。

weixin_30417487的博客 641

【Power Compiler手册】13.UPF多电压设计实现(2)

在这个场景中,在约束传播期间,工具会比较BLOCK中的原子电源域与TOP设计中的原子电源域,并且确认所有属性都匹配。因此,域合并成功,工具会丢弃来自BLOCK的域。在这个场景中,在约束传播期间,工具会比较BLOCK中的原子电源域与TOP设计中的非原子电源域,发现电源域不匹配。在这个场景中,在约束传播期间,工具会比较BLOCK中的非原子电源域与TOP设计中的原子电源域,发现电源域不匹配。在这个场景中,在约束传播期间,工具会比较BLOCK中的原子电源域与TOP设计中的原子电源域,发现它们的一些属性不匹配。

QRBQ 754

【Bluedroid】BLE连接过程详解

Bluedroid BLE的链接过程包括扫描、连接和通信三个基本步骤。通过这些步骤,中央设备和外围设备之间可以建立起稳定、高效的通信链路,实现数据传输和控制操作。

byte轻骑兵的技术小窝 1882

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: 干货!4面阿里java后端,才发现并发编程和JVM是必不可少,特此分享给为金九银十备战的你们
下一篇: 阿里P8大牛将HTTP/2核心教程编制成册,在线分享教学,看到就是赚到
Java_msb666
博客等级 码龄6年 10粉丝 35原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址