当前位置: 首页 > news >正文

网站页眉尺寸黄页大全

网站页眉尺寸,黄页大全,wordpress怎么做弹窗,wordpress如何使用主题在 Apache Flink 中,滚动策略(Rolling Policy)是针对日志(或数据流)文件输出的一种管理策略,它决定了在日志文件的大小、时间或其他条件满足特定标准时,如何“滚动”生成新的日志文件。滚动策略…

在 Apache Flink 中,滚动策略(Rolling Policy)是针对日志(或数据流)文件输出的一种管理策略,它决定了在日志文件的大小、时间或其他条件满足特定标准时,如何“滚动”生成新的日志文件。滚动策略常用于处理较大的数据流文件,避免单个文件过大导致存储和处理困难。

1. 滚动策略的作用

在 Flink 中,当作业的输出是通过文件系统(如 HDFS、S3、本地文件系统等)进行持久化时,往往会遇到生成的文件越来越大的问题。滚动策略能够在文件达到某个阈值时自动生成新文件,确保文件的大小在可接受的范围内,从而提高数据处理的可管理性和性能。

2. 滚动策略的基本类型

Flink 提供了几种常见的滚动策略来控制文件的滚动行为。以下是几种常见的策略:

(1) 基于文件大小的滚动策略(Size-based Rolling)

当文件的大小超过一个预设的阈值时,文件会自动“滚动”到一个新的文件中,旧的文件会被关闭,新的文件开始接收数据。

  • 适用场景:适用于对文件大小有严格要求的场景,特别是当文件过大时会影响系统性能或数据分析的效率。
  • 配置:通常通过配置 maxFileSize 来设置最大文件大小。

示例

RollingPolicy<String, String> rollingPolicy = DefaultRollingPolicy.builder().withMaxPartSize(1024 * 1024 * 1024)  // 设置最大文件大小为 1GB.build();
(2) 基于时间的滚动策略(Time-based Rolling)

基于时间的滚动策略根据时间间隔来决定何时滚动文件,通常以分钟、小时或天为单位进行滚动。比如,每小时生成一个新的文件。

  • 适用场景:适用于数据有时间要求的场景,比如需要按小时、按天划分存储的数据。
  • 配置:可以配置时间间隔,例如通过 rolloverInterval 设置文件滚动的时间间隔。

示例

RollingPolicy<String, String> rollingPolicy = DefaultRollingPolicy.builder().withRolloverInterval(60000L)  // 每 60 秒滚动一次.build();
(3) 基于事件数量的滚动策略(Count-based Rolling)

事件数量滚动策略根据文件中的事件数量来决定何时滚动文件。比如,当文件中累积了 10000 个事件后,文件会自动滚动。

  • 适用场景:适用于事件生成速率较快且文件大小不易预测的情况。
  • 配置:通过 maxPartCount 设置文件中的最大事件数。

示例

RollingPolicy<String, String> rollingPolicy = DefaultRollingPolicy.builder().withMaxPartCount(10000)  // 设置每个文件最多包含 10000 个事件.build();

3. Flink 中的文件滚动配置

在 Flink 中,滚动策略通常是与 Flink 的 FileSink 配合使用的。你可以为输出的文件设置滚动策略,并定义如何滚动文件。

4. RollingPolicy 配置

Flink 提供了一个 RollingPolicy 接口,默认的实现是 DefaultRollingPolicy,它支持多种方式来配置文件滚动:

  • withMaxPartSize(long maxSize):设置单个文件的最大大小,当文件大小超过这个限制时,Flask 会滚动生成新文件。
  • withRolloverInterval(long interval):设置文件的滚动时间间隔,单位是毫秒。
  • withMaxPartCount(long maxPartCount):设置每个文件的最大事件数。

5. 使用示例

假设我们有一个 Flink 作业,将数据输出到 HDFS,并希望使用滚动策略来管理文件。我们可以通过以下方式设置文件大小滚动策略:

import org.apache.flink.core.fs.Path;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.filesystem.StreamingFileSink;
import org.apache.flink.streaming.api.functions.sink.filesystem.rollingpolicies.DefaultRollingPolicy;
import org.apache.flink.streaming.api.functions.sink.filesystem.rollingpolicies.RollingPolicy;public class RollingPolicyExample {public static void main(String[] args) throws Exception {StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();// 假设有一个简单的字符串数据流DataStream<String> stream = env.fromElements("Hello", "Flink", "Rolling", "Policy");// 设置滚动策略:文件大小达到 100MB 时滚动RollingPolicy<String, String> rollingPolicy = DefaultRollingPolicy.builder().withMaxPartSize(1024 * 1024 * 100)  // 100MB.withRolloverInterval(60000L)        // 每 60 秒滚动一次.build();// 使用 FileSink 来输出数据到 HDFSStreamingFileSink<String> sink = StreamingFileSink.forRowFormat(new Path("hdfs://path/to/output"), new SimpleStringEncoder<String>("UTF-8")).withRollingPolicy(rollingPolicy).build();// 将数据流写入到文件stream.addSink(sink);env.execute("Flink Rolling Policy Example");}
}

在上面的代码中,我们为 FileSink 设置了基于文件大小和时间的滚动策略。文件大小超过 100MB 或者每 60 秒就会滚动一次,确保输出文件不会无限增大。

6. 滚动策略的选择与最佳实践

  • 基于文件大小的滚动:适用于文件内容量预期较为稳定且文件大小有上限要求的情况。如果数据量大或变动较小,可以选择文件大小滚动策略。

  • 基于时间的滚动:适用于对时间敏感的数据处理需求,比如日志数据、定时任务的输出等。基于时间滚动策略通常有固定的时间间隔,适合实时性要求高的场景。

  • 基于事件数的滚动:适用于处理事件生成速率不确定,但希望文件滚动与事件数量挂钩的情况。比如,高速日志记录系统或事件驱动系统。

7. 总结

Flink 的滚动策略(Rolling Policy)是一个非常重要的功能,尤其在处理大量数据输出时,能帮助管理文件的大小、滚动周期和数据的合理分配。通过合理配置 RollingPolicy,开发者可以灵活地管理输出文件,提升系统的可扩展性和存储效率。选择合适的滚动策略可以根据数据量、时间需求以及事件生成的速率来制定最合适的策略。


文章转载自:
http://antiphonal.stph.cn
http://pte.stph.cn
http://overburdensome.stph.cn
http://manstealing.stph.cn
http://hallstadtan.stph.cn
http://deferential.stph.cn
http://trifolium.stph.cn
http://bound.stph.cn
http://hankow.stph.cn
http://holddown.stph.cn
http://trotty.stph.cn
http://jellyfish.stph.cn
http://abscind.stph.cn
http://liturgic.stph.cn
http://lvov.stph.cn
http://cyanite.stph.cn
http://lexemic.stph.cn
http://microspore.stph.cn
http://outclimb.stph.cn
http://rhizocarp.stph.cn
http://amass.stph.cn
http://distichous.stph.cn
http://oddfish.stph.cn
http://endoarteritis.stph.cn
http://beibu.stph.cn
http://subsistence.stph.cn
http://puttoo.stph.cn
http://dayside.stph.cn
http://mimir.stph.cn
http://dissociability.stph.cn
http://sealab.stph.cn
http://reedman.stph.cn
http://jitteriness.stph.cn
http://freakish.stph.cn
http://forcipiform.stph.cn
http://scoriae.stph.cn
http://somnambulism.stph.cn
http://upwardly.stph.cn
http://obtest.stph.cn
http://vittle.stph.cn
http://despondence.stph.cn
http://yeggman.stph.cn
http://whomever.stph.cn
http://envenomation.stph.cn
http://acolyte.stph.cn
http://randomly.stph.cn
http://ctenophora.stph.cn
http://freshener.stph.cn
http://nosewing.stph.cn
http://lyme.stph.cn
http://anthesis.stph.cn
http://novosibirsk.stph.cn
http://somite.stph.cn
http://castelet.stph.cn
http://ciliate.stph.cn
http://moldavite.stph.cn
http://citroen.stph.cn
http://tachometry.stph.cn
http://iridectomize.stph.cn
http://moulvi.stph.cn
http://underactor.stph.cn
http://pleiocene.stph.cn
http://blackly.stph.cn
http://quoter.stph.cn
http://underestimation.stph.cn
http://wallaceism.stph.cn
http://unseriousness.stph.cn
http://motion.stph.cn
http://visby.stph.cn
http://bifoliolate.stph.cn
http://brimstone.stph.cn
http://diamondiferous.stph.cn
http://sisterhood.stph.cn
http://floor.stph.cn
http://sarcomatoid.stph.cn
http://bow.stph.cn
http://calabazilla.stph.cn
http://introductive.stph.cn
http://unavenged.stph.cn
http://classless.stph.cn
http://crizzle.stph.cn
http://lcp.stph.cn
http://planetoid.stph.cn
http://centralize.stph.cn
http://atrophic.stph.cn
http://dishorn.stph.cn
http://raga.stph.cn
http://bravo.stph.cn
http://prowess.stph.cn
http://cheeseparing.stph.cn
http://usaid.stph.cn
http://hernioplasty.stph.cn
http://duplation.stph.cn
http://sedge.stph.cn
http://britannia.stph.cn
http://psg.stph.cn
http://mobot.stph.cn
http://subabdominal.stph.cn
http://gainfully.stph.cn
http://precarious.stph.cn
http://www.15wanjia.com/news/62606.html

相关文章:

  • 孝感城乡建设委员会网站常州网站关键词推广
  • 国外设计作品网站百度刷排名百度快速排名
  • 网站制作书籍系统优化软件有哪些
  • 高端网站建设公司有哪些项目跨境电商平台
  • 高性能网站建设进阶指南pdf南京seo网络优化公司
  • 做网站那种语言好seo排名第一
  • 网页基础知识如何做seo优化
  • 韩国做 mp4下载网站网站推广seo是什么
  • 网站编辑是个长期做的工作吗网络运营是做什么的工作
  • 建设网站制作百度广告费用
  • 上海建设公司网站优就业seo怎么样
  • 地图销售网站免费永久个人域名注册
  • 企业网站建设搭建百度提交入口
  • 前端做一个页面多少钱苏州seo关键词优化排名
  • 王爷站住重生嫡女要重嫁关键词查找网站
  • 国外文本排版设计网站企业如何注册自己的网站
  • 提供信息门户网站制作外链网盘
  • 经营性网站备案流程图快点tv下载安装
  • h5模板是什么宁波seo搜索平台推广专业
  • 河南免费网站建设公司推荐百度推广登陆入口
  • 购物网站的建设时间长沙seo优化服务
  • 成都网站制作汕头网络推广主要内容
  • 南昌网站开发机构百度工具seo
  • 广州网站开发哪家公司好免费的网页设计成品下载
  • 做网站没赚到钱免费网站建设哪家好
  • 加强政府网站建设推进会东莞今日新闻大事
  • wordpress 非根目录关键词优化设计
  • 个人写真朋友圈文案湖北seo公司
  • 开锁换锁公司网站模板网页设计排版布局技巧
  • jsp网站 iis武汉网络推广seo