public RemoteLockerTester(RemoteLockerTesterConfig config = null) { config = config ?? RemoteLockerTesterConfig.Default(); var localRivalOptimizationIsEnabled = config.LocalRivalOptimization != LocalRivalOptimization.Disabled; var serializer = new Serializer(new AllPropertiesExtractor(), null, GroBufOptions.MergeOnRead); ICassandraCluster cassandraCluster = new CassandraCluster(config.CassandraClusterSettings, logger); if (config.CassandraFailProbability.HasValue) { cassandraCluster = new FailedCassandraCluster(cassandraCluster, config.CassandraFailProbability.Value); } var timestampProvider = new StochasticTimestampProvider(config.TimestampProviderStochasticType, config.LockTtl); var implementationSettings = new CassandraRemoteLockImplementationSettings(timestampProvider, SingleCassandraNodeSetUpFixture.RemoteLockKeyspace, SingleCassandraNodeSetUpFixture.RemoteLockColumnFamily, config.LockTtl, config.LockMetadataTtl, config.KeepLockAliveInterval, config.ChangeLockRowThreshold); var cassandraRemoteLockImplementation = new CassandraRemoteLockImplementation(cassandraCluster, serializer, implementationSettings); remoteLockers = new RemoteLocker[config.LockersCount]; remoteLockerMetrics = new RemoteLockerMetrics("dummyKeyspace"); if (localRivalOptimizationIsEnabled) { var remoteLocker = new RemoteLocker(cassandraRemoteLockImplementation, remoteLockerMetrics, logger); for (var i = 0; i < config.LockersCount; i++) { remoteLockers[i] = remoteLocker; } } else { for (var i = 0; i < config.LockersCount; i++) { remoteLockers[i] = new RemoteLocker(new CassandraRemoteLockImplementation(cassandraCluster, serializer, implementationSettings), remoteLockerMetrics, logger); } } // it is important to use another CassandraCluster (with another setting of attempts, for example) cassandraRemoteLockImplementationForCheckings = new CassandraRemoteLockImplementation(new CassandraCluster(SingleCassandraNodeSetUpFixture.CreateCassandraClusterSettings(), logger), serializer, implementationSettings); }
public IEventRepository CreateEventRepository(IShardCalculator shardCalculator, IEventRepositoryColumnFamilyFullNames columnFamilies, IEventLogProfiler profiler, TimeSpan eventsTtl) { var eventLogPointerCreator = new EventLogPointerCreator(); var remoteLockImplementation = new CassandraRemoteLockImplementation(cassandraCluster, serializer, CassandraRemoteLockImplementationSettings.Default(columnFamilies.RemoteLock.KeyspaceName, columnFamilies.RemoteLock.ColumnFamilyName)); var remoteLocker = new RemoteLocker(remoteLockImplementation, new RemoteLockerMetrics(columnFamilies.RemoteLock.KeyspaceName), logger); var eventLoggerAdditionalInfoRepository = new EventLoggerAdditionalInfoRepository(cassandraCluster, serializer, remoteLocker, columnFamilies.EventLogAdditionalInfo, columnFamilies.EventLog); var eventStorage = new EventStorage(columnFamilies.EventLog, eventLogPointerCreator, cassandraCluster, serializer); Func <IQueueRaker> createQueueRaker = () => new QueueRaker(eventStorage, eventLoggerAdditionalInfoRepository, profiler, logger, eventsTtl); var eventLogger = new EventLogger(cassandraCluster, serializer, columnFamilies.EventLog, eventLogPointerCreator, createQueueRaker, eventLoggerAdditionalInfoRepository, profiler, logger); return(new EventRepository(eventTypeIdentifierProvider, eventLogger, shardCalculator, serializer)); }
public TestCounterRepository(ILog log, ICassandraCluster cassandraCluster, ISerializer serializer, IGlobalTime globalTime, IRtqSettings rtqSettings) { this.serializer = serializer; this.globalTime = globalTime; var keyspaceName = rtqSettings.QueueKeyspace; cfConnection = cassandraCluster.RetrieveColumnFamilyConnection(keyspaceName, ColumnFamilyName); var remoteLockImplementationSettings = CassandraRemoteLockImplementationSettings.Default(keyspaceName, RtqColumnFamilyRegistry.LocksColumnFamilyName); var remoteLockImplementation = new CassandraRemoteLockImplementation(cassandraCluster, serializer, remoteLockImplementationSettings); remoteLockCreator = new RemoteLocker(remoteLockImplementation, new RemoteLockerMetrics(keyspaceName), log); }
private static IRemoteLockCreator[] PrepareRemoteLockCreators(int threadCount, LocalRivalOptimization localRivalOptimization, CassandraRemoteLockImplementation remoteLockImplementation) { var remoteLockCreators = new IRemoteLockCreator[threadCount]; var remoteLockerMetrics = new RemoteLockerMetrics(null); if (localRivalOptimization == LocalRivalOptimization.Enabled) { var singleRemoteLocker = new RemoteLocker(remoteLockImplementation, remoteLockerMetrics, logger); for (var i = 0; i < threadCount; i++) { remoteLockCreators[i] = singleRemoteLocker; } } else { for (var i = 0; i < threadCount; i++) { remoteLockCreators[i] = new RemoteLocker(remoteLockImplementation, remoteLockerMetrics, logger); } } return(remoteLockCreators); }
public RemoteLockHandle(string lockId, string threadId, RemoteLocker remoteLocker) { LockId = lockId; ThreadId = threadId; this.remoteLocker = remoteLocker; }