Search in sources :

Example 1 with LogAppender

use of co.cask.cdap.logging.appender.LogAppender in project cdap by caskdata.

the class TestFileLogging method setUpContext.

@BeforeClass
public static void setUpContext() throws Exception {
    Configuration hConf = HBaseConfiguration.create();
    final CConfiguration cConf = CConfiguration.create();
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, TMP_FOLDER.newFolder().getAbsolutePath());
    cConf.setInt(LoggingConfiguration.LOG_MAX_FILE_SIZE_BYTES, 20 * 1024);
    String logBaseDir = cConf.get(LoggingConfiguration.LOG_BASE_DIR) + "/" + TestFileLogging.class.getSimpleName();
    cConf.set(LoggingConfiguration.LOG_BASE_DIR, logBaseDir);
    injector = Guice.createInjector(new ConfigModule(cConf, hConf), new NonCustomLocationUnitTestModule().getModule(), new TransactionModules().getInMemoryModules(), new LoggingModules().getInMemoryModules(), new DataSetsModules().getInMemoryModules(), new SystemDatasetRuntimeModule().getInMemoryModules(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getNoOpModule(), new AbstractModule() {

        @Override
        protected void configure() {
            bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class);
            bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
            bind(UGIProvider.class).to(UnsupportedUGIProvider.class);
            bind(NamespaceQueryAdmin.class).to(SimpleNamespaceQueryAdmin.class);
        }
    });
    txManager = injector.getInstance(TransactionManager.class);
    txManager.startAndWait();
    LogAppender appender = injector.getInstance(LocalLogAppender.class);
    new LogAppenderInitializer(appender).initialize("TestFileLogging");
    Logger logger = LoggerFactory.getLogger("TestFileLogging");
    LoggingTester loggingTester = new LoggingTester();
    loggingTester.generateLogs(logger, new FlowletLoggingContext("TFL_NS_1", "APP_1", "FLOW_1", "FLOWLET_1", "RUN1", "INSTANCE1"));
    appender.stop();
}
Also used : CConfiguration(co.cask.cdap.common.conf.CConfiguration) LoggingConfiguration(co.cask.cdap.logging.LoggingConfiguration) Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) MetricsCollectionService(co.cask.cdap.api.metrics.MetricsCollectionService) NoOpMetricsCollectionService(co.cask.cdap.common.metrics.NoOpMetricsCollectionService) ConfigModule(co.cask.cdap.common.guice.ConfigModule) AuthenticationContextModules(co.cask.cdap.security.auth.context.AuthenticationContextModules) LocalLogAppender(co.cask.cdap.logging.framework.local.LocalLogAppender) LogAppender(co.cask.cdap.logging.appender.LogAppender) DataSetsModules(co.cask.cdap.data.runtime.DataSetsModules) DefaultOwnerAdmin(co.cask.cdap.security.impersonation.DefaultOwnerAdmin) OwnerAdmin(co.cask.cdap.security.impersonation.OwnerAdmin) UGIProvider(co.cask.cdap.security.impersonation.UGIProvider) UnsupportedUGIProvider(co.cask.cdap.security.impersonation.UnsupportedUGIProvider) NonCustomLocationUnitTestModule(co.cask.cdap.common.guice.NonCustomLocationUnitTestModule) Logger(org.slf4j.Logger) CConfiguration(co.cask.cdap.common.conf.CConfiguration) AuthorizationTestModule(co.cask.cdap.security.authorization.AuthorizationTestModule) LoggingModules(co.cask.cdap.logging.guice.LoggingModules) AbstractModule(com.google.inject.AbstractModule) TransactionModules(org.apache.tephra.runtime.TransactionModules) LoggingTester(co.cask.cdap.logging.appender.LoggingTester) LogAppenderInitializer(co.cask.cdap.logging.appender.LogAppenderInitializer) TransactionManager(org.apache.tephra.TransactionManager) NamespaceQueryAdmin(co.cask.cdap.common.namespace.NamespaceQueryAdmin) SimpleNamespaceQueryAdmin(co.cask.cdap.common.namespace.SimpleNamespaceQueryAdmin) SystemDatasetRuntimeModule(co.cask.cdap.data.runtime.SystemDatasetRuntimeModule) FlowletLoggingContext(co.cask.cdap.logging.context.FlowletLoggingContext) AuthorizationEnforcementModule(co.cask.cdap.security.authorization.AuthorizationEnforcementModule) BeforeClass(org.junit.BeforeClass)

Aggregations

MetricsCollectionService (co.cask.cdap.api.metrics.MetricsCollectionService)1 CConfiguration (co.cask.cdap.common.conf.CConfiguration)1 ConfigModule (co.cask.cdap.common.guice.ConfigModule)1 NonCustomLocationUnitTestModule (co.cask.cdap.common.guice.NonCustomLocationUnitTestModule)1 NoOpMetricsCollectionService (co.cask.cdap.common.metrics.NoOpMetricsCollectionService)1 NamespaceQueryAdmin (co.cask.cdap.common.namespace.NamespaceQueryAdmin)1 SimpleNamespaceQueryAdmin (co.cask.cdap.common.namespace.SimpleNamespaceQueryAdmin)1 DataSetsModules (co.cask.cdap.data.runtime.DataSetsModules)1 SystemDatasetRuntimeModule (co.cask.cdap.data.runtime.SystemDatasetRuntimeModule)1 LoggingConfiguration (co.cask.cdap.logging.LoggingConfiguration)1 LogAppender (co.cask.cdap.logging.appender.LogAppender)1 LogAppenderInitializer (co.cask.cdap.logging.appender.LogAppenderInitializer)1 LoggingTester (co.cask.cdap.logging.appender.LoggingTester)1 FlowletLoggingContext (co.cask.cdap.logging.context.FlowletLoggingContext)1 LocalLogAppender (co.cask.cdap.logging.framework.local.LocalLogAppender)1 LoggingModules (co.cask.cdap.logging.guice.LoggingModules)1 AuthenticationContextModules (co.cask.cdap.security.auth.context.AuthenticationContextModules)1 AuthorizationEnforcementModule (co.cask.cdap.security.authorization.AuthorizationEnforcementModule)1 AuthorizationTestModule (co.cask.cdap.security.authorization.AuthorizationTestModule)1 DefaultOwnerAdmin (co.cask.cdap.security.impersonation.DefaultOwnerAdmin)1