阿里云中Flink提交作业流程

访问阿里云首页面:https://www.aliyun.com/

选择"按量付费"

通过选择区域,看哪个区域有虚拟交换机。

查看创建的工作空间,当工作空间状态为运行中时,点击控制台。

开通完成后,会有一个控制台:

可以选择SQL开发或者作业运维运行自己的Flink程序。

java 复制代码
package com.bigdata.day06;

import org.apache.flink.api.common.RuntimeExecutionMode;
import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.source.SourceFunction;

import java.util.Random;

/**
 * @基本功能:
 * @program:FlinkDemo
 * @author: 闫哥
 * @create:2023-11-24 14:34:50
 **/
public class _03TestAliyun {

    public static void main(String[] args) throws Exception {

        //1. env-准备环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setRuntimeMode(RuntimeExecutionMode.AUTOMATIC);

        //2. source-加载数据
        DataStreamSource<String> dataStreamSource = env.addSource(new SourceFunction<String>() {
            @Override
            public void run(SourceContext<String> ctx) throws Exception {

                String[] words = {"hello", "world", "bigdata"};
                Random random = new Random();
                while (true) {
                    String word = words[random.nextInt(words.length)];
                    int num = random.nextInt(10);
                    ctx.collect(word + "," + num);
                    Thread.sleep(500);
                }
            }

            @Override
            public void cancel() {

            }
        });

        //3. transformation-数据处理转换
        //2. source-加载数据
        SingleOutputStreamOperator<Tuple2<String, Integer>> mapStream = dataStreamSource.map(new MapFunction<String, Tuple2<String, Integer>>() {
            @Override
            public Tuple2<String, Integer> map(String s) throws Exception {
                String[] arr = s.split(",");

                return Tuple2.of(arr[0], Integer.valueOf(arr[1]));
            }
        });
        //3. transformation-数据处理转换
        SingleOutputStreamOperator<Tuple2<String, Integer>> result = mapStream.keyBy(0).sum(1);


        result.print();
        //4. sink-数据输出


        //5. execute-执行
        env.execute();
    }
}

作业运维在本地IDEA开发,将jar包上传。

可以通过 UI 界面查看效果:

有些程序,是需要环境的,假如数据需要依赖我们虚拟机的环境,是没办法在flink上运行的,因为flink访问不到虚拟机的服务,可以写死一些数据,比如自定义数据源,或者写死一些数据,进行测试。

第一次可以无状态启动:

查看Flink自带的UI界面:

创建快照:

停止后重启,可以从某个快照进行重启:

查看运行结果:

以下是帮助文档:

Flink JAR快速入门_实时计算 Flink版(Flink)-阿里云帮助中心

相关推荐
Mr_sst2 分钟前
infra-ai模块宏观设计解析:业务与模型之间的中间层核心架构
大数据·人工智能·ai·llama
无忧智库13 分钟前
大型集团数字化用户主数据管理体系建设:从零到一的系统性规划实践(PPT)
大数据
AIwenIPgeolocation14 分钟前
IP地址数据服务:驱动电子商务精细化运营与智能风控
大数据·网络协议·tcp/ip
yongyoudayee29 分钟前
业务语义模型:AI CRM从“能用”到“好用”的技术分水岭
大数据·人工智能
tang7778931 分钟前
代理IP质量检测实战:Python实现IP可用性、延迟、匿名度自动测试脚本
大数据·爬虫·python·网络协议·tcp/ip
我就是妖怪38 分钟前
Kimi K2.6 新手快速上手与实战指南
大数据·人工智能
2501_9216494940 分钟前
企业定制金融数据 API:从架构设计到 Python 接入实战
大数据·开发语言·python·websocket·金融·量化
JZC_xiaozhong1 小时前
跨系统审批自动化怎么做?从采购到销售合同的完整方案
大数据·运维·自动化·流程自动化·数据集成与应用集成·业务流程管理·异构数据集成
2601_956139421 小时前
政府事业机构品牌策划公司哪家专业
大数据·人工智能·python
狮子座明仔1 小时前
ThinkTwice: 让模型学会“做完题再检查一遍“,推理+自纠错联合训练只加3%开销
大数据·人工智能·深度学习