Skip to content

parameterised log message, final variable migration, removing unused methods #60

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

Merged
merged 1 commit into from
Jun 29, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

import com.apple.foundationdb.KeyValue;
import com.apple.foundationdb.LocalityUtil;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing ununsed imports

import com.apple.foundationdb.async.CloseableAsyncIterator;
import com.apple.foundationdb.async.AsyncIterator;
import com.apple.foundationdb.async.CloseableAsyncIterator;
import com.apple.foundationdb.directory.DirectorySubspace;
import com.google.common.base.Preconditions;
import org.janusgraph.diskstorage.BackendException;
Expand Down Expand Up @@ -75,11 +75,6 @@ private static FoundationDBTx getTransaction(StoreTransaction txh) {

@Override
public synchronized void close() throws BackendException {
try {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant code as nothing was inside try catch. also no 82-83 do not call foundation db.

//if(isOpen) db.close();
} catch (Exception e) {
throw new PermanentBackendException(e);
}
if (isOpen) manager.removeDatabase(this);
isOpen = false;
}
Expand Down Expand Up @@ -168,7 +163,7 @@ public RecordIterator<KeyValueEntry> getSliceAsync(KVQuery query, StoreTransacti

return new FoundationDBRecordAsyncIterator(db, tx, rangeQuery, result, query.getKeySelector());
} catch (Exception e) {
log.error("getSliceAsync db=%s, tx=%s with exception", name, txh, e);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

migrating to slf4j parameterized logging

log.error("getSliceAsync db={}, tx={} with exception", name, txh, e);
throw new PermanentBackendException(e);
}
}
Expand Down Expand Up @@ -259,6 +254,9 @@ public void delete(StaticBuffer key, StoreTransaction txh) throws BackendExcepti
}
}

/* this method is not called within JanusGraph, it's used for bulk access in Spark jobs.
For more: Please check: {@link https://github.com/JanusGraph/janusgraph-foundationdb/pull/48#discussion_r498917927}
*/
public List<StaticBuffer> getBoundaryKeys() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused method

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method was introduced by @ruweih and they stated the reason for its existence here. Instead of removing it, you could add a comment that says why it's there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved. Please let me know if i need to. update the comment.

List<StaticBuffer> keys = new ArrayList<>();
try (CloseableAsyncIterator<byte[]> it = LocalityUtil.getBoundaryKeys(manager.db, db.range().begin, db.range().end)) {
Expand All @@ -275,4 +273,6 @@ public List<StaticBuffer> getBoundaryKeys() {
static StaticBuffer getBuffer(byte[] entry) {
return new StaticArrayBuffer(entry);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
*/
public class FoundationDBRangeQuery {

private KVQuery originalQuery;
private final KVQuery originalQuery;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both these attributes could be final

private KeySelector startKeySelector;
private KeySelector endKeySelector;
private int limit;
private final int limit;

public FoundationDBRangeQuery(Subspace db, KVQuery kvQuery) {
originalQuery = kvQuery;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ public class FoundationDBTx extends AbstractStoreTransaction {

private final Database db;

private List<Insert> inserts = Collections.synchronizedList(new ArrayList<>());
private List<byte[]> deletions = Collections.synchronizedList(new ArrayList<>());
private final List<Insert> inserts = Collections.synchronizedList(new ArrayList<>());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all these attributes can be final

private final List<byte[]> deletions = Collections.synchronizedList(new ArrayList<>());

private int maxRuns = 1;

public enum IsolationLevel {SERIALIZABLE, READ_COMMITTED_NO_WRITE, READ_COMMITTED_WITH_WRITE}

private final IsolationLevel isolationLevel;

private AtomicInteger txCtr = new AtomicInteger(0);
private final AtomicInteger txCtr = new AtomicInteger(0);

private static AtomicInteger transLocalIdCounter = new AtomicInteger(0);
private int transactionId = 0;
private static final AtomicInteger transLocalIdCounter = new AtomicInteger(0);
private final int transactionId;

public FoundationDBTx(Database db, Transaction t, BaseTransactionConfig config, IsolationLevel isolationLevel) {
super(config);
Expand Down Expand Up @@ -149,7 +149,7 @@ public synchronized void rollback() throws BackendException {


private void logFDBException(Throwable t) {
if (t != null && t instanceof FDBException) {
if (t instanceof FDBException) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t!=null was redundant as t instanceof FDBException checks for null case as well

FDBException fe = (FDBException) t;
if (log.isDebugEnabled()) {
log.debug("Catch FDBException code= {}, isRetryable={}, isMaybeCommitted={}, "
Expand Down Expand Up @@ -449,8 +449,8 @@ public void clear(final byte[] key) {


private class Insert {
private byte[] key;
private byte[] value;
private final byte[] key;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both the attributes could be final

private final byte[] value;

public Insert(final byte[] key, final byte[] value) {
this.key = key;
Expand Down