Skip to content

Commit

Permalink
fixes InstanceOperationsIT (#5150)
Browse files Browse the repository at this point in the history
The test was failing because of a change in exceptions thrown.  Made the
impl code throw the expected exception and made it fail faster.
  • Loading branch information
keith-turner authored Dec 9, 2024
1 parent 3f81bc3 commit 10a960c
Showing 1 changed file with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,18 +278,23 @@ public List<ActiveScan> getActiveScans(String tserver)
@Override
public List<ActiveScan> getActiveScans(Collection<ServerId> servers)
throws AccumuloException, AccumuloSecurityException {
servers.forEach(InstanceOperationsImpl::checkActiveScanServer);
return queryServers(servers, this::getActiveScans, INSTANCE_OPS_SCANS_FINDER_POOL);
}

private List<ActiveScan> getActiveScans(ServerId server)
throws AccumuloException, AccumuloSecurityException {

private static void checkActiveScanServer(ServerId server) {
Objects.requireNonNull(server);
Preconditions.checkArgument(
server.getType() == ServerId.Type.SCAN_SERVER
|| server.getType() == ServerId.Type.TABLET_SERVER,
"Server type %s is not %s or %s.", server.getType(), ServerId.Type.SCAN_SERVER,
ServerId.Type.TABLET_SERVER);
}

private List<ActiveScan> getActiveScans(ServerId server)
throws AccumuloException, AccumuloSecurityException {

checkActiveScanServer(server);

final var parsedTserver = HostAndPort.fromParts(server.getHost(), server.getPort());
TabletScanClientService.Client rpcClient = null;
Expand Down Expand Up @@ -335,12 +340,7 @@ public List<ActiveCompaction> getActiveCompactions(String server)
private List<ActiveCompaction> getActiveCompactions(ServerId server)
throws AccumuloException, AccumuloSecurityException {

Objects.requireNonNull(server);
Preconditions.checkArgument(
server.getType() == ServerId.Type.COMPACTOR
|| server.getType() == ServerId.Type.TABLET_SERVER,
"Server type %s is not %s or %s.", server.getType(), ServerId.Type.COMPACTOR,
ServerId.Type.TABLET_SERVER);
checkActiveCompactionServer(server);

final HostAndPort serverHostAndPort = HostAndPort.fromParts(server.getHost(), server.getPort());
final List<ActiveCompaction> as = new ArrayList<>();
Expand Down Expand Up @@ -371,6 +371,13 @@ private List<ActiveCompaction> getActiveCompactions(ServerId server)
}
}

private static void checkActiveCompactionServer(ServerId server) {
Objects.requireNonNull(server);
Preconditions.checkArgument(
server.getType() == Type.COMPACTOR || server.getType() == Type.TABLET_SERVER,
"Server type %s is not %s or %s.", server.getType(), Type.COMPACTOR, Type.TABLET_SERVER);
}

@Override
@Deprecated
public List<ActiveCompaction> getActiveCompactions()
Expand All @@ -386,6 +393,7 @@ public List<ActiveCompaction> getActiveCompactions()
@Override
public List<ActiveCompaction> getActiveCompactions(Collection<ServerId> compactionServers)
throws AccumuloException, AccumuloSecurityException {
compactionServers.forEach(InstanceOperationsImpl::checkActiveCompactionServer);
return queryServers(compactionServers, this::getActiveCompactions,
INSTANCE_OPS_COMPACTIONS_FINDER_POOL);
}
Expand Down

0 comments on commit 10a960c

Please sign in to comment.