private FacadeOptions replacePlacementIfMoveInProgress(FacadeOptions options) { String placement = options.getPlacement(); if (_placementsUnderMove.containsKey(placement)) { return new FacadeOptionsBuilder().setPlacement(_placementsUnderMove.get(placement)).build(); } return options; }
/** * Returns true if facade may be created for the specified table and placement. * Throws an exception if a facade is not allowed because of a conflict with the master or another facade. * Returns false if there is already a facade at the specified placement, so facade creation would be idempotent. */ @Override public boolean checkFacadeAllowed(String table, FacadeOptions options) throws FacadeExistsException { return checkFacadeAllowed(readTableJson(table, true), options.getPlacement(), null); }
private FacadeOptions replacePlacementIfMoveInProgress(FacadeOptions options) { String placement = options.getPlacement(); if (_placementsUnderMove.containsKey(placement)) { return new FacadeOptionsBuilder().setPlacement(_placementsUnderMove.get(placement)).build(); } return options; }
/** * Returns true if facade may be created for the specified table and placement. * Throws an exception if a facade is not allowed because of a conflict with the master or another facade. * Returns false if there is already a facade at the specified placement, so facade creation would be idempotent. */ @Override public boolean checkFacadeAllowed(String table, FacadeOptions options) throws FacadeExistsException { return checkFacadeAllowed(readTableJson(table, true), options.getPlacement(), null); }
if (facadeOptions.getPlacement().equals(placement)) { movePlacement.getFacades().add(table.getName());
if (facadeOptions.getPlacement().equals(placement)) { movePlacement.getFacades().add(table.getName());
@Timed (name = "bv.emodb.table.AstyanaxTableDAO.createFacade", absolute = true) @Override public void createFacade(String name, FacadeOptions facadeOptions, Audit audit) throws FacadeExistsException { checkNotNull(name, "table"); checkNotNull(facadeOptions, "facadeDefinition"); checkNotNull(audit, "audit"); checkTableChangesAllowed(name); // If placement move is in progress, create the new facade in its new placement facadeOptions = replacePlacementIfMoveInProgress(facadeOptions); if (!checkFacadeAllowed(name, facadeOptions)) { return; // Nothing to do } // Check that the placement string is valid String placement = checkPlacement(facadeOptions.getPlacement()); // Pick a unique table uuid that will determine where in Cassandra all the data will be stored. String uuid = newTableUuidString(name, audit); // Write the new facade definition to Cassandra. Delta delta = TableJson.newCreateFacade(uuid, placement, _defaultShardsLog2); Audit augmentedAudit = AuditBuilder.from(audit) .set("_op", "createFacade") .set("_uuid", uuid) .set("_placement", facadeOptions.getPlacement()) .build(); updateTableMetadata(name, delta, augmentedAudit, InvalidationScope.GLOBAL); }
@Timed (name = "bv.emodb.table.AstyanaxTableDAO.createFacade", absolute = true) @Override public void createFacade(String name, FacadeOptions facadeOptions, Audit audit) throws FacadeExistsException { checkNotNull(name, "table"); checkNotNull(facadeOptions, "facadeDefinition"); checkNotNull(audit, "audit"); checkTableChangesAllowed(name); // If placement move is in progress, create the new facade in its new placement facadeOptions = replacePlacementIfMoveInProgress(facadeOptions); if (!checkFacadeAllowed(name, facadeOptions)) { return; // Nothing to do } // Check that the placement string is valid String placement = checkPlacement(facadeOptions.getPlacement()); // Pick a unique table uuid that will determine where in Cassandra all the data will be stored. String uuid = newTableUuidString(name, audit); // Write the new facade definition to Cassandra. Delta delta = TableJson.newCreateFacade(uuid, placement, _defaultShardsLog2); Audit augmentedAudit = AuditBuilder.from(audit) .set("_op", "createFacade") .set("_uuid", uuid) .set("_placement", facadeOptions.getPlacement()) .build(); updateTableMetadata(name, delta, augmentedAudit, InvalidationScope.GLOBAL); }