/** * Create Grid configuration with configured checkpoints. * * @return Grid configuration. * @throws GridException If configuration creation failed. */ public static GridConfiguration configuration() throws GridException { GridConfiguration cfg = new GridConfiguration(); cfg.setLocalHost("127.0.0.1"); cfg.setPeerClassLoadingEnabled(true); GridOptimizedMarshaller marsh = new GridOptimizedMarshaller(); marsh.setRequireSerializable(false); cfg.setMarshaller(marsh); cfg.setDeploymentSpi(new GridUriDeploymentSpi()); GridTcpDiscoverySpi discoSpi = new GridTcpDiscoverySpi(); GridTcpDiscoveryVmIpFinder ipFinder = new GridTcpDiscoveryVmIpFinder(); ipFinder.setAddresses(Collections.singletonList("127.0.0.1:47500..47509")); discoSpi.setIpFinder(ipFinder); cfg.setDiscoverySpi(discoSpi); return cfg; }
/** @throws Exception If failed. */ public void testEmptyProjections() throws Exception { final GridClientCompute dflt = client.compute(); Collection<? extends GridClientNode> nodes = dflt.nodes(); assertEquals(NODES_CNT, nodes.size()); Iterator<? extends GridClientNode> iter = nodes.iterator(); final GridClientCompute singleNodePrj = dflt.projection(Collections.singletonList(iter.next())); final GridClientNode second = iter.next(); final GridClientPredicate<GridClientNode> noneFilter = new GridClientPredicate<GridClientNode>() { @Override public boolean apply(GridClientNode node) { return false; } }; final GridClientPredicate<GridClientNode> targetFilter = new GridClientPredicate<GridClientNode>() { @Override public boolean apply(GridClientNode node) { return node.nodeId().equals(second.nodeId()); } }; GridTestUtils.assertThrows( log(), new Callable<Object>() { @Override public Object call() throws Exception { return dflt.projection(noneFilter).log(-1, -1); } }, GridServerUnreachableException.class, null); GridTestUtils.assertThrows( log(), new Callable<Object>() { @Override public Object call() throws Exception { return singleNodePrj.projection(second); } }, GridClientException.class, null); GridTestUtils.assertThrows( log(), new Callable<Object>() { @Override public Object call() throws Exception { return singleNodePrj.projection(targetFilter); } }, GridClientException.class, null); }