Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Collections.Generic;
using HaaSMiddleware.ConnectionPool;
using HaaSMiddleware.DomainObjects.ClusterInformation;
using HaaSMiddleware.DomainObjects.FileTransfer;
using HaaSMiddleware.FileTransferFramework.NetworkShare;
using HaaSMiddleware.FileTransferFramework.Sftp;
namespace HaaSMiddleware.FileTransferFramework {
public abstract class FileSystemFactory {
#region Instantiation
private static FileSystemFactory windowsSharedFactorySingleton;
private static FileSystemFactory sftpFactorySingleton;
public static FileSystemFactory GetInstance(FileTransferProtocol type) {
switch (type) {
case FileTransferProtocol.NetworkShare:
if (windowsSharedFactorySingleton == null)
windowsSharedFactorySingleton = new NetworkShareFileSystemFactory();
return windowsSharedFactorySingleton;
case FileTransferProtocol.SftpScp:
if (sftpFactorySingleton == null)
sftpFactorySingleton = new SftpFileSystemFactory();
return sftpFactorySingleton;
}
throw new ApplicationException("File system manager factory with type \"" + type + "\" does not exist.");
}
#endregion
#region Abstract Methods
public abstract IRexFileSystemManager CreateFileSystemManager(FileTransferMethod configuration);
internal abstract IFileSynchronizer CreateFileSynchronizer(FullFileSpecification syncFile, ClusterAuthenticationCredentials credentials);
protected abstract IPoolableAdapter CreateFileSystemConnector(FileTransferMethod configuration);
#endregion
#region Local Methods
protected IConnectionPool GetSchedulerConnectionPool(FileTransferMethod configuration) {
if (!schedulerConnectionPoolSingletons.ContainsKey(configuration)) {
schedulerConnectionPoolSingletons[configuration] = new ConnectionPool.ConnectionPool(
configuration.ServerHostname,
FileTransferFrameworkSettings.Default.ConnectionPoolMinSize,
FileTransferFrameworkSettings.Default.ConnectionPoolMaxSize,
FileTransferFrameworkSettings.Default.ConnectionPoolCleaningInterval,
FileTransferFrameworkSettings.Default.ConnectionPoolMaxUnusedInterval,
CreateFileSystemConnector(configuration));
}
return schedulerConnectionPoolSingletons[configuration];
}
#endregion
#region Instance Fields
private readonly Dictionary<FileTransferMethod, IConnectionPool> schedulerConnectionPoolSingletons =
new Dictionary<FileTransferMethod, IConnectionPool>();
#endregion
}
}