/** * Write ack received from node with given ID for given batch ID. * * @param nodeId Node ID. * @param batchId Batch ID. */ private void onWriteAck(UUID nodeId, long batchId) { if (!isDone()) { Set<Long> reqIds = pendingAcks.get(nodeId); assert reqIds != null : "Received acknowledgement message for not registered node [nodeId=" + nodeId + ", batchId=" + batchId + ']'; boolean rmv = reqIds.remove(batchId); assert rmv : "Received acknowledgement message for not registered batch [nodeId=" + nodeId + ", batchId=" + batchId + ']'; if (awaitingLast && checkCompleted()) onDone(true); } }
/** * Error occurred on node with given ID. * * @param nodeId Node ID. * @param e Caught exception. */ private void onError(UUID nodeId, GridException e) { Set<Long> reqIds = pendingAcks.get(nodeId); // If waiting for ack from this node. if (reqIds != null && !reqIds.isEmpty()) { if (e instanceof GridGgfsOutOfSpaceException) onDone(new GridException("Failed to write data (not enough space on node): " + nodeId, e)); else onDone(new GridException( "Failed to wait for write completion (write failed on node): " + nodeId, e)); } }
/** * Error occurred on node with given ID. * * @param nodeId Node ID. * @param e Caught exception. */ private void onError(UUID nodeId, GridException e) { Set<Long> reqIds = pendingAcks.get(nodeId); // If waiting for ack from this node. if (reqIds != null && !reqIds.isEmpty()) { if (e instanceof GridGgfsOutOfSpaceException) onDone(new GridException("Failed to write data (not enough space on node): " + nodeId, e)); else onDone(new GridException( "Failed to wait for write completion (write failed on node): " + nodeId, e)); } }
/** * Registers write future in ggfs data manager. * * @param fileInfo File info of file opened to write. * @return Future that will be completed when all ack messages are received or when write failed. */ public GridFuture<Boolean> writeStart(GridGgfsFileInfo fileInfo) { WriteCompletionFuture fut = new WriteCompletionFuture(ggfsCtx.kernalContext(), fileInfo.id()); WriteCompletionFuture oldFut = pendingWrites.putIfAbsent(fileInfo.id(), fut); assert oldFut == null : "Opened write that is being concurrently written: " + fileInfo; if (log.isDebugEnabled()) log.debug("Registered write completion future for file output stream [fileInfo=" + fileInfo + ", fut=" + fut + ']'); return fut; }
/** * Registers write future in ggfs data manager. * * @param fileInfo File info of file opened to write. * @return Future that will be completed when all ack messages are received or when write failed. */ public GridFuture<Boolean> writeStart(GridGgfsFileInfo fileInfo) { WriteCompletionFuture fut = new WriteCompletionFuture(ggfsCtx.kernalContext(), fileInfo.id()); WriteCompletionFuture oldFut = pendingWrites.putIfAbsent(fileInfo.id(), fut); assert oldFut == null : "Opened write that is being concurrently written: " + fileInfo; if (log.isDebugEnabled()) log.debug("Registered write completion future for file output stream [fileInfo=" + fileInfo + ", fut=" + fut + ']'); return fut; }
/** * Write ack received from node with given ID for given batch ID. * * @param nodeId Node ID. * @param batchId Batch ID. */ private void onWriteAck(UUID nodeId, long batchId) { if (!isDone()) { Set<Long> reqIds = pendingAcks.get(nodeId); assert reqIds != null : "Received acknowledgement message for not registered node [nodeId=" + nodeId + ", batchId=" + batchId + ']'; boolean rmv = reqIds.remove(batchId); assert rmv : "Received acknowledgement message for not registered batch [nodeId=" + nodeId + ", batchId=" + batchId + ']'; if (awaitingLast && checkCompleted()) onDone(true); } }
/** * Write request will be asynchronously executed on node with given ID. * * @param nodeId Node ID. * @param batchId Assigned batch ID. */ private void onWriteRequest(UUID nodeId, long batchId) { if (!isDone()) { Set<Long> reqIds = pendingAcks.get(nodeId); if (reqIds == null) reqIds = F.addIfAbsent(pendingAcks, nodeId, new GridConcurrentHashSet<Long>()); reqIds.add(batchId); } }
/** * Write request will be asynchronously executed on node with given ID. * * @param nodeId Node ID. * @param batchId Assigned batch ID. */ private void onWriteRequest(UUID nodeId, long batchId) { if (!isDone()) { Set<Long> reqIds = pendingAcks.get(nodeId); if (reqIds == null) reqIds = F.addIfAbsent(pendingAcks, nodeId, new GridConcurrentHashSet<Long>()); reqIds.add(batchId); } }
/** * @param e Error. */ private void onLocalError(GridException e) { if (e instanceof GridGgfsOutOfSpaceException) onDone(new GridException("Failed to write data (not enough space on node): " + ggfsCtx.kernalContext().localNodeId(), e)); else onDone(new GridException( "Failed to wait for write completion (write failed on node): " + ggfsCtx.kernalContext().localNodeId(), e)); }
/** * Marks this future as waiting last ack. */ private void markWaitingLastAck() { awaitingLast = true; if (log.isDebugEnabled()) log.debug("Marked write completion future as awaiting last ack: " + fileId); if (checkCompleted()) onDone(true); }
/** {@inheritDoc} */ @Override public boolean onDone(@Nullable Boolean res, @Nullable Throwable err) { if (!isDone()) { pendingWrites.remove(fileId, this); if (super.onDone(res, err)) return true; } return false; }
/** * Marks this future as waiting last ack. */ private void markWaitingLastAck() { awaitingLast = true; if (log.isDebugEnabled()) log.debug("Marked write completion future as awaiting last ack: " + fileId); if (checkCompleted()) onDone(true); }
/** * @param e Error. */ private void onLocalError(GridException e) { if (e instanceof GridGgfsOutOfSpaceException) onDone(new GridException("Failed to write data (not enough space on node): " + ggfsCtx.kernalContext().localNodeId(), e)); else onDone(new GridException( "Failed to wait for write completion (write failed on node): " + ggfsCtx.kernalContext().localNodeId(), e)); }
/** {@inheritDoc} */ @Override public boolean onDone(@Nullable Boolean res, @Nullable Throwable err) { if (!isDone()) { pendingWrites.remove(fileId, this); if (super.onDone(res, err)) return true; } return false; }