@Test public void writeInvalidOffsetLaterRequest() throws Exception { mWriteHandler.write(newWriteRequestCommand(0)); mWriteHandler.write(newWriteRequestCommand(1)); waitForResponses(); checkErrorCode(mResponseObserver, Status.Code.INVALID_ARGUMENT); }
public void write(WriteRequest writeRequest) { if (!tryAcquireSemaphore()) { return; } mSerializingExecutor.execute(() -> { try { if (mContext == null) { LOG.debug("Received write request {}.", writeRequest); try { mContext = createRequestContext(writeRequest); } catch (Exception e) { replyError(new Error(AlluxioStatusException.fromThrowable(e), true)); throw e; } } else { Preconditions.checkState(!mContext.isDoneUnsafe(), "invalid request after write request is completed."); } if (mContext.isDoneUnsafe() || mContext.getError() != null) { return; } validateWriteRequest(writeRequest); if (writeRequest.hasCommand()) { WriteRequestCommand command = writeRequest.getCommand(); if (command.getFlush()) { flush(); } else { handleCommand(command, mContext); } } else { Preconditions.checkState(writeRequest.hasChunk(), "write request is missing data chunk in non-command message"); ByteString data = writeRequest.getChunk().getData(); Preconditions.checkState(data != null && data.size() > 0, "invalid data size from write request message"); writeData(new NioDataBuffer(data.asReadOnlyByteBuffer(), data.size())); } } catch (Exception e) { LogUtils.warnWithException(LOG, "Exception occurred while processing write request {}.", writeRequest, e); abort(new Error(AlluxioStatusException.fromThrowable(e), true)); } finally { mSemaphore.release(); } }); }
AbstractWriteHandler { public void write(WriteRequest writeRequest) { if (!tryAcquireSemaphore()) { return; } mSerializingExecutor.execute(() -> { try { if (mContext == null) { LOG.debug("Received write request {}.", writeRequest); try { mContext = createRequestContext(writeRequest); } catch (Exception e) { replyError(new Error(AlluxioStatusException.fromThrowable(e), true)); throw e; } } else { Preconditions.checkState(!mContext.isDoneUnsafe(), "invalid request after write request is completed."); } if (mContext.isDoneUnsafe() || mContext.getError() != null) { return; } validateWriteRequest(writeRequest); if (writeRequest.hasCommand()) { WriteRequestCommand command = writeRequest.getCommand(); if (command.getFlush()) { flush(); } else { handleCommand(command, mContext); } } else { Preconditions.checkState(writeRequest.hasChunk(), "write request is missing data chunk in non-command message"); ByteString data = writeRequest.getChunk().getData(); Preconditions.checkState(data != null && data.size() > 0, "invalid data size from write request message"); writeData(new NioDataBuffer(data.asReadOnlyByteBuffer(), data.size())); } } catch (Exception e) { LogUtils.warnWithException(LOG, "Exception occurred while processing write request {}.", writeRequest, e); abort(new Error(AlluxioStatusException.fromThrowable(e), true)); } finally { mSemaphore.release(); } }); } }
AbstractWriteHandler { public void write(WriteRequest writeRequest) { if (!tryAcquireSemaphore()) { return; } mSerializingExecutor.execute(() -> { try { if (mContext == null) { LOG.debug("Received write request {}.", writeRequest); try { mContext = createRequestContext(writeRequest); } catch (Exception e) { replyError(new Error(AlluxioStatusException.fromThrowable(e), true)); throw e; } } else { Preconditions.checkState(!mContext.isDoneUnsafe(), "invalid request after write request is completed."); } if (mContext.isDoneUnsafe() || mContext.getError() != null) { return; } validateWriteRequest(writeRequest); if (writeRequest.hasCommand()) { WriteRequestCommand command = writeRequest.getCommand(); if (command.getFlush()) { flush(); } else { handleCommand(command, mContext); } } else { Preconditions.checkState(writeRequest.hasChunk(), "write request is missing data chunk in non-command message"); ByteString data = writeRequest.getChunk().getData(); Preconditions.checkState(data != null && data.size() > 0, "invalid data size from write request message"); writeData(new NioDataBuffer(data.asReadOnlyByteBuffer(), data.size())); } } catch (Exception e) { LogUtils.warnWithException(LOG, "Exception occurred while processing write request {}.", writeRequest, e); abort(new Error(AlluxioStatusException.fromThrowable(e), true)); } finally { mSemaphore.release(); } }); } AbstractWriteHandler(StreamObserver<WriteResponse> responseObserver,
      AuthenticatedUserInfo userInfo); }
AbstractWriteHandler { public void write(WriteRequest writeRequest) { if (!tryAcquireSemaphore()) { return; } mSerializingExecutor.execute(() -> { try { if (mContext == null) { LOG.debug("Received write request {}.", writeRequest); try { mContext = createRequestContext(writeRequest); } catch (Exception e) { replyError(new Error(AlluxioStatusException.fromThrowable(e), true)); throw e; } } else { Preconditions.checkState(!mContext.isDoneUnsafe(), "invalid request after write request is completed."); } if (mContext.isDoneUnsafe() || mContext.getError() != null) { return; } validateWriteRequest(writeRequest); if (writeRequest.hasCommand()) { WriteRequestCommand command = writeRequest.getCommand(); if (command.getFlush()) { flush(); } else { handleCommand(command, mContext); } } else { Preconditions.checkState(writeRequest.hasChunk(), "write request is missing data chunk in non-command message"); ByteString data = writeRequest.getChunk().getData(); Preconditions.checkState(data != null && data.size() > 0, "invalid data size from write request message"); writeData(new NioDataBuffer(data.asReadOnlyByteBuffer(), data.size())); } } catch (Exception e) { LogUtils.warnWithException(LOG, "Exception occurred while processing write request {}.", writeRequest, e); abort(new Error(AlluxioStatusException.fromThrowable(e), true)); } finally { mSemaphore.release(); } }); } AbstractWriteHandler(StreamObserver<WriteResponse> responseObserver,
      AuthenticatedUserInfo userInfo); void write(WriteRequest writeRequest); void writeDataMessage(WriteRequest request, DataBuffer buffer); void onCompleted(); void onCancel(); void onError(Throwable cause); }
AbstractWriteHandler { public void write(WriteRequest writeRequest) { if (!tryAcquireSemaphore()) { return; } mSerializingExecutor.execute(() -> { try { if (mContext == null) { LOG.debug("Received write request {}.", writeRequest); try { mContext = createRequestContext(writeRequest); } catch (Exception e) { replyError(new Error(AlluxioStatusException.fromThrowable(e), true)); throw e; } } else { Preconditions.checkState(!mContext.isDoneUnsafe(), "invalid request after write request is completed."); } if (mContext.isDoneUnsafe() || mContext.getError() != null) { return; } validateWriteRequest(writeRequest); if (writeRequest.hasCommand()) { WriteRequestCommand command = writeRequest.getCommand(); if (command.getFlush()) { flush(); } else { handleCommand(command, mContext); } } else { Preconditions.checkState(writeRequest.hasChunk(), "write request is missing data chunk in non-command message"); ByteString data = writeRequest.getChunk().getData(); Preconditions.checkState(data != null && data.size() > 0, "invalid data size from write request message"); writeData(new NioDataBuffer(data.asReadOnlyByteBuffer(), data.size())); } } catch (Exception e) { LogUtils.warnWithException(LOG, "Exception occurred while processing write request {}.", writeRequest, e); abort(new Error(AlluxioStatusException.fromThrowable(e), true)); } finally { mSemaphore.release(); } }); } AbstractWriteHandler(StreamObserver<WriteResponse> responseObserver,
      AuthenticatedUserInfo userInfo); void write(WriteRequest writeRequest); void writeDataMessage(WriteRequest request, DataBuffer buffer); void onCompleted(); void onCancel(); void onError(Throwable cause);  }