use of io.prestosql.spi.seedstore.SeedStoreSubType in project hetu-core by openlookeng.
the class SeedStoreManager method updateSeed.
/**
* Update the existing seed at seedLocation with new properties
* @param subType
* @param seedLocation
* @param updatedProperties
*/
public void updateSeed(SeedStoreSubType subType, String seedLocation, Map<String, String> updatedProperties) {
SeedStore seedStore = getSeedStore(subType);
if (seedStore == null) {
throw new PrestoException(SEED_STORE_FAILURE, "Seed store is null");
}
try {
Collection<Seed> existingSeeds = seedStore.get();
List<Seed> toUpdate = existingSeeds.stream().filter(s -> {
return s.getLocation().equals(seedLocation);
}).collect(Collectors.toList());
LOG.debug("SeedStoreManager::updateSeed toUpdate.size() is %s", Integer.toString(toUpdate.size()));
for (Seed s : toUpdate) {
seedStore.remove(ImmutableList.of(s));
Seed newSeed = seedStore.create(updatedProperties);
addSeed(subType, newSeed);
}
} catch (IOException e) {
LOG.warn("Update seed %s failed with error: %s", seedLocation, e.getMessage());
}
}
use of io.prestosql.spi.seedstore.SeedStoreSubType in project hetu-core by openlookeng.
the class SeedStoreManager method clearExpiredSeeds.
/**
* Clear expired seed in the seed store
*
* @throws IOException
*/
public void clearExpiredSeeds(SeedStoreSubType subType) throws IOException {
SeedStore seedStore = getSeedStore(subType);
if (seedStore == null) {
throw new PrestoException(SEED_STORE_FAILURE, "Seed store is null");
}
try {
Collection<Seed> expiredSeeds = seedStore.get().stream().filter(s -> (System.currentTimeMillis() - s.getTimestamp() > seedHeartBeatTimeout)).collect(Collectors.toList());
if (expiredSeeds.size() > 0) {
LOG.info("Expired seeds=%s will be cleared", expiredSeeds);
seedStore.remove(expiredSeeds);
}
} catch (RuntimeException e) {
LOG.warn("clearExpiredSeed failed with following message: %s", e.getMessage());
}
}
Aggregations