if (!(lm instanceof DbLockManager)) {
throw new RuntimeException("New lock format only supported with db lock manager.");
}
lockMgr = (DbLockManager)lm;
ShowLocksResponse rsp = lockMgr.getLocks();
// write the results in the file
DataOutputStream os = null;
try {
Path resFile = new Path(showLocks.getResFile());
FileSystem fs = resFile.getFileSystem(conf);
os = fs.create(resFile);
// Write a header
os.writeBytes("Lock ID");
os.write(separator);
os.writeBytes("Database");
os.write(separator);
os.writeBytes("Table");
os.write(separator);
os.writeBytes("Partition");
os.write(separator);
os.writeBytes("State");
os.write(separator);
os.writeBytes("Type");
os.write(separator);
os.writeBytes("Transaction ID");
os.write(separator);
os.writeBytes("Last Hearbeat");
os.write(separator);
os.writeBytes("Acquired At");
os.write(separator);
os.writeBytes("User");
os.write(separator);
os.writeBytes("Hostname");
os.write(terminator);
List<ShowLocksResponseElement> locks = rsp.getLocks();
if (locks != null) {
for (ShowLocksResponseElement lock : locks) {
os.writeBytes(Long.toString(lock.getLockid()));
os.write(separator);
os.writeBytes(lock.getDbname());