@Override public void open() throws Exception { super.open(); collector = new TimestampedCollector<>(output); this.broadcastStates = new HashMap<>(broadcastStateDescriptors.size()); for (MapStateDescriptor<?, ?> descriptor: broadcastStateDescriptors) { broadcastStates.put(descriptor, getOperatorStateBackend().getBroadcastState(descriptor)); } rwContext = new ReadWriteContextImpl(getExecutionConfig(), userFunction, broadcastStates, getProcessingTimeService()); rContext = new ReadOnlyContextImpl(getExecutionConfig(), userFunction, broadcastStates, getProcessingTimeService()); }
@Override public void open() throws Exception { super.open(); InternalTimerService<VoidNamespace> internalTimerService = getInternalTimerService("user-timers", VoidNamespaceSerializer.INSTANCE, this); TimerService timerService = new SimpleTimerService(internalTimerService); collector = new TimestampedCollector<>(output); this.broadcastStates = new HashMap<>(broadcastStateDescriptors.size()); for (MapStateDescriptor<?, ?> descriptor: broadcastStateDescriptors) { broadcastStates.put(descriptor, getOperatorStateBackend().getBroadcastState(descriptor)); } rwContext = new ReadWriteContextImpl(getExecutionConfig(), getKeyedStateBackend(), userFunction, broadcastStates, timerService); rContext = new ReadOnlyContextImpl(getExecutionConfig(), userFunction, broadcastStates, timerService); onTimerContext = new OnTimerContextImpl(getExecutionConfig(), userFunction, broadcastStates, timerService); }
@Override public void open() throws Exception { super.open(); collector = new TimestampedCollector<>(output); this.broadcastStates = new HashMap<>(broadcastStateDescriptors.size()); for (MapStateDescriptor<?, ?> descriptor: broadcastStateDescriptors) { broadcastStates.put(descriptor, getOperatorStateBackend().getBroadcastState(descriptor)); } rwContext = new ReadWriteContextImpl(getExecutionConfig(), userFunction, broadcastStates, getProcessingTimeService()); rContext = new ReadOnlyContextImpl(getExecutionConfig(), userFunction, broadcastStates, getProcessingTimeService()); }
@Override public void open() throws Exception { super.open(); collector = new TimestampedCollector<>(output); this.broadcastStates = new HashMap<>(broadcastStateDescriptors.size()); for (MapStateDescriptor<?, ?> descriptor: broadcastStateDescriptors) { broadcastStates.put(descriptor, getOperatorStateBackend().getBroadcastState(descriptor)); } rwContext = new ReadWriteContextImpl(getExecutionConfig(), userFunction, broadcastStates, getProcessingTimeService()); rContext = new ReadOnlyContextImpl(getExecutionConfig(), userFunction, broadcastStates, getProcessingTimeService()); }
@Override public void open() throws Exception { super.open(); InternalTimerService<VoidNamespace> internalTimerService = getInternalTimerService("user-timers", VoidNamespaceSerializer.INSTANCE, this); TimerService timerService = new SimpleTimerService(internalTimerService); collector = new TimestampedCollector<>(output); this.broadcastStates = new HashMap<>(broadcastStateDescriptors.size()); for (MapStateDescriptor<?, ?> descriptor: broadcastStateDescriptors) { broadcastStates.put(descriptor, getOperatorStateBackend().getBroadcastState(descriptor)); } rwContext = new ReadWriteContextImpl(getExecutionConfig(), getKeyedStateBackend(), userFunction, broadcastStates, timerService); rContext = new ReadOnlyContextImpl(getExecutionConfig(), userFunction, broadcastStates, timerService); onTimerContext = new OnTimerContextImpl(getExecutionConfig(), userFunction, broadcastStates, timerService); }
@Override public void open() throws Exception { super.open(); InternalTimerService<VoidNamespace> internalTimerService = getInternalTimerService("user-timers", VoidNamespaceSerializer.INSTANCE, this); TimerService timerService = new SimpleTimerService(internalTimerService); collector = new TimestampedCollector<>(output); this.broadcastStates = new HashMap<>(broadcastStateDescriptors.size()); for (MapStateDescriptor<?, ?> descriptor: broadcastStateDescriptors) { broadcastStates.put(descriptor, getOperatorStateBackend().getBroadcastState(descriptor)); } rwContext = new ReadWriteContextImpl(getExecutionConfig(), getKeyedStateBackend(), userFunction, broadcastStates, timerService); rContext = new ReadOnlyContextImpl(getExecutionConfig(), userFunction, broadcastStates, timerService); onTimerContext = new OnTimerContextImpl(getExecutionConfig(), userFunction, broadcastStates, timerService); }
private void validateSecondSavepoint(Savepoint savepoint) throws Exception { // Validate the contents of the broadcast state OperatorStateReader reader = new OperatorStateReader(ExecutionEnvironment.createLocalEnvironment(), savepoint, "stateful"); OperatorStateBackend backend = reader.createOperatorStateBackendFromSnapshot(1); BroadcastState<Boolean, List<Integer>> state = backend.getBroadcastState(bcstate); assertEquals(Lists.newArrayList(2, 3), state.get(true)); }
private Path validateStateAndTransform(Savepoint savepoint) throws IOException, Exception { ExecutionEnvironment environment = ExecutionEnvironment.createLocalEnvironment(); // Validate the contents of the broadcast state OperatorStateReader reader = new OperatorStateReader(environment, savepoint, "stateful"); OperatorStateBackend backend = reader.createOperatorStateBackendFromSnapshot(1); BroadcastState<Boolean, List<Integer>> state = backend.getBroadcastState(bcstate); assertEquals(Lists.newArrayList(1), state.get(true)); Path newCheckpointBasePath = new Path(getCheckpointDir(), "new"); OperatorStateWriter writer = new OperatorStateWriter(savepoint, "stateful", newCheckpointBasePath); writer.transformNonKeyedState((i, b) -> { try { b.getBroadcastState(bcstate).put(true, Lists.newArrayList(2, 3)); } catch (Exception e) { throw new RuntimeException(e); } }); StateMetadataUtils.writeSavepointMetadata(newCheckpointBasePath, StateMetadataUtils.createNewSavepoint(savepoint, writer.writeAll())); return newCheckpointBasePath; }