/** * Set the timeoutResponse for all the routers connected to the given endpoints with the * given value. * * @param endpoints Router endpoints. * @param timeout New timeout value. */ private void tuneRoutersResponseTimeout(Map<String, IClientRouter> clientRouters, Set<String> endpoints, long timeout) { log.trace("Tuning router timeout responses for endpoints:{} to {}ms", endpoints, timeout); endpoints.forEach(server -> { if (clientRouters.get(server) != null) { clientRouters.get(server).setTimeoutResponse(timeout); } }); } }
/** * Executes the policy once. * Checks for changes in the layout. * Then polls all the servers generates pollReport. * * @param layout Current Layout */ public PollReport poll( @Nonnull Layout layout, @Nonnull CorfuRuntime corfuRuntime, @NonNull SequencerMetrics sequencerMetrics) { log.trace("Poll report. Layout: {}", layout); Map<String, IClientRouter> routerMap; // Collect and set all responsive servers in the members array. Set<String> allServers = layout.getAllServers(); // Set up arrays for routers to the endpoints. routerMap = new HashMap<>(); allServers.forEach(s -> { try { IClientRouter router = corfuRuntime.getRouter(s); router.setTimeoutResponse(period); routerMap.put(s, router); } catch (NetworkException ne) { log.error("Error creating router for {}", s); } }); // Perform polling of all responsive servers. return pollRound(layout.getEpoch(), allServers, routerMap, sequencerMetrics, layout); }
/** * Sets aggressive timeouts for all test routers. */ public void setAggressiveTimeouts(RuntimeLayout runtimeLayout) { // Setting aggressive timeouts List<Integer> serverPorts = new ArrayList<>(); serverPorts.add(SERVERS.PORT_0); serverPorts.add(SERVERS.PORT_1); serverPorts.add(SERVERS.PORT_2); serverPorts.add(SERVERS.PORT_3); serverPorts.add(SERVERS.PORT_4); List<String> routerEndpoints = new ArrayList<>(); routerEndpoints.add(SERVERS.ENDPOINT_0); routerEndpoints.add(SERVERS.ENDPOINT_1); routerEndpoints.add(SERVERS.ENDPOINT_2); routerEndpoints.add(SERVERS.ENDPOINT_3); routerEndpoints.add(SERVERS.ENDPOINT_4); serverPorts.forEach(serverPort -> { routerEndpoints.forEach(routerEndpoint -> { runtimeLayout.getRuntime().getRouter(routerEndpoint).setTimeoutConnect(PARAMETERS.TIMEOUT_VERY_SHORT.toMillis()); runtimeLayout.getRuntime().getRouter(routerEndpoint).setTimeoutResponse(PARAMETERS.TIMEOUT_VERY_SHORT.toMillis()); runtimeLayout.getRuntime().getRouter(routerEndpoint).setTimeoutRetry(PARAMETERS.TIMEOUT_VERY_SHORT.toMillis()); }); }); }
/** * Sets aggressive timeouts for all the router endpoints on all the runtimes. * <p> * * @param layout Layout to get all server endpoints. * @param corfuRuntimes All runtimes whose routers' timeouts are to be set. */ public void setAggressiveTimeouts(Layout layout, CorfuRuntime... corfuRuntimes) { layout.getAllServers().forEach(routerEndpoint -> { for (CorfuRuntime runtime : corfuRuntimes) { runtime.getRouter(routerEndpoint).setTimeoutConnect(PARAMETERS.TIMEOUT_VERY_SHORT.toMillis()); runtime.getRouter(routerEndpoint).setTimeoutResponse(PARAMETERS.TIMEOUT_VERY_SHORT.toMillis()); runtime.getRouter(routerEndpoint).setTimeoutRetry(PARAMETERS.TIMEOUT_VERY_SHORT.toMillis()); } }); }
/** * Sets aggressive timeouts for all the router endpoints on all the runtimes. * <p> * * @param layout Layout to get all server endpoints. * @param corfuRuntimes All runtimes whose routers' timeouts are to be set. */ public void setAggressiveTimeouts(Layout layout, CorfuRuntime... corfuRuntimes) { layout.getAllServers().forEach(routerEndpoint -> { for (CorfuRuntime runtime : corfuRuntimes) { runtime.getRouter(routerEndpoint).setTimeoutConnect(PARAMETERS.TIMEOUT_VERY_SHORT.toMillis()); runtime.getRouter(routerEndpoint).setTimeoutResponse(PARAMETERS.TIMEOUT_VERY_SHORT.toMillis()); runtime.getRouter(routerEndpoint).setTimeoutRetry(PARAMETERS.TIMEOUT_VERY_SHORT.toMillis()); } }); }
getCorfuRuntime().getLayoutView().getLayout().getAllServers().forEach(endpoint -> getCorfuRuntime().getRouter(endpoint) .setTimeoutResponse(PARAMETERS.TIMEOUT_VERY_SHORT.toMillis()));
rt.getRouter(SERVERS.ENDPOINT_2).setTimeoutResponse(1); rt.getRouter(SERVERS.ENDPOINT_2).setTimeoutResponse(PARAMETERS.TIMEOUT_NORMAL.toMillis()); new TestRule().always().drop()); rt.getRouter(SERVERS.ENDPOINT_0).setTimeoutResponse(1); rt.getRouter(SERVERS.ENDPOINT_1).setTimeoutResponse(1);
corfuRuntime.getRouter(serverEndpoint).setTimeoutResponse(PARAMETERS.TIMEOUT_VERY_SHORT.toMillis()); corfuRuntime.getRouter(serverEndpoint).setTimeoutRetry(PARAMETERS.TIMEOUT_VERY_SHORT.toMillis()); });