/** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { commState.setBuffer(buf); if (!super.writeTo(buf)) return false; if (!commState.typeWritten) { if (!commState.putByte(directType())) return false; commState.typeWritten = true; } switch (commState.idx) { case 2: if (!commState.putBoolean(err)) return false; commState.idx++; case 3: if (!commState.putLong(futId)) return false; commState.idx++; case 4: if (rejectedKeyBytes != null) { if (commState.it == null) { if (!commState.putInt(rejectedKeyBytes.size())) return false; commState.it = rejectedKeyBytes.iterator(); } while (commState.it.hasNext() || commState.cur != NULL) { if (commState.cur == NULL) commState.cur = commState.it.next(); if (!commState.putByteArray((byte[]) commState.cur)) return false; commState.cur = NULL; } commState.it = null; } else { if (!commState.putInt(-1)) return false; } commState.idx++; } return true; }
/** @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); }