Skip to content

Commit

Permalink
fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
kexianjun committed Jun 15, 2019
1 parent a7e77d2 commit 8ec929d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Expand Up @@ -83,7 +83,7 @@ class ReadSocketService extends ServiceThread {
private final Selector selector;
private final SocketChannel socketChannel;
private final ByteBuffer byteBufferRead = ByteBuffer.allocate(READ_MAX_BUFFER_SIZE);
private int processPostion = 0;
private int processPosition = 0;
private volatile long lastReadTimestamp = System.currentTimeMillis();

public ReadSocketService(final SocketChannel socketChannel) throws IOException {
Expand Down Expand Up @@ -150,7 +150,7 @@ private boolean processReadEvent() {

if (!this.byteBufferRead.hasRemaining()) {
this.byteBufferRead.flip();
this.processPostion = 0;
this.processPosition = 0;
}

while (this.byteBufferRead.hasRemaining()) {
Expand All @@ -159,10 +159,10 @@ private boolean processReadEvent() {
if (readSize > 0) {
readSizeZeroTimes = 0;
this.lastReadTimestamp = HAConnection.this.haService.getDefaultMessageStore().getSystemClock().now();
if ((this.byteBufferRead.position() - this.processPostion) >= 8) {
if ((this.byteBufferRead.position() - this.processPosition) >= 8) {
int pos = this.byteBufferRead.position() - (this.byteBufferRead.position() % 8);
long readOffset = this.byteBufferRead.getLong(pos - 8);
this.processPostion = pos;
this.processPosition = pos;

HAConnection.this.slaveAckOffset = readOffset;
if (HAConnection.this.slaveRequestOffset < 0) {
Expand Down
20 changes: 10 additions & 10 deletions store/src/main/java/org/apache/rocketmq/store/ha/HAService.java
Expand Up @@ -332,7 +332,7 @@ class HAClient extends ServiceThread {
private long lastWriteTimestamp = System.currentTimeMillis();

private long currentReportedOffset = 0;
private int dispatchPostion = 0;
private int dispatchPosition = 0;
private ByteBuffer byteBufferRead = ByteBuffer.allocate(READ_MAX_BUFFER_SIZE);
private ByteBuffer byteBufferBackup = ByteBuffer.allocate(READ_MAX_BUFFER_SIZE);

Expand Down Expand Up @@ -378,9 +378,9 @@ private boolean reportSlaveMaxOffset(final long maxOffset) {
}

private void reallocateByteBuffer() {
int remain = READ_MAX_BUFFER_SIZE - this.dispatchPostion;
int remain = READ_MAX_BUFFER_SIZE - this.dispatchPosition;
if (remain > 0) {
this.byteBufferRead.position(this.dispatchPostion);
this.byteBufferRead.position(this.dispatchPosition);

this.byteBufferBackup.position(0);
this.byteBufferBackup.limit(READ_MAX_BUFFER_SIZE);
Expand All @@ -391,7 +391,7 @@ private void reallocateByteBuffer() {

this.byteBufferRead.position(remain);
this.byteBufferRead.limit(READ_MAX_BUFFER_SIZE);
this.dispatchPostion = 0;
this.dispatchPosition = 0;
}

private void swapByteBuffer() {
Expand Down Expand Up @@ -435,10 +435,10 @@ private boolean dispatchReadRequest() {
int readSocketPos = this.byteBufferRead.position();

while (true) {
int diff = this.byteBufferRead.position() - this.dispatchPostion;
int diff = this.byteBufferRead.position() - this.dispatchPosition;
if (diff >= msgHeaderSize) {
long masterPhyOffset = this.byteBufferRead.getLong(this.dispatchPostion);
int bodySize = this.byteBufferRead.getInt(this.dispatchPostion + 8);
long masterPhyOffset = this.byteBufferRead.getLong(this.dispatchPosition);
int bodySize = this.byteBufferRead.getInt(this.dispatchPosition + 8);

long slavePhyOffset = HAService.this.defaultMessageStore.getMaxPhyOffset();

Expand All @@ -452,13 +452,13 @@ private boolean dispatchReadRequest() {

if (diff >= (msgHeaderSize + bodySize)) {
byte[] bodyData = new byte[bodySize];
this.byteBufferRead.position(this.dispatchPostion + msgHeaderSize);
this.byteBufferRead.position(this.dispatchPosition + msgHeaderSize);
this.byteBufferRead.get(bodyData);

HAService.this.defaultMessageStore.appendToCommitLog(masterPhyOffset, bodyData);

this.byteBufferRead.position(readSocketPos);
this.dispatchPostion += msgHeaderSize + bodySize;
this.dispatchPosition += msgHeaderSize + bodySize;

if (!reportSlaveMaxOffsetPlus()) {
return false;
Expand Down Expand Up @@ -532,7 +532,7 @@ private void closeMaster() {
}

this.lastWriteTimestamp = 0;
this.dispatchPostion = 0;
this.dispatchPosition = 0;

this.byteBufferBackup.position(0);
this.byteBufferBackup.limit(READ_MAX_BUFFER_SIZE);
Expand Down

0 comments on commit 8ec929d

Please sign in to comment.