@Test(expectedExceptions = IllegalStateException.class) public void testIncrCounterStateDisabled() { context.incrCounter("test-key", 10); }
@Override public void incrCounter(String key, long amount) { ensureStateEnabled(); try { result(stateContext.incrCounter(key, amount)); } catch (Exception e) { throw new RuntimeException("Failed to increment key '" + key + "' by amount '" + amount + "'", e); } }
ContextImpl implements Context, SinkContext, SourceContext, AutoCloseable { @Override public void incrCounter(String key, long amount) { ensureStateEnabled(); try { result(stateContext.incrCounter(key, amount)); } catch (Exception e) { throw new RuntimeException("Failed to increment key '" + key + "' by amount '" + amount + "'", e); } } }
ContextImpl implements Context, SinkContext, SourceContext, AutoCloseable { @Override public void incrCounter(String key, long amount) { ensureStateEnabled(); try { result(stateContext.incrCounter(key, amount)); } catch (Exception e) { throw new RuntimeException("Failed to increment key '" + key + "' by amount '" + amount + "'", e); } } ContextImpl(InstanceConfig config, Logger logger, PulsarClient client,
                       SecretsProvider secretsProvider, CollectorRegistry collectorRegistry, String[] metricsLabels,
                       Function.FunctionDetails.ComponentType componentType, ComponentStatsManager statsManager,
                       Table<ByteBuf, ByteBuf> stateTable); }
ContextImpl implements Context, SinkContext, SourceContext, AutoCloseable { @Override public void incrCounter(String key, long amount) { ensureStateEnabled(); try { result(stateContext.incrCounter(key, amount)); } catch (Exception e) { throw new RuntimeException("Failed to increment key '" + key + "' by amount '" + amount + "'", e); } } ContextImpl(InstanceConfig config, Logger logger, PulsarClient client,
                       SecretsProvider secretsProvider, CollectorRegistry collectorRegistry, String[] metricsLabels,
                       Function.FunctionDetails.ComponentType componentType, ComponentStatsManager statsManager,
                       Table<ByteBuf, ByteBuf> stateTable); void setCurrentMessageContext(Record<?> record); @Override Record<?> getCurrentRecord(); @Override Collection<String> getInputTopics(); @Override String getOutputTopic(); @Override String getOutputSchemaType(); @Override String getTenant(); @Override String getNamespace(); @Override String getSinkName(); @Override String getSourceName(); @Override String getFunctionName(); @Override String getFunctionId(); @Override int getInstanceId(); @Override int getNumInstances(); @Override String getFunctionVersion(); @Override Logger getLogger(); @Override Optional<Object> getUserConfigValue(String key); @Override Object getUserConfigValueOrDefault(String key, Object defaultValue); @Override Map<String, Object> getUserConfigMap(); @Override String getSecret(String secretName); @Override CompletableFuture<Void> incrCounterAsync(String key, long amount); @Override void incrCounter(String key, long amount); @Override CompletableFuture<Long> getCounterAsync(String key); @Override long getCounter(String key); @Override CompletableFuture<Void> putStateAsync(String key, ByteBuffer value); @Override void putState(String key, ByteBuffer value); @Override CompletableFuture<Void> deleteStateAsync(String key); @Override void deleteState(String key); @Override CompletableFuture<ByteBuffer> getStateAsync(String key); @Override ByteBuffer getState(String key); @Override CompletableFuture<Void> publish(String topicName, O object); @SuppressWarnings("unchecked") @Override CompletableFuture<Void> publish(String topicName, O object, String schemaOrSerdeClassName); @Override TypedMessageBuilder<O> newOutputMessage(String topicName, Schema<O> schema); @Override ConsumerBuilder<O> newConsumerBuilder(Schema<O> schema); CompletableFuture<Void> publish(String topicName, O object, Schema<O> schema); @Override void recordMetric(String metricName, double value); Map<String, Double> getAndResetMetrics(); void resetMetrics(); Map<String, Double> getMetrics(); @Override void close(); }
ContextImpl implements Context, SinkContext, SourceContext, AutoCloseable { @Override public void incrCounter(String key, long amount) { ensureStateEnabled(); try { result(stateContext.incrCounter(key, amount)); } catch (Exception e) { throw new RuntimeException("Failed to increment key '" + key + "' by amount '" + amount + "'", e); } } ContextImpl(InstanceConfig config, Logger logger, PulsarClient client,
                       SecretsProvider secretsProvider, CollectorRegistry collectorRegistry, String[] metricsLabels,
                       Function.FunctionDetails.ComponentType componentType, ComponentStatsManager statsManager,
                       Table<ByteBuf, ByteBuf> stateTable); void setCurrentMessageContext(Record<?> record); @Override Record<?> getCurrentRecord(); @Override Collection<String> getInputTopics(); @Override String getOutputTopic(); @Override String getOutputSchemaType(); @Override String getTenant(); @Override String getNamespace(); @Override String getSinkName(); @Override String getSourceName(); @Override String getFunctionName(); @Override String getFunctionId(); @Override int getInstanceId(); @Override int getNumInstances(); @Override String getFunctionVersion(); @Override Logger getLogger(); @Override Optional<Object> getUserConfigValue(String key); @Override Object getUserConfigValueOrDefault(String key, Object defaultValue); @Override Map<String, Object> getUserConfigMap(); @Override String getSecret(String secretName); @Override CompletableFuture<Void> incrCounterAsync(String key, long amount); @Override void incrCounter(String key, long amount); @Override CompletableFuture<Long> getCounterAsync(String key); @Override long getCounter(String key); @Override CompletableFuture<Void> putStateAsync(String key, ByteBuffer value); @Override void putState(String key, ByteBuffer value); @Override CompletableFuture<Void> deleteStateAsync(String key); @Override void deleteState(String key); @Override CompletableFuture<ByteBuffer> getStateAsync(String key); @Override ByteBuffer getState(String key); @Override CompletableFuture<Void> publish(String topicName, O object); @SuppressWarnings("unchecked") @Override CompletableFuture<Void> publish(String topicName, O object, String schemaOrSerdeClassName); @Override TypedMessageBuilder<O> newOutputMessage(String topicName, Schema<O> schema); @Override ConsumerBuilder<O> newConsumerBuilder(Schema<O> schema); CompletableFuture<Void> publish(String topicName, O object, Schema<O> schema); @Override void recordMetric(String metricName, double value); Map<String, Double> getAndResetMetrics(); void resetMetrics(); Map<String, Double> getMetrics(); @Override void close();  }