use of com.hortonworks.registries.storage.StorageManager in project registry by hortonworks.
the class RefreshHAServerListTask method run.
@Override
public void run() {
try {
transactionManager.beginTransaction(TransactionIsolation.SERIALIZABLE);
Collection<HostConfigStorable> hostConfigStorables = storageManager.<HostConfigStorable>list(HostConfigStorable.NAME_SPACE);
List<HostConfigStorable> hostConfigWithoutStaleEntries = hostConfigStorables.stream().filter(hostConfigStorable -> {
if ((System.currentTimeMillis() - hostConfigStorable.getTimestamp()) > 600000) {
LOG.debug("Removing : {} from list of available servers", hostConfigStorable.getHostUrl());
storageManager.remove(hostConfigStorable.getStorableKey());
return false;
} else {
return true;
}
}).collect(Collectors.toList());
LOG.debug("Fetched : {} as the latest available servers", Arrays.toString(hostConfigWithoutStaleEntries.toArray()));
haServerNotificationManager.refreshServerInfo(hostConfigWithoutStaleEntries);
HostConfigStorable hostConfWithUpdatedTimeStamp = storageManager.get(new HostConfigStorable(haServerNotificationManager.getHomeNodeURL()).getStorableKey());
if (hostConfWithUpdatedTimeStamp == null) {
hostConfWithUpdatedTimeStamp = new HostConfigStorable(storageManager.nextId(HostConfigStorable.NAME_SPACE), haServerNotificationManager.getHomeNodeURL(), System.currentTimeMillis());
} else {
hostConfWithUpdatedTimeStamp.setTimestamp(System.currentTimeMillis());
}
storageManager.addOrUpdate(hostConfWithUpdatedTimeStamp);
transactionManager.commitTransaction();
} catch (Exception e) {
transactionManager.rollbackTransaction();
throw e;
}
}
use of com.hortonworks.registries.storage.StorageManager in project registry by hortonworks.
the class RegistryApplication method getStorageManager.
private StorageManager getStorageManager(StorageProviderConfiguration storageProviderConfiguration) {
final String providerClass = storageProviderConfiguration.getProviderClass();
StorageManager storageManager;
try {
storageManager = (StorageManager) Class.forName(providerClass).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
storageManager.init(storageProviderConfiguration.getProperties());
return storageManager;
}
use of com.hortonworks.registries.storage.StorageManager in project registry by hortonworks.
the class DbFileStorageTest method setUp.
@Before
public void setUp() throws Exception {
connectionBuilder = new HikariCPConnectionBuilder(HikariBasicConfig.getH2HikariConfig());
MySqlExecutor queryExecutor = new MySqlExecutor(new ExecutionConfig(-1), connectionBuilder);
StorageManager jdbcStorageManager = new JdbcStorageManager(queryExecutor);
transactionManager = (TransactionManager) jdbcStorageManager;
jdbcStorageManager.registerStorables(StorageUtils.getStorableEntities());
dbFileStorage = new DbFileStorage();
dbFileStorage.setStorageManager(jdbcStorageManager);
runScript("create_fileblob.sql");
}
use of com.hortonworks.registries.storage.StorageManager in project streamline by hortonworks.
the class TestApplication method getStorageManager.
private StorageManager getStorageManager(StorageProviderConfiguration storageProviderConfiguration) {
final String providerClass = storageProviderConfiguration.getProviderClass();
StorageManager storageManager = null;
try {
storageManager = (StorageManager) Class.forName(providerClass).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
storageManager.init(storageProviderConfiguration.getProperties());
return storageManager;
}
use of com.hortonworks.registries.storage.StorageManager in project streamline by hortonworks.
the class TestApplication method run.
@Override
public void run(TestConfiguration testConfiguration, Environment environment) throws Exception {
StorageManager storageManager = getCacheBackedDao(testConfiguration);
final TagService tagService = new CatalogTagService(storageManager);
final TagCatalogResource tagCatalogResource = new TagCatalogResource(tagService);
environment.jersey().register(tagCatalogResource);
environment.jersey().register(MultiPartFeature.class);
}
Aggregations