/** * Ensures that a given table/family pair really exists. * <p> * It's recommended to call this method in the startup code of your * application if you know ahead of time which tables / families you're * going to need, because it'll allow you to "fail fast" if they're missing. * <p> * @param table The name of the table you intend to use. * @param family The column family you intend to use in that table. * @return A deferred object that indicates the completion of the request. * The {@link Object} has not special meaning and can be {@code null} * (think of it as {@code Deferred<Void>}). But you probably want to attach * at least an errback to this {@code Deferred} to handle failures. * @throws TableNotFoundException (deferred) if the table doesn't exist. * @throws NoSuchColumnFamilyException (deferred) if the family doesn't exist. */ public Deferred<Object> ensureTableFamilyExists(final byte[] table, final byte[] family) { // Just "fault in" the first region of the table. Not the most optimal or // useful thing to do but gets the job done for now. TODO(tsuna): Improve. final HBaseRpc dummy; if (family == EMPTY_ARRAY) { dummy = GetRequest.exists(table, probeKey(ZERO_ARRAY)); } else { dummy = GetRequest.exists(table, probeKey(ZERO_ARRAY), family); } @SuppressWarnings("unchecked") final Deferred<Object> d = (Deferred) sendRpcToRegion(dummy); return d; }
exists_rpc = GetRequest.exists(rpc.table, probeKey(rpc.key)); newlist.add(exists_rpc); if (can_retry_rpc) { got_nsre.putIfAbsent(region_name, nsred_rpcs); if (added == null) { // We've just put `nsred_rpcs'. exists_rpc = GetRequest.exists(rpc.table, probeKey(rpc.key)); + " an empty list of NSRE'd RPCs (" + added + ") for " + Bytes.pretty(region_name)); exists_rpc = GetRequest.exists(rpc.table, probeKey(rpc.key)); added.add(exists_rpc); } else {