@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 TableOptions replacePlacementIfMoveInProgress(TableOptions options) { String placement = options.getPlacement(); if (_placementsUnderMove.containsKey(placement)) { return new TableOptionsBuilder().setFacades(options.getFacades()) .setPlacement(_placementsUnderMove.get(placement)).build(); } return options; }
@Override public void start() throws Exception { // Ensure the basic system tables exist. For the DataStore these will be bootstrap tables. for (String table : new String[] {_systemTable, _systemTableUuid, _systemTableUnPublishedDatabusEvents}) { TableOptions options = new TableOptionsBuilder().setPlacement(_systemTablePlacement).build(); Audit audit = new AuditBuilder().setComment("initial startup").setLocalHost().build(); _backingStore.createTable(table, options, ImmutableMap.<String, Object>of(), audit); } }
private TableOptions replacePlacementIfMoveInProgress(TableOptions options) { String placement = options.getPlacement(); if (_placementsUnderMove.containsKey(placement)) { return new TableOptionsBuilder().setFacades(options.getFacades()) .setPlacement(_placementsUnderMove.get(placement)).build(); } return options; }
@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); }
Collection<Storage> facades = json.getFacades(); TableOptions options = new TableOptionsBuilder() .setPlacement(masterPlacement) .setFacades(ImmutableList.copyOf(Iterables.transform(facades, new Function<Storage, FacadeOptions>() { @Override public FacadeOptions apply(Storage facade) { .build();
/** * Creates a placeholder for unknown tables. A table may be unknown for one of two reasons: 1) the table * used to exist but has been deleted, or 2) the table never existed. In the former case the table will have * a name, but in the latter case the table will be unnamed and the "name" parameter will be null. */ public static AstyanaxTable createUnknown(long uuid, Placement placement, @Nullable String name) { AstyanaxStorage storage = new AstyanaxStorage( uuid, RowKeyUtils.NUM_SHARDS_UNKNOWN, false/*reads-not-allowed*/, placement.getName(), Suppliers.ofInstance(placement)); return new AstyanaxTable( name != null ? name : "__unknown:" + TableUuidFormat.encode(uuid), new TableOptionsBuilder().setPlacement(placement.getName()).build(), ImmutableMap.<String, Object>of("~unknown", true, "uuid", uuid), null/*availability*/, storage, ImmutableList.of(storage), Suppliers.<Collection<DataCenter>>ofInstance(ImmutableList.<DataCenter>of())); }
Collection<Storage> facades = json.getFacades(); TableOptions options = new TableOptionsBuilder() .setPlacement(masterPlacement) .setFacades(ImmutableList.copyOf(Iterables.transform(facades, new Function<Storage, FacadeOptions>() { @Override public FacadeOptions apply(Storage facade) { .build();
/** * Creates a placeholder for unknown tables. A table may be unknown for one of two reasons: 1) the table * used to exist but has been deleted, or 2) the table never existed. In the former case the table will have * a name, but in the latter case the table will be unnamed and the "name" parameter will be null. */ public static AstyanaxTable createUnknown(long uuid, Placement placement, @Nullable String name) { AstyanaxStorage storage = new AstyanaxStorage( uuid, RowKeyUtils.NUM_SHARDS_UNKNOWN, false/*reads-not-allowed*/, placement.getName(), Suppliers.ofInstance(placement)); return new AstyanaxTable( name != null ? name : "__unknown:" + TableUuidFormat.encode(uuid), new TableOptionsBuilder().setPlacement(placement.getName()).build(), ImmutableMap.<String, Object>of("~unknown", true, "uuid", uuid), null/*availability*/, storage, ImmutableList.of(storage), Suppliers.<Collection<DataCenter>>ofInstance(ImmutableList.<DataCenter>of())); }
@Override public void start() throws Exception { // Ensure the basic system tables exist. For the DataStore these will be bootstrap tables. for (String table : new String[] {_systemTable, _systemTableUuid, _systemTableUnPublishedDatabusEvents}) { TableOptions options = new TableOptionsBuilder().setPlacement(_systemTablePlacement).build(); Audit audit = new AuditBuilder().setComment("initial startup").setLocalHost().build(); _backingStore.createTable(table, options, ImmutableMap.<String, Object>of(), audit); } }
@Override public String get() { // Lazily ensure the table exists on the first use. String tableName = tableNameSupplier.get(); if (!_dataStore.getTableExists(tableName)) { _dataStore.createTable(tableName, new TableOptionsBuilder().setPlacement(placement).build(), ImmutableMap.<String, String>of(), new AuditBuilder().setLocalHost().setComment("create table").build() ); } return tableName; } }
@Override public String get() { // Lazily ensure the table exists on the first use. String tableName = tableNameSupplier.get(); if (!_dataStore.getTableExists(tableName)) { _dataStore.createTable(tableName, new TableOptionsBuilder().setPlacement(placement).build(), ImmutableMap.<String, String>of(), new AuditBuilder().setLocalHost().setComment("create table").build() ); } return tableName; } }
/** * Returns the migration status table name. On the first call it also verifies that the table exists, then skips this * check on future calls. */ private String getTable() { if (!_tableChecked) { if (!_dataStore.getTableExists(_tableName)) { _dataStore.createTable( _tableName, new TableOptionsBuilder().setPlacement(_tablePlacement).build(), ImmutableMap.<String, Object>of(), new AuditBuilder().setLocalHost().setComment("Create migration status table").build()); _tableChecked = true; } } return _tableName; }
private void validateTable() { if (_tableValidated) { return; } synchronized(this) { if (!_dataStore.getTableExists(_tableName)) { _dataStore.createTable( _tableName, new TableOptionsBuilder().setPlacement(_placement).build(), ImmutableMap.<String, Object>of(), new AuditBuilder().setLocalHost().setComment("create permissions table").build()); } _tableValidated = true; } } }
private void validateTable() { if (_tableValidated) { return; } synchronized(this) { if (!_dataStore.getTableExists(_tableName)) { _dataStore.createTable( _tableName, new TableOptionsBuilder().setPlacement(_placement).build(), ImmutableMap.<String, Object>of(), new AuditBuilder().setLocalHost().setComment("create permissions table").build()); } _tableValidated = true; } } }
/** * Returns the scan status table name. On the first call it also verifies that the table exists, then skips this * check on future calls. */ private String getTable() { if (!_tableChecked) { if (!_dataStore.getTableExists(_tableName)) { _dataStore.createTable( _tableName, new TableOptionsBuilder().setPlacement(_tablePlacement).build(), ImmutableMap.<String, Object>of(), new AuditBuilder().setLocalHost().setComment("Create scan status table").build()); _tableChecked = true; } } return _tableName; }
/** * Returns the scan request table name. On the first call it also verifies that the table exists, then skips this * check on future calls. */ private String getTable() { if (!_tableChecked) { if (!_dataStore.getTableExists(_tableName)) { _dataStore.createTable( _tableName, new TableOptionsBuilder().setPlacement(_tablePlacement).build(), ImmutableMap.<String, Object>of(), new AuditBuilder().setLocalHost().setComment("Create scan request table").build()); } _tableChecked = true; } return _tableName; }
/** * Verifies that the given report table exists or, if not, creates it. */ @Override public void verifyOrCreateReport(String reportId) { checkNotNull(reportId, "reportId"); String tableName = getTableName(reportId); if (_dataStore.getTableExists(tableName)) { return; // Nothing to do. } try { // TODO: when run in the EU this should be routed to the US data center. _dataStore.createTable(tableName, new TableOptionsBuilder().setPlacement(_systemTablePlacement).build(), ImmutableMap.<String, String>of(), new AuditBuilder().setComment("create table").build() ); } catch (TableExistsException e) { // This is expected if we're continuing an existing report. } }
private void validateTables() { if (_tablesValidated) { return; } synchronized(this) { if (!_dataStore.getTableExists(_identityTableName)) { _dataStore.createTable( _identityTableName, new TableOptionsBuilder().setPlacement(_placement).build(), ImmutableMap.<String, Object>of(), new AuditBuilder().setLocalHost().setComment("create identity table").build()); } if (!_dataStore.getTableExists(_idIndexTableName)) { _dataStore.createTable( _idIndexTableName, new TableOptionsBuilder().setPlacement(_placement).build(), ImmutableMap.<String, Object>of(), new AuditBuilder().setLocalHost().setComment("create ID table").build()); } _tablesValidated = true; } }
private void validateTables() { if (_tablesValidated) { return; } synchronized(this) { if (!_dataStore.getTableExists(_identityTableName)) { _dataStore.createTable( _identityTableName, new TableOptionsBuilder().setPlacement(_placement).build(), ImmutableMap.<String, Object>of(), new AuditBuilder().setLocalHost().setComment("create identity table").build()); } if (!_dataStore.getTableExists(_idIndexTableName)) { _dataStore.createTable( _idIndexTableName, new TableOptionsBuilder().setPlacement(_placement).build(), ImmutableMap.<String, Object>of(), new AuditBuilder().setLocalHost().setComment("create ID table").build()); } _tablesValidated = true; } }