|
@@ -40,7 +40,7 @@ public class RMAuditLogger {
|
|
|
static enum Keys {USER, OPERATION, TARGET, RESULT, IP, PERMISSIONS,
|
|
|
DESCRIPTION, APPID, APPATTEMPTID, CONTAINERID,
|
|
|
CALLERCONTEXT, CALLERSIGNATURE, RESOURCE, QUEUENAME,
|
|
|
- INCLUDEAPPS, INCLUDECHILDQUEUES, RECURSIVE}
|
|
|
+ INCLUDEAPPS, INCLUDECHILDQUEUES, RECURSIVE, NODELABEL}
|
|
|
|
|
|
public static class AuditConstants {
|
|
|
static final String SUCCESS = "SUCCESS";
|
|
@@ -98,7 +98,7 @@ public class RMAuditLogger {
|
|
|
ApplicationId appId, ApplicationAttemptId attemptId,
|
|
|
ContainerId containerId, Resource resource) {
|
|
|
return createSuccessLog(user, operation, target, appId, attemptId,
|
|
|
- containerId, resource, null, Server.getRemoteIp());
|
|
|
+ containerId, resource, null, Server.getRemoteIp(), null, null);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -124,7 +124,7 @@ public class RMAuditLogger {
|
|
|
static String createSuccessLog(String user, String operation, String target,
|
|
|
ApplicationId appId, ApplicationAttemptId attemptId,
|
|
|
ContainerId containerId, Resource resource, CallerContext callerContext,
|
|
|
- InetAddress ip) {
|
|
|
+ InetAddress ip, String queueName, String partition) {
|
|
|
StringBuilder b =
|
|
|
createStringBuilderForSuccessEvent(user, operation, target, ip);
|
|
|
if (appId != null) {
|
|
@@ -140,6 +140,12 @@ public class RMAuditLogger {
|
|
|
add(Keys.RESOURCE, resource.toString(), b);
|
|
|
}
|
|
|
appendCallerContext(b, callerContext);
|
|
|
+ if (queueName != null) {
|
|
|
+ add(Keys.QUEUENAME, queueName, b);
|
|
|
+ }
|
|
|
+ if (partition != null) {
|
|
|
+ add(Keys.NODELABEL, partition, b);
|
|
|
+ }
|
|
|
return b.toString();
|
|
|
}
|
|
|
|
|
@@ -202,6 +208,32 @@ public class RMAuditLogger {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Create a readable and parseable audit log string for a successful event.
|
|
|
+ *
|
|
|
+ * @param user User who made the service request to the ResourceManager
|
|
|
+ * @param operation Operation requested by the user.
|
|
|
+ * @param target The target on which the operation is being performed.
|
|
|
+ * @param appId Application Id in which operation was performed.
|
|
|
+ * @param containerId Container Id in which operation was performed.
|
|
|
+ * @param resource Resource associated with container.
|
|
|
+ * @param queueName Name of queue.
|
|
|
+ * @param partition Name of labeled partition.
|
|
|
+ *
|
|
|
+ * <br><br>
|
|
|
+ * Note that the {@link RMAuditLogger} uses tabs ('\t') as a key-val delimiter
|
|
|
+ * and hence the value fields should not contains tabs ('\t').
|
|
|
+ */
|
|
|
+ public static void logSuccess(String user, String operation, String target,
|
|
|
+ ApplicationId appId, ContainerId containerId, Resource resource,
|
|
|
+ String queueName, String partition) {
|
|
|
+ if (LOG.isInfoEnabled()) {
|
|
|
+ LOG.info(createSuccessLog(user, operation, target, appId, null,
|
|
|
+ containerId, resource, null, Server.getRemoteIp(), queueName,
|
|
|
+ partition));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Create a general readable and parseable audit log string for a successful
|
|
|
* event.
|
|
@@ -263,12 +295,20 @@ public class RMAuditLogger {
|
|
|
null, null));
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static void logSuccess(String user, String operation, String target,
|
|
|
ApplicationId appId, CallerContext callerContext) {
|
|
|
if (LOG.isInfoEnabled()) {
|
|
|
LOG.info(createSuccessLog(user, operation, target, appId, null, null,
|
|
|
- null, callerContext, Server.getRemoteIp()));
|
|
|
+ null, callerContext, Server.getRemoteIp(), null, null));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void logSuccess(String user, String operation, String target,
|
|
|
+ ApplicationId appId, CallerContext callerContext, String queueName) {
|
|
|
+ if (LOG.isInfoEnabled()) {
|
|
|
+ LOG.info(createSuccessLog(user, operation, target, appId, null, null,
|
|
|
+ null, callerContext, Server.getRemoteIp(), queueName, null));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -296,7 +336,7 @@ public class RMAuditLogger {
|
|
|
ApplicationId appId, InetAddress ip) {
|
|
|
if (LOG.isInfoEnabled()) {
|
|
|
LOG.info(createSuccessLog(user, operation, target, appId, null, null,
|
|
|
- null, null, ip));
|
|
|
+ null, null, ip, null, null));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -355,7 +395,7 @@ public class RMAuditLogger {
|
|
|
static String createFailureLog(String user, String operation, String perm,
|
|
|
String target, String description, ApplicationId appId,
|
|
|
ApplicationAttemptId attemptId, ContainerId containerId,
|
|
|
- Resource resource, CallerContext callerContext) {
|
|
|
+ Resource resource, CallerContext callerContext, String queueName) {
|
|
|
StringBuilder b = createStringBuilderForFailureLog(user,
|
|
|
operation, target, description, perm);
|
|
|
if (appId != null) {
|
|
@@ -371,6 +411,9 @@ public class RMAuditLogger {
|
|
|
add(Keys.RESOURCE, resource.toString(), b);
|
|
|
}
|
|
|
appendCallerContext(b, callerContext);
|
|
|
+ if (queueName != null) {
|
|
|
+ add(Keys.QUEUENAME, queueName, b);
|
|
|
+ }
|
|
|
return b.toString();
|
|
|
}
|
|
|
|
|
@@ -381,7 +424,7 @@ public class RMAuditLogger {
|
|
|
String target, String description, ApplicationId appId,
|
|
|
ApplicationAttemptId attemptId, ContainerId containerId, Resource resource) {
|
|
|
return createFailureLog(user, operation, perm, target, description, appId,
|
|
|
- attemptId, containerId, resource, null);
|
|
|
+ attemptId, containerId, resource, null, null);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -447,13 +490,22 @@ public class RMAuditLogger {
|
|
|
appId, attemptId, null, null));
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static void logFailure(String user, String operation, String perm,
|
|
|
String target, String description, ApplicationId appId,
|
|
|
CallerContext callerContext) {
|
|
|
if (LOG.isWarnEnabled()) {
|
|
|
LOG.warn(createFailureLog(user, operation, perm, target, description,
|
|
|
- appId, null, null, null, callerContext));
|
|
|
+ appId, null, null, null, callerContext, null));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void logFailure(String user, String operation, String perm,
|
|
|
+ String target, String description, ApplicationId appId,
|
|
|
+ CallerContext callerContext, String queueName) {
|
|
|
+ if (LOG.isWarnEnabled()) {
|
|
|
+ LOG.warn(createFailureLog(user, operation, perm, target, description,
|
|
|
+ appId, null, null, null, callerContext, queueName));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -480,6 +532,15 @@ public class RMAuditLogger {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static void logFailure(String user, String operation, String perm,
|
|
|
+ String target, String description, ApplicationId appId,
|
|
|
+ String queueName) {
|
|
|
+ if (LOG.isWarnEnabled()) {
|
|
|
+ LOG.warn(createFailureLog(user, operation, perm, target, description,
|
|
|
+ appId, null, null, null, null, queueName));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Create a readable and parseable audit log string for a failed event.
|
|
|
*
|