我有以下 gradle 构建配置:
plugins {
id 'com.github.johnrengelman.shadow' version '1.2.3'
}
group 'abc'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'application'
mainClassName = "abc.Driver"
repositories {
mavenCentral()
}
dependencies {
compile (group: 'org.apache.hadoop', name: 'hadoop-client', version: '2.6.0')
}
sourceSets {
main {
java {
srcDir './src'
}
}
}
jar {
manifest {
attributes(
'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
'Main-Class': mainClassName
)
}
}
task fatJar(type: Jar) {
manifest {
attributes 'Implementation-Title': 'Gradle Jar File Example',
'Implementation-Version': version,
'Main-Class': mainClassName …Run Code Online (Sandbox Code Playgroud) 我希望有一个Kafka Consumer,它从一个主题中的最新消息开始.
这是java代码:
private static Properties properties = new Properties();
private static KafkaConsumer<String, String> consumer;
static
{
properties.setProperty("bootstrap.servers","localhost");
properties.setProperty("enable.auto.commit", "true");
properties.setProperty("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
properties.setProperty("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
properties.setProperty("group.id", "test");
properties.setProperty("auto.offset.reset", "latest");
consumer = new KafkaConsumer<>(properties);
consumer.subscribe(Collections.singletonList("mytopic"));
}
@Override
public StreamHandler call() throws Exception
{
while (true)
{
ConsumerRecords<String, String> consumerRecords = consumer.poll(200);
Iterable<ConsumerRecord<String, String>> records = consumerRecords.records("mytopic");
for(ConsumerRecord<String, String> rec : records)
{
System.out.println(rec.value());
}
}
}
Run Code Online (Sandbox Code Playgroud)
尽管auto.offset.reset的值是最新的,但是消费者会在2天前启动表单消息,然后赶上最新的消息.
我错过了什么?
我被介绍是运营商给我的学生时,我注意到,在Python(3.6版以上)和(3.7版)之间的行为不一致.
启动python shell并运行:
5/2 is 2.5
Run Code Online (Sandbox Code Playgroud)
要么:
(1, 2, 3) is (1, 2, 3)
Run Code Online (Sandbox Code Playgroud)
在v3.6.X中,你得到False了两者,但在v3.7中他们结果是True.
我的期望是结果应该是True,因为我认为不可变数字对象(或它们的元组)只有一个实例.
似乎至少我的想法在以前的Python版本中是不对的.
有谁知道解释这种新行为的变化是什么?