public static TableState getTableState(ClientContext context, Table.ID tableId) { return getTableState(context, tableId, false); }
public static boolean isOnline(AccumuloClient client) { return Tables.getTableState((ClientContext) client, ID) == TableState.ONLINE; }
private void checkOffline(ClientContext context) throws Exception { if (Tables.getTableState(context, tableInfo.tableID) != TableState.OFFLINE) { Tables.clearCache(context); if (Tables.getTableState(context, tableInfo.tableID) != TableState.OFFLINE) { throw new AcceptableThriftTableOperationException(tableInfo.tableID.canonicalID(), tableInfo.tableName, TableOperation.EXPORT, TableOperationExceptionType.OTHER, "Table is not offline"); } } }
private boolean isTableDeleting() { try { return Tables.getTableState(tabletServer.getContext(), extent.getTableId()) == TableState.DELETING; } catch (Exception e) { log.warn("Failed to determine if table " + extent.getTableId() + " was deleting ", e); return false; // can not get positive confirmation that its deleting. } }
Table.ID getTableId(String tableName) throws TableNotFoundException { Table.ID tableId = Tables.getTableId(this, tableName); if (Tables.getTableState(this, tableId) == TableState.OFFLINE) throw new TableOfflineException(Tables.getTableOfflineMsg(this, tableId)); return tableId; }
if (!Tables.exists(context, tableId)) throw new TableDeletedException(tableId.canonicalID()); else if (Tables.getTableState(context, tableId) == TableState.OFFLINE) throw new TableOfflineException(Tables.getTableOfflineMsg(context, tableId));
@Override public void online(String tableName, boolean wait) throws AccumuloSecurityException, AccumuloException, TableNotFoundException { checkArgument(tableName != null, "tableName is null"); Table.ID tableId = Tables.getTableId(context, tableName); /** * ACCUMULO-4574 if table is already online return without executing fate operation. */ TableState expectedState = Tables.getTableState(context, tableId, true); if (expectedState == TableState.ONLINE) { if (wait) waitForTableStateTransition(tableId, TableState.ONLINE); return; } List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.getUtf8())); Map<String,String> opts = new HashMap<>(); try { doTableFateOperation(tableName, TableNotFoundException.class, FateOperation.TABLE_ONLINE, args, opts); } catch (TableExistsException e) { // should not happen throw new AssertionError(e); } if (wait) waitForTableStateTransition(tableId, TableState.ONLINE); }
private void queue(List<QCMutation> mutations) { List<QCMutation> failures = new ArrayList<>(); Map<String,TabletServerMutations<QCMutation>> binnedMutations = new HashMap<>(); try { locator.binMutations(context, mutations, binnedMutations, failures); if (failures.size() == mutations.size()) if (!Tables.exists(context, tableId)) throw new TableDeletedException(tableId.canonicalID()); else if (Tables.getTableState(context, tableId) == TableState.OFFLINE) throw new TableOfflineException(Tables.getTableOfflineMsg(context, tableId)); } catch (Exception e) { for (QCMutation qcm : mutations) qcm.queueResult(new Result(e, qcm, null)); // do not want to queue anything that was put in before binMutations() failed failures.clear(); binnedMutations.clear(); } if (failures.size() > 0) queueRetry(failures, null); for (Entry<String,TabletServerMutations<QCMutation>> entry : binnedMutations.entrySet()) { queue(entry.getKey(), entry.getValue()); } }
@Override public int getNumFilesPendingReplication() { if (TableState.ONLINE != Tables.getTableState(master.getContext(), ReplicationTable.ID)) { return 0; } // Get all of the configured replication peers Map<String,String> peers = replicationUtil.getPeers(); // A quick lookup to see if have any replication peer configured if (peers.isEmpty()) { return 0; } // The total set of configured targets Set<ReplicationTarget> allConfiguredTargets = replicationUtil.getReplicationTargets(); // Number of files per target we have to replicate Map<ReplicationTarget,Long> targetCounts = replicationUtil.getPendingReplications(); int filesPending = 0; // Sum pending replication over all targets for (ReplicationTarget configuredTarget : allConfiguredTargets) { Long numFiles = targetCounts.get(configuredTarget); if (numFiles != null) { filesPending += numFiles; } } return filesPending; }
bulkInfo.tableState = Tables.getTableState(master.getContext(), bulkInfo.tableId);
public void mustBeOnline(final Table.ID tableId) throws ThriftTableOperationException { Tables.clearCache(context); if (!Tables.getTableState(context, tableId).equals(TableState.ONLINE)) throw new ThriftTableOperationException(tableId.canonicalID(), null, TableOperation.MERGE, TableOperationExceptionType.OFFLINE, "table is not online"); }
if (!Tables.exists(context, tableId)) throw new TableDeletedException(tableId.canonicalID()); if (Tables.getTableState(context, tableId) == TableState.OFFLINE) throw new TableOfflineException(Tables.getTableOfflineMsg(context, tableId));
if (!Tables.exists(context, entry.getKey())) throw new TableDeletedException(entry.getKey().canonicalID()); else if (Tables.getTableState(context, tableId) == TableState.OFFLINE) throw new TableOfflineException( Tables.getTableOfflineMsg(context, entry.getKey()));
@Override public long isReady(long tid, Master master) throws Exception { if (!Utils.getReadLock(master, tableId, tid).tryLock()) return 100; Tables.clearCache(master.getContext()); if (Tables.getTableState(master.getContext(), tableId) == TableState.ONLINE) { long reserve1, reserve2; reserve1 = reserve2 = Utils.reserveHdfsDirectory(master, sourceDir, tid); if (reserve1 == 0) reserve2 = Utils.reserveHdfsDirectory(master, errorDir, tid); return reserve2; } else { throw new AcceptableThriftTableOperationException(tableId.canonicalID(), null, TableOperation.BULK_IMPORT, TableOperationExceptionType.OFFLINE, null); } }
protected void snapshot() { // Only add these metrics if the replication table is online and there are peers if (TableState.ONLINE == Tables.getTableState(master.getContext(), ReplicationTable.ID) && !replicationUtil.getPeers().isEmpty()) { registry.add(PENDING_FILES, getNumFilesPendingReplication()); addReplicationQueueTimeMetrics(); } else { registry.add(PENDING_FILES, 0); } registry.add(NUM_PEERS, getNumConfiguredPeers()); registry.add(MAX_REPLICATION_THREADS, getMaxReplicationThreads()); }
if (Tables.getTableState(context, tableId) == TableState.OFFLINE) throw new TableOfflineException(Tables.getTableOfflineMsg(context, tableId));
if (Tables.getTableState(context, tableId) != TableState.OFFLINE) { Tables.clearCache(context); if (Tables.getTableState(context, tableId) != TableState.OFFLINE) { throw new AccumuloException("Table is online " + tableId + " cannot scan tablet in offline mode " + tablet.getExtent());
&& Tables.getTableState(master.getContext(), tableId) == TableState.OFFLINE) throw new AcceptableThriftTableOperationException(tableId.canonicalID(), null, TableOperation.COMPACT, TableOperationExceptionType.OFFLINE, null);
if (!Tables.exists(context, tableId)) throw new TableNotFoundException(tableId.canonicalID(), tableName, null); else if (Tables.getTableState(context, tableId) == TableState.OFFLINE) throw new TableOfflineException(Tables.getTableOfflineMsg(context, tableId)); continue;
@Override public List<Summary> retrieve() throws AccumuloException, AccumuloSecurityException, TableNotFoundException { Table.ID tableId = Tables.getTableId(context, tableName); if (Tables.getTableState(context, tableId) == TableState.OFFLINE) throw new TableOfflineException(Tables.getTableOfflineMsg(context, tableId)); TRowRange range = new TRowRange(TextUtil.getByteBuffer(startRow), TextUtil.getByteBuffer(endRow)); TSummaryRequest request = new TSummaryRequest(tableId.canonicalID(), range, summariesToFetch, summarizerClassRegex); if (flush) { _flush(tableId, startRow, endRow, true); } TSummaries ret = ServerClient.execute(context, new TabletClientService.Client.Factory(), client -> { TSummaries tsr = client.startGetSummaries(Tracer.traceInfo(), context.rpcCreds(), request); while (!tsr.finished) { tsr = client.contiuneGetSummaries(Tracer.traceInfo(), tsr.sessionId); } return tsr; }); return new SummaryCollection(ret).getSummaries(); }