The following filesystem APIs are available in
com.mapr.fs.MapRFileSystem for converting fid to file path
and volid to volume name:
public String getMountPathFidCached(String fidStr) throws IOExceptionpublic String getVolumeNameCached(int volId) throws IOExceptionpublic String getVolumeName(int volId) throws IOExceptionpublic String getMountPathFid(String fidStr) throws IOExceptionThe getMountPathFid(string) and
getMountPathFidCached(string) APIs can be used for converting file ID to
the full path to the file. The getMountPathFid() API makes a call to CLDB
and filesystem to get the file path from the fid. Because this API does not cache or store this
information locally, it might make repeated requests to CLDB and filesystem for the same fid and
this might result in many RPCs to both CLDB and filesystem. The
getMountPathFidCached() API makes a call the CLDB and filesystem one time and
stores the information locally in the shared library of the client. For subsequent calls, it
uses the locally stored information to retrieve the file path from the fid. However, if
there are many files in the volume, there might still be a large number of calls to CLDB and
filesystem to determine the file path for each fid in the volume. The caching is useful if the API
attempts to determine the file path for the same fid repeatedly. The cache is purged after
15 seconds. If the file name changes before the cache is purged, you will see the old name
for the file until the cache expires. You can use these APIs to convert the fid to the file
path.
For example, the sample consumer application and the sample uncached consumer application for consuming audit logs as stream messages use these methods as shown below.
{
String token = st1.nextToken();
/* If the field has fid, expand it using Cached API */
if (token.endsWith("Fid")) {
String lfidStr = st1.nextToken();
String path= null;
try {
path = fs.getMountPathFidCached(lfidStr); // Expand FID to path
} catch (IOException e){
}
lfidPath = "\"FidPath\":\""+path+"\",";
// System.out.println("\nPAth for fid " + lfidStr + "is " + path);
}{
String token = st1.nextToken();
if (token.endsWith("Fid")) {
String lfidStr = st1.nextToken();
String path= null;
try {
path = fs.getMountPathFid(lfidStr);// Expand FID to path
} catch (IOException e){
}
lfidPath = "\"FidPath\":\""+path+"\",";
// System.out.println("\nPAth for fid " + lfidStr + "is " + path);
}The getVolumeName() and getVolumeNameCached() APIs can be
used for converting volume IDs to volume name. The getVolumeName() API
makes a call to the CLDB every time to get the volume name from the volid and this may
result in too many RPCs to CLDB. The getVolumeNameCached() API makes a call
the CLDB one time and stores the information locally in the shared library of the client.
For subsequent calls, it uses the locally stored information to retrieve the volume name
from the volid. The cache is purged after 15 seconds. You can use these APIs to
convert the volid to volume name.
For example, the sample consumer application and the sample uncached consumer application for consuming audit logs as stream messages uses these methods as shown below.
if (token.endsWith("volumeId")) {
String volid = st1.nextToken();
String name= null;
try {
int volumeId = Integer.parseInt(volid);
// Cached API to convert volume Id to volume Name
name = fs.getVolumeNameCached(volumeId);
}
catch (IOException e){
}
lvolName = "\"VolumeName\":\""+name+"\",";
// System.out.println("\nVolume Name for volid " + volid + "is " + name);
}if (token.endsWith("volumeId")) {
String volid = st1.nextToken();
String name= null;
try {
int volumeId = Integer.parseInt(volid);
// API to convert volume Id to volume Name
name = fs.getVolumeName(volumeId);
}
catch (IOException e){
}
lvolName = "\"VolumeName\":\""+name+"\",";
// System.out.println("\nVolume Name for volid " + volid + "is " + name);
}