use of io.cdap.cdap.store.NamespaceStore in project cdap by caskdata.
the class MetadataSubscriberService method preProcess.
@Override
protected void preProcess() {
if (didBackfill) {
return;
}
if (backfillAttempts > 10) {
LOG.info("Skipping attempt to back-fill plugin metadata after 10 failures.");
return;
}
// Backfill plugin metadata
backfillAttempts++;
LOG.info("Starting back-fill process(attempt {}) for plugin metadata", backfillAttempts);
boolean updateFailed = false;
NamespaceStore namespaceStore = new DefaultNamespaceStore(this.transactionRunner);
List<String> namespaces = namespaceStore.list().stream().map(NamespaceMeta::getName).collect(Collectors.toList());
LOG.debug("Back-filling plugin metadata for {} namespaces", namespaces.size());
for (String namespace : namespaces) {
List<ApplicationMeta> apps = TransactionRunners.run(this.transactionRunner, context -> {
AppMetadataStore appMetadataStore = AppMetadataStore.create(context);
return appMetadataStore.getAllApplications(namespace);
});
LOG.debug("Back-filling plugin metadata for namespace '{}' with {} applications", namespace, apps.size());
try {
this.getPluginCounts(namespace, apps);
} catch (IOException e) {
updateFailed = true;
LOG.warn("Failed to write plugin metadata updates for namespace '{}': {}", namespace, e);
}
}
if (!updateFailed) {
LOG.info("Successfully back-filled plugin metadata for {} namespaces.", namespaces.size());
didBackfill = true;
TransactionRunners.run(transactionRunner, (TxRunnable) context -> AppMetadataStore.create(context).persistSubscriberState(getTopicId().getTopic(), BACKFILL_SUBSCRIBER_NAME, "true"));
}
}
use of io.cdap.cdap.store.NamespaceStore in project cdap by caskdata.
the class EntityExistenceTest method setup.
@BeforeClass
public static void setup() throws Exception {
CConfiguration cConf = CConfiguration.create();
cConf.set(Constants.INSTANCE_NAME, EXISTS);
Injector injector = AppFabricTestHelper.getInjector(cConf);
NamespaceStore nsStore = injector.getInstance(NamespaceStore.class);
ArtifactRepository artifactRepository = injector.getInstance(ArtifactRepository.class);
cConf = injector.getInstance(CConfiguration.class);
nsStore.create(new NamespaceMeta.Builder().setName(EXISTS).build());
existenceVerifier = injector.getInstance(Key.get(new TypeLiteral<EntityExistenceVerifier<EntityId>>() {
}));
LocalLocationFactory lf = new LocalLocationFactory(TEMPORARY_FOLDER.newFolder());
File artifactFile = new File(AppJarHelper.createDeploymentJar(lf, AllProgramsApp.class).toURI());
artifactRepository.addArtifact(Id.Artifact.fromEntityId(ARTIFACT), artifactFile);
AppFabricTestHelper.deployApplication(Id.Namespace.fromEntityId(NAMESPACE), AllProgramsApp.class, null, cConf);
}
use of io.cdap.cdap.store.NamespaceStore in project cdap by caskdata.
the class StorageProviderNamespaceAdminTest method setup.
@BeforeClass
public static void setup() throws Exception {
CConfiguration cConf = CConfiguration.create();
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
cConf.setBoolean(Constants.Explore.EXPLORE_ENABLED, true);
Injector injector = Guice.createInjector(Modules.override(new AppFabricTestModule(cConf)).with(new AbstractModule() {
@Override
protected void configure() {
// use the DefaultNamespacePathLocator here to test proper namespace creation in storage handler and
// not the NamespacedLocationFactoryTestClient
bind(NamespacePathLocator.class).to(DefaultNamespacePathLocator.class);
}
}));
namespacePathLocator = injector.getInstance(NamespacePathLocator.class);
storageProviderNamespaceAdmin = injector.getInstance(StorageProviderNamespaceAdmin.class);
// start the dataset service for namespace store to work
transactionManager = injector.getInstance(TransactionManager.class);
transactionManager.startAndWait();
// Define all StructuredTable before starting any services that need StructuredTable
StoreDefinition.createAllTables(injector.getInstance(StructuredTableAdmin.class));
datasetService = injector.getInstance(DatasetService.class);
datasetService.startAndWait();
// we don't use namespace admin here but the store because namespaceadmin will try to create the
// home directory for namespace which we don't want. We just want to store the namespace meta in store
// to look up during the delete.
namespaceStore = injector.getInstance(NamespaceStore.class);
}
Aggregations