use of com.hortonworks.registries.storage.Storable in project registry by hortonworks.
the class SchemaVersionLifecycleManager method getSchemaBranches.
public Set<SchemaBranch> getSchemaBranches(Long schemaVersionId) throws SchemaBranchNotFoundException {
List<QueryParam> schemaVersionMappingStorableQueryParams = new ArrayList<>();
Set<SchemaBranch> schemaBranches = new HashSet<>();
schemaVersionMappingStorableQueryParams.add(new QueryParam(SchemaBranchVersionMapping.SCHEMA_VERSION_INFO_ID, schemaVersionId.toString()));
for (Storable storable : storageManager.find(SchemaBranchVersionMapping.NAMESPACE, schemaVersionMappingStorableQueryParams)) {
schemaBranches.add(schemaBranchCache.get(SchemaBranchCache.Key.of(((SchemaBranchVersionMapping) storable).getSchemaBranchId())));
}
return schemaBranches;
}
use of com.hortonworks.registries.storage.Storable in project registry by hortonworks.
the class DefaultSchemaRegistry method addSchemaMetadata.
public Long addSchemaMetadata(SchemaMetadata schemaMetadata, boolean throwErrorIfExists) throws UnsupportedSchemaTypeException {
SchemaMetadataStorable givenSchemaMetadataStorable = SchemaMetadataStorable.fromSchemaMetadataInfo(new SchemaMetadataInfo(schemaMetadata));
String type = schemaMetadata.getType();
if (schemaTypeWithProviders.get(type) == null) {
throw new UnsupportedSchemaTypeException("Given schema type " + type + " not supported");
}
if (!throwErrorIfExists) {
Storable schemaMetadataStorable = storageManager.get(givenSchemaMetadataStorable.getStorableKey());
if (schemaMetadataStorable != null) {
return schemaMetadataStorable.getId();
}
}
final Long nextId = storageManager.nextId(givenSchemaMetadataStorable.getNameSpace());
givenSchemaMetadataStorable.setId(nextId);
givenSchemaMetadataStorable.setTimestamp(System.currentTimeMillis());
storageManager.addOrUpdate(givenSchemaMetadataStorable);
// Add a schema branch for this metadata
SchemaBranchStorable schemaBranchStorable = new SchemaBranchStorable(SchemaBranch.MASTER_BRANCH, schemaMetadata.getName(), String.format(SchemaBranch.MASTER_BRANCH_DESC, schemaMetadata.getName()), System.currentTimeMillis());
schemaBranchStorable.setId(storageManager.nextId(SchemaBranchStorable.NAME_SPACE));
storageManager.add(schemaBranchStorable);
return givenSchemaMetadataStorable.getId();
}
use of com.hortonworks.registries.storage.Storable in project registry by hortonworks.
the class TestApplication method getCacheBackedDao.
private StorageManager getCacheBackedDao(TestConfiguration testConfiguration) {
StorageProviderConfiguration storageProviderConfiguration = testConfiguration.getStorageProviderConfiguration();
final StorageManager dao = getStorageManager(storageProviderConfiguration);
final CacheBuilder cacheBuilder = getGuavaCacheBuilder();
final Cache<StorableKey, Storable> cache = getCache(dao, cacheBuilder);
final StorageWriter storageWriter = getStorageWriter(dao);
return doGetCacheBackedDao(cache, storageWriter);
}
use of com.hortonworks.registries.storage.Storable in project registry by hortonworks.
the class GuavaCacheTest method test_get_unexisting_key_null_expected.
@Test
public void test_get_unexisting_key_null_expected() {
Storable val = cache.get(storableKey);
Assert.assertNull(val);
}
use of com.hortonworks.registries.storage.Storable in project registry by hortonworks.
the class JdbcStorageManagerIntegrationTest method testSearchQueryApi.
@Test
public void testSearchQueryApi() {
for (StorableTest storableTest : storableTests) {
storableTest.addAllToStorage();
String nameSpace = storableTest.getNameSpace();
SearchQuery searchQuery = SearchQuery.searchFrom(nameSpace).where(WhereClause.begin().contains("name", "info").and().gt("id", 1L).combine()).orderBy(OrderBy.asc("name"));
Collection<Storable> storablesWithIdGt1 = getStorageManager().search(searchQuery);
System.out.println("storablesWithIdGt1 = " + storablesWithIdGt1);
for (Storable storable : storablesWithIdGt1) {
Assert.assertTrue(storable.getId() > 1L);
}
Collection<Storable> allStorables = getStorageManager().list(searchQuery.getNameSpace());
System.out.println("list = " + allStorables);
Assert.assertEquals(allStorables.size() - 1, storablesWithIdGt1.size());
}
}
Aggregations