Search in sources :

Example 1 with ClusterAddressDTO

use of io.hops.hopsworks.dela.dto.common.ClusterAddressDTO 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

Gson (com.google.gson.Gson)1 AddressJSON (io.hops.hopsworks.common.dela.AddressJSON)1 ClusterAddressDTO (io.hops.hopsworks.dela.dto.common.ClusterAddressDTO)1 HopsTorrentStartDownload (io.hops.hopsworks.dela.old_dto.HopsTorrentStartDownload)1 SuccessJSON (io.hops.hopsworks.dela.old_dto.SuccessJSON)1 TorrentId (io.hops.hopsworks.dela.old_dto.TorrentId)1 DelaException (io.hops.hopsworks.exceptions.DelaException)1 LinkedList (java.util.LinkedList)1