Search in sources :

Example 1 with SuccessJSON

use of io.hops.hopsworks.dela.old_dto.SuccessJSON in project hopsworks by logicalclocks.

the class DelaProjectService method downloadDatasetHdfs.

@POST
@Path("/downloads/{publicDSId}/hdfs")
@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 downloadDatasetHdfs(@Context SecurityContext sc, @PathParam("publicDSId") String publicDSId, HopsworksTransferDTO.Download downloadDTO) throws DelaException {
    Users user = jWTHelper.getUserPrincipal(sc);
    Dataset dataset = getDatasetByPublicId(downloadDTO.getPublicDSId());
    delaWorkerCtrl.advanceDownload(project, dataset, user, downloadDTO, null, null);
    return successResponse(new SuccessJSON(""));
}
Also used : Dataset(io.hops.hopsworks.persistence.entity.dataset.Dataset) SuccessJSON(io.hops.hopsworks.dela.old_dto.SuccessJSON) Users(io.hops.hopsworks.persistence.entity.user.Users) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles)

Example 2 with SuccessJSON

use of io.hops.hopsworks.dela.old_dto.SuccessJSON in project hopsworks by logicalclocks.

the class TransferDelaController method advanceDownload.

public void advanceDownload(String publicDSId, HDFSEndpoint hdfsEndpoint, KafkaEndpoint kafkaEndpoint, ExtendedDetails details) throws DelaException {
    if (!delaStateController.transferDelaAvailable()) {
        throw new DelaException(RESTCodes.DelaErrorCode.DELA_TRANSFER_NOT_AVAILABLE, Level.SEVERE, DelaException.Source.LOCAL);
    }
    HopsTorrentAdvanceDownload reqContent = new HopsTorrentAdvanceDownload(new TorrentId(publicDSId), kafkaEndpoint, hdfsEndpoint, details);
    try {
        ClientWrapper<SuccessJSON> rc = ClientWrapper.httpInstance(SuccessJSON.class).setTarget(settings.getDELA_TRANSFER_HTTP_ENDPOINT()).setPath("torrent/hops/download/advance/xml").setPayload(reqContent);
        SuccessJSON result = rc.doPost();
    } catch (IllegalStateException ise) {
        logger.log(Level.WARNING, "dela communication fail:{0}", ise.getMessage());
        throw new DelaException(RESTCodes.DelaErrorCode.COMMUNICATION_FAILURE, Level.SEVERE, DelaException.Source.DELA, null, ise.getMessage(), ise);
    }
}
Also used : TorrentId(io.hops.hopsworks.dela.old_dto.TorrentId) SuccessJSON(io.hops.hopsworks.dela.old_dto.SuccessJSON) HopsTorrentAdvanceDownload(io.hops.hopsworks.dela.old_dto.HopsTorrentAdvanceDownload) DelaException(io.hops.hopsworks.exceptions.DelaException)

Example 3 with SuccessJSON

use of io.hops.hopsworks.dela.old_dto.SuccessJSON in project hopsworks by logicalclocks.

the class TransferDelaController method upload.

public void upload(String publicDSId, HopsDatasetDetailsDTO datasetDetails, HDFSResource resource, HDFSEndpoint endpoint) throws DelaException {
    if (!delaStateController.transferDelaAvailable()) {
        throw new DelaException(RESTCodes.DelaErrorCode.DELA_TRANSFER_NOT_AVAILABLE, Level.SEVERE, DelaException.Source.LOCAL);
    }
    logger.log(Settings.DELA_DEBUG, "{0} upload - transfer");
    HopsTorrentUpload reqContent = new HopsTorrentUpload(new TorrentId(publicDSId), datasetDetails.getDatasetName(), datasetDetails.getProjectId(), datasetDetails.getDatasetId(), resource, endpoint);
    try {
        ClientWrapper<SuccessJSON> rc = ClientWrapper.httpInstance(SuccessJSON.class).setTarget(settings.getDELA_TRANSFER_HTTP_ENDPOINT()).setPath("torrent/hops/upload/xml").setPayload(reqContent);
        SuccessJSON result = rc.doPost();
    } catch (IllegalStateException ise) {
        logger.log(Level.WARNING, "dela communication fail:{0}", ise.getMessage());
        throw new DelaException(RESTCodes.DelaErrorCode.COMMUNICATION_FAILURE, Level.SEVERE, DelaException.Source.DELA, null, ise.getMessage(), ise);
    }
}
Also used : TorrentId(io.hops.hopsworks.dela.old_dto.TorrentId) HopsTorrentUpload(io.hops.hopsworks.dela.old_dto.HopsTorrentUpload) SuccessJSON(io.hops.hopsworks.dela.old_dto.SuccessJSON) DelaException(io.hops.hopsworks.exceptions.DelaException)

Example 4 with SuccessJSON

use of io.hops.hopsworks.dela.old_dto.SuccessJSON in project hopsworks by logicalclocks.

the class TransferDelaController method cancel.

public void cancel(String publicDSId) throws DelaException {
    if (!delaStateController.transferDelaAvailable()) {
        throw new DelaException(RESTCodes.DelaErrorCode.DELA_TRANSFER_NOT_AVAILABLE, Level.SEVERE, DelaException.Source.LOCAL);
    }
    try {
        ClientWrapper<SuccessJSON> rc = ClientWrapper.httpInstance(SuccessJSON.class).setTarget(settings.getDELA_TRANSFER_HTTP_ENDPOINT()).setPath("torrent/hops/stop").setPayload(new TorrentId(publicDSId));
        SuccessJSON result = rc.doPost();
    } catch (IllegalStateException ise) {
        throw new DelaException(RESTCodes.DelaErrorCode.COMMUNICATION_FAILURE, Level.SEVERE, DelaException.Source.DELA, null, ise.getMessage(), ise);
    }
}
Also used : TorrentId(io.hops.hopsworks.dela.old_dto.TorrentId) SuccessJSON(io.hops.hopsworks.dela.old_dto.SuccessJSON) DelaException(io.hops.hopsworks.exceptions.DelaException)

Example 5 with SuccessJSON

use of io.hops.hopsworks.dela.old_dto.SuccessJSON in project hopsworks by logicalclocks.

the class TransferDelaController method startDownload.

public void startDownload(String publicDSId, HopsDatasetDetailsDTO datasetDetails, HDFSResource resource, HDFSEndpoint endpoint, List<ClusterAddressDTO> bootstrap) throws DelaException {
    if (!delaStateController.transferDelaAvailable()) {
        throw new DelaException(RESTCodes.DelaErrorCode.DELA_TRANSFER_NOT_AVAILABLE, Level.SEVERE, DelaException.Source.LOCAL);
    }
    List<AddressJSON> bootstrapAdr = new LinkedList<>();
    Gson gson = new Gson();
    for (ClusterAddressDTO b : bootstrap) {
        bootstrapAdr.add(gson.fromJson(b.getDelaTransferAddress(), AddressJSON.class));
    }
    HopsTorrentStartDownload reqContent = new HopsTorrentStartDownload(new TorrentId(publicDSId), datasetDetails.getDatasetName(), datasetDetails.getProjectId(), datasetDetails.getDatasetId(), resource, bootstrapAdr, endpoint);
    try {
        ClientWrapper<SuccessJSON> rc = ClientWrapper.httpInstance(SuccessJSON.class).setTarget(settings.getDELA_TRANSFER_HTTP_ENDPOINT()).setPath("torrent/hops/download/start/xml").setPayload(reqContent);
        SuccessJSON result = rc.doPost();
    } catch (IllegalStateException ise) {
        logger.log(Level.WARNING, "dela communication fail:{0}", ise.getMessage());
        throw new DelaException(RESTCodes.DelaErrorCode.COMMUNICATION_FAILURE, Level.SEVERE, DelaException.Source.DELA, null, ise.getMessage(), ise);
    }
}
Also used : AddressJSON(io.hops.hopsworks.common.dela.AddressJSON) ClusterAddressDTO(io.hops.hopsworks.dela.dto.common.ClusterAddressDTO) TorrentId(io.hops.hopsworks.dela.old_dto.TorrentId) HopsTorrentStartDownload(io.hops.hopsworks.dela.old_dto.HopsTorrentStartDownload) SuccessJSON(io.hops.hopsworks.dela.old_dto.SuccessJSON) Gson(com.google.gson.Gson) DelaException(io.hops.hopsworks.exceptions.DelaException) LinkedList(java.util.LinkedList)

Aggregations

SuccessJSON (io.hops.hopsworks.dela.old_dto.SuccessJSON)6 DelaException (io.hops.hopsworks.exceptions.DelaException)5 TorrentId (io.hops.hopsworks.dela.old_dto.TorrentId)4 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)2 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)2 Dataset (io.hops.hopsworks.persistence.entity.dataset.Dataset)2 Users (io.hops.hopsworks.persistence.entity.user.Users)2 Consumes (javax.ws.rs.Consumes)2 POST (javax.ws.rs.POST)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 Gson (com.google.gson.Gson)1 ServiceDiscoveryException (com.logicalclocks.servicediscoverclient.exceptions.ServiceDiscoveryException)1 AddressJSON (io.hops.hopsworks.common.dela.AddressJSON)1 ClusterAddressDTO (io.hops.hopsworks.dela.dto.common.ClusterAddressDTO)1 HopsTorrentAdvanceDownload (io.hops.hopsworks.dela.old_dto.HopsTorrentAdvanceDownload)1 HopsTorrentStartDownload (io.hops.hopsworks.dela.old_dto.HopsTorrentStartDownload)1 HopsTorrentUpload (io.hops.hopsworks.dela.old_dto.HopsTorrentUpload)1 KafkaEndpoint (io.hops.hopsworks.dela.old_dto.KafkaEndpoint)1 ServiceException (io.hops.hopsworks.exceptions.ServiceException)1