Skip to content
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

fix: change txnId to uniqueId (Ruth's suggestion) #323

Merged
merged 1 commit into from
May 6, 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 @@ -902,7 +902,7 @@ void update_subtree(Set<INode> renameSet) {
}
try {
if (strAttr.size() > 0) {
INodeKeyedObjects.setTxnId(DatabaseINode.batchUpdateINodes(longAttr, strAttr, fileIds, fileAttr));
INodeKeyedObjects.setUniqueId(DatabaseINode.batchUpdateINodes(longAttr, strAttr, fileIds, fileAttr));
}
} catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -981,16 +981,16 @@ public void remoteRename(INode node, String oldName, String oldParent, String ne
// update_subtree_v2(renameSet, address);
}

long start = INodeKeyedObjects.getTxnId();
INodeKeyedObjects.setTxnId(DatabaseINode.updateSubtree(old_id, 40000000,
long start = INodeKeyedObjects.getUniqueId();
INodeKeyedObjects.setUniqueId(DatabaseINode.updateSubtree(old_id, 40000000,
oldParent, "/nnThroughputBenchmark/rename", node.getParentId())
);
try{
Thread.sleep(2); // 2 ms
} catch (Exception e) {
e.printStackTrace();
}
long end = INodeKeyedObjects.getTxnId();
long end = INodeKeyedObjects.getUniqueId();
FSDirectory.getInstance()
.getEditLog()
.logRenameMP("/nnThroughputBenchmark/create", "/nnThroughputBenchmark/rename",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ public class INodeKeyedObjects {
private static long preRenameSize = 0;
private static long preUpdateSize = 0;

// gloabal transaction ID (VoltDB)
private static AtomicLong txnId = new AtomicLong();;
// gloabal unique ID (VoltDB)
private static AtomicLong uniqueId = new AtomicLong();

private static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);

static final Logger LOG = LoggerFactory.getLogger(INodeKeyedObjects.class);

INodeKeyedObjects() {}

public static long getTxnId() {
return txnId.longValue();
public static long getUniqueId() {
return uniqueId.longValue();
}

public static void setTxnId(long id) {
txnId.set(id);
public static void setUniqueId(long id) {
uniqueId.set(id);
}

public static Set<String> getUpdateSet() {
Expand Down Expand Up @@ -117,7 +117,7 @@ private static void insertToDB() {
}
try {
if (strAttr.size() > 0) {
INodeKeyedObjects.setTxnId(DatabaseINode.batchUpdateINodes(longAttr, strAttr, fileIds, fileAttr));
INodeKeyedObjects.setUniqueId(DatabaseINode.batchUpdateINodes(longAttr, strAttr, fileIds, fileAttr));
}
} catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -161,7 +161,7 @@ private static void insertToDB() {
iterator.remove();
}
if (strAttr.size() > 0) {
INodeKeyedObjects.setTxnId(DatabaseINode.batchUpdateINodes(longAttr, strAttr, fileIds, fileAttr));
INodeKeyedObjects.setUniqueId(DatabaseINode.batchUpdateINodes(longAttr, strAttr, fileIds, fileAttr));
}
} catch (Exception e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ private static void update_subtree(Set<INode> inodes) {
}
try {
if (strAttr.size() > 0) {
INodeKeyedObjects.setTxnId(DatabaseINode.batchUpdateINodes(longAttr, strAttr, fileIds, fileAttr));
INodeKeyedObjects.setUniqueId(DatabaseINode.batchUpdateINodes(longAttr, strAttr, fileIds, fileAttr));
}
} catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -504,14 +504,14 @@ private final void remoteChmod(Set<Pair<String, String>> mpoints) {
// 2. execute distributed txn
LOG.info("Execute dist txn for chmod");

long start = INodeKeyedObjects.getTxnId();
INodeKeyedObjects.setTxnId(DatabaseINode.setPermissions(parents, names, this.permission));
long start = INodeKeyedObjects.getUniqueId();
INodeKeyedObjects.setUniqueId(DatabaseINode.setPermissions(parents, names, this.permission));
try{
Thread.sleep(2); // 2 ms
} catch (Exception e) {
e.printStackTrace();
}
long end = INodeKeyedObjects.getTxnId();
long end = INodeKeyedObjects.getUniqueId();
FSDirectory.getInstance()
.getEditLog()
.logSetPermissionsMP(getPath(), new FsPermission(getFsPermissionShort()), start, end);
Expand All @@ -530,7 +530,7 @@ private final void updatePermissionStatus(PermissionStatusFormat f, long n) {
e.printStackTrace();
}
} else {
INodeKeyedObjects.setTxnId(DatabaseINode.setPermission(getId(), this.permission));
INodeKeyedObjects.setUniqueId(DatabaseINode.setPermission(getId(), this.permission));
}
}

Expand Down
2 changes: 1 addition & 1 deletion voltdb/BatchUpdateINodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ public long run(
}

voltExecuteSQL();
return getTxnId();
return getUniqueId();
}
}
2 changes: 1 addition & 1 deletion voltdb/SetPermission.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public class SetPermissions extends VoltProcedure {
public long run(final long id, final long permission) throws VoltAbortException {
voltQueueSQL(sql, permission, id);
voltExecuteSQL();
return getTxnId();
return getUniqueId();
}
}
2 changes: 1 addition & 1 deletion voltdb/SetPermissions.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public long run(final String[] parents, final String[] names, final long permiss
voltQueueSQL(sql, permission, parents[i], names[i]);
}
voltExecuteSQL();
return getTxnId();
return getUniqueId();
}
}
2 changes: 1 addition & 1 deletion voltdb/UpdateSubtree.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ public long run(final long dir_id, final long dest_id, final String old_parent_n
}
voltExecuteSQL();

return getTxnId();
return getUniqueId();
}
}