/** * @param request block request in proto */ BlockWriteRequest(alluxio.grpc.WriteRequest request) { super(request); mTier = request.getCommand().getTier(); if (request.getCommand().hasCreateUfsBlockOptions()) { mCreateUfsBlockOptions = request.getCommand().getCreateUfsBlockOptions(); } else { mCreateUfsBlockOptions = null; } }
UfsFileWriteRequest(alluxio.grpc.WriteRequest request) { super(request); mUfsPath = request.getCommand().getCreateUfsFileOptions().getUfsPath(); mCreateUfsFileOptions = request.getCommand().getCreateUfsFileOptions(); }
WriteRequest(alluxio.grpc.WriteRequest request) { mId = request.getCommand().getId(); mSessionId = IdUtils.createSessionId(); }
/** * Validates a block write request. * * @param request the block write request * @throws InvalidArgumentException if the write request is invalid */ @GuardedBy("mLock") private void validateWriteRequest(alluxio.grpc.WriteRequest request) throws InvalidArgumentException { if (request.hasCommand() && request.getCommand().hasOffset() && request.getCommand().getOffset() != mContext.getPos()) { throw new InvalidArgumentException(String.format( "Offsets do not match [received: %d, expected: %d].", request.getCommand().getOffset(), mContext.getPos())); } }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); switch (valueCase_) { case 1: hash = (37 * hash) + COMMAND_FIELD_NUMBER; hash = (53 * hash) + getCommand().hashCode(); break; case 2: hash = (37 * hash) + CHUNK_FIELD_NUMBER; hash = (53 * hash) + getChunk().hashCode(); break; case 0: default: } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof alluxio.grpc.WriteRequest)) { return super.equals(obj); } alluxio.grpc.WriteRequest other = (alluxio.grpc.WriteRequest) obj; boolean result = true; result = result && getValueCase().equals( other.getValueCase()); if (!result) return false; switch (valueCase_) { case 1: result = result && getCommand() .equals(other.getCommand()); break; case 2: result = result && getChunk() .equals(other.getChunk()); break; case 0: default: } result = result && unknownFields.equals(other.unknownFields); return result; }
private AbstractWriteHandler createWriterHandler(alluxio.grpc.WriteRequest request) { switch (request.getCommand().getType()) { case ALLUXIO_BLOCK: return new BlockWriteHandler(mWorkerProcess.getWorker(BlockWorker.class), mResponseObserver); case UFS_FILE: return new UfsFileWriteHandler(mWorkerProcess.getUfsManager(), mResponseObserver); case UFS_FALLBACK_BLOCK: return new UfsFallbackBlockWriteHandler( mWorkerProcess.getWorker(BlockWorker.class), mWorkerProcess.getUfsManager(), mResponseObserver); default: throw new IllegalArgumentException(String.format("Invalid request type %s", request.getCommand().getType().name())); } }
/** * Validates the read request sent. * * @param request the request * @param offset the offset */ private void validateWriteRequest(WriteRequest request, long offset) { if (request.hasCommand()) { assertEquals(RequestType.UFS_FALLBACK_BLOCK, request.getCommand().getType()); assertEquals(BLOCK_ID, request.getCommand().getId()); assertEquals(offset, request.getCommand().getOffset()); assertTrue(request.getCommand().hasCreateUfsBlockOptions()); assertEquals(MOUNT_ID, request.getCommand().getCreateUfsBlockOptions().getMountId()); } else { assertTrue(request.hasChunk()); } } }
/** * Validates the read request sent. * * @param request the request * @param offset the offset */ private void validateWriteRequest(WriteRequest request, long offset) { if (request.hasCommand()) { Assert.assertEquals(BLOCK_ID, request.getCommand().getId()); Assert.assertEquals(offset, request.getCommand().getOffset()); } else { Assert.assertTrue(request.hasChunk()); } } }
public Builder mergeFrom(alluxio.grpc.WriteRequest other) { if (other == alluxio.grpc.WriteRequest.getDefaultInstance()) return this; switch (other.getValueCase()) { case COMMAND: { mergeCommand(other.getCommand()); break; } case CHUNK: { mergeChunk(other.getChunk()); break; } case VALUE_NOT_SET: { break; } } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
validateWriteRequest(writeRequest, pos); if (writeRequest.hasCommand() && writeRequest.getCommand().getCreateUfsBlockOptions().hasBytesInBlockStore()) { pos += writeRequest.getCommand().getCreateUfsBlockOptions().getBytesInBlockStore(); continue;
WriteRequestCommand command = writeRequest.getCommand(); if (command.getFlush()) { flush();