小编kpc*_*der的帖子

如何在集成测试中一起使用这些@DataMongoTest 和@SpringBootTest

我正在尝试为我的其余应用程序之一编写集成测试用例,该应用程序在内部使用 mongodb 来持久化数据

@DataMongoTest 
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class MainControllerTest {
@LocalServerPort
    private int port = 8080;
/* some test cases*/ 
}
Run Code Online (Sandbox Code Playgroud)

但我得到以下错误

java.lang.IllegalStateException: Configuration error: found multiple declarations of @BootstrapWith for test class [com.sample.core.controller.MainControllerTest]: [@org.springframework.test.context.BootstrapWith(value=class org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTestContextBootstrapper), @org.springframework.test.context.BootstrapWith(value=class org.springframework.boot.test.context.SpringBootTestContextBootstrapper)]
Run Code Online (Sandbox Code Playgroud)

看起来这两者是相互排斥的,那么如何进行集成测试。

junit integration-testing spring-boot-test

13
推荐指数
1
解决办法
6409
查看次数

spring feign 客户端异常处理

我有一些 fiegn 客户端发送请求其他微服务。

@FeignClient(name="userservice")
public interface UserClient {

    @RequestMapping(
            method= RequestMethod.GET,
                      path = "/userlist")
    String getUserByid(@RequestParam(value ="id") String id);

}
Run Code Online (Sandbox Code Playgroud)

现在我正在发送这样的请求

try {
    String responseData = userClient.getUserByid(id);
    return responseData;
    }

catch(FeignException e)
 {
 logger.error("Failed to get user", id);
}

catch (Exception e) 
{
 logger.error("Failed to get user", id);
}
Run Code Online (Sandbox Code Playgroud)

这里的问题是,如果发生任何 FeignException,我不会收到任何错误代码。

我需要在其他 APIS 中发送相应的错误代码以发送给调用方

那么如何提取错误代码呢?我想提取错误代码并构建一个 responseEntity

我得到了这段代码,但不知道如何在我的函数中使用。

exception spring-cloud-feign feign

12
推荐指数
4
解决办法
5万
查看次数

Kafka Streams如何获取kafka headers

我有下面的卡夫卡流代码

    public class KafkaStreamHandler implements  Processor<String, String>{

    private ProcessorContext context;


        @Override
    public void init(ProcessorContext context) {
        // TODO Auto-generated method stub
        this.context = context;
    }

    public KeyValue<String, KafkaStatusRecordWrapper> process(String key, String value) {

        Headers contexts = context.headers();

        contexts.forEach(header -> System.out.println(header));
     }

public void StartFailstreamHandler() {
       StreamsBuilder builder = new StreamsBuilder();

        KStream<String, String> userStream = builder.stream("usertopic",Consumed.with(Serdes.String(), Serdes.String()));
        Properties props = new Properties();
        props.put(StreamsConfig.APPLICATION_ID_CONFIG, "failed-streams-userstream");
        props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "ALL my bootstrap servers);
        props.put(StreamsConfig.NUM_STREAM_THREADS_CONFIG, 4);
        props.put("enable.auto.commit", "true");
        props.put("auto.commit.interval.ms", "500");
        props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "latest");
        //consumer_timeout_ms
        props.put(ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG, 2000);

        props.put("state.dir","/tmp/kafka/stat)); …
Run Code Online (Sandbox Code Playgroud)

java apache-kafka apache-kafka-streams

7
推荐指数
1
解决办法
1万
查看次数

Zeppelin内部错误处理创建解释器

我尝试安装新的zeppelin即0.8.0版本,我按照链接安装zeppelin.

由于我想要凤凰翻译,我在这里给出的指南的帮助下添加了翻译.

当我运行以下段落时,我得到以下错误

%phoenix
select * from "mytable"  

org.apache.thrift.TApplicationException: Internal error processing createInterpreter
at org.apache.thrift.TApplicationException.read(TApplicationException.java:111)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:71)
at org.apache.zeppelin.interpreter.thrift.RemoteInterpreterService$Client.recv_createInterpreter(RemoteInterpreterService.java:209)
at org.apache.zeppelin.interpreter.thrift.RemoteInterpreterService$Client.createInterpreter(RemoteInterpreterService.java:192)
at org.apache.zeppelin.interpreter.remote.RemoteInterpreter$2.call(RemoteInterpreter.java:164)
at org.apache.zeppelin.interpreter.remote.RemoteInterpreter$2.call(RemoteInterpreter.java:160)
at org.apache.zeppelin.interpreter.remote.RemoteInterpreterProcess.callRemoteFunction(RemoteInterpreterProcess.java:141)
at org.apache.zeppelin.interpreter.remote.RemoteInterpreter.internal_create(RemoteInterpreter.java:160)
at org.apache.zeppelin.interpreter.remote.RemoteInterpreter.open(RemoteInterpreter.java:129)
at org.apache.zeppelin.interpreter.remote.RemoteInterpreter.getFormType(RemoteInterpreter.java:287)
at org.apache.zeppelin.notebook.Paragraph.jobRun(Paragraph.java:425)
at org.apache.zeppelin.scheduler.Job.run(Job.java:182)
at org.apache.zeppelin.scheduler.RemoteScheduler$JobRunner.run(RemoteScheduler.java:307)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Run Code Online (Sandbox Code Playgroud)

phoenix apache-zeppelin

5
推荐指数
0
解决办法
1211
查看次数

按时间戳写入Spark分区数据

我有一些时间戳列字段很长且具有时代标准的数据,我需要使用Spark Scala将数据保存为拆分格式,例如yyyy / mm / dd / hh

data.write.partitionBy("timestamp").format("orc").save("mypath") 
Run Code Online (Sandbox Code Playgroud)

这只是按时间戳分割数据,如下所示

timestamp=1458444061098
timestamp=1458444061198
Run Code Online (Sandbox Code Playgroud)

但我希望它像

??? YYYY
    ??? MM
        ??? DD
            ??? HH
Run Code Online (Sandbox Code Playgroud)

scala apache-spark apache-spark-sql

5
推荐指数
2
解决办法
4907
查看次数

AWS允许不同账户访问kinesis流

我在我的帐户中创建了一个运动流,我需要向另一个根帐户中的另一用户提供访问权限。

  1. 我没有找到任何方法来添加流策略,因此如何为不同帐户中的其他用户提供访问权限?

  2. 用户如何通过另一个帐户访问 Kinesis 流?

amazon-web-services amazon-iam amazon-kinesis

5
推荐指数
1
解决办法
1万
查看次数

齐柏林飞艇战胜超级组

我已经使用 zeppelin 几年了,现在 superset 因更好的可视化功能等而获得更多关注。所以我试图了解确切的差异,并在有人想要选择 BI 工具时提供帮助。

我根据对超集的初步阅读列出了一些独特的功能,如果有人能为该列表做出更多贡献,我将不胜感激。

  • 大多数大数据集群集成支持(Spark、flink等)
  • 使用段落执行内联代码
  • 多语言支持

由于我不是 Superset 的正式用户,我想了解 Zeppelin 的更多独特功能,而这些功能在 Superset 中是不可能或很难做到的。

我还从 apache wiki 获得了以下详细信息,但我不认为这些可以是除了利用笔记本风格之外的独特因素

Apache Zeppelin 是一个间接竞争对手,但它解决了不同的用例。

Apache Zeppelin 是一款基于 Web 的笔记本,支持交互式数据分析。它支持使用 SQL、Scala 等创建精美的数据驱动、交互式和协作文档。尽管用户可以使用此项目创建数据可视化,但它利用笔记本式用户界面,并且面向 Scala 和 SQL 共存的 Spark 社区

bi-tool apache-zeppelin apache-superset

3
推荐指数
1
解决办法
1307
查看次数

加入后火花删除多个重复的列

加入两个数据框后,我得到了许多重复的列,现在我想删除最后一个列,下面是我的 printSchema

root
 |-- id: string (nullable = true)
 |-- value: string (nullable = true)
 |-- test: string (nullable = true)
 |-- details: string (nullable = true)
 |-- test: string (nullable = true)
 |-- value: string (nullable = true)
Run Code Online (Sandbox Code Playgroud)

现在我想删除最后两列

 |-- test: string (nullable = true)
 |-- value: string (nullable = true)
Run Code Online (Sandbox Code Playgroud)

我尝试使用 df..dropDuplicates() 但它全部删除

如何删除最后出现的重复列?

apache-spark apache-spark-sql

1
推荐指数
1
解决办法
7985
查看次数

postgres 仅当用户不存在时才创建用户

我很少有 CREATE 用户作为 myquery.sql 文件的一部分,并且它也包含很少的其他查询

我的文件看起来像这样

CREATE USER myuser NOLOGIN;
GRANT CONNECT on DATABSE myDataBase to myuser;
GRANT USAGE ON SCHEAMA myschema to myuser;
Run Code Online (Sandbox Code Playgroud)

我在同一个文件中很少有这样的查询,由于某种原因,我需要向同一个文件添加新查询,当再次执行同一个文件时,我坚持错误用户已经存在,并且无法到达新添加的查询。

我还检查了 postgres 中没有 IF NOT EXISTS 类型的 CREATE USER 帮助。

那么如何添加检查以仅在不存在时创建用户。

sql postgresql

0
推荐指数
1
解决办法
8151
查看次数