public static IActorRef StartUserAccountClusterProxy(ActorSystem actorSystem, string proxyRoleName) { var clusterProxy = ClusterFactory <UserAccountAggregateManager, UserAccountAggregate, UserAccountId> .StartAggregateClusterProxy(actorSystem, proxyRoleName); return(clusterProxy); }
// methods public ICluster BuildCluster() { IStreamFactory streamFactory = new TcpStreamFactory(_tcpStreamSettings); // TODO: SSL gets handled here specifically... streamFactory = _streamFactoryWrapper(streamFactory); var connectionFactory = new BinaryConnectionFactory( _connectionSettings, streamFactory, _connectionListener); var connectionPoolFactory = new ExclusiveConnectionPoolFactory( _connectionPoolSettings, connectionFactory, _connectionPoolListener); var serverFactory = new ServerFactory( _serverSettings, connectionPoolFactory, connectionFactory, _serverListener); var clusterFactory = new ClusterFactory( _clusterSettings, serverFactory, _clusterListener); return(clusterFactory.CreateCluster()); }
// methods public ICluster BuildCluster() { IStreamFactory streamFactory = new TcpStreamFactory(_tcpStreamSettings); if (_sslStreamSettings != null) { streamFactory = new SslStreamFactory(_sslStreamSettings, streamFactory); } streamFactory = _streamFactoryWrapper(streamFactory); var connectionFactory = new BinaryConnectionFactory( _connectionSettings, streamFactory, _connectionListener); var connectionPoolFactory = new ExclusiveConnectionPoolFactory( _connectionPoolSettings, connectionFactory, _connectionPoolListener); var serverFactory = new ServerFactory( _serverSettings, connectionPoolFactory, connectionFactory, _serverListener); var clusterFactory = new ClusterFactory( _clusterSettings, serverFactory, _clusterListener); return(clusterFactory.CreateCluster()); }
public MapReduceResult Work(HadoopJobConfiguration config, out StatusResult statusCode) { var myCluster = ClusterFactory.GetCluster(); var jobResult = myCluster.MapReduceJob.Execute <TMapper, TReducer>(config); statusCode = jobResult.Info.ExitCode.ToStatusResult(); return(jobResult); }
public IList <Cluster <TNode, double> > Solve([NotNull] IList <TNode> Nodes, [NotNull] CostAnalyzer <double> costanalyzer, double maxCostOfNearestNeighbor, int maxNodesPerCluster = -1) { var clusterFactory = new ClusterFactory(Nodes, costanalyzer); var transposedCostMatrix = CostMatrix <double> .CreateTransposed(costanalyzer.CostMatrix); var transposedCostanalyzer = new CostAnalyzer <double>(transposedCostMatrix); // While unhandled indexes available and the loop runs for at most a certain amount of times, continue the algorithm for (var counter = 0; counter < Nodes.Count * maxFactorOfLoopCount && clusterFactory.NodesAsIndexes.Count > 0; counter++) { // set the current pointer to a random node index among the nodes not yet classified in a cluster int currentPointer = clusterFactory.NodesAsIndexes[randomizer.Next(0, clusterFactory.NodesAsIndexes.Count - 1)]; var candidateCluster = CalculateCluster(clusterFactory.NodesAsIndexes, costanalyzer, transposedCostanalyzer, maxCostOfNearestNeighbor, maxNodesPerCluster); if (candidateCluster.Count > 1) { // loop over the cluster again maybe to cut the cluster in pieces. Clusters with one item are thrown back in the pool for (int indexInCluster = 0; indexInCluster < candidateCluster.Count - 1; indexInCluster++) { var maxCostInCluster = indexInCluster == 0 ? costanalyzer.AllNeighborsOrdered(candidateCluster[0])[candidateCluster[1]] : candidateCluster.Take(indexInCluster + 1).Tuples().Max(t => costanalyzer.AllNeighborsOrdered(t.Item1)[t.Item2]); var nodesOutsideClusterQuiteCloseToCluster = costanalyzer.AllNeighborsOrdered(candidateCluster[indexInCluster]) .Where(neighbor => !candidateCluster.Contains(neighbor.Key) && neighbor.Value <= maxCostInCluster); if (nodesOutsideClusterQuiteCloseToCluster.Count() > 1) // Split the cluster { var firstPart = candidateCluster.GetRange(0, indexInCluster + 1); clusterFactory.CreateCluster(firstPart); candidateCluster.RemoveRange(0, indexInCluster + 1); indexInCluster = -1; } } } clusterFactory.CreateCluster(candidateCluster); } // Here we add the singleton clusters from the remaining nodes clusterFactory.CreateSingletonClusters(); return(clusterFactory.ListOfClusters); }
public void Client_proxies_can_be_started() { RunOn(() => { var proxy = ClusterFactory <TestAggregateManager, TestAggregate, TestAggregateId> .StartAggregateClusterProxy(Sys, "worker", _numberOfShards); proxy.Tell(new Identify(5)); ExpectMsg <ActorIdentity>(x => x.MessageId.Equals(5), TimeSpan.FromSeconds(10)); Sys.Log.Info("proxy address: {0}", proxy.Path.ToString()); }, _config.Client); EnterBarrier("client-proxies-started"); }
public void Aggregate_managers_can_be_started() { RunOn(() => { var region = ClusterFactory <TestAggregateManager, TestAggregate, TestAggregateId> .StartClusteredAggregate(Sys, _numberOfShards); region.Tell(new Identify(1)); ExpectMsg <ActorIdentity>(x => x.MessageId.Equals(1)); Sys.Log.Info("region address: {0}", region.Path); }, _config.Worker); EnterBarrier("aggregate-managers-started"); }
public void Saga_managers_can_be_started() { RunOn(() => { var region = ClusterFactory <TestSagaManager, TestSaga, TestSagaId, TestSagaLocator> .StartClusteredAggregateSaga(Sys, () => new TestSaga(_aggregateRegion.Value), "worker", _numberOfShards); region.Tell(new Identify(1)); ExpectMsg <ActorIdentity>(x => x.MessageId.Equals(1)); Sys.Log.Info("saga region address: {0}", region.Path); }, _config.Worker); EnterBarrier("aggregate-managers-started"); }
public static IAkkatectureBuilder AddAggregateManagerCluster <TAggregateManager, TAggregate, TIdentity>( this IAkkatectureBuilder builder, int numberOfShards = 12) where TAggregateManager : ReceiveActor, IAggregateManager <TAggregate, TIdentity> where TAggregate : IAggregateRoot <TIdentity> where TIdentity : IIdentity { var aggregateManager = ClusterFactory <TAggregateManager, TAggregate, TIdentity> .StartClusteredAggregate( builder.ActorSystem, numberOfShards); var actorRef = new ActorRefOfT <TAggregateManager>(aggregateManager); builder.Services.AddSingleton <IActorRef <TAggregateManager> >(actorRef); return(builder); }
// methods /// <summary> /// Builds the cluster. /// </summary> /// <returns>A cluster.</returns> public ICluster BuildCluster() { IStreamFactory streamFactory = new TcpStreamFactory(_tcpStreamSettings); if (_sslStreamSettings != null) { streamFactory = new SslStreamFactory(_sslStreamSettings, streamFactory); } streamFactory = _streamFactoryWrapper(streamFactory); var connectionFactory = new BinaryConnectionFactory( _connectionSettings, streamFactory, _eventAggregator); var connectionPoolFactory = new ExclusiveConnectionPoolFactory( _connectionPoolSettings, connectionFactory, _eventAggregator); var serverMonitorConnectionSettings = _connectionSettings.With(authenticators: new IAuthenticator[] { }); var serverMonitorConnectionFactory = new BinaryConnectionFactory( serverMonitorConnectionSettings, streamFactory, new EventAggregator()); var serverMonitorFactory = new ServerMonitorFactory( _serverSettings, serverMonitorConnectionFactory, _eventAggregator); var serverFactory = new ServerFactory( _clusterSettings.ConnectionMode, _serverSettings, connectionPoolFactory, serverMonitorFactory, _eventAggregator); var clusterFactory = new ClusterFactory( _clusterSettings, serverFactory, _eventAggregator); return(clusterFactory.CreateCluster()); }
public ShardedAggregateSagaDispatcher(string proxyRoleName, int numberOfShards) { Logger = Context.GetLogger(); AggregateSagaManager = ClusterFactory <TAggregateSagaManager, TAggregateSaga, TIdentity, TSagaLocator> .StartAggregateSagaClusterProxy(Context.System, proxyRoleName, numberOfShards); var sagaType = typeof(TAggregateSaga); var sagaHandlesSubscriptionTypes = sagaType .GetSagaEventSubscriptionTypes(); foreach (var type in sagaHandlesSubscriptionTypes) { Context.System.EventStream.Subscribe(Self, type); } }
public MsToLcmsFeatures(IScanSummaryProvider provider, LcmsFeatureFindingOptions options = null) { if (provider == null) { throw new ArgumentNullException(); } Comparison <MSFeatureLight> mzSort = (x, y) => x.Mz.CompareTo(y.Mz); Comparison <UMCLight> monoSort = (x, y) => x.MassMonoisotopic.CompareTo(y.MassMonoisotopic); Func <MSFeatureLight, MSFeatureLight, double> mzDiff = (x, y) => FeatureLight.ComputeMassPPMDifference(x.Mz, y.Mz); Func <UMCLight, UMCLight, double> monoDiff = (x, y) => FeatureLight.ComputeMassPPMDifference(x.MassMonoisotopic, y.MassMonoisotopic); this.provider = provider; this.options = options ?? new LcmsFeatureFindingOptions(); // Set clusterers if (this.options.FirstPassClusterer == MsFeatureClusteringAlgorithmType.BinarySearchTree) { this.firstPassClusterer = new MsFeatureTreeClusterer <MSFeatureLight, UMCLight>( mzSort, mzDiff, MassComparison.Mz, this.options.InstrumentTolerances.Mass); } else { this.firstPassClusterer = ClusterFactory.Create(this.options.FirstPassClusterer); } if (this.options.SecondPassClusterer == GenericClusteringAlgorithmType.BinarySearchTree) { this.secondPassClusterer = new MsFeatureTreeClusterer <UMCLight, UMCLight>( monoSort, monoDiff, MassComparison.Monoisotopic, this.options.InstrumentTolerances.Mass); } else { var clusterFactory = new GenericClusterFactory <UMCLight, UMCLight>(); this.secondPassClusterer = clusterFactory.Create(this.options.SecondPassClusterer); } }
// methods private ICluster CreateCluster(ClusterKey clusterKey) { var clusterSettings = CreateClusterSettings(clusterKey); var serverSettings = CreateServerSettings(clusterKey); var connectionSettings = CreateConnectionSettings(clusterKey); var connectionPoolSettings = CreateConnectionPoolSettings(clusterKey); var listener = EmptyListener.Instance; var streamFactory = CreateStreamFactory(clusterKey); var connectionFactory = new BinaryConnectionFactory(connectionSettings, streamFactory, listener); var connectionPoolFactory = new ExclusiveConnectionPoolFactory(connectionPoolSettings, connectionFactory, listener); var serverFactory = new ServerFactory(serverSettings, connectionPoolFactory, connectionFactory, listener); var clusterFactory = new ClusterFactory(clusterSettings, serverFactory, listener); var cluster = clusterFactory.CreateCluster(); cluster.Initialize(); return(cluster); }
static async Task Main() { var movieList = await MovieSubjectFactory .ParseMoviesAsync(Path.Combine(AppContext.BaseDirectory, "movies.txt")); Console.Clear(); var factory = new ClusterFactory <string>(movieList, new SubjectComparer(), 10); factory.MakeClusters(); foreach (var cluster in factory) { Console.WriteLine(cluster.Description); Console.WriteLine("--------------------------------"); foreach (var item in cluster.Subjects) { Console.WriteLine(item); } Console.WriteLine(""); Console.WriteLine(""); } Console.ReadLine(); }
public static void StartUserAccountCluster(ActorSystem actorSystem) { var cluster = ClusterFactory <UserAccountAggregateManager, UserAccountAggregate, UserAccountId> .StartAggregateCluster(actorSystem); }
public void GenerateClusterAlignmentStatistics(string relativeDatabasePath, string relativeName, string name, FeatureAlignmentType alignmentType, LcmsFeatureClusteringAlgorithmType clusterType) { var databasePath = GetPath(relativeDatabasePath); var outputPath = GetOutputPath(relativeName); if (!Directory.Exists(outputPath)) { Directory.CreateDirectory(outputPath); } // Connect to the NHibernate database var providers = DataAccessFactory.CreateDataAccessProviders(databasePath, false); // Setup our alignment options var alignmentOptions = new AlignmentOptions(); var spectralOptions = new SpectralOptions { ComparerType = SpectralComparison.CosineDotProduct, Fdr = .01, IdScore = 1e-09, MzBinSize = .5, MzTolerance = .5, NetTolerance = .1, RequiredPeakCount = 32, SimilarityCutoff = .75, TopIonPercent = .8 }; // Options setup var instrumentOptions = InstrumentPresetFactory.Create(InstrumentPresets.LtqOrbitrap); var featureTolerances = new FeatureTolerances { Mass = instrumentOptions.Mass + 6, Net = instrumentOptions.NetTolerance, DriftTime = instrumentOptions.DriftTimeTolerance }; UpdateStatus("Retrieving all datasets for test."); var datasets = providers.DatasetCache.FindAll(); // Create our algorithms var aligner = FeatureAlignerFactory.CreateDatasetAligner(alignmentType, alignmentOptions.LCMSWarpOptions, spectralOptions); var clusterer = ClusterFactory.Create(clusterType); clusterer.Parameters = new FeatureClusterParameters <UMCLight> { Tolerances = featureTolerances }; RegisterProgressNotifier(aligner); RegisterProgressNotifier(clusterer); for (var i = 0; i < datasets.Count - 1; i++) { var matchPath = string.Format("{0}-{1}-matches.txt", name, i); var errorPath = string.Format("{0}-{1}-errors.txt", name, i); matchPath = Path.Combine(outputPath, matchPath); errorPath = Path.Combine(outputPath, errorPath); var aligneeDataset = datasets[i + 1]; var baselineDataset = datasets[i]; // Load the baseline reference set using (var rawProviderX = new InformedProteomicsReader()) { rawProviderX.AddDataFile(baselineDataset.RawFile.Path, 0); // Load the baseline reference set using (var rawProviderY = new InformedProteomicsReader()) { rawProviderY.AddDataFile(aligneeDataset.RawFile.Path, 0); var baselineFeatures = RetrieveFeatures(baselineDataset.DatasetId, providers); var aligneeFeatures = RetrieveFeatures(aligneeDataset.DatasetId, providers); var providerX = new CachedFeatureSpectraProvider(rawProviderX, baselineFeatures); var providerY = new CachedFeatureSpectraProvider(rawProviderY, aligneeFeatures); AlignDatasets(baselineFeatures, aligneeFeatures, providerX, providerY, aligner, clusterer, matchPath, errorPath); } } } }
public void TestClustering( string directory, string outputPath, FeatureAlignmentType alignmentType, LcmsFeatureClusteringAlgorithmType clusterType) { var matchPath = string.Format("{0}.txt", outputPath); var errorPath = string.Format("{0}-errors.txt", outputPath); // Loads the supported MultiAlign types var supportedTypes = DatasetLoader.SupportedFileTypes; var extensions = new List <string>(); supportedTypes.ForEach(x => extensions.Add("*" + x.Extension)); // Find our datasets var datasetLoader = new DatasetLoader(); var datasets = datasetLoader.GetValidDatasets(directory, extensions, SearchOption.TopDirectoryOnly); // Setup our alignment options var alignmentOptions = new AlignmentOptions(); var spectralOptions = new SpectralOptions { ComparerType = SpectralComparison.CosineDotProduct, Fdr = .01, IdScore = 1e-09, MzBinSize = .5, MzTolerance = .5, NetTolerance = .1, RequiredPeakCount = 32, SimilarityCutoff = .75, TopIonPercent = .8 }; // Options setup var instrumentOptions = InstrumentPresetFactory.Create(InstrumentPresets.LtqOrbitrap); var featureTolerances = new FeatureTolerances { Mass = instrumentOptions.Mass + 6, Net = instrumentOptions.NetTolerance, DriftTime = instrumentOptions.DriftTimeTolerance }; var featureFindingOptions = new LcmsFeatureFindingOptions(featureTolerances) { MaximumNetRange = .002, MaximumScanRange = 50 }; // Create our algorithms var finder = FeatureFinderFactory.CreateFeatureFinder(FeatureFinderType.TreeBased); var aligner = FeatureAlignerFactory.CreateDatasetAligner(alignmentType, alignmentOptions.LCMSWarpOptions, spectralOptions); var clusterer = ClusterFactory.Create(clusterType); clusterer.Parameters = new FeatureClusterParameters <UMCLight> { Tolerances = featureTolerances }; RegisterProgressNotifier(aligner); RegisterProgressNotifier(finder); RegisterProgressNotifier(clusterer); var lcmsFilters = new LcmsFeatureFilteringOptions { FeatureLengthRangeScans = new FilterRange(50, 300) }; var msFilterOptions = new MsFeatureFilteringOptions { MinimumIntensity = 5000, ChargeRange = new FilterRange(1, 6), ShouldUseChargeFilter = true, ShouldUseDeisotopingFilter = true, ShouldUseIntensityFilter = true }; for (var i = 0; i < 1; i++) { var aligneeDatasets = datasets.Where((t, j) => j != i).ToList(); PerformMultiAlignAnalysis(datasets[0], aligneeDatasets, featureFindingOptions, msFilterOptions, lcmsFilters, spectralOptions, finder, aligner, clusterer, matchPath, errorPath); } }