use of io.hops.hopsworks.dela.old_dto.KafkaEndpoint in project hopsworks by logicalclocks.
the class DelaProjectService method downloadDatasetKafka.
@POST
@Path("/downloads/{publicDSId}/kafka")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_SCIENTIST, AllowedProjectRoles.DATA_OWNER })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response downloadDatasetKafka(@Context HttpServletRequest req, @Context SecurityContext sc, @PathParam("publicDSId") String publicDSId, HopsworksTransferDTO.Download downloadDTO) throws DelaException, ServiceException {
Users user = jWTHelper.getUserPrincipal(sc);
Dataset dataset = getDatasetByPublicId(publicDSId);
String certPath = kafkaController.getKafkaCertPaths(project);
Optional<String> kafkaBrokerOpt = kafkaBrokers.getAnyKafkaBroker();
String brokerEndpoint = kafkaBrokerOpt.orElseThrow(() -> new DelaException(RESTCodes.DelaErrorCode.MISCONFIGURED, Level.WARNING, DelaException.Source.KAFKA, "Could not find any active Kafka broker"));
String restEndpoint;
try {
restEndpoint = "https://" + serviceDiscoveryController.constructServiceFQDNWithPort(ServiceDiscoveryController.HopsworksService.HOPSWORKS_APP);
} catch (ServiceDiscoveryException e) {
throw new ServiceException(RESTCodes.ServiceErrorCode.SERVICE_NOT_FOUND, Level.SEVERE, "Could not find Hopsworks service");
}
String keyStore = certPath + "/keystore.jks";
String trustStore = certPath + "/truststore.jks";
KafkaEndpoint kafkaEndpoint = new KafkaEndpoint(brokerEndpoint, restEndpoint, settings.getDELA_DOMAIN(), "" + project.getId(), keyStore, trustStore);
delaWorkerCtrl.advanceDownload(project, dataset, user, downloadDTO, req.getSession().getId(), kafkaEndpoint);
return successResponse(new SuccessJSON(""));
}
Aggregations