kafka.utils.Time不存在

时间:2017-12-01 14:39:13

标签: apache-kafka confluent

环境pom.xml

with c_list as
(
select 'Contract A' as TheContract
union all
select 'Contract B'
union all
select 'Contract C'
union all
select 'Contract D'
)
, MixList as
(
select distinct T2.Title, C1.TheContract
from TitleContracts T2
cross join c_list C1
)
select M3.*
from MixList M3
left join TitleContracts T3
on T3.Title = M3.Title
and M3.TheContract = T3.Contract
where T3.T3.Title is null

申请代码:

    <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka_2.11</artifactId>
        <version>0.10.1.0</version>
        <classifier>test</classifier>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka-clients</artifactId>
        <version>0.10.1.0</version>
        <classifier>test</classifier>
        <scope>test</scope>
    </dependency>

问题是:

TestUtils中的createServer函数需要Time类作为第二个参数,但utils中没有Time类

表示

import kafka.utils.MockTime;

"""
 Time mock = (Time) new MockTime();
 kafka = TestUtils.createServer(kafkaConfig, mock);
"""

将失败

如果我使用org.apache.kafka.common.utils.Time,

TestUtils.createServer抱怨

import kafka.utils.Time

函数如何需要类型类在其模块中不具有的参数?

1 个答案:

答案 0 :(得分:1)

您需要使用实现org.apache.kafka.common.utils.Time接口的东西。 org.apache.kafka.common.utils.SystemTimeorg.apache.kafka.common.utils.MockTime

从Scala到Java的过渡使得一些测试工具依赖项略显凌乱。