public void EndFileTransfer(long submittedJobInfoId, FileTransferMethod transferMethod, AdaptorUser loggedUser) { log.Info("Removing file transfer method for submitted job info ID " + submittedJobInfoId + " with user " + loggedUser.GetLogIdentification()); SubmittedJobInfo jobInfo = LogicFactory.GetLogicFactory().CreateJobManagementLogic(unitOfWork).GetSubmittedJobInfoById(submittedJobInfoId, loggedUser); AsymmetricKeyCredentials asymmetricKeyCredentials = transferMethod.Credentials as AsymmetricKeyCredentials; if (asymmetricKeyCredentials != null) { SchedulerFactory.GetInstance(jobInfo.Specification.Cluster.SchedulerType).CreateScheduler(jobInfo.Specification.Cluster). RemoveDirectFileTransferAccessForUserToJob(asymmetricKeyCredentials.PublicKey, jobInfo); } else { log.Error("Credentials of class " + transferMethod.Credentials.GetType().Name + " are not supported. Change the HaaSMiddleware.BusinessLogicTier.FileTransfer.FileTransferLogic.EndFileTransfer() method to add support for additional credential types."); throw new ArgumentException("Credentials of class " + transferMethod.Credentials.GetType().Name + " are not supported. Change the HaaSMiddleware.BusinessLogicTier.FileTransfer.FileTransferLogic.EndFileTransfer() method to add support for additional credential types."); } }
public IList <JobFileContent> DownloadPartsOfJobFilesFromCluster(long submittedJobInfoId, TaskFileOffset[] taskFileOffsets, AdaptorUser loggedUser) { log.Info("Getting part of job files from cluster for submitted job info ID " + submittedJobInfoId + " with user " + loggedUser.GetLogIdentification()); SubmittedJobInfo jobInfo = LogicFactory.GetLogicFactory().CreateJobManagementLogic(unitOfWork).GetSubmittedJobInfoById(submittedJobInfoId, loggedUser); IRexFileSystemManager fileManager = FileSystemFactory.GetInstance(jobInfo.Specification.FileTransferMethod.Protocol).CreateFileSystemManager(jobInfo.Specification.FileTransferMethod); IList <JobFileContent> result = new List <JobFileContent>(); foreach (SubmittedTaskInfo taskInfo in jobInfo.Tasks) { IList <TaskFileOffset> currentTaskFileOffsets = (from taskFileOffset in taskFileOffsets where taskFileOffset.SubmittedTaskInfoId == taskInfo.Id select taskFileOffset).ToList(); foreach (TaskFileOffset currentOffset in currentTaskFileOffsets) { ICollection <JobFileContent> contents = fileManager.DownloadPartOfJobFileFromCluster(taskInfo, currentOffset.FileType, currentOffset.Offset); if (contents != null) { foreach (JobFileContent content in contents) { result.Add(content); } } } } return(result); }
public FileTransferMethod GetFileTransferMethod(long submittedJobInfoId, AdaptorUser loggedUser) { log.Info("Getting file transfer method for submitted job info ID " + submittedJobInfoId + " with user " + loggedUser.GetLogIdentification()); SubmittedJobInfo jobInfo = LogicFactory.GetLogicFactory().CreateJobManagementLogic(unitOfWork).GetSubmittedJobInfoById(submittedJobInfoId, loggedUser); var certificateGenerator = new CertificateGenerator.CertificateGenerator(); certificateGenerator.GenerateKey(2048); string publicKey = certificateGenerator.DhiPublicKey(); string jobDir = FileSystemUtils.GetJobClusterDirectoryPath(jobInfo.Specification.FileTransferMethod.Cluster.LocalBasepath, jobInfo.Specification); var transferMethod = new FileTransferMethod { Protocol = jobInfo.Specification.FileTransferMethod.Protocol, ServerHostname = jobInfo.Specification.FileTransferMethod.ServerHostname, SharedBasePath = jobDir, Credentials = new AsymmetricKeyCredentials { Username = jobInfo.Specification.ClusterUser.Username, PrivateKey = certificateGenerator.DhiPrivateKey(), PublicKey = publicKey } }; SchedulerFactory.GetInstance(jobInfo.Specification.Cluster.SchedulerType).CreateScheduler(jobInfo.Specification.Cluster).AllowDirectFileTransferAccessForUserToJob(publicKey, jobInfo); return(transferMethod); }