/** * Get a table layout monitor for the provided table. The returned table layout monitor should * be closed when no longer needed. * * @param tableName of table's monitor to retrieve. * @return a table layout monitor for the table. */ public TableLayoutMonitor getTableLayoutMonitor(String tableName) { Preconditions.checkState(mState.get() == State.OPEN, "InstanceMonitor is closed."); LOG.debug("Retrieving TableLayoutMonitor for table {} with userID {}.", FijiURI.newBuilder(mInstanceURI).withTableName(tableName).build(), mUserID); return new ReferencedTableLayoutMonitor(tableName, mTableLayoutMonitors); }
/** {@inheritDoc} */ @Override public FijiTableLayout getTableLayout(String table) throws IOException { final List<FijiTableLayout> layouts = getTableLayoutVersions(table, 1); if (layouts.isEmpty()) { throw new FijiTableNotFoundException( FijiURI.newBuilder(mFijiURI).withTableName(table).build()); } return layouts.get(0); }
/** {@inheritDoc} */ @Override public FijiTableLayout getTableLayout(String table) throws IOException { final List<FijiTableLayout> layouts = getTableLayoutVersions(table, 1); if (layouts.isEmpty()) { throw new FijiTableNotFoundException( FijiURI.newBuilder(mFijiURI).withTableName(table).build()); } return layouts.get(0); }
final FijiURI tableURI = FijiURI.newBuilder(mURI).withTableName(tableName).build(); LOG.debug("Applying layout update {} on table {}", update, tableURI);
final FijiURI tableURI = FijiURI.newBuilder(mURI).withTableName(tableName).build(); LOG.debug("Applying layout update {} on table {}", update, tableURI);
TableLayoutDesc tableLayout, byte[][] splitKeys) throws IOException { final FijiURI tableURI = FijiURI.newBuilder(mURI).withTableName(tableLayout.getName()).build();
if (conf.get(FijiConfKeys.FIJI_INPUT_TABLE_URI) != null) { instanceURIs.add(FijiURI.newBuilder(conf.get(FijiConfKeys.FIJI_INPUT_TABLE_URI)) .withTableName(null) .withColumnNames(Collections.<String>emptyList()) .build()); .withTableName(null) .withColumnNames(Collections.<String>emptyList()) .build());
mHTableFactory = htableFactory; mConf = conf; mTableURI = FijiURI.newBuilder(mFiji.getURI()).withTableName(mName).build(); LOG.debug("Opening Fiji table '{}' with client version '{}'.", mTableURI, VersionInfo.getSoftwareVersion());
final FijiURI tableURI = FijiURI.newBuilder(mURI).withTableName(tableLayout.getName()).build(); CassandraTableLayoutUpdater.validateCassandraTableLayout(tableLayout);
/** * Attempt to delete a table from this System_2_0 Fiji instance. * * @param tableName to delete * @throws IOException on unrecoverable error. */ private void deleteTableSystem_2_0(String tableName) throws IOException { final FijiURI tableURI = FijiURI.newBuilder(mURI).withTableName(tableName).build(); final String tableZKPath = ZooKeeperUtils.getTableDir(tableURI).getPath(); final UsersTracker usersTracker = ZooKeeperUtils.newTableUsersTracker(mZKClient, tableURI); try { usersTracker.start(); final Set<String> users = usersTracker.getUsers().keySet(); if (!users.isEmpty()) { LOG.warn( "Uninstalling Fiji table '{}' with registered users." + " Current registered users: {}. Stale table metadata will remain in" + " ZooKeeper at path {}.", tableName, users, tableZKPath); } } finally { usersTracker.close(); } // The delete of tables from HBase is the same as System_1_0 deleteTableSystem_1_0(tableName); // Delete ZNodes from ZooKeeper if table delete was successful ZooKeeperUtils.atomicRecursiveDelete(mZKClient, tableZKPath); } // CSON
/** {@inheritDoc} */ @Override public void deleteTable(String tableName) throws IOException { final State state = mState.get(); Preconditions.checkState(state == State.OPEN, "Cannot delete table in Fiji instance %s in state %s.", this, state); // Delete from Cassandra. final FijiURI tableURI = FijiURI.newBuilder(mURI).withTableName(tableName).build(); final FijiTableLayout layout = mMetaTable.getTableLayout(tableName); final List<ResultSetFuture> futures = Lists.newArrayListWithCapacity(layout.getLocalityGroups().size()); for (LocalityGroupLayout localityGroup : layout.getLocalityGroups()) { final String delete = CQLUtils.getDropTableStatement( CassandraTableName.getLocalityGroupTableName(tableURI, localityGroup.getId())); futures.add(mAdmin.executeAsync(delete)); } // Delete from the meta table getMetaTable().deleteTable(tableName); for (ResultSetFuture future : futures) { future.getUninterruptibly(); } }
/** {@inheritDoc} */ @Override public void createTable(TableLayoutDesc tableLayout, byte[][] splitKeys) throws IOException { final State state = mState.get(); Preconditions.checkState(state == State.OPEN, "Cannot create table in Fiji instance %s in state %s.", this, state); final FijiURI tableURI = FijiURI.newBuilder(mURI).withTableName(tableLayout.getName()).build(); LOG.debug("Creating Fiji table '{}'.", tableURI); ensureValidationCompatibility(tableLayout); // If security is enabled, apply the permissions to the new table. if (isSecurityEnabled()) { getSecurityManager().lock(); try { createTableUnchecked(tableLayout, splitKeys); getSecurityManager().applyPermissionsToNewTable(tableURI); } finally { getSecurityManager().unlock(); } } else { createTableUnchecked(tableLayout, splitKeys); } }
/** {@inheritDoc} */ @Override public void createTable(final TableLayoutDesc tableLayout) throws IOException { final State state = mState.get(); Preconditions.checkState(state == State.OPEN, "Cannot create table in Fiji instance %s in state %s.", this, state); final FijiURI tableURI = FijiURI.newBuilder(mURI).withTableName(tableLayout.getName()).build(); LOG.debug("Creating Fiji table '{}'.", tableURI); ensureValidationCompatibility(tableLayout); // If security is enabled, apply the permissions to the new table. if (isSecurityEnabled()) { getSecurityManager().lock(); try { createTableUnchecked(tableLayout); getSecurityManager().applyPermissionsToNewTable(tableURI); } finally { getSecurityManager().unlock(); } } else { createTableUnchecked(tableLayout); } }
/** {@inheritDoc} */ @Deprecated @Override public void createTable(String tableName, FijiTableLayout tableLayout, byte[][] splitKeys) throws IOException { if (getMetaTable().tableExists(tableName)) { final FijiURI tableURI = FijiURI.newBuilder(mURI).withTableName(tableName).build(); throw new FijiAlreadyExistsException(String.format( "Fiji table '%s' already exists.", tableURI), tableURI); } if (!tableName.equals(tableLayout.getName())) { throw new RuntimeException(String.format( "Table name from layout descriptor '%s' does match table name '%s'.", tableLayout.getName(), tableName)); } createTable(tableLayout.getDesc(), splitKeys); }
/** {@inheritDoc} */ @Override public HBaseFijiTable openTable(String tableName) throws IOException { final State state = mState.get(); Preconditions.checkState(state == State.OPEN, "Cannot open table in Fiji instance %s in state %s.", this, state); if (!getTableNames().contains(tableName)) { throw new FijiTableNotFoundException( FijiURI.newBuilder(mURI).withTableName(tableName).build()); } return new HBaseFijiTable( this, tableName, mConf, mHTableFactory, mInstanceMonitor.getTableLayoutMonitor(tableName)); }
/** {@inheritDoc} */ @Override public void applyPermissionsToNewTable(FijiURI tableURI) throws IOException { // The argument must be for a table in the instance this manages. Preconditions.checkArgument( FijiURI.newBuilder(mInstanceUri).withTableName(tableURI.getTable()).build() .equals(tableURI)); for (FijiUser user : listAllUsers()) { grantHTablePermissions(user.getName(), FijiManagedHBaseTableName .getFijiTableName(tableURI.getInstance(), tableURI.getTable()).toBytes(), getPermissions(user).toHBaseActions()); } }
/** * Overridden to provide specific return type. * * {@inheritDoc} */ @Override public CassandraFijiURIBuilder withTableName(String tableName) { super.withTableName(tableName); return this; }
@Override /** {@inheritDoc} */ public TableLayoutMonitor apply(String tableName) { final FijiURI tableURI = FijiURI.newBuilder(mInstanceURI).withTableName(tableName).build(); try { return new DefaultTableLayoutMonitor(tableURI, mSchemaTable, mMetaTable, mZKClient).start(); } catch (IOException e) { throw new FijiIOException(e); } } }
/** * Overridden to provide specific return type. * * {@inheritDoc} */ @Override public HBaseFijiURIBuilder withTableName(String tableName) { super.withTableName(tableName); return this; }