Examples of MdcExpression


Examples of co.cask.cdap.logging.filter.MdcExpression

      String systemId = loggingContext.getSystemTagsMap().get(ServiceLoggingContext.TAG_SYSTEM_ID).getValue();
      String componentId = loggingContext.getSystemTagsMap().get(ServiceLoggingContext.TAG_COMPONENT_ID).getValue();
      String tagName = ServiceLoggingContext.TAG_SERVICE_ID;
      String entityId = loggingContext.getSystemTagsMap().get(ServiceLoggingContext.TAG_SERVICE_ID).getValue();
      return new AndFilter(
        ImmutableList.of(new MdcExpression(ServiceLoggingContext.TAG_SYSTEM_ID, systemId),
                         new MdcExpression(ServiceLoggingContext.TAG_COMPONENT_ID, componentId),
                         new MdcExpression(tagName, entityId)));
    } else {
      String accountId = loggingContext.getSystemTagsMap().get(ApplicationLoggingContext.TAG_ACCOUNT_ID).getValue();
      String applId = loggingContext.getSystemTagsMap().get(ApplicationLoggingContext.TAG_APPLICATION_ID).getValue();

      String tagName;
      String entityId;
      if (loggingContext instanceof FlowletLoggingContext) {
        tagName = FlowletLoggingContext.TAG_FLOW_ID;
        entityId = loggingContext.getSystemTagsMap().get(tagName).getValue();
      } else if (loggingContext instanceof ProcedureLoggingContext) {
        tagName = ProcedureLoggingContext.TAG_PROCEDURE_ID;
        entityId = loggingContext.getSystemTagsMap().get(tagName).getValue();
      } else if (loggingContext instanceof MapReduceLoggingContext) {
        tagName = MapReduceLoggingContext.TAG_MAP_REDUCE_JOB_ID;
        entityId = loggingContext.getSystemTagsMap().get(tagName).getValue();
      } else if (loggingContext instanceof SparkLoggingContext) {
        tagName = SparkLoggingContext.TAG_SPARK_JOB_ID;
        entityId = loggingContext.getSystemTagsMap().get(tagName).getValue();
      } else if (loggingContext instanceof UserServiceLoggingContext) {
        tagName = UserServiceLoggingContext.TAG_USERSERVICE_ID;
        entityId = loggingContext.getSystemTagsMap().get(tagName).getValue();
      } else if (loggingContext instanceof GenericLoggingContext) {
        entityId = loggingContext.getSystemTagsMap().get(GenericLoggingContext.TAG_ENTITY_ID).getValue();
        return createGenericFilter(accountId, applId, entityId);
      } else {
        throw new IllegalArgumentException(String.format("Invalid logging context: %s", loggingContext));
      }

      return new AndFilter(
        ImmutableList.of(new MdcExpression(FlowletLoggingContext.TAG_ACCOUNT_ID, accountId),
                         new MdcExpression(FlowletLoggingContext.TAG_APPLICATION_ID, applId),
                         new MdcExpression(tagName, entityId)
        )
      );
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.