Skip to content

Commit

Permalink
Fix #858, File Access Event should set user info
Browse files Browse the repository at this point in the history
  • Loading branch information
littlezhou committed Nov 21, 2017
1 parent 227cb59 commit ba34d19
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.hadoop.fs.UnresolvedLinkException;
import org.apache.hadoop.hdfs.DFSClient;
import org.apache.hadoop.hdfs.DFSInputStream;
import org.apache.hadoop.security.UserGroupInformation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.smartdata.SmartConstants;
Expand Down Expand Up @@ -141,7 +142,13 @@ private void reportFileAccessEvent(String src) {
if (!healthy) {
return;
}
smartClient.reportFileAccessEvent(new FileAccessEvent(src));
String userName;
try {
userName = UserGroupInformation.getCurrentUser().getUserName();
} catch (IOException e) {
userName = "Unknown";
}
smartClient.reportFileAccessEvent(new FileAccessEvent(src, userName));
} catch (IOException e) {
// Here just ignores that failed to report
LOG.error("Cannot report file access event to SmartServer: " + src
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public FileAccessEvent(String path, long timeStamp, String user) {
this.user = user;
}

public FileAccessEvent(String path, String user) {
this(path, -1, user);
}

/**
* Get the accessed file path.
* @return file path
Expand Down

0 comments on commit ba34d19

Please sign in to comment.