/** {@inheritDoc} */ @Nullable @Override public V2 put(V1 key, V2 val) { V2 old = containsKey(key) ? val2 : null; set(key, val); return old; }
/** * Extract batching error from general exception. * @param e Exception * @param rowsAffected List containing the number of affected rows for every query in batch. * @param err Error tuple containing error code and error message. */ private static void extractBatchError(Exception e, List<Long> rowsAffected, IgniteBiTuple<Integer, String> err) { if (e instanceof IgniteSQLException) { BatchUpdateException batchCause = X.cause(e, BatchUpdateException.class); if (batchCause != null) { if (rowsAffected != null) { for (long cnt : batchCause.getLargeUpdateCounts()) rowsAffected.add(cnt); } err.set(batchCause.getErrorCode(), batchCause.getMessage()); } else err.set(((IgniteSQLException)e).statusCode(), OdbcUtils.tryRetrieveH2ErrorMessage(e)); } else err.set(IgniteQueryErrorCode.UNKNOWN, e.getMessage()); }
@Override public void onEvent(Event evt) { assert evt instanceof DiscoveryEvent && (evt.type() == EVT_NODE_FAILED || evt.type() == EVT_NODE_LEFT) : "Unexpected event: " + evt; DiscoveryEvent discoEvt = (DiscoveryEvent)evt; if (taskNodeId.equals(discoEvt.eventNode().id())) { lock.lock(); try { if (t.isEmpty()) { t.set("Node that originated task execution has left grid: " + taskNodeId, null); cond.signalAll(); } } finally { lock.unlock(); } } } };
@Override public void onEvent(Event evt) { assert evt instanceof DiscoveryEvent && (evt.type() == EVT_NODE_FAILED || evt.type() == EVT_NODE_LEFT) : "Unexpected event: " + evt; DiscoveryEvent discoEvt = (DiscoveryEvent)evt; if (resHolderId.equals(discoEvt.eventNode().id())) { lock.lock(); try { if (t.isEmpty()) { t.set("Node that originated task execution has left grid: " + resHolderId, null); cond.signalAll(); } } finally { lock.unlock(); } } } };
t.set(err, res);
@Override public void onMessage(UUID nodeId, Object msg, byte plc) { String err = null; GridTaskResultResponse res = null; if (!(msg instanceof GridTaskResultResponse)) err = "Received unexpected message: " + msg; else if (!nodeId.equals(resHolderId)) err = "Received task result response from unexpected node [resHolderId=" + resHolderId + ", nodeId=" + nodeId + ']'; else // Sender and message type are fine. res = (GridTaskResultResponse)msg; try { res.result(U.unmarshal(ctx, res.resultBytes(), U.resolveClassLoader(ctx.config()))); } catch (IgniteCheckedException e) { U.error(log, "Failed to unmarshal task result: " + res, e); } lock.lock(); try { if (t.isEmpty()) { t.set(err, res); cond.signalAll(); } } finally { lock.unlock(); } } };
firstErr.set(code, msg); else U.error(log, "Failed to execute batch query [qry=" + qry + ']', e);
/** {@inheritDoc} */ @Nullable @Override public V2 put(V1 key, V2 val) { V2 old = containsKey(key) ? val2 : null; set(key, val); return old; }
/** * Extract batching error from general exception. * @param e Exception * @param rowsAffected List containing the number of affected rows for every query in batch. * @param err Error tuple containing error code and error message. */ private static void extractBatchError(Exception e, List<Long> rowsAffected, IgniteBiTuple<Integer, String> err) { if (e instanceof IgniteSQLException) { BatchUpdateException batchCause = X.cause(e, BatchUpdateException.class); if (batchCause != null) { if (rowsAffected != null) { for (long cnt : batchCause.getLargeUpdateCounts()) rowsAffected.add(cnt); } err.set(batchCause.getErrorCode(), batchCause.getMessage()); } else err.set(((IgniteSQLException)e).statusCode(), OdbcUtils.tryRetrieveH2ErrorMessage(e)); } else err.set(IgniteQueryErrorCode.UNKNOWN, e.getMessage()); }
@Override public void onEvent(Event evt) { assert evt instanceof DiscoveryEvent && (evt.type() == EVT_NODE_FAILED || evt.type() == EVT_NODE_LEFT) : "Unexpected event: " + evt; DiscoveryEvent discoEvt = (DiscoveryEvent)evt; if (resHolderId.equals(discoEvt.eventNode().id())) { lock.lock(); try { if (t.isEmpty()) { t.set("Node that originated task execution has left grid: " + resHolderId, null); cond.signalAll(); } } finally { lock.unlock(); } } } };
@Override public void onEvent(Event evt) { assert evt instanceof DiscoveryEvent && (evt.type() == EVT_NODE_FAILED || evt.type() == EVT_NODE_LEFT) : "Unexpected event: " + evt; DiscoveryEvent discoEvt = (DiscoveryEvent)evt; if (taskNodeId.equals(discoEvt.eventNode().id())) { lock.lock(); try { if (t.isEmpty()) { t.set("Node that originated task execution has left grid: " + taskNodeId, null); cond.signalAll(); } } finally { lock.unlock(); } } } };
t.set(err, res);
@Override public void onMessage(UUID nodeId, Object msg, byte plc) { String err = null; GridTaskResultResponse res = null; if (!(msg instanceof GridTaskResultResponse)) err = "Received unexpected message: " + msg; else if (!nodeId.equals(resHolderId)) err = "Received task result response from unexpected node [resHolderId=" + resHolderId + ", nodeId=" + nodeId + ']'; else // Sender and message type are fine. res = (GridTaskResultResponse)msg; try { res.result(U.unmarshal(ctx, res.resultBytes(), U.resolveClassLoader(ctx.config()))); } catch (IgniteCheckedException e) { U.error(log, "Failed to unmarshal task result: " + res, e); } lock.lock(); try { if (t.isEmpty()) { t.set(err, res); cond.signalAll(); } } finally { lock.unlock(); } } };
firstErr.set(code, msg); else U.error(log, "Failed to execute batch query [qry=" + qry +']', e);