@Override public TableAvailability getAvailability() { if (!_facade) { return new TableAvailability(_options.getPlacement(), false); } // Facades aren't fully supported throw new UnsupportedOperationException(); }
@Override public boolean isFacade() { return _availability != null && _availability.isFacade(); }
private Expanded expand(final Record record, boolean ignoreRecent, final ReadConsistency consistency) { long fullConsistencyTimeStamp = _dataWriterDao.getFullConsistencyTimestamp(record.getKey().getTable()); long rawConsistencyTimeStamp = _dataWriterDao.getRawConsistencyTimestamp(record.getKey().getTable()); Map<StashTimeKey, StashRunTimeInfo> stashTimeInfoMap = _compactionControlSource.getStashTimesForPlacement(record.getKey().getTable().getAvailability().getPlacement()); // we will consider the earliest timestamp found as our compactionControlTimestamp. // we are also filtering out any expired timestamps. (CompactionControlMonitor should do this for us, but for now it's running every hour. So, just to fill that gap, we are filtering here.) // If no timestamps are found, then taking minimum value because we want all the deltas after the compactionControlTimestamp to be deleted as per the compaction rules as usual. long compactionControlTimestamp = stashTimeInfoMap.isEmpty() ? Long.MIN_VALUE : stashTimeInfoMap.values().stream().filter(s -> s.getExpiredTimestamp() > System.currentTimeMillis()).map(StashRunTimeInfo::getTimestamp).min(Long::compareTo).orElse(Long.MIN_VALUE); return expand(record, fullConsistencyTimeStamp, rawConsistencyTimeStamp, compactionControlTimestamp, ignoreRecent, consistency); }
private String getPlacement(Table table, boolean useOptionsPlacement) { if (!useOptionsPlacement) { TableAvailability availability = table.getAvailability(); if (availability != null) { return availability.getPlacement(); } // If the table isn't available locally then defer to it's placement from the table options. // If the user doesn't have permission the permission check will fail. If he does the permission // check won't fail but another more informative exception will likely be thrown. } return table.getOptions().getPlacement(); } }
private String getPlacement(Table table, boolean useMasterPlacement) { if (!useMasterPlacement) { TableAvailability availability = table.getAvailability(); if (availability != null) { return availability.getPlacement(); } // If the table isn't available locally then defer to it's placement from the table options. // If the user doesn't have permission the permission check will fail. If he does the permission // check won't fail but another more informative exception will likely be thrown. } return table.getOptions().getPlacement(); } }
@Override public TableAvailability getAvailability() { if (!_facade) { return new TableAvailability(_options.getPlacement(), false); } // Facades aren't fully supported throw new UnsupportedOperationException(); }
@Override public boolean isFacade() { return _availability != null && _availability.isFacade(); }
private Expanded expand(final Record record, boolean ignoreRecent, final ReadConsistency consistency) { long fullConsistencyTimeStamp = _dataWriterDao.getFullConsistencyTimestamp(record.getKey().getTable()); long rawConsistencyTimeStamp = _dataWriterDao.getRawConsistencyTimestamp(record.getKey().getTable()); Map<StashTimeKey, StashRunTimeInfo> stashTimeInfoMap = _compactionControlSource.getStashTimesForPlacement(record.getKey().getTable().getAvailability().getPlacement()); // we will consider the earliest timestamp found as our compactionControlTimestamp. // we are also filtering out any expired timestamps. (CompactionControlMonitor should do this for us, but for now it's running every hour. So, just to fill that gap, we are filtering here.) // If no timestamps are found, then taking minimum value because we want all the deltas after the compactionControlTimestamp to be deleted as per the compaction rules as usual. long compactionControlTimestamp = stashTimeInfoMap.isEmpty() ? Long.MIN_VALUE : stashTimeInfoMap.values().stream().filter(s -> s.getExpiredTimestamp() > System.currentTimeMillis()).map(StashRunTimeInfo::getTimestamp).min(Long::compareTo).orElse(Long.MIN_VALUE); return expand(record, fullConsistencyTimeStamp, rawConsistencyTimeStamp, compactionControlTimestamp, ignoreRecent, consistency); }
@Nullable private Table loadBootstrapTable(String name) { // Each system table uses a hard-coded randomly generated uuid. Long uuid = _bootstrapTables.get(name); if (uuid == null) { return null; // Unknown table } TableOptions options = new TableOptionsBuilder().setPlacement(_systemTablePlacement).build(); Map<String, Object> attributes = ImmutableMap.of(); TableAvailability availability = new TableAvailability(_systemTablePlacement, false); AstyanaxStorage storage = newAstyanaxStorage(uuid, LEGACY_SHARDS_LOG2, true, _systemTablePlacement, name); Supplier<Collection<DataCenter>> dcSupplier = getDataCentersSupplier(_systemTablePlacement, null); return new AstyanaxTable(name, options, attributes, availability, storage, ImmutableList.of(storage), dcSupplier); }
@Nullable private Table loadBootstrapTable(String name) { // Each system table uses a hard-coded randomly generated uuid. Long uuid = _bootstrapTables.get(name); if (uuid == null) { return null; // Unknown table } TableOptions options = new TableOptionsBuilder().setPlacement(_systemTablePlacement).build(); Map<String, Object> attributes = ImmutableMap.of(); TableAvailability availability = new TableAvailability(_systemTablePlacement, false); AstyanaxStorage storage = newAstyanaxStorage(uuid, LEGACY_SHARDS_LOG2, true, _systemTablePlacement, name); Supplier<Collection<DataCenter>> dcSupplier = getDataCentersSupplier(_systemTablePlacement, null); return new AstyanaxTable(name, options, attributes, availability, storage, ImmutableList.of(storage), dcSupplier); }
private Table newTable(String name, TableOptions options, Map<String, Object> attributes, boolean available, Storage storage) { TableAvailability availability = available ? new TableAvailability(storage.getPlacement(), storage.isFacade()) : null; // Reads are performed using placement and table uuid of the specified storage. AstyanaxStorage read = newAstyanaxStorage(storage, name); // If there's a move in progress, writes go to both the regular location and the move destination. List<AstyanaxStorage> write = Lists.newArrayList(); write.add(read); // Usual case. for (Storage mirrorTo : storage.getMirrors()) { write.add(newAstyanaxStorage(mirrorTo, name)); // When a move is in progress. } // Data centers for facade = all dc in the placement - dc of the master placement. String excludePlacement = storage.isFacade() ? options.getPlacement() : null; Supplier<Collection<DataCenter>> dcSupplier = getDataCentersSupplier(storage.getPlacement(), excludePlacement); return new AstyanaxTable(name, options, attributes, availability, read, write, dcSupplier); }
private Table newTable(String name, TableOptions options, Map<String, Object> attributes, boolean available, Storage storage) { TableAvailability availability = available ? new TableAvailability(storage.getPlacement(), storage.isFacade()) : null; // Reads are performed using placement and table uuid of the specified storage. AstyanaxStorage read = newAstyanaxStorage(storage, name); // If there's a move in progress, writes go to both the regular location and the move destination. List<AstyanaxStorage> write = Lists.newArrayList(); write.add(read); // Usual case. for (Storage mirrorTo : storage.getMirrors()) { write.add(newAstyanaxStorage(mirrorTo, name)); // When a move is in progress. } // Data centers for facade = all dc in the placement - dc of the master placement. String excludePlacement = storage.isFacade() ? options.getPlacement() : null; Supplier<Collection<DataCenter>> dcSupplier = getDataCentersSupplier(storage.getPlacement(), excludePlacement); return new AstyanaxTable(name, options, attributes, availability, read, write, dcSupplier); }