@Override public CompletableFuture<SpaceQuotaSnapshot> getCurrentSpaceQuotaSnapshot(String namespace) { return getCurrentSpaceQuotaSnapshot(resp -> resp.getNsSnapshotsList().stream() .filter(s -> s.getNamespace().equals(namespace)).findFirst() .map(s -> SpaceQuotaSnapshot.toSpaceQuotaSnapshot(s.getSnapshot())).orElse(null)); }
@Override public CompletableFuture<SpaceQuotaSnapshot> getCurrentSpaceQuotaSnapshot(TableName tableName) { HBaseProtos.TableName protoTableName = ProtobufUtil.toProtoTableName(tableName); return getCurrentSpaceQuotaSnapshot(resp -> resp.getTableSnapshotsList().stream() .filter(s -> s.getTableName().equals(protoTableName)).findFirst() .map(s -> SpaceQuotaSnapshot.toSpaceQuotaSnapshot(s.getSnapshot())).orElse(null)); }
@Override public Map<TableName, SpaceQuotaSnapshot> getRegionServerSpaceQuotaSnapshots( ServerName serverName) throws IOException { final AdminService.BlockingInterface admin = this.connection.getAdmin(serverName); Callable<GetSpaceQuotaSnapshotsResponse> callable = new Callable<GetSpaceQuotaSnapshotsResponse>() { @Override public GetSpaceQuotaSnapshotsResponse call() throws Exception { return admin.getSpaceQuotaSnapshots(rpcControllerFactory.newController(), RequestConverter.buildGetSpaceQuotaSnapshotsRequest()); } }; GetSpaceQuotaSnapshotsResponse resp = ProtobufUtil.call(callable); Map<TableName, SpaceQuotaSnapshot> snapshots = new HashMap<>(); for (TableQuotaSnapshot snapshot : resp.getSnapshotsList()) { snapshots.put(ProtobufUtil.toTableName(snapshot.getTableName()), SpaceQuotaSnapshot.toSpaceQuotaSnapshot(snapshot.getSnapshot())); } return snapshots; }
try { QuotaProtos.SpaceQuotaSnapshot snapshot = QuotaProtos.SpaceQuotaSnapshot.parseFrom(buffer); snapshots.put(targetTableName, SpaceQuotaSnapshot.toSpaceQuotaSnapshot(snapshot)); } catch (InvalidProtocolBufferException e) { throw new IllegalArgumentException(
@Override protected SpaceQuotaSnapshot rpcCall() throws Exception { GetQuotaStatesResponse resp = master.getQuotaStates(getRpcController(), RequestConverter.buildGetQuotaStatesRequest()); for (GetQuotaStatesResponse.NamespaceQuotaSnapshot nsSnapshot : resp .getNsSnapshotsList()) { if (namespace.equals(nsSnapshot.getNamespace())) { return SpaceQuotaSnapshot.toSpaceQuotaSnapshot(nsSnapshot.getSnapshot()); } } return null; } });
@Override public CompletableFuture<Map<TableName, SpaceQuotaSnapshot>> getRegionServerSpaceQuotaSnapshots( ServerName serverName) { return this.<Map<TableName, SpaceQuotaSnapshot>> newAdminCaller() .action((controller, stub) -> this .<GetSpaceQuotaSnapshotsRequest, GetSpaceQuotaSnapshotsResponse, Map<TableName, SpaceQuotaSnapshot>> adminCall(controller, stub, RequestConverter.buildGetSpaceQuotaSnapshotsRequest(), (s, c, req, done) -> s.getSpaceQuotaSnapshots(controller, req, done), resp -> resp.getSnapshotsList().stream() .collect(Collectors.toMap(snapshot -> ProtobufUtil.toTableName(snapshot.getTableName()), snapshot -> SpaceQuotaSnapshot.toSpaceQuotaSnapshot(snapshot.getSnapshot()))))) .serverName(serverName).call(); }
@Override protected SpaceQuotaSnapshot rpcCall() throws Exception { GetQuotaStatesResponse resp = master.getQuotaStates(getRpcController(), RequestConverter.buildGetQuotaStatesRequest()); HBaseProtos.TableName protoTableName = ProtobufUtil.toProtoTableName(tableName); for (GetQuotaStatesResponse.TableQuotaSnapshot tableSnapshot : resp .getTableSnapshotsList()) { if (protoTableName.equals(tableSnapshot.getTableName())) { return SpaceQuotaSnapshot.toSpaceQuotaSnapshot(tableSnapshot.getSnapshot()); } } return null; } });
/** * Returns the Master's view of a quota on the given {@code namespace} or null if the * Master has no quota information on that namespace. */ public static SpaceQuotaSnapshot getCurrentSnapshot( Connection conn, String namespace) throws IOException { if (!(conn instanceof ClusterConnection)) { throw new IllegalArgumentException("Expected a ClusterConnection"); } ClusterConnection clusterConn = (ClusterConnection) conn; GetQuotaStatesResponse resp = QuotaStatusCalls.getMasterQuotaStates(clusterConn, 0); for (GetQuotaStatesResponse.NamespaceQuotaSnapshot nsSnapshot : resp.getNsSnapshotsList()) { if (namespace.equals(nsSnapshot.getNamespace())) { return SpaceQuotaSnapshot.toSpaceQuotaSnapshot(nsSnapshot.getSnapshot()); } } return null; }
/** * Fetches the observed {@link SpaceQuotaSnapshot}s observed by a RegionServer. */ public static Map<TableName,SpaceQuotaSnapshot> getRegionServerQuotaSnapshots( Connection conn, ServerName regionServer) throws IOException { if (!(conn instanceof ClusterConnection)) { throw new IllegalArgumentException("Expected a ClusterConnection"); } ClusterConnection clusterConn = (ClusterConnection) conn; GetSpaceQuotaSnapshotsResponse response = QuotaStatusCalls.getRegionServerQuotaSnapshot( clusterConn, 0, regionServer); Map<TableName,SpaceQuotaSnapshot> snapshots = new HashMap<>(); for (TableQuotaSnapshot snapshot : response.getSnapshotsList()) { snapshots.put( ProtobufUtil.toTableName(snapshot.getTableName()), SpaceQuotaSnapshot.toSpaceQuotaSnapshot(snapshot.getSnapshot())); } return snapshots; }
try { QuotaProtos.SpaceQuotaSnapshot snapshot = QuotaProtos.SpaceQuotaSnapshot.parseFrom(buffer); snapshots.put(targetTableName, SpaceQuotaSnapshot.toSpaceQuotaSnapshot(snapshot)); } catch (InvalidProtocolBufferException e) { throw new IllegalArgumentException(
/** * Returns the Master's view of a quota on the given {@code tableName} or null if the * Master has no quota information on that table. */ public static SpaceQuotaSnapshot getCurrentSnapshot( Connection conn, TableName tn) throws IOException { if (!(conn instanceof ClusterConnection)) { throw new IllegalArgumentException("Expected a ClusterConnection"); } ClusterConnection clusterConn = (ClusterConnection) conn; GetQuotaStatesResponse resp = QuotaStatusCalls.getMasterQuotaStates(clusterConn, 0); HBaseProtos.TableName protoTableName = ProtobufUtil.toProtoTableName(tn); for (GetQuotaStatesResponse.TableQuotaSnapshot tableSnapshot : resp.getTableSnapshotsList()) { if (protoTableName.equals(tableSnapshot.getTableName())) { return SpaceQuotaSnapshot.toSpaceQuotaSnapshot(tableSnapshot.getSnapshot()); } } return null; }
/** * Fetches the observed {@link SpaceQuotaSnapshot}s observed by a RegionServer. */ public static Map<TableName,SpaceQuotaSnapshot> getRegionServerQuotaSnapshots( Connection conn, ServerName regionServer) throws IOException { if (!(conn instanceof ClusterConnection)) { throw new IllegalArgumentException("Expected a ClusterConnection"); } ClusterConnection clusterConn = (ClusterConnection) conn; GetSpaceQuotaSnapshotsResponse response = QuotaStatusCalls.getRegionServerQuotaSnapshot( clusterConn, 0, regionServer); Map<TableName,SpaceQuotaSnapshot> snapshots = new HashMap<>(); for (TableQuotaSnapshot snapshot : response.getSnapshotsList()) { snapshots.put( ProtobufUtil.toTableName(snapshot.getTableName()), SpaceQuotaSnapshot.toSpaceQuotaSnapshot(snapshot.getSnapshot())); } return snapshots; }
/** * Returns the Master's view of a quota on the given {@code namespace} or null if the * Master has no quota information on that namespace. */ public static SpaceQuotaSnapshot getCurrentSnapshot( Connection conn, String namespace) throws IOException { if (!(conn instanceof ClusterConnection)) { throw new IllegalArgumentException("Expected a ClusterConnection"); } ClusterConnection clusterConn = (ClusterConnection) conn; GetQuotaStatesResponse resp = QuotaStatusCalls.getMasterQuotaStates(clusterConn, 0); for (GetQuotaStatesResponse.NamespaceQuotaSnapshot nsSnapshot : resp.getNsSnapshotsList()) { if (namespace.equals(nsSnapshot.getNamespace())) { return SpaceQuotaSnapshot.toSpaceQuotaSnapshot(nsSnapshot.getSnapshot()); } } return null; }
try { QuotaProtos.SpaceQuotaSnapshot snapshot = QuotaProtos.SpaceQuotaSnapshot.parseFrom(buffer); snapshots.put(targetTableName, SpaceQuotaSnapshot.toSpaceQuotaSnapshot(snapshot)); } catch (InvalidProtocolBufferException e) { throw new IllegalArgumentException(
/** * Returns the Master's view of a quota on the given {@code tableName} or null if the * Master has no quota information on that table. */ public static SpaceQuotaSnapshot getCurrentSnapshot( Connection conn, TableName tn) throws IOException { if (!(conn instanceof ClusterConnection)) { throw new IllegalArgumentException("Expected a ClusterConnection"); } ClusterConnection clusterConn = (ClusterConnection) conn; GetQuotaStatesResponse resp = QuotaStatusCalls.getMasterQuotaStates(clusterConn, 0); HBaseProtos.TableName protoTableName = ProtobufUtil.toProtoTableName(tn); for (GetQuotaStatesResponse.TableQuotaSnapshot tableSnapshot : resp.getTableSnapshotsList()) { if (protoTableName.equals(tableSnapshot.getTableName())) { return SpaceQuotaSnapshot.toSpaceQuotaSnapshot(tableSnapshot.getSnapshot()); } } return null; }