Feign Client + Eureka POST请求正文(Feign Client + Eureka POST request body)
我正在尝试使用Feign和Eureka将服务器A的发布请求转发到服务器B.这两个服务器都被Eureka成功地取消了。
这有效:
@Feignclient public interface MyFeignClient { @RequestMapping(value = "test", = RequestMethod.POST, consumes = "application/json") ResponseEntity<String> theActualMethod( HttpServletRequest request, @RequestHeader("firstHeader") String header1, @RequestHeader("secondHeader") byte[] header2); }
但是,当我将第二个参数更改为@RequestBody以读取POST请求内容时,我得到一个异常:
java.lang.IllegalStateException: Method has too many Body parameters: public abstract org.springframework.http.ResponseEntity MyFeignClient.theActualMethod(javax.servlet.http.HttpServletRequest,java.lang.String,byte[])
I'm trying to use Feign and Eureka to forward a post request from server A to server B. Both servers are discrovered sucessfully by Eureka.
This works:
@Feignclient public interface MyFeignClient { @RequestMapping(value = "test", = RequestMethod.POST, consumes = "application/json") ResponseEntity<String> theActualMethod( HttpServletRequest request, @RequestHeader("firstHeader") String header1, @RequestHeader("secondHeader") byte[] header2); }
However, when I change the second argument to @RequestBody in order to read the POST request content, I get an exception:
java.lang.IllegalStateException: Method has too many Body parameters: public abstract org.springframework.http.ResponseEntity MyFeignClient.theActualMethod(javax.servlet.http.HttpServletRequest,java.lang.String,byte[])
原文:https://stackoverflow.com/questions/35264620
满意答案
程序启动时,在main()中,使用任何系统计时器记录时间。 当程序在main()的底部结束时,使用相同的系统计时器记录时间。 取时间2和时间1之间的差异。 你去!
您可以使用不同的系统计时器,其中一些计时器的分辨率高于其他计时器。 我建议您在SO网站上搜索“系统计时器”,而不是在这里讨论。 如果您只想要任何系统计时器,gettimeofday()可以在Linux系统上运行,但它已被更新,更高精度的功能所取代。 实际上,gettimeofday()只测量以微秒为单位的时间,这应该足以满足您的需求。
如果您无法获得具有足够好分辨率的计时器,请考虑多次循环运行程序,计算循环执行时间,并将测量时间除以循环迭代次数。
编辑:
系统计时器可用于测量总应用程序性能,包括GPU计算期间使用的时间。 请注意,以这种方式使用系统计时器仅适用于实时或挂钟时间,而不是处理时间。 基于挂钟时间的测量必须包括等待GPU操作完成所花费的时间。
如果要测量GPU内核所用的时间,可以选择几个选项。 首先,您可以使用Compute Visual Profiler收集各种分析信息,虽然我不确定它是否报告时间,但它必须能够(这是一个基本的分析功能)。 其他分析器 - 脑海中浮现 - 提供对CUDA内核的支持。
另一种选择是使用CUDA事件来记录时间。 请参阅CUDA 4.0编程指南,其中讨论了使用CUDA事件来测量时间。
另一种选择是使用围绕GPU内核调用的系统计时器。 请注意,鉴于内核调用返回的异步性质,您还需要使用主机端GPU同步调用(例如cudaThreadSynchronize())来跟随内核调用,以使此方法适用。 如果你选择这个选项,我强烈建议在循环中调用内核,在结束时定时循环+一次同步(因为在不在不同流中执行的内核调用之间发生同步,循环内部不需要cudaThreadSynchronize()),并除以迭代次数。
When your program starts, in main(), use any system timer to record the time. When your program ends at the bottom of main(), use the same system timer to record the time. Take the difference between time2 and time1. There you go!
There are different system timers you can use, some with higher resolution than others. Rather than discuss those here, I'd suggest you search for "system timer" on the SO site. If you just want any system timer, gettimeofday() works on Linux systems, but it has been superseded by newer, higher-precision functions. As it is, gettimeofday() only measures time in microseconds, which should be sufficient for your needs.
If you can't get a timer with good enough resolution, consider running your program in a loop many times, timing the execution of the loop, and dividing the measured time by the number of loop iterations.
EDIT:
System timers can be used to measure total application performance, including time used during the GPU calculation. Note that using system timers in this way applies only to real, or wall-clock, time, rather than process time. Measurements based on the wall-clock time must include time spent waiting for GPU operations to complete.
If you want to measure the time taken by a GPU kernel, you have a few options. First, you can use the Compute Visual Profiler to collect a variety of profiling information, and although I'm not sure that it reports time, it must be able to (that's a basic profiling function). Other profilers - PAPI comes to mind - offer support for CUDA kernels.
Another option is to use CUDA events to record times. Please refer to the CUDA 4.0 Programming Guide where it discusses using CUDA events to measure time.
Yet another option is to use system timers wrapped around GPU kernel invocations. Note that, given the asynchronous nature of kernel invocation returns, you will also need to follow the kernel invocation with a host-side GPU synchronization call such as cudaThreadSynchronize() for this method to be applicable. If you go with this option, I highly recommend calling the kernel in a loop, timing the loop + one synchronization at the end (since synchronization occurs between kernel calls not executing in different streams, cudaThreadSynchronize() is not needed inside the loop), and dividing by the number of iterations.
相关问答
更多我应该在GPU上还是在CPU上计算矩阵?(Should I calculate matrices on the GPU or on the CPU?)
从GPU复制到CPU比将CPU复制到GPU要慢(copy from GPU to CPU is slower than copying CPU to GPU)
将PyTorch代码从CPU移植到GPU(Porting PyTorch code from CPU to GPU)
为什么Opencv GPU代码比CPU慢?(Why Opencv GPU code is slower than CPU?)
mxnet(gluon):选择gpu(0)上下文时使用的cpu(mxnet (gluon): cpu used when gpu(0) context selected)
关于CPU的GPU性能(GPU performance with respect to CPU)
如何计算CPU + GPU的总时间(How to calculate total time for CPU + GPU)
CPU何时在GPU上等待?(When does the CPU wait on the GPU?)
将数据从GPU复制到CPU(Copy data from GPU to CPU)
异步CPU读取和GPU + CPU计算(Asynchronous CPU reading and GPU+CPU calculations)
相关文章
更多httpclient post 请求
httpclient post 表单参数请求
HDFS Client如何从Datanode读取block
HDFS源码分析——RPC Client实现
Riak, haproxy, and client side applications
HDFS1.0源代码解析—Hadoop的RPC机制之Client解析
HDFS Datanode与Client之间的数据传输
solr python client
storm client command
solr实例代码 import org.apache.solr.client.solrj.SolrServer
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!