/** * Returns the {@link CConfiguration} stored inside the job {@link Configuration}. */ CConfiguration getCConf() { String conf = hConf.getRaw(HCONF_ATTR_CCONF); Preconditions.checkArgument(conf != null, "No CConfiguration available"); return CConfiguration.create(new ByteArrayInputStream(conf.getBytes(Charsets.UTF_8))); } }
/** * For guice injecting configuration object to this singleton. */ @Inject public void setConfiguration(CConfiguration config) { basePath = config.get(Constants.CFG_DATA_LEVELDB_DIR); Preconditions.checkNotNull(basePath, "No base directory configured for LevelDB."); blockSize = config.getInt(Constants.CFG_DATA_LEVELDB_BLOCKSIZE, Constants.DEFAULT_DATA_LEVELDB_BLOCKSIZE); cacheSize = config.getLong(Constants.CFG_DATA_LEVELDB_CACHESIZE, Constants.DEFAULT_DATA_LEVELDB_CACHESIZE); writeOptions = new WriteOptions().sync( config.getBoolean(Constants.CFG_DATA_LEVELDB_FSYNC, Constants.DEFAULT_DATA_LEVELDB_FSYNC)); }
RunRecordCorrectorService(CConfiguration cConf, Store store, ProgramStateWriter programStateWriter, ProgramRuntimeService runtimeService, NamespaceAdmin namespaceAdmin, DatasetFramework datasetFramework) { this(cConf, store, programStateWriter, runtimeService, namespaceAdmin, datasetFramework, 2L * cConf.getLong(Constants.AppFabric.PROGRAM_MAX_START_SECONDS), cConf.getInt(Constants.AppFabric.PROGRAM_RUNID_CORRECTOR_TX_BATCH_SIZE)); }
private static int getPort(CConfiguration cConf) { return cConf.getBoolean(Constants.Security.SSL.EXTERNAL_ENABLED) ? cConf.getInt(Constants.Security.AuthenticationServer.SSL_PORT) : cConf.getInt(Constants.Security.AUTH_SERVER_BIND_PORT); } }
@BeforeClass public static void beforeClass() throws Exception { CConfiguration conf = CConfiguration.create(); conf.set(Constants.AppFabric.OUTPUT_DIR, System.getProperty("java.io.tmpdir")); conf.set(Constants.AppFabric.TEMP_DIR, System.getProperty("java.io.tmpdir")); injector = startMetricsService(conf); metricStore = injector.getInstance(MetricStore.class); }
@Inject DefaultAuditPublisher(CConfiguration cConf, MessagingService messagingService) { this.messagingService = messagingService; this.auditTopic = NamespaceId.SYSTEM.topic(cConf.get(Constants.Audit.TOPIC)); this.retryStrategy = RetryStrategies.timeLimit( cConf.getLong(Constants.Audit.PUBLISH_TIMEOUT_MS), TimeUnit.MILLISECONDS, RetryStrategies.exponentialDelay(10, 200, TimeUnit.MILLISECONDS)); }
private void checkPruningAndReplication(Set<String> problemKeys) { String hbaseDDLExtensionDir = cConf.get(Constants.HBaseDDLExecutor.EXTENSIONS_DIR); boolean pruningEnabled = cConf.getBoolean(TxConstants.TransactionPruning.PRUNE_ENABLE); if (hbaseDDLExtensionDir != null && pruningEnabled) { LOG.error(" Invalid transaction list cannot be automatically pruned when replication is in use. " + "Please disable pruning by setting {} to false, or remove your custom HBase DDL executor from {}.", TxConstants.TransactionPruning.PRUNE_ENABLE, Constants.HBaseDDLExecutor.EXTENSIONS_DIR); problemKeys.add(Constants.HBaseDDLExecutor.EXTENSIONS_DIR); problemKeys.add(TxConstants.TransactionPruning.PRUNE_ENABLE); } }
protected static CConfiguration createCConf() throws IOException { CConfiguration cConf = CConfiguration.create(); File dataDir = new File(TMP_FOLDER.newFolder(), "data"); cConf.set(Constants.CFG_LOCAL_DATA_DIR, dataDir.getAbsolutePath()); if (!DirUtils.mkdirs(dataDir)) { throw new RuntimeException(String.format("Could not create DatasetFramework output dir %s", dataDir)); } cConf.set(Constants.Dataset.Manager.OUTPUT_DIR, dataDir.getAbsolutePath()); cConf.set(Constants.Service.MASTER_SERVICES_BIND_ADDRESS, "localhost"); cConf.setBoolean(Constants.Dangerous.UNRECOVERABLE_RESET, true); return cConf; }
DatasetModulesDeployer(DatasetFramework datasetFramework, DatasetFramework inMemoryDatasetFramework, CConfiguration cConf) { this.datasetFramework = datasetFramework; this.systemDatasetFramework = inMemoryDatasetFramework; this.allowDatasetUncheckedUpgrade = cConf.getBoolean(Constants.Dataset.DATASET_UNCHECKED_UPGRADE); }
@BeforeClass public static void init() throws Exception { cConf = CConfiguration.create(); cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath()); Injector injector = AppFabricTestHelper.getInjector(cConf, new AuditModule().getDistributedModules()); messagingService = injector.getInstance(MessagingService.class); if (messagingService instanceof Service) { ((Service) messagingService).startAndWait(); } auditTopic = NamespaceId.SYSTEM.topic(cConf.get(Constants.Audit.TOPIC)); }
private static CConfiguration createCConf() throws IOException { CConfiguration cConf = CConfiguration.create(); cConf.setBoolean(Constants.Security.ENABLED, true); cConf.setBoolean(Constants.Security.Authorization.ENABLED, true); // we only want to test authorization, but we don't specify principal/keytab, so disable kerberos cConf.setBoolean(Constants.Security.KERBEROS_ENABLED, false); cConf.setInt(Constants.Security.Authorization.CACHE_MAX_ENTRIES, 0); LocationFactory locationFactory = new LocalLocationFactory(new File(TEMPORARY_FOLDER.newFolder().toURI())); Location authorizerJar = AppJarHelper.createDeploymentJar(locationFactory, InMemoryAuthorizer.class); cConf.set(Constants.Security.Authorization.EXTENSION_JAR_PATH, authorizerJar.toURI().getPath()); return cConf; }
@Inject MessagingWorkflowStateWriter(CConfiguration cConf, MessagingService messagingService) { this.topic = NamespaceId.SYSTEM.topic(cConf.get(Constants.Metadata.MESSAGING_TOPIC)); this.messagingService = messagingService; this.retryStrategy = RetryStrategies.fromConfiguration(cConf, "system.metadata."); }
public AbstractDistributedMasterServiceManager(CConfiguration cConf, String serviceName, TwillRunnerService twillRunnerService, DiscoveryServiceClient discoveryServiceClient) { this.cConf = cConf; this.serviceName = serviceName; this.twillRunnerService = twillRunnerService; this.discoveryTimeout = cConf.getLong(Constants.Monitor.DISCOVERY_TIMEOUT_SECONDS); this.discoveryServiceClient = discoveryServiceClient; }
@Test public void testGetACLs() throws Exception { CConfiguration kerbConf = CConfiguration.create(); kerbConf.set(Constants.Security.KERBEROS_ENABLED, "true"); kerbConf.set(Constants.Security.CFG_CDAP_MASTER_KRB_PRINCIPAL, "prinicpal@REALM.NET"); kerbConf.set(Constants.Security.CFG_CDAP_MASTER_KRB_KEYTAB_PATH, "/path/to/keytab"); Assert.assertEquals(ZooDefs.Ids.CREATOR_ALL_ACL, DistributedKeyManager.getACLs(kerbConf)); CConfiguration noKerbConf = CConfiguration.create(); noKerbConf.unset(Constants.Security.CFG_CDAP_MASTER_KRB_PRINCIPAL); Assert.assertEquals(ZooDefs.Ids.OPEN_ACL_UNSAFE, DistributedKeyManager.getACLs(noKerbConf)); }
@Test public void testAuthenticationDisabled() throws Exception { CConfiguration cConf = CConfiguration.create(); cConf.setBoolean(Constants.Security.ENABLED, false); cConf.setBoolean(Constants.Security.Authorization.ENABLED, true); testDisabled(cConf, FeatureDisabledException.Feature.AUTHENTICATION, Constants.Security.ENABLED); }
/** * Constructor only takes the configuration to determine the maximal allowed length for a key. */ public MetadataValidator(CConfiguration cConf) { maxCharacters = cConf.getInt(Constants.Metadata.MAX_CHARS_ALLOWED); }
protected static CConfiguration createCConf() throws IOException { CConfiguration cConf = DatasetServiceTestBase.createCConf(); cConf.setBoolean(Constants.Security.ENABLED, true); cConf.setBoolean(Constants.Security.Authorization.ENABLED, true); // we only want to test authorization, but we don't specify principal/keytab, so disable kerberos cConf.setBoolean(Constants.Security.KERBEROS_ENABLED, false); cConf.setInt(Constants.Security.Authorization.CACHE_MAX_ENTRIES, 0); Location authorizerJar = AppJarHelper.createDeploymentJar(locationFactory, InMemoryAuthorizer.class); cConf.set(Constants.Security.Authorization.EXTENSION_JAR_PATH, authorizerJar.toURI().getPath()); return cConf; }