use of co.cask.cdap.common.conf.CConfiguration in project cdap by caskdata.
the class LogPipelineLoader method load.
/**
* Creates the {@link LogPipelineSpecification} representing the given log pipeline configuration URL.
*/
private <T extends LoggerContext> LogPipelineSpecification<T> load(Provider<T> contextProvider, URL configURL) throws JoranException {
// Create one AppenderContext per config file
T context = contextProvider.get();
CConfiguration pipelineCConf = CConfiguration.copy(cConf);
LogPipelineConfigurator configurator = new LogPipelineConfigurator(pipelineCConf);
configurator.setContext(context);
configurator.doConfigure(configURL);
// Check if the configuration has any error in it.
if (!new StatusChecker(context).isErrorFree(Status.ERROR)) {
List<Status> errors = new ArrayList<>();
for (Status status : context.getStatusManager().getCopyOfStatusList()) {
if (status.getEffectiveLevel() == Status.ERROR) {
errors.add(status);
}
}
throw new JoranException("Configuration failed " + errors);
}
// Default the pipeline name to the config file name (without extension) if it is not set
if (context.getName() == null) {
String path = configURL.getPath();
int idx = path.lastIndexOf("/");
int dotIdx = path.lastIndexOf('.');
int startIdx = idx < 0 ? 0 : idx + 1;
int endIdx = dotIdx > idx ? dotIdx : path.length();
context.setName(path.substring(startIdx, endIdx));
}
byte[] checkpointPrefix = Bytes.toBytes(context.getName());
String prefixNum = configurator.getExecutionContext().getProperty(Constants.Logging.PIPELINE_CHECKPOINT_PREFIX_NUM);
if (prefixNum != null) {
try {
checkpointPrefix = Bytes.toBytes(Integer.parseInt(prefixNum));
} catch (NumberFormatException e) {
LOG.warn("Ignoring invalid {} setting for pipeline in {}", Constants.Logging.PIPELINE_CHECKPOINT_PREFIX_NUM, configURL);
}
}
return new LogPipelineSpecification<>(configURL, context, setupPipelineCConf(configurator, pipelineCConf), checkpointPrefix);
}
use of co.cask.cdap.common.conf.CConfiguration in project cdap by caskdata.
the class FileMetadataCleanerTest 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());
String logBaseDir = cConf.get(LoggingConfiguration.LOG_BASE_DIR) + "/" + CDAPLogAppender.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(UGIProvider.class).to(UnsupportedUGIProvider.class);
bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
bind(NamespaceQueryAdmin.class).to(SimpleNamespaceQueryAdmin.class);
}
});
txManager = injector.getInstance(TransactionManager.class);
txManager.startAndWait();
}
use of co.cask.cdap.common.conf.CConfiguration in project cdap by caskdata.
the class LogCleanerTest 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());
String logBaseDir = cConf.get(LoggingConfiguration.LOG_BASE_DIR) + "/" + CDAPLogAppender.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(UGIProvider.class).to(UnsupportedUGIProvider.class);
bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
bind(NamespaceQueryAdmin.class).to(SimpleNamespaceQueryAdmin.class);
}
});
txManager = injector.getInstance(TransactionManager.class);
txManager.startAndWait();
}
use of co.cask.cdap.common.conf.CConfiguration in project cdap by caskdata.
the class RollingLocationLogAppenderTest 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());
String logBaseDir = cConf.get(LoggingConfiguration.LOG_BASE_DIR) + "/" + RollingLocationLogAppender.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(UGIProvider.class).to(UnsupportedUGIProvider.class);
bind(NamespaceQueryAdmin.class).to(SimpleNamespaceQueryAdmin.class);
bind(OwnerAdmin.class).to(NoOpOwnerAdmin.class);
}
});
txManager = injector.getInstance(TransactionManager.class);
txManager.startAndWait();
}
use of co.cask.cdap.common.conf.CConfiguration in project cdap by caskdata.
the class FileMetadataTest 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());
String logBaseDir = cConf.get(LoggingConfiguration.LOG_BASE_DIR) + "/" + CDAPLogAppender.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(UGIProvider.class).to(UnsupportedUGIProvider.class);
bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
bind(NamespaceQueryAdmin.class).to(SimpleNamespaceQueryAdmin.class);
}
});
txManager = injector.getInstance(TransactionManager.class);
txManager.startAndWait();
}
Aggregations