use of com.linkedin.pinot.common.utils.TenantRole in project pinot by linkedin.
the class PinotTenantRestletResource method deleteTenant.
@HttpVerb("delete")
@Summary("Deletes a tenant")
@Tags({ "tenant" })
@Description("Deletes a tenant from the cluster")
@Paths({ "/tenants/{tenantName}", "/tenants/{tenantName}/" })
private StringRepresentation deleteTenant(@Parameter(name = "tenantName", in = "path", description = "The tenant id") String tenantName, @Parameter(name = "type", in = "query", description = "The type of tenant, either SERVER or BROKER", required = true) String type) {
StringRepresentation presentation;
if (type == null) {
presentation = new StringRepresentation("Not specify the type for the tenant name. Please try to append:" + "/?type=SERVER or /?type=BROKER ");
} else {
TenantRole tenantRole = TenantRole.valueOf(type.toUpperCase());
PinotResourceManagerResponse res = null;
switch(tenantRole) {
case BROKER:
if (_pinotHelixResourceManager.isBrokerTenantDeletable(tenantName)) {
res = _pinotHelixResourceManager.deleteBrokerTenantFor(tenantName);
} else {
res = new PinotResourceManagerResponse();
res.status = ResponseStatus.failure;
res.message = "Broker Tenant is not null, cannot delete it.";
}
break;
case SERVER:
if (_pinotHelixResourceManager.isServerTenantDeletable(tenantName)) {
res = _pinotHelixResourceManager.deleteOfflineServerTenantFor(tenantName);
if (res.isSuccessful()) {
res = _pinotHelixResourceManager.deleteRealtimeServerTenantFor(tenantName);
}
} else {
res = new PinotResourceManagerResponse();
res.status = ResponseStatus.failure;
res.message = "Server Tenant is not null, cannot delete it.";
}
break;
default:
break;
}
presentation = new StringRepresentation(res.toString());
}
return presentation;
}
Aggregations