Commit a00e9626 authored by Vaclav Svaton's avatar Vaclav Svaton

initial commit

parent bfabdf0d
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
**/bin/
**/obj/
**/debug/
**/release/
MiddlewareServiceSetup/Release/MiddlewareServiceSetup.msi
HpcAsAServiceMiddleware.v12.suo
.vs
*.htm
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{2EAD192F-CB6E-4DE0-BC7F-342DCA347F27}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>HaaSMiddleware.BackgroundThread</RootNamespace>
<AssemblyName>BackgroundThread</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=1.2.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\log4net.2.0.5\lib\net40-full\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Tasks\AbstractTask.cs" />
<Compile Include="Tasks\CloseConnectionToFinishedJobs.cs" />
<Compile Include="Tasks\GetAllJobsInfo.cs" />
<Compile Include="Tasks\IBackgroundTask.cs" />
<Compile Include="MiddlewareBackgroundTaskRunner.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Tasks\SynchronizeJobFileContents.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BusinessLogicTier\BusinessLogicTier.csproj">
<Project>{EE3A5C6A-F74A-4B55-86BA-35ECFF8A7C2F}</Project>
<Name>BusinessLogicTier</Name>
</ProjectReference>
<ProjectReference Include="..\DataAccessTier\DataAccessTier.csproj">
<Project>{88827C9B-82AF-4302-AC72-4A2636E839EB}</Project>
<Name>DataAccessTier</Name>
</ProjectReference>
<ProjectReference Include="..\DomainObjects\DomainObjects.csproj">
<Project>{C3F683C1-16C6-4F99-8ECB-118BAC0788C3}</Project>
<Name>DomainObjects</Name>
</ProjectReference>
<ProjectReference Include="..\ServiceTier\ServiceTier.csproj">
<Project>{54C62001-0291-4362-AF0C-B48D659FBB53}</Project>
<Name>ServiceTier</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
using System;
using System.Collections.Generic;
using HaaSMiddleware.BackgroundThread.Tasks;
namespace HaaSMiddleware.BackgroundThread {
public class MiddlewareBackgroundTaskRunner {
private readonly List<IBackgroundTask> tasks;
public MiddlewareBackgroundTaskRunner() {
this.tasks = new List<IBackgroundTask>();
this.tasks.Add(new GetAllJobsInfo(new TimeSpan(0, 0, 30)));
this.tasks.Add(new SynchronizeJobFileContents(new TimeSpan(0, 0, 30)));
this.tasks.Add(new CloseConnectionToFinishedJobs(new TimeSpan(0, 0, 30)));
}
public void Start() {
foreach (var task in tasks) {
task.StartTimer();
}
}
public void Stop() {
foreach (var task in tasks) {
task.StopTimer();
}
}
}
}
\ No newline at end of file
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("BackgroundThread")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BackgroundThread")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1c787f65-81a9-45ad-842e-6e1f01755f04")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
\ No newline at end of file
using System;
using System.Threading;
using System.Timers;
using log4net;
using Timer = System.Timers.Timer;
namespace HaaSMiddleware.BackgroundThread.Tasks {
internal abstract class AbstractTask : IBackgroundTask {
protected readonly ILog log;
private readonly Timer taskTimer;
public AbstractTask(TimeSpan interval) {
this.log = LogManager.GetLogger(this.GetType().ToString());
this.taskTimer = new Timer(interval.TotalMilliseconds);
this.taskTimer.Elapsed += taskTimer_Elapsed;
}
public void StartTimer() {
this.taskTimer.Start();
}
public void StopTimer() {
this.taskTimer.Stop();
}
private void taskTimer_Elapsed(object sender, ElapsedEventArgs e) {
// Run the task in its own thread
Thread thread = new Thread(delegate() {
try {
RunTask();
}
catch (Exception ex) {
log.Error("An error occured during execution of the background task: {0}", ex);
}
});
thread.Name = "Timer - " + this.GetType().ToString();
thread.Start();
}
protected abstract void RunTask();
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using HaaSMiddleware.BusinessLogicTier.Factory;
using HaaSMiddleware.DataAccessTier.UnitOfWork;
using HaaSMiddleware.DomainObjects.JobManagement.JobInformation;
using HaaSMiddleware.ServiceTier.JobManagement;
using HaaSMiddleware.ServiceTier.DataTransfer;
using HaaSMiddleware.BusinessLogicTier.Logic.DataTransfer;
namespace HaaSMiddleware.BackgroundThread.Tasks {
/// <summary>
/// Close all open sockets to finished/failed/canceled jobs
/// </summary>
internal class CloseConnectionToFinishedJobs : AbstractTask, IBackgroundTask {
public CloseConnectionToFinishedJobs(TimeSpan interval) : base(interval) { }
protected override void RunTask() {
using (IUnitOfWork unitOfWork = new DatabaseUnitOfWork()) {
List<long> jobIds = LogicFactory.GetLogicFactory().CreateDataTransferLogic(unitOfWork).GetJobIdsForOpenSockets();
foreach (long jobId in jobIds)
{
//check the job's status
SubmittedJobInfo jobInfo = unitOfWork.SubmittedJobInfoRepository.GetById(jobId);
if (jobInfo.State >= JobState.Finished)
{
LogicFactory.GetLogicFactory().CreateDataTransferLogic(unitOfWork).CloseAllConnectionsForJob(jobInfo);
}
}
}
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using HaaSMiddleware.BusinessLogicTier.Factory;
using HaaSMiddleware.DataAccessTier.UnitOfWork;
using HaaSMiddleware.DomainObjects.JobManagement.JobInformation;
using HaaSMiddleware.ServiceTier.JobManagement;
namespace HaaSMiddleware.BackgroundThread.Tasks {
/// <summary>
/// Get all unfinished jobs from db and load their status from cluster
/// and updates their status in DB
/// </summary>
internal class GetAllJobsInfo : AbstractTask, IBackgroundTask {
public GetAllJobsInfo(TimeSpan interval) : base(interval) {}
protected override void RunTask() {
using (IUnitOfWork unitOfWork = new DatabaseUnitOfWork()) {
List<SubmittedJobInfo> updatedJobs =
(List<SubmittedJobInfo>) LogicFactory.GetLogicFactory().CreateJobManagementLogic(unitOfWork).UpdateCurrentStateOfUnfinishedJobs();
JobManagementService jobMgmtService = new JobManagementService();
jobMgmtService.SendSubmittedJobInfosToClient(updatedJobs);
}
}
}
}
\ No newline at end of file
namespace HaaSMiddleware.BackgroundThread.Tasks {
internal interface IBackgroundTask {
void StartTimer();
void StopTimer();
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using HaaSMiddleware.BusinessLogicTier.Factory;
using HaaSMiddleware.DataAccessTier.Factory.UnitOfWork;
using HaaSMiddleware.DataAccessTier.UnitOfWork;
using HaaSMiddleware.DomainObjects.FileTransfer;
using HaaSMiddleware.ServiceTier.FileTransfer;
namespace HaaSMiddleware.BackgroundThread.Tasks {
internal class SynchronizeJobFileContents : AbstractTask {
public SynchronizeJobFileContents(TimeSpan interval) : base(interval) {}
protected override void RunTask() {
using (IUnitOfWork unitOfWork = UnitOfWorkFactory.GetUnitOfWorkFactory().CreateUnitOfWork()) {
IList<SynchronizedJobFiles> jobFileContents = LogicFactory.GetLogicFactory().CreateFileTransferLogic(unitOfWork).SynchronizeAllUnfinishedJobFiles();
new FileTransferService().SendSynchronizedJobFilesToClient(jobFileContents);
}
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.5" targetFramework="net40" />
</packages>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{EE3A5C6A-F74A-4B55-86BA-35ECFF8A7C2F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>HaaSMiddleware.BusinessLogicTier</RootNamespace>
<AssemblyName>BusinessLogicTier</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=1.2.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\log4net.2.0.5\lib\net40-full\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Logic\ClusterInformation\ClusterUserCache.cs" />
<Compile Include="Factory\LogicFactory.cs" />
<Compile Include="Factory\BusinessLogicType.cs" />
<Compile Include="Factory\PocoLogicFactory.cs" />
<Compile Include="Logic\AdminUserManagement\AdminUserManagementLogic.cs" />
<Compile Include="Logic\AdminUserManagement\IAdminUserManagementLogic.cs" />
<Compile Include="Logic\ClusterInformation\ClusterInformationLogic.cs" />
<Compile Include="Logic\ClusterInformation\IClusterInformationLogic.cs" />
<Compile Include="Logic\DataTransfer\Exceptions\UnableToCreateConnectionException.cs" />
<Compile Include="Logic\ExternallyVisibleException.cs" />
<Compile Include="Logic\DataTransfer\DataTransferLogic.cs" />
<Compile Include="Logic\DataTransfer\IDataTransferLogic.cs" />
<Compile Include="Logic\InputValidationException.cs" />
<Compile Include="Logic\JobManagement\Exceptions\RequestedJobResourcesExceededUserLimitationsException.cs" />
<Compile Include="Logic\JobManagement\Exceptions\UnableToAppendToJobTemplatePropertyException.cs" />
<Compile Include="Logic\JobManagement\Exceptions\RequestedObjectDoesNotExistException.cs" />
<Compile Include="Logic\JobReporting\Exceptions\NotAllowedException.cs" />
<Compile Include="Logic\UserAndLimitationManagement\Exceptions\AuthenticatedUserAlreadyDeletedException.cs" />
<Compile Include="Logic\UserAndLimitationManagement\Exceptions\AdaptorUserNotAuthorizedForJobException.cs" />
<Compile Include="Logic\FileTransfer\FileTransferLogic.cs" />
<Compile Include="Logic\FileTransfer\IFileTransferLogic.cs" />
<Compile Include="Logic\JobManagement\IJobManagementLogic.cs" />
<Compile Include="Logic\JobManagement\JobManagementLogic.cs" />
<Compile Include="Logic\JobReporting\IJobReportingLogic.cs" />
<Compile Include="Logic\JobReporting\JobReportingLogic.cs" />
<Compile Include="Logic\Notifications\INotificationLogic.cs" />
<Compile Include="Logic\Notifications\NotificationLogic.cs" />
<Compile Include="Logic\UserAndLimitationManagement\Exceptions\InvalidAuthenticationCredentialsException.cs" />
<Compile Include="Logic\UserAndLimitationManagement\IUserAndLimitationManagementLogic.cs" />
<Compile Include="Logic\UserAndLimitationManagement\Exceptions\SessionCodeNotValidException.cs" />
<Compile Include="Logic\UserAndLimitationManagement\UserAndLimitationManagementLogic.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CertificateGenerator\CertificateGenerator.csproj">
<Project>{3255281C-462A-461A-9C94-29E8A3D0922B}</Project>
<Name>CertificateGenerator</Name>
</ProjectReference>
<ProjectReference Include="..\DataAccessTier\DataAccessTier.csproj">
<Project>{88827C9B-82AF-4302-AC72-4A2636E839EB}</Project>
<Name>DataAccessTier</Name>
</ProjectReference>
<ProjectReference Include="..\DomainObjects\DomainObjects.csproj">
<Project>{C3F683C1-16C6-4F99-8ECB-118BAC0788C3}</Project>
<Name>DomainObjects</Name>
</ProjectReference>
<ProjectReference Include="..\FileTransferFramework\FileTransferFramework.csproj">
<Project>{D9B98C36-14CA-4D8E-A1F3-7C095F71EB74}</Project>
<Name>FileTransferFramework</Name>
</ProjectReference>
<ProjectReference Include="..\HpcConnectionFramework\HpcConnectionFramework.csproj">
<Project>{AFEA11EF-C33F-462D-9EE5-180DD4E5338D}</Project>
<Name>HpcConnectionFramework</Name>
</ProjectReference>
<ProjectReference Include="..\MiddlewareUtils\MiddlewareUtils.csproj">
<Project>{5B2013D5-B99A-4A33-9CC1-814D3867B5BF}</Project>
<Name>MiddlewareUtils</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
namespace HaaSMiddleware.BusinessLogicTier.Factory {
public enum BusinessLogicType {
Poco
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using HaaSMiddleware.BusinessLogicTier.Logic.AdminUserManagement;
using HaaSMiddleware.BusinessLogicTier.Logic.ClusterInformation;
using HaaSMiddleware.BusinessLogicTier.Logic.DataTransfer;
using HaaSMiddleware.BusinessLogicTier.Logic.FileTransfer;
using HaaSMiddleware.BusinessLogicTier.Logic.JobManagement;
using HaaSMiddleware.BusinessLogicTier.Logic.JobReporting;
using HaaSMiddleware.BusinessLogicTier.Logic.Notifications;
using HaaSMiddleware.BusinessLogicTier.Logic.UserAndLimitationManagement;
using HaaSMiddleware.DataAccessTier.UnitOfWork;
namespace HaaSMiddleware.BusinessLogicTier.Factory {
public abstract class LogicFactory {
private static readonly Dictionary<BusinessLogicType, LogicFactory> factoryInstances =
new Dictionary<BusinessLogicType, LogicFactory>(Enum.GetValues(typeof (BusinessLogicType)).Length);
#region Instantiation
public static LogicFactory GetLogicFactory() {
return GetLogicFactory(BusinessLogicType.Poco);
}
public static LogicFactory GetLogicFactory(BusinessLogicType type) {
lock (factoryInstances)
{
if (!factoryInstances.ContainsKey(type))
{
factoryInstances.Add(type, CreateLogicFactory(type));
}
}
return factoryInstances[type];
}
private static LogicFactory CreateLogicFactory(BusinessLogicType type) {
switch (type) {