use of co.cask.cdap.common.conf.CConfiguration in project cdap by caskdata.
the class SystemArguments method getRetryStrategy.
/**
* Get the retry strategy for a program given its arguments and the CDAP defaults for the program type.
*
* @return the retry strategy to use for internal calls
* @throws IllegalArgumentException if there is an invalid value for an argument
*/
public static RetryStrategy getRetryStrategy(Map<String, String> args, ProgramType programType, CConfiguration cConf) {
String keyPrefix;
switch(programType) {
case MAPREDUCE:
keyPrefix = Constants.Retry.MAPREDUCE_PREFIX;
break;
case SPARK:
keyPrefix = Constants.Retry.SPARK_PREFIX;
break;
case WORKFLOW:
keyPrefix = Constants.Retry.WORKFLOW_PREFIX;
break;
case WORKER:
keyPrefix = Constants.Retry.WORKER_PREFIX;
break;
case SERVICE:
keyPrefix = Constants.Retry.SERVICE_PREFIX;
break;
case FLOW:
keyPrefix = Constants.Retry.FLOW_PREFIX;
break;
case CUSTOM_ACTION:
keyPrefix = Constants.Retry.CUSTOM_ACTION_PREFIX;
break;
default:
throw new IllegalArgumentException("Invalid program type " + programType);
}
// Override from runtime arguments
CConfiguration policyConf = CConfiguration.copy(cConf);
String typeStr = args.get(RETRY_POLICY_TYPE);
if (typeStr != null) {
policyConf.set(keyPrefix + Constants.Retry.TYPE, typeStr);
}
int maxRetries = getNonNegativeInt(args, RETRY_POLICY_MAX_RETRIES, RETRY_POLICY_MAX_RETRIES, -1);
if (maxRetries >= 0) {
policyConf.setInt(keyPrefix + Constants.Retry.MAX_RETRIES, maxRetries);
}
long maxTimeSecs = getNonNegativeLong(args, RETRY_POLICY_MAX_TIME_SECS, RETRY_POLICY_MAX_TIME_SECS, -1L);
if (maxTimeSecs >= 0) {
policyConf.setLong(keyPrefix + Constants.Retry.MAX_TIME_SECS, maxTimeSecs);
}
long baseDelay = getNonNegativeLong(args, RETRY_POLICY_DELAY_BASE_MS, RETRY_POLICY_DELAY_BASE_MS, -1L);
if (baseDelay >= 0) {
policyConf.setLong(keyPrefix + Constants.Retry.DELAY_BASE_MS, baseDelay);
}
long maxDelay = getNonNegativeLong(args, RETRY_POLICY_DELAY_MAX_MS, RETRY_POLICY_DELAY_MAX_MS, -1L);
if (maxDelay >= 0) {
policyConf.setLong(keyPrefix + Constants.Retry.DELAY_MAX_MS, maxDelay);
}
return RetryStrategies.fromConfiguration(policyConf, keyPrefix);
}
use of co.cask.cdap.common.conf.CConfiguration in project cdap by caskdata.
the class MapReduceRunnerTestBase method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
CConfiguration conf = CConfiguration.create();
// allow subclasses to override the following two parameters
Integer txTimeout = Integer.getInteger(TxConstants.Manager.CFG_TX_TIMEOUT);
if (txTimeout != null) {
conf.setInt(TxConstants.Manager.CFG_TX_TIMEOUT, txTimeout);
}
Integer txCleanupInterval = Integer.getInteger(TxConstants.Manager.CFG_TX_CLEANUP_INTERVAL);
if (txCleanupInterval != null) {
conf.setInt(TxConstants.Manager.CFG_TX_CLEANUP_INTERVAL, txCleanupInterval);
}
injector = AppFabricTestHelper.getInjector(conf, new AbstractModule() {
@Override
protected void configure() {
bind(StreamFileWriterFactory.class).to(LocationStreamFileWriterFactory.class);
}
});
txService = injector.getInstance(TransactionManager.class);
txExecutorFactory = injector.getInstance(TransactionExecutorFactory.class);
dsFramework = injector.getInstance(DatasetFramework.class);
datasetCache = new SingleThreadDatasetCache(new SystemDatasetInstantiator(dsFramework, MapReduceRunnerTestBase.class.getClassLoader(), null), injector.getInstance(TransactionSystemClient.class), NamespaceId.DEFAULT, DatasetDefinition.NO_ARGUMENTS, null, null);
metricStore = injector.getInstance(MetricStore.class);
txService.startAndWait();
streamHandler = injector.getInstance(StreamHandler.class);
// Always create the default namespace
injector.getInstance(NamespaceAdmin.class).create(NamespaceMeta.DEFAULT);
}
use of co.cask.cdap.common.conf.CConfiguration in project cdap by caskdata.
the class RemoteNamespaceQueryTest method setup.
@BeforeClass
public static void setup() throws Exception {
CConfiguration cConf = CConfiguration.create();
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMPORARY_FOLDER.newFolder().getAbsolutePath());
Injector injector = AppFabricTestHelper.getInjector(cConf);
txManager = injector.getInstance(TransactionManager.class);
txManager.startAndWait();
datasetService = injector.getInstance(DatasetService.class);
datasetService.startAndWait();
appFabricServer = injector.getInstance(AppFabricServer.class);
appFabricServer.startAndWait();
DiscoveryServiceClient discoveryServiceClient = injector.getInstance(DiscoveryServiceClient.class);
waitForService(discoveryServiceClient, Constants.Service.DATASET_MANAGER);
waitForService(discoveryServiceClient, Constants.Service.APP_FABRIC_HTTP);
namespaceAdmin = injector.getInstance(NamespaceAdmin.class);
queryClient = injector.getInstance(RemoteNamespaceQueryClient.class);
namespacedLocationFactory = injector.getInstance(NamespacedLocationFactory.class);
}
use of co.cask.cdap.common.conf.CConfiguration in project cdap by caskdata.
the class RemotePrivilegesTest method setup.
@BeforeClass
public static void setup() throws IOException, InterruptedException {
CConfiguration cConf = CConfiguration.create();
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMPORARY_FOLDER.newFolder().getAbsolutePath());
cConf.setBoolean(Constants.Security.ENABLED, true);
cConf.setBoolean(Constants.Security.KERBEROS_ENABLED, false);
cConf.setBoolean(Constants.Security.Authorization.ENABLED, true);
cConf.setInt(Constants.Security.Authorization.CACHE_MAX_ENTRIES, 10000);
cConf.setInt(Constants.Security.Authorization.CACHE_TTL_SECS, CACHE_TIMEOUT);
Manifest manifest = new Manifest();
manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, InMemoryAuthorizer.class.getName());
LocationFactory locationFactory = new LocalLocationFactory(TEMPORARY_FOLDER.newFolder());
Location externalAuthJar = AppJarHelper.createDeploymentJar(locationFactory, InMemoryAuthorizer.class, manifest);
cConf.set(Constants.Security.Authorization.EXTENSION_JAR_PATH, externalAuthJar.toString());
Injector injector = AppFabricTestHelper.getInjector(cConf);
discoveryService = injector.getInstance(DiscoveryServiceClient.class);
appFabricServer = injector.getInstance(AppFabricServer.class);
appFabricServer.startAndWait();
waitForService(Constants.Service.APP_FABRIC_HTTP);
authorizationEnforcer = injector.getInstance(RemoteAuthorizationEnforcer.class);
privilegesManager = injector.getInstance(PrivilegesManager.class);
}
use of co.cask.cdap.common.conf.CConfiguration in project cdap by caskdata.
the class LevelDBFileStreamAdminTest method init.
@BeforeClass
public static void init() throws Exception {
CConfiguration cConf = CConfiguration.create();
cConf.set(Constants.CFG_LOCAL_DATA_DIR, tmpFolder.newFolder().getAbsolutePath());
addCConfProperties(cConf);
Injector injector = Guice.createInjector(new ConfigModule(cConf), new NonCustomLocationUnitTestModule().getModule(), new SystemDatasetRuntimeModule().getInMemoryModules(), new DataSetsModules().getInMemoryModules(), new DataFabricLevelDBModule(), new TransactionMetricsModule(), new DiscoveryRuntimeModule().getInMemoryModules(), new ExploreClientModule(), new ViewAdminModules().getInMemoryModules(), new AuditModule().getInMemoryModules(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getNoOpModule(), Modules.override(new StreamAdminModules().getStandaloneModules()).with(new AbstractModule() {
@Override
protected void configure() {
bind(StreamMetaStore.class).to(InMemoryStreamMetaStore.class);
bind(NotificationFeedManager.class).to(NoOpNotificationFeedManager.class);
bind(UGIProvider.class).to(UnsupportedUGIProvider.class);
bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
bind(NamespaceQueryAdmin.class).to(SimpleNamespaceQueryAdmin.class);
}
}));
streamAdmin = injector.getInstance(StreamAdmin.class);
txManager = injector.getInstance(TransactionManager.class);
fileWriterFactory = injector.getInstance(StreamFileWriterFactory.class);
streamCoordinatorClient = injector.getInstance(StreamCoordinatorClient.class);
inMemoryAuditPublisher = injector.getInstance(InMemoryAuditPublisher.class);
authorizer = injector.getInstance(AuthorizerInstantiator.class).get();
ownerAdmin = injector.getInstance(OwnerAdmin.class);
streamCoordinatorClient.startAndWait();
setupNamespaces(injector.getInstance(NamespacedLocationFactory.class));
txManager.startAndWait();
}
Aggregations