我正在实现一个SchedulerService使用AgentRestClientbean 从外部系统获取一些数据的方法。它看起来像这样:
@Service
public class SchedulerService {
@Inject
private AgentRestClient agentRestClient;
public String updateStatus(String uuid) {
String status = agentRestClient.get(uuid);
...
}
...
}
Run Code Online (Sandbox Code Playgroud)
为了测试这个服务,我正在使用 Cucumber,同时我试图模拟AgentRestClient使用 Spring Boot@MockBean注释的行为,如下所示:
import cucumber.api.CucumberOptions;
import cucumber.api.java.Before;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = CentralApp.class)
@CucumberOptions(glue = {"com.company.project.cucumber.stepdefs", "cucumber.api.spring"})
public class RefreshActiveJobsStepDefs {
@MockBean
private AgentRestClient agentRestClient;
@Inject
private SchedulerService schedulerService;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
given(agentRestClient.get(anyString())).willReturn("FINISHED");//agentRestClient is always null here
} …Run Code Online (Sandbox Code Playgroud) 我的目标是遍历目录图并使用反应流和Project Reactor记录所有名称.
由于文件系统是远程的,因此对它的调用是阻塞的.因此,我希望将阻塞调用的执行与其他非阻塞异步代码分开.我正在使用这个建议这样做:http://projectreactor.io/docs/core/release/reference/#faq.wrap-blocking.
这是我需要遍历的结构:
/
/jupiter
/phase-1
/sub-phase-1
/sub-phase-2
/sub-phase-3
/phase-2
/phase-3
/phase-4
/earth
/phase-1
/sub-phase-1
/sub-phase-2
/sub-phase-3
/phase-2
/phase-3
/phase-4
/mars
/phase-1
/sub-phase-1
/sub-phase-2
/sub-phase-3
/phase-2
/phase-3
/phase-4
Run Code Online (Sandbox Code Playgroud)
这是我到目前为止提出的代码:
public class ReactorEngine {
private static Logger log = LoggerFactory.getLogger(ReactorEngine.class);
public static void main(String[] args) throws InterruptedException {
CountDownLatch latch = new CountDownLatch(1);
Server server = new Server();
Flux.fromIterable(server.getChildren("/"))
.flatMap(parent -> Mono.fromCallable(() -> server.getChildren(parent)).subscribeOn(Schedulers.elastic()))
.publishOn(Schedulers.elastic())
.doOnTerminate(latch::countDown)
.subscribe(ReactorEngine::handleResponse);
latch.await();
}
private static void handleResponse(List<String> value) {
log.info("Received: …Run Code Online (Sandbox Code Playgroud) 我正在使用此图表:https://github.com/helm/charts/tree/master/stable/rabbitmq在 Kubernetes 上部署由 3 个 RabbitMQ 节点组成的集群。我的目的是让所有队列在集群中的 2 个节点内进行镜像。
这是我用来运行 Helm 的命令:helm install --name rabbitmq-local -f rabbitmq-values.yaml stable/rabbitmq
这是内容rabbitmq-values.yaml:
persistence:
enabled: true
resources:
requests:
memory: 256Mi
cpu: 100m
replicas: 3
rabbitmq:
extraConfiguration: |-
{
"policies": [
{
"name": "queue-mirroring-exactly-two",
"pattern": "^ha\.",
"vhost": "/",
"definition": {
"ha-mode": "exactly",
"ha-params": 2
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
然而,由于一些解析错误,节点无法启动,并且处于崩溃循环中。这是输出kubectl logs rabbitmq-local-0:
BOOT FAILED
===========
Config file generation failed:
=CRASH REPORT==== 23-Jul-2019::15:32:52.880991 ===
crasher:
initial call: lager_handler_watcher:init/1
pid: <0.95.0> …Run Code Online (Sandbox Code Playgroud) java ×2
asynchronous ×1
bitnami ×1
cucumber ×1
graph ×1
kubernetes ×1
mockito ×1
rabbitmq ×1
spring ×1
spring-boot ×1