FunctionExecutionServiceImpl implements FunctionExecutionService { @Override public TokenWrapper getTokenHandle(Map<String, String> attributes, Map<String, Interest> interests, boolean createSession, TokenWrapperOwner tokenWrapperOwner) throws FunctionExecutionServiceException { try { return gridClient.getTokenHandle(attributes, interests, createSession, tokenWrapperOwner); } catch (AgentCallTimeoutException e) { throw new FunctionExecutionServiceException("Timeout after "+e.getCallTimeout()+"ms while reserving the agent token. You can increase the call timeout by setting 'grid.client.token.reserve.timeout.ms' in step.properties",e ); } catch (AgentSideException e) { throw new FunctionExecutionServiceException("Unexepected error on the agent side while reserving the agent token: "+e.getMessage(),e); } catch (AgentCommunicationException e) { throw new FunctionExecutionServiceException("Communication error between the controller and the agent while reserving the agent token",e); } } FunctionExecutionServiceImpl(GridClient gridClient, FunctionTypeRegistry functionTypeRegistry, DynamicBeanResolver dynamicBeanResolver); @Override TokenWrapper getLocalTokenHandle(); @Override TokenWrapper getTokenHandle(Map<String, String> attributes, Map<String, Interest> interests, boolean createSession, TokenWrapperOwner tokenWrapperOwner); @Override void returnTokenHandle(String tokenHandleId); @Override Output<OUT> callFunction(String tokenHandleId, Function function, FunctionInput<IN> functionInput, Class<OUT> outputClass);  }
@Test public void testReserveError() { FunctionExecutionService f = getFunctionExecutionServiceForGridClientTest(null, null, new AgentCommunicationException("Reserve error"), null); FunctionExecutionServiceException e = null; try { f.getTokenHandle(new HashMap<>(), new HashMap<>(), true, null); } catch (FunctionExecutionServiceException e1) { e = e1; } Assert.assertNotNull(e); Assert.assertEquals("Communication error between the controller and the agent while reserving the agent token", e.getMessage()); }
@Test public void testReserveTimeoutError() { FunctionExecutionService f = getFunctionExecutionServiceForGridClientTest(null, null, new AgentCallTimeoutException(functionCallTimeout, "Reserve error", null), null); FunctionExecutionServiceException e = null; try { f.getTokenHandle(new HashMap<>(), new HashMap<>(), true, null); } catch (FunctionExecutionServiceException e1) { e = e1; } Assert.assertNotNull(e); Assert.assertEquals("Timeout after "+functionCallTimeout+"ms while reserving the agent token. You can increase the call timeout by setting 'grid.client.token.reserve.timeout.ms' in step.properties", e.getMessage()); }