Skip to content

Synchronize some improvements: #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 40 additions & 41 deletions src/main/java/cn/hashdata/bireme/AbstractCommitCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,51 +12,50 @@
* after all corresponding {@link ChangeLoader} finish their task.
*
* @author yuze
*
*/
public abstract class AbstractCommitCallback implements CommitCallback {
protected int numOfTables;
protected AtomicInteger numOfCommitedTables;
protected AtomicBoolean committed;
protected AtomicBoolean ready;
protected long newestRecord; // the produce time of newest record

public AbstractCommitCallback() {
this.numOfCommitedTables = new AtomicInteger();
this.committed = new AtomicBoolean();
this.committed.set(false);
this.ready = new AtomicBoolean();
this.ready.set(false);
}

@Override
public void setNumOfTables(int tables) {
this.numOfTables = tables;
}

@Override
public void done() {
if (numOfCommitedTables.incrementAndGet() == numOfTables) {
ready.set(true);
protected int numOfTables;
protected AtomicInteger numOfCommitedTables;
protected AtomicBoolean committed;
protected AtomicBoolean ready;
protected long newestRecord; // the produce time of newest record

public AbstractCommitCallback() {
this.numOfCommitedTables = new AtomicInteger();
this.committed = new AtomicBoolean();
this.committed.set(false);
this.ready = new AtomicBoolean();
this.ready.set(false);
}

@Override
public void setNumOfTables(int tables) {
this.numOfTables = tables;
}

@Override
public void done() {
if (numOfCommitedTables.incrementAndGet() == numOfTables) {
ready.set(true);
}
}

@Override
public boolean ready() {
return ready.get();
}
}

@Override
public boolean ready() {
return ready.get();
}
@Override
public synchronized void setNewestRecord(Long time) {
if (time > newestRecord) {
newestRecord = time;
}
}

@Override
public synchronized void setNewestRecord(Long time) {
if (time > newestRecord) {
newestRecord = time;
@Override
public void destory() {
numOfCommitedTables = null;
committed = null;
ready = null;
}
}

@Override
public void destory() {
numOfCommitedTables = null;
committed = null;
ready = null;
}
}
Loading