/** * Separated for testing. */ @VisibleForTesting BlockReceiver getBlockReceiver( final ExtendedBlock block, final StorageType storageType, final DataInputStream in, final String inAddr, final String myAddr, final BlockConstructionStage stage, final long newGs, final long minBytesRcvd, final long maxBytesRcvd, final String clientname, final DatanodeInfo srcDataNode, final DataNode dn, DataChecksum requestedChecksum, CachingStrategy cachingStrategy, final boolean allowLazyPersist, final boolean pinning, final String storageId) throws IOException { return new BlockReceiver(block, storageType, in, inAddr, myAddr, stage, newGs, minBytesRcvd, maxBytesRcvd, clientname, srcDataNode, dn, requestedChecksum, cachingStrategy, allowLazyPersist, pinning, storageId); }
mirrorOut = mirrOut; mirrorAddr = mirrAddr; initPerfMonitoring(downstreams); throttler = throttlerArg; while (receivePacket() >= 0) { /* Receive until the last packet */ } try (ReplicaHandler handler = claimReplicaHandler()) { close(); block.setNumBytes(replicaInfo.getNumBytes()); cleanupBlock();
if (responder != null && !syncBlock && !shouldVerifyChecksum()) { ((PacketResponder) responder.getRunnable()).enqueue(seqno, lastPacketInBlock, offsetInBlock, Status.SUCCESS); mirrorOut.flush(); long now = Time.monotonicNow(); setLastSentTime(now); long duration = now - begin; DataNodeFaultInjector.get().logDelaySendingPacketDownstream( mirrorAddr, duration); trackSendPacketToLastNodeInPipeline(duration); if (duration > datanodeSlowLogThresholdMs && LOG.isWarnEnabled()) { LOG.warn("Slow BlockReceiver write packet to mirror took " + duration handleMirrorOutError(e); flushOrSync(true); if (checksumReceivedLen > 0 && shouldVerifyChecksum()) { try { verifyChunks(dataBuf, checksumBuf); } catch (IOException ioe) { translateChunks(dataBuf, checksumBuf); partialCrc = computePartialChunkCrc(onDiskLen, offsetInChecksum); LOG.warn("Slow BlockReceiver write data to disk cost:" + duration
blockReceiver.receiveBlock(null, null, replyOut, null, dataXceiverServer.balanceThrottler, null, true); final Replica r = blockReceiver.getReplica(); datanode.notifyNamenodeReceivedBlock( block, delHint, r.getStorageUuid(), r.isOnTransientStorage());
while ((tempReceiveSize = receivePacket()) > 0) { totalReceiveSize += tempReceiveSize; mirrorOut.flush(); } catch (IOException e) { handleMirrorOutError(e); close(); responder.interrupt(); cleanupBlock(); throw ioe; } finally {
checksumInfo.getChecksum()); blockReceiver = new BlockReceiver(block, storageType, proxyReply, proxySock.getRemoteSocketAddress().toString(), proxySock.getLocalSocketAddress().toString(), blockReceiver.receiveBlock(null, null, replyOut, null, dataXceiverServer.balanceThrottler, null, true); final Replica r = blockReceiver.getReplica(); datanode.notifyNamenodeReceivedBlock( block, delHint, r.getStorageUuid(), r.isOnTransientStorage());
int payloadLen = readNextPacket(); setBlockPosition(offsetInBlock); mirrorOut.flush(); } catch (IOException e) { handleMirrorOutError(e); verifyChunks(pktBuf, dataOff, len, pktBuf, checksumOff); flush();
try { blockReceiver = new BlockReceiver(block, in, s.getRemoteSocketAddress().toString(), s.getLocalSocketAddress().toString(), blockReceiver.writeChecksumHeader(mirrorOut); mirrorOut.flush(); blockReceiver.receiveBlock(mirrorOut, mirrorIn, replyOut, mirrorAddr, null, targets.length);
NetUtils.getInputStream(proxySock), BUFFER_SIZE)); blockReceiver = new BlockReceiver( block, proxyReply, proxySock.getRemoteSocketAddress().toString(), proxySock.getLocalSocketAddress().toString(), blockReceiver.receiveBlock(null, null, null, null, dataXceiverServer.balanceThrottler, -1);
BlockReceiver.this.close(); endTime = ClientTraceLog.isInfoEnabled() ? System.nanoTime() : 0; block.setNumBytes(replicaInfo.getNumBytes());
" which is not a multiple of bytesPerChecksum " + bytesPerChecksum); computePartialChunkCrc(offsetInBlock, offsetInChecksum, bytesPerChecksum);
if (partialCrc.getValue() != checksum2long(crcbuf)) { String msg = "Partial CRC " + partialCrc.getValue() + " does not match value computed the " + " last time file was closed " + checksum2long(crcbuf); throw new IOException(msg);
while (receivePacket() > 0) {} mirrorOut.flush(); } catch (IOException e) { handleMirrorOutError(e); close(); responder.interrupt(); cleanupBlock(); throw ioe; } finally {
stage != BlockConstructionStage.PIPELINE_CLOSE_RECOVERY) { blockReceiver = new BlockReceiver(block, storageType, in, peer.getRemoteAddressString(), peer.getLocalAddressString(), clientname, srcDataNode, datanode, requestedChecksum, cachingStrategy, allowLazyPersist, pinning); replica = blockReceiver.getReplica(); } else { replica = datanode.data.recoverClose( blockReceiver.receiveBlock(mirrorOut, mirrorIn, replyOut, mirrorAddr, null, targets, false);
int payloadLen = readNextPacket(); datanode.myMetrics.mirrorWritePacketLatency.inc(mirrorWritePacketDuration); } catch (IOException e) { handleMirrorOutError(e); LOG.debug("Receiving empty packet for block " + block); } else { setBlockPosition(offsetInBlock); // adjust file position verifyChunks(pktBuf, dataOff, len, pktBuf, checksumOff); flush(forceSync);
try { blockReceiver = new BlockReceiver(namespaceid, block, in, s.getRemoteSocketAddress().toString(), s.getLocalSocketAddress().toString(), headerToSend.writeVersionAndOpCode(mirrorOut); headerToSend.write(mirrorOut); blockReceiver.writeChecksumHeader(mirrorOut); mirrorOut.flush(); long totalReceiveSize = blockReceiver.receiveBlock(mirrorOut, mirrorIn, replyOut, mirrorAddr, null, targets.length);
blockReceiver = new BlockReceiver(namespaceId, block, proxyReply, proxySock.getRemoteSocketAddress().toString(), proxySock.getLocalSocketAddress().toString(), totalReceiveSize = blockReceiver.receiveBlock(null, null, null, null, dataXceiverServer.balanceThrottler, -1);
receiver.close(); block.setNumBytes(receiver.offsetInBlock); datanode.data.finalizeBlock(block);
clientname, srcDataNode, datanode, requestedChecksum, cachingStrategy, allowLazyPersist, pinning, storageId)); replica = blockReceiver.getReplica(); } else { replica = datanode.data.recoverClose( blockReceiver.receiveBlock(mirrorOut, mirrorIn, replyOut, mirrorAddr, null, targets, false);