@Override public void init(Context context) { super.init(context); Preconditions.checkNotNull(this.context, "Must specify context for local tables."); kvStore = this.context.getTaskContext().getStore(tableId); Preconditions.checkNotNull(kvStore, String.format( "Backing store for table %s was not injected by SamzaContainer", tableId)); logger.info("Initialized backing store for table " + tableId); }
@Override public void init(Context context) { String rightStoreName = joinOpSpec.getRightOpId(); rightStreamState = (KeyValueStore<Object, TimestampedValue<Object>>) context.getTaskContext().getStore(rightStoreName); // user-defined joinFn should only be initialized once, // so we do it only in left partial join function and not here again. }
@Override public void init(Context context) { String rightStoreName = joinOpSpec.getRightOpId(); rightStreamState = (KeyValueStore<Object, TimestampedValue<Object>>) context.getTaskContext().getStore(rightStoreName); // user-defined joinFn should only be initialized once, // so we do it only in left partial join function and not here again. }
@Override public void init(Context context) { String rightStoreName = joinOpSpec.getRightOpId(); rightStreamState = (KeyValueStore<Object, TimestampedValue<Object>>) context.getTaskContext().getStore(rightStoreName); // user-defined joinFn should only be initialized once, // so we do it only in left partial join function and not here again. }
StreamTableJoinOperatorImpl(StreamTableJoinOperatorSpec<K, M, R, JM> joinOpSpec, Context context) { this.joinOpSpec = joinOpSpec; this.table = context.getTaskContext().getTable(joinOpSpec.getTableId()); }
@Override public void init(Context context) { String rightStoreName = joinOpSpec.getRightOpId(); rightStreamState = (KeyValueStore<Object, TimestampedValue<Object>>) context.getTaskContext().getStore(rightStoreName); // user-defined joinFn should only be initialized once, // so we do it only in left partial join function and not here again. }
@Override public void init(Context context) { String rightStoreName = joinOpSpec.getRightOpId(); rightStreamState = (KeyValueStore<Object, TimestampedValue<Object>>) context.getTaskContext().getStore(rightStoreName); // user-defined joinFn should only be initialized once, // so we do it only in left partial join function and not here again. }
BroadcastOperatorImpl(BroadcastOperatorSpec<M> broadcastOpSpec, SystemStream systemStream, Context context) { this.broadcastOpSpec = broadcastOpSpec; this.systemStream = systemStream; this.taskName = context.getTaskContext().getTaskModel().getTaskName().getTaskName(); }
@Override public void init(Context context) { String leftStoreName = joinOpSpec.getLeftOpId(); leftStreamState = (KeyValueStore<Object, TimestampedValue<Object>>) context.getTaskContext().getStore(leftStoreName); // user-defined joinFn should only be initialized once, so we do it only in left partial join function. joinFn.init(context); }
@Override public void init(Context context) { super.init(context); Preconditions.checkNotNull(this.context, "Must specify context for local tables."); kvStore = (KeyValueStore) this.context.getTaskContext().getStore(tableSpec.getId()); if (kvStore == null) { throw new SamzaException(String.format( "Backing store for table %s was not injected by SamzaContainer", tableSpec.getId())); } logger.info("Initialized backing store for table " + tableSpec.getId()); }
BroadcastOperatorImpl(BroadcastOperatorSpec<M> broadcastOpSpec, SystemStream systemStream, Context context) { this.broadcastOpSpec = broadcastOpSpec; this.systemStream = systemStream; this.taskName = context.getTaskContext().getTaskModel().getTaskName().getTaskName(); }
SendToTableOperatorImpl(SendToTableOperatorSpec<K, V> sendToTableOpSpec, Context context) { this.sendToTableOpSpec = sendToTableOpSpec; this.table = (ReadWriteTable) context.getTaskContext().getTable(sendToTableOpSpec.getTableSpec().getId()); }
StreamTableJoinOperatorImpl(StreamTableJoinOperatorSpec<K, M, R, JM> joinOpSpec, Context context) { this.joinOpSpec = joinOpSpec; this.table = (ReadableTable) context.getTaskContext().getTable(joinOpSpec.getTableSpec().getId()); }
BroadcastOperatorImpl(BroadcastOperatorSpec<M> broadcastOpSpec, SystemStream systemStream, Context context) { this.broadcastOpSpec = broadcastOpSpec; this.systemStream = systemStream; this.taskName = context.getTaskContext().getTaskModel().getTaskName().getTaskName(); }
PartitionByOperatorImpl(PartitionByOperatorSpec<M, K, V> partitionByOpSpec, SystemStream systemStream, Context context) { this.partitionByOpSpec = partitionByOpSpec; this.systemStream = systemStream; this.keyFunction = partitionByOpSpec.getKeyFunction(); this.valueFunction = partitionByOpSpec.getValueFunction(); this.taskName = context.getTaskContext().getTaskModel().getTaskName().getTaskName(); StreamMetadataCache streamMetadataCache = ((TaskContextImpl) context.getTaskContext()).getStreamMetadataCache(); this.controlMessageSender = new ControlMessageSender(streamMetadataCache); }
PartitionByOperatorImpl(PartitionByOperatorSpec<M, K, V> partitionByOpSpec, SystemStream systemStream, Context context) { this.partitionByOpSpec = partitionByOpSpec; this.systemStream = systemStream; this.keyFunction = partitionByOpSpec.getKeyFunction(); this.valueFunction = partitionByOpSpec.getValueFunction(); this.taskName = context.getTaskContext().getTaskModel().getTaskName().getTaskName(); StreamMetadataCache streamMetadataCache = ((TaskContextImpl) context.getTaskContext()).getStreamMetadataCache(); this.controlMessageSender = new ControlMessageSender(streamMetadataCache); }
PartitionByOperatorImpl(PartitionByOperatorSpec<M, K, V> partitionByOpSpec, SystemStream systemStream, Context context) { this.partitionByOpSpec = partitionByOpSpec; this.systemStream = systemStream; this.keyFunction = partitionByOpSpec.getKeyFunction(); this.valueFunction = partitionByOpSpec.getValueFunction(); this.taskName = context.getTaskContext().getTaskModel().getTaskName().getTaskName(); StreamMetadataCache streamMetadataCache = ((TaskContextImpl) context.getTaskContext()).getStreamMetadataCache(); this.controlMessageSender = new ControlMessageSender(streamMetadataCache); }
PartitionByOperatorImpl(PartitionByOperatorSpec<M, K, V> partitionByOpSpec, SystemStream systemStream, Context context) { this.partitionByOpSpec = partitionByOpSpec; this.systemStream = systemStream; this.keyFunction = partitionByOpSpec.getKeyFunction(); this.valueFunction = partitionByOpSpec.getValueFunction(); this.taskName = context.getTaskContext().getTaskModel().getTaskName().getTaskName(); StreamMetadataCache streamMetadataCache = ((TaskContextImpl) context.getTaskContext()).getStreamMetadataCache(); this.controlMessageSender = new ControlMessageSender(streamMetadataCache); }
@Before public void setup() { this.context = new MockContext(); when(this.context.getTaskContext().getTaskMetricsRegistry()).thenReturn(new MetricsRegistryMap()); when(this.context.getTaskContext().getTaskModel()).thenReturn(mock(TaskModel.class)); when(this.context.getContainerContext().getContainerMetricsRegistry()).thenReturn(new MetricsRegistryMap()); }
@Before public void setup() { this.context = new MockContext(); // individual tests can override this config if necessary when(this.context.getJobContext().getConfig()).thenReturn(mock(Config.class)); TaskModel taskModel = mock(TaskModel.class); when(taskModel.getTaskName()).thenReturn(new TaskName("task 0")); when(this.context.getTaskContext().getTaskModel()).thenReturn(taskModel); when(this.context.getTaskContext().getTaskMetricsRegistry()).thenReturn(new MetricsRegistryMap()); when(this.context.getContainerContext().getContainerMetricsRegistry()).thenReturn(new MetricsRegistryMap()); }