Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ALLUXIO-2977] Implement BlockReadRequestContext and other required c…
…lasses
- Loading branch information
Showing
6 changed files
with
177 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
core/server/worker/src/main/java/alluxio/worker/netty/BlockReadRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,54 @@ | |||
package alluxio.worker.netty; | |||
|
|||
import alluxio.proto.dataserver.Protocol; | |||
|
|||
import javax.annotation.concurrent.NotThreadSafe; | |||
|
|||
/** | |||
* The internal representation of a block read request. | |||
*/ | |||
@NotThreadSafe | |||
public final class BlockReadRequest extends ReadRequest { | |||
private final Protocol.OpenUfsBlockOptions mOpenUfsBlockOptions; | |||
private final boolean mPromote; | |||
|
|||
/** | |||
* Creates an instance of {@link BlockReadRequest}. | |||
* | |||
* @param request the block read request | |||
*/ | |||
BlockReadRequest(Protocol.ReadRequest request) { | |||
super(request.getBlockId(), request.getOffset(), request.getOffset() + request.getLength(), | |||
request.getPacketSize()); | |||
|
|||
if (request.hasOpenUfsBlockOptions()) { | |||
mOpenUfsBlockOptions = request.getOpenUfsBlockOptions(); | |||
} else { | |||
mOpenUfsBlockOptions = null; | |||
} | |||
mPromote = request.getPromote(); | |||
// Note that we do not need to seek to offset since the block worker is created at the offset. | |||
} | |||
|
|||
/** | |||
* @return if the block read type indicate promote in tier storage | |||
*/ | |||
public boolean isPromote() { | |||
return mPromote; | |||
} | |||
|
|||
/** | |||
* @return the option to open UFS block | |||
*/ | |||
public Protocol.OpenUfsBlockOptions getOpenUfsBlockOptions() { | |||
return mOpenUfsBlockOptions; | |||
} | |||
|
|||
/** | |||
* @return true if the block is persisted in UFS | |||
*/ | |||
public boolean isPersisted() { | |||
return mOpenUfsBlockOptions != null && mOpenUfsBlockOptions.hasUfsPath(); | |||
} | |||
|
|||
} |
34 changes: 34 additions & 0 deletions
34
core/server/worker/src/main/java/alluxio/worker/netty/BlockReadRequestContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,34 @@ | |||
package alluxio.worker.netty; | |||
|
|||
import alluxio.proto.dataserver.Protocol; | |||
import alluxio.worker.block.io.BlockReader; | |||
|
|||
import javax.annotation.Nullable; | |||
import javax.annotation.concurrent.NotThreadSafe; | |||
|
|||
/** | |||
* Context of {@link BlockReadRequest}. | |||
*/ | |||
@NotThreadSafe | |||
public final class BlockReadRequestContext extends ReadRequestContext<BlockReadRequest> { | |||
private BlockReader mBlockReader; | |||
|
|||
public BlockReadRequestContext(Protocol.ReadRequest request) { | |||
super(new BlockReadRequest(request)); | |||
} | |||
|
|||
/** | |||
* @return block reader | |||
*/ | |||
@Nullable | |||
public BlockReader getBlockReader() { | |||
return mBlockReader; | |||
} | |||
|
|||
/** | |||
* @param blockReader block reader to set | |||
*/ | |||
public void setBlockReader(BlockReader blockReader) { | |||
mBlockReader = blockReader; | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.