- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我最近一直在处理一个让我发疯的问题,因为它只是在部署到 Dataflow 中后才会发生,但从来没有在本地运行过,一切都完美无缺。仅供引用,我正在使用 Apache Beam 2.9.0
。
我正在定义一个 DoFn 步骤,它将事件缓冲一段时间(例如 5 分钟),然后在该时间之后触发一些逻辑。
@StateId("bufferSize")
private final StateSpec<ValueState<Integer>> bufferSizeSpec =
StateSpecs.value(VarIntCoder.of());
@StateId("eventsBuffer")
private final StateSpec<BagState<String>> eventsBufferSpec =
StateSpecs.bag(StringUtf8Coder.of());
@TimerId("trigger")
private final TimerSpec triggerSpec =
TimerSpecs.timer(TimeDomain.PROCESSING_TIME);
我有我的 processElement
逻辑来添加传入事件...
@ProcessElement
public void processElement(
ProcessContext processContext,
@StateId("bufferSize") ValueState<Integer> bufferSize,
@StateId("eventsBuffer") BagState<String> eventsBuffer,
@TimerId("trigger") Timer triggerTimer) {
triggerTimer.offset(Duration.standardMinutes(1)).setRelative();
int size = ObjectUtils.firstNonNull(bufferSize.read(), 0);
eventsBuffer.add(processContext.element().getValue());
bufferSize.write(++size);
}
然后我的触发器...
@OnTimer("trigger")
public void onExpiry(
@StateId("bufferSize") ValueState<Integer> bufferSize,
@StateId("eventsBuffer") BagState<String> eventsBuffer) throws Exception {
doSomethingHere();
}
每当执行onExpiry
时,它接收到的参数都是null和0。
集群方面会发生什么?
编辑:
DoFn 之前使用的窗口。
.apply(
"1min Window",
Window
.<KV<String, String>>into(
FixedWindows.of(Duration.standardMinutes(1)))
.triggering(AfterProcessingTime
.pastFirstElementInPane()
.plusDelayOf(Duration.standardSeconds(1)))
.withAllowedLateness(Duration.ZERO)
.accumulatingFiredPanes())
最佳答案
需要注意的是,当窗口过期时,状态将被 GC 回收。
因此,对于 key-1,您的 Bag 对象将包含 {key-1, TimeInterval-1} 、 {key-1,TimeInterval-2} 等的数据。
如果您希望输入值和计时器之间具有强语义,您可能需要探索 EventTime 计时器的使用。
关于java - @OnTimer 方法在触发时接收空引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56988591/
我写下了下面的VBA代码,每5秒执行一次,但它不起作用。 Option Explicit Public RunWhen As Double Public Const cRunIntervalSecon
我一直在尝试使用 Apache Beam 的计时器,但无法触发它们。 据我所知,您可以在 DoFn 中按以下方式定义计时器。 @TimerId("expiry") private final Time
我最近一直在处理一个让我发疯的问题,因为它只是在部署到 Dataflow 中后才会发生,但从来没有在本地运行过,一切都完美无缺。仅供引用,我正在使用 Apache Beam 2.9.0。 我正在定义一
我有一个分配给 StopRecordingData 子的按钮来取消两个子,但它没有。时间表 False 似乎并没有取消 que 中的预定潜艇。 Dim NextTime As Double Sub R
我遇到过解释“要取消挂起的 OnTime 事件,您必须提供它计划运行的确切时间”的帖子。 我应该提供事件第一次运行的时间,还是应该提供下一次触发事件的时间? 我已经尝试了两个版本的 StopTimer
我正在尝试取消 ThisWorkbook 模块的 Workbook_Close 例程中的计时器。谁能解释以下行为?: 手动关闭工作簿 Application.OnTime 按预期运行并取消计时器。 如
我正在使用 Application.Ontime 命令在一段时间不活动(10 分钟)后自动关闭电子表格。 以下代码似乎可以正常工作,但是,如果您自己手动关闭工作表,工作簿似乎仍然在后台处于事件状态,并
基本上我有一个程序,它有 6 个通过串行端口发送值的 slider ,我使用计时器在用户更改这些值时动态重新发送这些值。我遇到的问题是我的计时器调用的 6 个函数的行为很奇怪,第一个函数调用正常工作,
我的应用程序中有一个 TTimer,每 2 秒触发一次并调用我的事件处理程序 HandleTimerEvent()。 HandleTimerEvent() 函数会修改共享资源,并且在返回之前可能需要
我需要每天在特定时间运行我的 Excel VBA。我用谷歌搜索了 ontime 方法,但是我没有从中得到全面的理解。我会提出这个来消除我对 ontime 方法的困惑。 在运行之前,包含的 Excel
我正在开发 Excel 2010 的数据采集前端。我无法弄清楚将多个局部变量参数传递给 Application.OnTime 的语法。 http://markrowlinson.co.uk/artic
vba 函数中字符串中可以使用的最大字符数为 255。我正在尝试运行这个函数 Var1= 1 Var2= 2 . . . Var256 =256 RunMacros= "'Tims_pet_Robot
我已经阅读了一些关于如何停止 VBA Application.OnTime 的问题/线程(例如 this 和 this )程序,但我就是无法停止! 我用它每 x 秒提取一些数据。我明白当我调用 OnT
这里遇到了一些麻烦,现在我只是想让一个图像在屏幕上移动,变量和定位是有效的,但由于某种原因,OnTimer 从未被调用,我在其中放置了一个断点,但它从未被调用到达。没有错误,所以我假设所有方法和变量都
我有一个使用 ON_WM_TIMER 的 MFC 应用程序。 前 1-2 分钟,我用 启动计时器 m_nIDEvent = SetTimer( 234, 500, NULL ); 这工作得很好,但在运
我不确定我是否在做一些没有记录的事情。我创建了自己的派生自 CListCtrl 的类然后覆盖其中的 OnTimer 处理程序: void CListCtrl2::OnTimer(UINT_PTR nI
通常,当人们收到“'onTimer' 没有重载匹配委托(delegate) 'ElapsedEventHandler'”错误时,这是由于没有在每次计时器结束时运行的 void 中包含 Elapse
我使用 application.ontime 在 Excel 中的 VBA 中编写了一个计时器当到达结束时间时,它会发出声音并给出一个消息框。 当时间在同一天晚些时候时,这很好用,但是当它到第二天时,
我正在尝试使用类似于此的代码在宏中实现递归功能-: Dim showTime As Boolean Sub RunClock() Range("A1", "A1").Valu
我想制作一个在后台循环运行的程序,并在可刷新的查询上运行,而不会同时挂起 excel,当发生错误时,它会显示一条消息。 因此,对我有用的唯一想法是使用 Application.Ontime 安排一个过
我是一名优秀的程序员,十分优秀!