我有以下应用程序(我对这个框架很陌生),我希望看到缓存大小(增加),因为它从队列中读取消息但它始终保持为0。
KafkaStreamer<String, String, String> kafkaStreamer = new KafkaStreamer<>();
Ignition.setClientMode(true);
Ignite ignite = Ignition.start();
Properties settings = new Properties();
// Set a few key parameters
settings.put("bootstrap.servers", "localhost:9092");
settings.put("group.id", "test");
settings.put("zookeeper.connect", "localhost:2181");
settings.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
settings.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
settings.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
settings.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
// Create an instance of StreamsConfig from the Properties instance
kafka.consumer.ConsumerConfig config = new ConsumerConfig(settings);
IgniteCache<String, String> cache = ignite.getOrCreateCache("myCache");
IgniteDataStreamer<String, String> stmr = ignite.dataStreamer("myCache");
// allow overwriting cache data
stmr.allowOverwrite(true);
kafkaStreamer.setIgnite(ignite);
kafkaStreamer.setStreamer(stmr);
// set the topic
kafkaStreamer.setTopic("test");
// set the number of threads to process Kafka streams
kafkaStreamer.setThreads(1);
// set Kafka consumer configurations
kafkaStreamer.setConsumerConfig(config);
// set decoders
StringDecoder keyDecoder = new StringDecoder(null);
StringDecoder valueDecoder = new StringDecoder(null);
kafkaStreamer.setKeyDecoder(keyDecoder);
kafkaStreamer.setValueDecoder(valueDecoder);
kafkaStreamer.start();
while (true) {
System.out.println(cache.metrics().getSize());
Thread.sleep(200);
}
任何人都可以说出缺失/错误的原因吗?
谢谢!
答案 0 :(得分:1)
可能您没有消耗足够的条目来填充<form method="post" th:object="${element}" enctype="multipart/form-data" th:action="@{/elements/edit(id=${element.id})}">
<div class="form-group">
<label>Element name (en, de, fr)</label>
<div class="input-group flex-container">
<input type="text" name="name.en" th:value="${element.name.en}" placeholder="(EN)"/>
<input type="text" name="name.de" th:value="${element.name.hu}" placeholder="(DE)"/>
<input type="text" name="name.fr" th:value="${element.name.ro}" placeholder="(FR)"/>
</div>
</div>
// BELOW IS THE PROBLEM: (the rest of the form works properly)
<div th:each="ctg : ${element.category}" class="form-group">
<label>Category</label>
<input type="text" th:field="*{ctg.name}" name="en" th:value="${ctg.name.en}" placeholder="en"/>
<input type="text" th:field="*{ctg.name}" name="de" th:value="${ctg.name.de}" placeholder="(de)"/>
<input type="text" th:field="*{ctg.name}" name="fr" th:value="${ctg.name.fr}" placeholder="(fr)"/>
</div>
</form>
个缓冲区。尝试设置刷新超时:
IgniteDataStreamer
答案 1 :(得分:0)
由于性能原因,默认情况下禁用度量标准。您可以使用配置文件中的CacheConfiguration.setStatisticsEnabled(true)
或statisticsEnabled
属性启用指标。