|
@@ -27,6 +27,7 @@ import org.apache.hadoop.ipc.Server;
|
|
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
|
|
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
|
|
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
|
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
|
import org.apache.hadoop.yarn.api.records.ContainerId;
|
|
import org.apache.hadoop.yarn.api.records.ContainerId;
|
|
|
|
+import org.apache.hadoop.yarn.api.records.Resource;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Manages ResourceManager audit logs.
|
|
* Manages ResourceManager audit logs.
|
|
@@ -38,7 +39,7 @@ public class RMAuditLogger {
|
|
|
|
|
|
static enum Keys {USER, OPERATION, TARGET, RESULT, IP, PERMISSIONS,
|
|
static enum Keys {USER, OPERATION, TARGET, RESULT, IP, PERMISSIONS,
|
|
DESCRIPTION, APPID, APPATTEMPTID, CONTAINERID,
|
|
DESCRIPTION, APPID, APPATTEMPTID, CONTAINERID,
|
|
- CALLERCONTEXT, CALLERSIGNATURE}
|
|
|
|
|
|
+ CALLERCONTEXT, CALLERSIGNATURE, RESOURCE}
|
|
|
|
|
|
public static class AuditConstants {
|
|
public static class AuditConstants {
|
|
static final String SUCCESS = "SUCCESS";
|
|
static final String SUCCESS = "SUCCESS";
|
|
@@ -77,9 +78,9 @@ public class RMAuditLogger {
|
|
|
|
|
|
static String createSuccessLog(String user, String operation, String target,
|
|
static String createSuccessLog(String user, String operation, String target,
|
|
ApplicationId appId, ApplicationAttemptId attemptId,
|
|
ApplicationId appId, ApplicationAttemptId attemptId,
|
|
- ContainerId containerId) {
|
|
|
|
|
|
+ ContainerId containerId, Resource resource) {
|
|
return createSuccessLog(user, operation, target, appId, attemptId,
|
|
return createSuccessLog(user, operation, target, appId, attemptId,
|
|
- containerId, null);
|
|
|
|
|
|
+ containerId, resource, null);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -87,7 +88,7 @@ public class RMAuditLogger {
|
|
*/
|
|
*/
|
|
static String createSuccessLog(String user, String operation, String target,
|
|
static String createSuccessLog(String user, String operation, String target,
|
|
ApplicationId appId, ApplicationAttemptId attemptId,
|
|
ApplicationId appId, ApplicationAttemptId attemptId,
|
|
- ContainerId containerId, CallerContext callerContext) {
|
|
|
|
|
|
+ ContainerId containerId, Resource resource, CallerContext callerContext) {
|
|
StringBuilder b = new StringBuilder();
|
|
StringBuilder b = new StringBuilder();
|
|
start(Keys.USER, user, b);
|
|
start(Keys.USER, user, b);
|
|
addRemoteIP(b);
|
|
addRemoteIP(b);
|
|
@@ -103,6 +104,9 @@ public class RMAuditLogger {
|
|
if (containerId != null) {
|
|
if (containerId != null) {
|
|
add(Keys.CONTAINERID, containerId.toString(), b);
|
|
add(Keys.CONTAINERID, containerId.toString(), b);
|
|
}
|
|
}
|
|
|
|
+ if (resource != null) {
|
|
|
|
+ add(Keys.RESOURCE, resource.toString(), b);
|
|
|
|
+ }
|
|
appendCallerContext(b, callerContext);
|
|
appendCallerContext(b, callerContext);
|
|
return b.toString();
|
|
return b.toString();
|
|
}
|
|
}
|
|
@@ -138,16 +142,17 @@ public class RMAuditLogger {
|
|
* @param target The target on which the operation is being performed.
|
|
* @param target The target on which the operation is being performed.
|
|
* @param appId Application Id in which operation was performed.
|
|
* @param appId Application Id in which operation was performed.
|
|
* @param containerId Container Id in which operation was performed.
|
|
* @param containerId Container Id in which operation was performed.
|
|
|
|
+ * @param resource Resource associated with container.
|
|
*
|
|
*
|
|
* <br><br>
|
|
* <br><br>
|
|
* Note that the {@link RMAuditLogger} uses tabs ('\t') as a key-val delimiter
|
|
* Note that the {@link RMAuditLogger} uses tabs ('\t') as a key-val delimiter
|
|
* and hence the value fields should not contains tabs ('\t').
|
|
* and hence the value fields should not contains tabs ('\t').
|
|
*/
|
|
*/
|
|
public static void logSuccess(String user, String operation, String target,
|
|
public static void logSuccess(String user, String operation, String target,
|
|
- ApplicationId appId, ContainerId containerId) {
|
|
|
|
|
|
+ ApplicationId appId, ContainerId containerId, Resource resource) {
|
|
if (LOG.isInfoEnabled()) {
|
|
if (LOG.isInfoEnabled()) {
|
|
LOG.info(createSuccessLog(user, operation, target, appId, null,
|
|
LOG.info(createSuccessLog(user, operation, target, appId, null,
|
|
- containerId));
|
|
|
|
|
|
+ containerId, resource));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -168,7 +173,7 @@ public class RMAuditLogger {
|
|
ApplicationId appId, ApplicationAttemptId attemptId) {
|
|
ApplicationId appId, ApplicationAttemptId attemptId) {
|
|
if (LOG.isInfoEnabled()) {
|
|
if (LOG.isInfoEnabled()) {
|
|
LOG.info(createSuccessLog(user, operation, target, appId, attemptId,
|
|
LOG.info(createSuccessLog(user, operation, target, appId, attemptId,
|
|
- null));
|
|
|
|
|
|
+ null, null));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -176,7 +181,7 @@ public class RMAuditLogger {
|
|
ApplicationId appId, CallerContext callerContext) {
|
|
ApplicationId appId, CallerContext callerContext) {
|
|
if (LOG.isInfoEnabled()) {
|
|
if (LOG.isInfoEnabled()) {
|
|
LOG.info(createSuccessLog(user, operation, target, appId, null, null,
|
|
LOG.info(createSuccessLog(user, operation, target, appId, null, null,
|
|
- callerContext));
|
|
|
|
|
|
+ null, callerContext));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -196,7 +201,7 @@ public class RMAuditLogger {
|
|
public static void logSuccess(String user, String operation, String target,
|
|
public static void logSuccess(String user, String operation, String target,
|
|
ApplicationId appId) {
|
|
ApplicationId appId) {
|
|
if (LOG.isInfoEnabled()) {
|
|
if (LOG.isInfoEnabled()) {
|
|
- LOG.info(createSuccessLog(user, operation, target, appId, null, null));
|
|
|
|
|
|
+ LOG.info(createSuccessLog(user, operation, target, appId, null, null, null));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -213,14 +218,14 @@ public class RMAuditLogger {
|
|
*/
|
|
*/
|
|
public static void logSuccess(String user, String operation, String target) {
|
|
public static void logSuccess(String user, String operation, String target) {
|
|
if (LOG.isInfoEnabled()) {
|
|
if (LOG.isInfoEnabled()) {
|
|
- LOG.info(createSuccessLog(user, operation, target, null, null, null));
|
|
|
|
|
|
+ LOG.info(createSuccessLog(user, operation, target, null, null, null, null));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
static String createFailureLog(String user, String operation, String perm,
|
|
static String createFailureLog(String user, String operation, String perm,
|
|
String target, String description, ApplicationId appId,
|
|
String target, String description, ApplicationId appId,
|
|
ApplicationAttemptId attemptId, ContainerId containerId,
|
|
ApplicationAttemptId attemptId, ContainerId containerId,
|
|
- CallerContext callerContext) {
|
|
|
|
|
|
+ Resource resource, CallerContext callerContext) {
|
|
StringBuilder b = new StringBuilder();
|
|
StringBuilder b = new StringBuilder();
|
|
start(Keys.USER, user, b);
|
|
start(Keys.USER, user, b);
|
|
addRemoteIP(b);
|
|
addRemoteIP(b);
|
|
@@ -238,6 +243,9 @@ public class RMAuditLogger {
|
|
if (containerId != null) {
|
|
if (containerId != null) {
|
|
add(Keys.CONTAINERID, containerId.toString(), b);
|
|
add(Keys.CONTAINERID, containerId.toString(), b);
|
|
}
|
|
}
|
|
|
|
+ if (resource != null) {
|
|
|
|
+ add(Keys.RESOURCE, resource.toString(), b);
|
|
|
|
+ }
|
|
appendCallerContext(b, callerContext);
|
|
appendCallerContext(b, callerContext);
|
|
return b.toString();
|
|
return b.toString();
|
|
}
|
|
}
|
|
@@ -247,9 +255,9 @@ public class RMAuditLogger {
|
|
*/
|
|
*/
|
|
static String createFailureLog(String user, String operation, String perm,
|
|
static String createFailureLog(String user, String operation, String perm,
|
|
String target, String description, ApplicationId appId,
|
|
String target, String description, ApplicationId appId,
|
|
- ApplicationAttemptId attemptId, ContainerId containerId) {
|
|
|
|
|
|
+ ApplicationAttemptId attemptId, ContainerId containerId, Resource resource) {
|
|
return createFailureLog(user, operation, perm, target, description, appId,
|
|
return createFailureLog(user, operation, perm, target, description, appId,
|
|
- attemptId, containerId, null);
|
|
|
|
|
|
+ attemptId, containerId, resource, null);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -263,6 +271,7 @@ public class RMAuditLogger {
|
|
* failed.
|
|
* failed.
|
|
* @param appId Application Id in which operation was performed.
|
|
* @param appId Application Id in which operation was performed.
|
|
* @param containerId Container Id in which operation was performed.
|
|
* @param containerId Container Id in which operation was performed.
|
|
|
|
+ * @param resource Resources associated with container.
|
|
*
|
|
*
|
|
* <br><br>
|
|
* <br><br>
|
|
* Note that the {@link RMAuditLogger} uses tabs ('\t') as a key-val delimiter
|
|
* Note that the {@link RMAuditLogger} uses tabs ('\t') as a key-val delimiter
|
|
@@ -270,10 +279,10 @@ public class RMAuditLogger {
|
|
*/
|
|
*/
|
|
public static void logFailure(String user, String operation, String perm,
|
|
public static void logFailure(String user, String operation, String perm,
|
|
String target, String description, ApplicationId appId,
|
|
String target, String description, ApplicationId appId,
|
|
- ContainerId containerId) {
|
|
|
|
|
|
+ ContainerId containerId, Resource resource) {
|
|
if (LOG.isWarnEnabled()) {
|
|
if (LOG.isWarnEnabled()) {
|
|
LOG.warn(createFailureLog(user, operation, perm, target, description,
|
|
LOG.warn(createFailureLog(user, operation, perm, target, description,
|
|
- appId, null, containerId));
|
|
|
|
|
|
+ appId, null, containerId, resource));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -297,7 +306,7 @@ public class RMAuditLogger {
|
|
ApplicationAttemptId attemptId) {
|
|
ApplicationAttemptId attemptId) {
|
|
if (LOG.isWarnEnabled()) {
|
|
if (LOG.isWarnEnabled()) {
|
|
LOG.warn(createFailureLog(user, operation, perm, target, description,
|
|
LOG.warn(createFailureLog(user, operation, perm, target, description,
|
|
- appId, attemptId, null));
|
|
|
|
|
|
+ appId, attemptId, null, null));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -306,7 +315,7 @@ public class RMAuditLogger {
|
|
CallerContext callerContext) {
|
|
CallerContext callerContext) {
|
|
if (LOG.isWarnEnabled()) {
|
|
if (LOG.isWarnEnabled()) {
|
|
LOG.warn(createFailureLog(user, operation, perm, target, description,
|
|
LOG.warn(createFailureLog(user, operation, perm, target, description,
|
|
- appId, null, null, callerContext));
|
|
|
|
|
|
+ appId, null, null, null, callerContext));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -329,7 +338,7 @@ public class RMAuditLogger {
|
|
String target, String description, ApplicationId appId) {
|
|
String target, String description, ApplicationId appId) {
|
|
if (LOG.isWarnEnabled()) {
|
|
if (LOG.isWarnEnabled()) {
|
|
LOG.warn(createFailureLog(user, operation, perm, target, description,
|
|
LOG.warn(createFailureLog(user, operation, perm, target, description,
|
|
- appId, null, null));
|
|
|
|
|
|
+ appId, null, null, null));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -351,7 +360,7 @@ public class RMAuditLogger {
|
|
String target, String description) {
|
|
String target, String description) {
|
|
if (LOG.isWarnEnabled()) {
|
|
if (LOG.isWarnEnabled()) {
|
|
LOG.warn(createFailureLog(user, operation, perm, target, description,
|
|
LOG.warn(createFailureLog(user, operation, perm, target, description,
|
|
- null, null, null));
|
|
|
|
|
|
+ null, null, null, null));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|