Search in sources :

Example 1 with AddressJSON

use of io.hops.hopsworks.common.dela.AddressJSON in project hopsworks by logicalclocks.

the class TransferDelaController method getDelaPublicEndpoint.

public AddressJSON getDelaPublicEndpoint(String delaVersion) throws DelaException {
    String delaTransferHttpEndpoint = SettingsHelper.delaTransferHttpEndpoint(settings);
    try {
        ClientWrapper<AddressJSON> rc = ClientWrapper.httpInstance(AddressJSON.class).setTarget(delaTransferHttpEndpoint).setPath(TransferDela.CONTACT).setPayload(delaVersion);
        logger.log(Settings.DELA_DEBUG, "dela:contact {0}", rc.getFullPath());
        AddressJSON result = rc.doPost();
        logger.log(Settings.DELA_DEBUG, "dela:contact - done {0} {1}", new Object[] { rc.getFullPath(), result.getIp() });
        return result;
    } catch (IllegalStateException ise) {
        logger.log(Level.WARNING, "dela:contact - 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) DelaException(io.hops.hopsworks.exceptions.DelaException)

Example 2 with AddressJSON

use of io.hops.hopsworks.common.dela.AddressJSON in project hopsworks by logicalclocks.

the class DelaSetupWorker method getDelaTransferEndpoint.

private AddressJSON getDelaTransferEndpoint(String delaVersion) throws DelaException {
    String delaTransferHttpEndpoint = SettingsHelper.delaTransferHttpEndpoint(settings);
    LOGGER.log(Level.INFO, "{0} - dela http endpoint: {1}", new Object[] { DelaException.Source.HOPS_SITE, delaTransferHttpEndpoint });
    AddressJSON delaTransferEndpoint = delaCtrl.getDelaPublicEndpoint(delaVersion);
    LOGGER.log(Level.INFO, "{0} - dela transfer endpoint: {1}", new Object[] { DelaException.Source.HOPS_SITE, delaTransferEndpoint.toString() });
    return delaTransferEndpoint;
}
Also used : AddressJSON(io.hops.hopsworks.common.dela.AddressJSON)

Example 3 with AddressJSON

use of io.hops.hopsworks.common.dela.AddressJSON in project hopsworks by logicalclocks.

the class DelaSetupWorker method delaContact.

private void delaContact(Timer timer) {
    LOGGER.log(Level.INFO, "{0} - state:{1}", new Object[] { DelaException.Source.HOPS_SITE, state });
    AddressJSON delaTransferEndpoint;
    try {
        delaTransferEndpoint = SettingsHelper.delaTransferEndpoint(settings);
    } catch (DelaException tpe) {
        try {
            delaTransferEndpoint = getDelaTransferEndpoint(delaVersion);
            delaStateCtrl.transferDelaContacted();
            settings.setDELA_PUBLIC_ENDPOINT(delaTransferEndpoint);
            timer = resetToRegister(timer);
            hopsSiteRegister(timer, delaTransferEndpoint);
        } catch (DelaException tpe2) {
            LOGGER.log(Level.WARNING, "{0} - source:<{1}>:{2}", new Object[] { DelaException.Source.HOPS_SITE, tpe2.getSource(), tpe2.getMessage() });
            timer = tryAgainLater(timer);
        }
    }
}
Also used : AddressJSON(io.hops.hopsworks.common.dela.AddressJSON) DelaException(io.hops.hopsworks.exceptions.DelaException)

Example 4 with AddressJSON

use of io.hops.hopsworks.common.dela.AddressJSON in project hopsworks by logicalclocks.

the class DelaSetupWorker method hopsSiteRegister.

private void hopsSiteRegister(Timer timer) {
    LOGGER.log(Level.INFO, "{0} - state:{1}", new Object[] { DelaException.Source.HOPS_SITE, state });
    AddressJSON delaTransferEndpoint;
    try {
        delaTransferEndpoint = SettingsHelper.delaTransferEndpoint(settings);
    } catch (DelaException ex) {
        timer = resetToDelaContact(timer);
        return;
    }
    try {
        hopsSiteRegister(timer, delaTransferEndpoint);
    } catch (DelaException tpe) {
        LOGGER.log(Level.WARNING, "{0} - source:<{1}>:{2}", new Object[] { DelaException.Source.HOPS_SITE, tpe.getSource(), tpe.getMessage() });
        timer = tryAgainLater(timer);
    }
}
Also used : AddressJSON(io.hops.hopsworks.common.dela.AddressJSON) DelaException(io.hops.hopsworks.exceptions.DelaException)

Example 5 with AddressJSON

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

AddressJSON (io.hops.hopsworks.common.dela.AddressJSON)5 DelaException (io.hops.hopsworks.exceptions.DelaException)4 Gson (com.google.gson.Gson)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 LinkedList (java.util.LinkedList)1