/** * Reports the ZooKeeper node path for a Fiji instance. * * @param fijiURI URI of a Fiji instance to report the ZooKeeper node path for. * @return the ZooKeeper node path for a Fiji instance. */ public static File getInstanceDir(FijiURI fijiURI) { return new File(INSTANCES_ZOOKEEPER_PATH, fijiURI.getInstance()); }
/** * Reports the ZooKeeper node path for a Fiji instance. * * @param fijiURI URI of a Fiji instance to report the ZooKeeper node path for. * @return the ZooKeeper node path for a Fiji instance. */ public static File getInstanceDir(FijiURI fijiURI) { return new File(INSTANCES_ZOOKEEPER_PATH, fijiURI.getInstance()); }
/** * Reports the path of the ZooKeeper node for schema table lock. * * @param instanceURI of schema table for which to retrieve lock directory. * @return the path of the ZooKeeper directory used to create locks for schema table. */ public static File getSchemaTableLock(FijiURI instanceURI) { return new File("/fiji/" + instanceURI.getInstance()); }
/** * Returns the name of the missing Fiji instance. * @return the name of the missing Fiji instance. */ public String getInstanceName() { if (mURI == null) { Preconditions.checkNotNull(mInstanceName != null); return mInstanceName; } else { return mURI.getInstance(); } } }
/** * Get the Cassandra keyspace (formatted for CQL) for a Fiji instance. * * @param instanceURI The URI of the Fiji instance. * @return The Cassandra keyspace of the instance. */ public static String getKeyspace(FijiURI instanceURI) { return appendCassandraKeyspace(new StringBuilder().append('"'), instanceURI.getInstance()) .append('"') .toString(); }
/** * Get the Cassandra table name of a Fiji schema hash table. * * @param fijiURI The name of the Fiji instance. * @return The name of the Cassandra table used to store the Fiji schema hash table. */ public static CassandraTableName getSchemaHashTableName(FijiURI fijiURI) { return new CassandraTableName(TableType.SCHEMA_HASH, fijiURI.getInstance()); }
/** * Get the Cassandra table name of a Fiji schema ID table. * * @param fijiURI The name of the Fiji instance. * @return The name of the Cassandra table used to store the Fiji schema IDs table. */ public static CassandraTableName getSchemaIdTableName(FijiURI fijiURI) { return new CassandraTableName(TableType.SCHEMA_ID, fijiURI.getInstance()); }
/** * Get the name of the Cassandra keyspace for a Fiji instance. * * @param instanceURI The URI of the Fiji instance. * @return The Cassandra keyspace. */ public static String getUnquotedKeyspace(FijiURI instanceURI) { return appendCassandraKeyspace(new StringBuilder(), instanceURI.getInstance()).toString(); }
/** * Get the Cassandra table name of a Fiji meta able. * * @param fijiURI The name of the Fiji instance. * @return The name of the Cassandra table used to store the Fiji meta table. */ public static CassandraTableName getMetaLayoutTableName(FijiURI fijiURI) { return new CassandraTableName(TableType.META_LAYOUT, fijiURI.getInstance()); }
/** * Get the Cassandra table name of a Fiji meta key-value table. * * @param fijiURI The name of the Fiji instance. * @return The name of the Cassandra table used to store the Fiji meta key-value table. */ public static CassandraTableName getMetaKeyValueTableName(FijiURI fijiURI) { return new CassandraTableName(TableType.META_KEY_VALUE, fijiURI.getInstance()); }
/** * Get the Cassandra table name of a Fiji schema counter table. * * @param fijiURI The name of the Fiji instance. * @return The name of the Cassandra table used to store the Fiji schema IDs counter table. */ public static CassandraTableName getSchemaCounterTableName(FijiURI fijiURI) { return new CassandraTableName(TableType.SCHEMA_COUNTER, fijiURI.getInstance()); }
/** * Get the Cassandra table name of a Fiji system table. * * @param fijiURI The name of the Fiji instance. * @return The name of the Cassandra table used to store the Fiji system table. */ public static CassandraTableName getSystemTableName(FijiURI fijiURI) { return new CassandraTableName(TableType.SYSTEM, fijiURI.getInstance()); }
/** {@inheritDoc} */ @Override protected void setup() throws Exception { Preconditions.checkArgument((mFijiURIFlag != null) && !mFijiURIFlag.isEmpty(), "Specify the Fiji instance to uninstall with --fiji=fiji://hbase-address/fiji-instance"); mFijiURI = FijiURI.newBuilder(mFijiURIFlag).build(); Preconditions.checkArgument(mFijiURI.getInstance() != null, "Specify the Fiji instance to uninstall with --fiji=fiji://hbase-address/fiji-instance"); }
/** {@inheritDoc} */ @Override protected void setup() throws Exception { super.setup(); Preconditions.checkArgument((mFijiURIFlag != null) && !mFijiURIFlag.isEmpty(), "Specify the Fiji instance to install with --fiji=fiji://hbase-address/fiji-instance"); mFijiURI = FijiURI.newBuilder(mFijiURIFlag).build(); Preconditions.checkArgument(mFijiURI.getInstance() != null, "Specify the Fiji instance to install with --fiji=fiji://hbase-address/fiji-instance"); }
/** {@inheritDoc} */ @Override protected void setup() throws Exception { super.setup(); Preconditions.checkArgument((mFijiURIFlag != null) && !mFijiURIFlag.isEmpty(), "Specify the Fiji instance to uninstall with --fiji=fiji://hbase-address/fiji-instance"); mFijiURI = FijiURI.newBuilder(mFijiURIFlag).build(); Preconditions.checkArgument(mFijiURI.getInstance() != null, "Specify the Fiji instance to uninstall with --fiji=fiji://hbase-address/fiji-instance"); }
/** {@inheritDoc} */ @Override protected int run(List<String> nonFlagArgs) throws Exception { if (mFlushMeta) { getPrintStream().println("Flushing metadata tables for fiji instance: " + mTargetURI.toString()); flushMetaTables(mHBaseAdmin, mTargetURI.getInstance()); } if (null != mTargetURI) { getPrintStream().printf("Flushing table '%s'.%n", mTargetURI); flushTable(mHBaseAdmin, mTargetURI); } getPrintStream().println("Flush operations successfully enqueued."); return 0; }
/** * Removes the meta table from HBase. * * @param admin The HBase admin object. * @param uri The uri of the Fiji instance to uninstall. * @throws IOException If there is an error. */ public static void uninstall(HBaseAdmin admin, FijiURI uri) throws IOException { String tableName = FijiManagedHBaseTableName.getMetaTableName(uri.getInstance()).toString(); admin.disableTable(tableName); admin.deleteTable(tableName); }
/** * Disables and delete the system table from HBase. * * @param admin The HBase admin object. * @param fijiURI The URI for the fiji instance to remove. * @throws IOException If there is an error. */ public static void uninstall(HBaseAdmin admin, FijiURI fijiURI) throws IOException { final String tableName = FijiManagedHBaseTableName.getSystemTableName(fijiURI.getInstance()).toString(); admin.disableTable(tableName); admin.deleteTable(tableName); }
/** * Flushes a fiji table with the name 'tableName'. * * @param hbaseAdmin An hbase admin utility. * @param tableURI URI of the Fiji table to flush. * @throws IOException If there is an error. * @throws InterruptedException If the thread is interrupted. */ private static void flushTable(HBaseAdmin hbaseAdmin, FijiURI tableURI) throws IOException, InterruptedException { final FijiManagedHBaseTableName hbaseTableName = FijiManagedHBaseTableName.getFijiTableName(tableURI.getInstance(), tableURI.getTable()); hbaseAdmin.flush(hbaseTableName.toString()); }
/** {@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()); } }