Search in sources :

Example 11 with DelaException

use of io.hops.hopsworks.exceptions.DelaException in project hopsworks by logicalclocks.

the class HopssiteController method removeComment.

public void removeComment(String publicCId, String publicDSId, Integer commentId, String userEmail) throws DelaException {
    checkHopssiteReady();
    try {
        ClientWrapper client = getClient(HopsSite.CommentService.removeComment(publicCId, publicDSId, commentId), String.class).setPayload(userEmail);
        LOG.log(Settings.DELA_DEBUG, "hops-site:comment:remove {0}", client.getFullPath());
        client.doPost();
        LOG.log(Settings.DELA_DEBUG, "hops-site:comment:remove - done {0}", client.getFullPath());
    } catch (IllegalStateException ise) {
        throw new DelaException(RESTCodes.DelaErrorCode.COMMUNICATION_FAILURE, Level.SEVERE, DelaException.Source.HOPS_SITE, null, ise.getMessage(), ise);
    }
}
Also used : DelaException(io.hops.hopsworks.exceptions.DelaException) ClientWrapper(io.hops.hopsworks.common.util.ClientWrapper)

Example 12 with DelaException

use of io.hops.hopsworks.exceptions.DelaException 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 13 with DelaException

use of io.hops.hopsworks.exceptions.DelaException 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 14 with DelaException

use of io.hops.hopsworks.exceptions.DelaException 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 15 with DelaException

use of io.hops.hopsworks.exceptions.DelaException in project hopsworks by logicalclocks.

the class HopssiteController method page.

public SearchServiceDTO.Item[] page(String sessionId, int startItem, int nrItems) throws DelaException {
    checkHopssiteReady();
    try {
        ClientWrapper client = getClient(HopsSite.DatasetService.searchPage(sessionId, startItem, nrItems), String.class);
        LOG.log(Settings.DELA_DEBUG, "hops-site:dataset - {0}", client.getFullPath());
        String auxResult = (String) client.doGet();
        SearchServiceDTO.Item[] result = new Gson().fromJson(auxResult, SearchServiceDTO.Item[].class);
        LOG.log(Settings.DELA_DEBUG, "hops-site:dataset:done - {0}", client.getFullPath());
        return result;
    } catch (IllegalStateException ise) {
        throw new DelaException(RESTCodes.DelaErrorCode.COMMUNICATION_FAILURE, Level.SEVERE, DelaException.Source.HOPS_SITE, null, ise.getMessage(), ise);
    }
}
Also used : Gson(com.google.gson.Gson) DelaException(io.hops.hopsworks.exceptions.DelaException) ClientWrapper(io.hops.hopsworks.common.util.ClientWrapper)

Aggregations

DelaException (io.hops.hopsworks.exceptions.DelaException)62 ClientWrapper (io.hops.hopsworks.common.util.ClientWrapper)31 Users (io.hops.hopsworks.persistence.entity.user.Users)8 Path (javax.ws.rs.Path)8 Gson (com.google.gson.Gson)7 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)7 IOException (java.io.IOException)6 HopsSite (io.hops.hopsworks.dela.hopssite.HopsSite)5 ManifestJSON (io.hops.hopsworks.dela.old_dto.ManifestJSON)5 SuccessJSON (io.hops.hopsworks.dela.old_dto.SuccessJSON)5 Dataset (io.hops.hopsworks.persistence.entity.dataset.Dataset)5 Produces (javax.ws.rs.Produces)5 AddressJSON (io.hops.hopsworks.common.dela.AddressJSON)4 DistributedFileSystemOps (io.hops.hopsworks.common.hdfs.DistributedFileSystemOps)4 TorrentId (io.hops.hopsworks.dela.old_dto.TorrentId)4 LinkedList (java.util.LinkedList)4 GET (javax.ws.rs.GET)4 POST (javax.ws.rs.POST)4 UserDTO (io.hops.hopsworks.dela.dto.common.UserDTO)3 SearchServiceDTO (io.hops.hopsworks.dela.dto.hopssite.SearchServiceDTO)3