Examples of CorrelationContext


Examples of org.apache.hadoop.gateway.audit.api.CorrelationContext

 
  public static final String MDC_CORRELATION_CONTEXT_KEY = "correlation_context";
 
  @Override
  public CorrelationContext createContext() {
    CorrelationContext context = getContext();
    if ( context == null ) {
      context = new Log4jCorrelationContext();
      attachContext( context );
    }
    return context;
View Full Code Here

Examples of org.apache.hadoop.gateway.audit.api.CorrelationContext

    }
  }

  @Override
  public CorrelationContext detachContext() {
    CorrelationContext context = (CorrelationContext) MDC.get( MDC_CORRELATION_CONTEXT_KEY );
    MDC.remove( MDC_CORRELATION_CONTEXT_KEY );
    return context;
  }
View Full Code Here

Examples of org.apache.hadoop.gateway.audit.api.CorrelationContext

    }
  }

  @Override
  public CorrelationContext attachExternalizedContext(byte[] externalizedContext) {
    CorrelationContext context = readExternalizedContext( externalizedContext );
    attachContext( context );
    return context;
  }
View Full Code Here

Examples of org.apache.hadoop.gateway.audit.api.CorrelationContext

  @Override
  public CorrelationContext readExternalizedContext(byte[] externalizedContext) {
    ByteArrayInputStream bais = new ByteArrayInputStream( externalizedContext );
    ObjectInput oi = null;
    CorrelationContext context = null;
    try {
      oi = new ObjectInputStream( bais );
      context = (CorrelationContext) oi.readObject();
    } catch ( IOException e ) {
      throw new IllegalArgumentException( e );
View Full Code Here

Examples of org.apache.hadoop.gateway.audit.api.CorrelationContext

    Holder holder = new Holder( path, name, clazz, params, resourceRole );
    addHolder( holder );
  }
 
  private void assignCorrelationRequestId() {
    CorrelationContext correlationContext = CorrelationServiceFactory.getCorrelationService().createContext();
    correlationContext.setRequestId( UUID.randomUUID().toString() );
  }
View Full Code Here

Examples of org.apache.hadoop.gateway.audit.api.CorrelationContext

  @Override
  public String format( LoggingEvent event ) {
    sb.setLength( 0 );
    dateFormat( sb, event );
    CorrelationContext cc = (CorrelationContext)event.getMDC( Log4jCorrelationService.MDC_CORRELATION_CONTEXT_KEY );
    AuditContext ac = (AuditContext)event.getMDC( Log4jAuditService.MDC_AUDIT_CONTEXT_KEY );
    appendParameter( cc == null ? null : cc.getRootRequestId() );
    appendParameter( cc == null ? null : cc.getParentRequestId() );
    appendParameter( cc == null ? null : cc.getRequestId() );
    appendParameter( event.getLoggerName() );
    appendParameter( ac == null ? null : ac.getTargetServiceName() );
    appendParameter( ac == null ? null : ac.getUsername() );
    appendParameter( ac == null ? null : ac.getProxyUsername() );
    appendParameter( ac == null ? null : ac.getSystemUsername() );
View Full Code Here

Examples of org.apache.hadoop.gateway.audit.api.CorrelationContext

  private void verifyAuditEvent( LoggingEvent event, String resourceName,
      String resourceType, String action, String outcome, String targetService,
      String message ) {
    event.getMDCCopy();
    CorrelationContext cc = (CorrelationContext) event.getMDC( Log4jCorrelationService.MDC_CORRELATION_CONTEXT_KEY );
    assertThat( cc, notNullValue() );
    assertThat( cc.getRequestId(), is( notNullValue() ) );
    AuditContext ac = (AuditContext) event.getMDC( Log4jAuditService.MDC_AUDIT_CONTEXT_KEY );
    assertThat( ac, notNullValue() );
    assertThat( ac.getRemoteIp(), is( ADDRESS ) );
    assertThat( ac.getRemoteHostname(), is( HOST ) );
    assertThat( (String) event.getMDC( AuditConstants.MDC_SERVICE_KEY ), is( AuditConstants.KNOX_SERVICE_NAME ) );
View Full Code Here

Examples of org.apache.hadoop.gateway.audit.api.CorrelationContext

      assertThat( actual, is( expected ) );
    }
  }

  private String getRequestId( LoggingEvent event ) {
    CorrelationContext cc = (CorrelationContext) event
        .getMDC( Log4jCorrelationService.MDC_CORRELATION_CONTEXT_KEY );
    return cc == null ? null : cc.getRequestId();
  }
View Full Code Here

Examples of org.apache.hadoop.gateway.audit.api.CorrelationContext

    auditContext.setUsername( USERNAME );
    auditContext.setRemoteHostname( HOST_NAME );
    auditContext.setRemoteIp( HOST_ADDRESS );
    auditContext.setTargetServiceName( TARGET_SERVICE );
   
    CorrelationContext correlationContext = correlationService.createContext();
    correlationContext.setRequestId( REQUEST_ID );
    correlationContext.setParentRequestId( PARENT_REQUEST_ID );
    correlationContext.setRootRequestId( ROOT_REQUEST_ID );
    auditor.audit( ACTION, RESOURCE_NAME, RESOURCE_TYPE, OUTCOME, MESSAGE );
   
    assertThat( CollectAppender.queue.size(), is( 1 ) );
    LoggingEvent event = CollectAppender.queue.iterator().next();
    SimpleDateFormat format = new SimpleDateFormat( "yy/MM/dd HH:mm:ss" );
View Full Code Here

Examples of org.apache.hadoop.gateway.audit.api.CorrelationContext

    this.serviceName = serviceName;
  }

  @Override
  public void audit( CorrelationContext correlationContext, AuditContext auditContext, String action, String resourceName, String resourceType, String outcome, String message ) {
    CorrelationContext previousCorrelationContext = null;
    AuditContext previousAuditContext = null;
    try {
      previousCorrelationContext = correlationService.getContext();
      previousAuditContext = auditService.getContext();
      auditService.attachContext( auditContext );
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.