internal ControlConnection(Cluster cluster,
                                   Policies policies,
                                   ProtocolOptions protocolOptions,
                                   PoolingOptions poolingOptions,
                                   SocketOptions socketOptions,
                                   ClientOptions clientOptions,
                                   IAuthProvider authProvider,
                                   IAuthInfoProvider authInfoProvider,
                                   IAddressTranslator addressTranslator)
        {
            _cluster              = cluster;
            _addressTranslator    = addressTranslator;
            _reconnectionSchedule = _reconnectionPolicy.NewSchedule();
            _reconnectionTimer    = new Timer(ReconnectionClb, null, Timeout.Infinite, Timeout.Infinite);

            var config = new Configuration
                         (
                policies,
                protocolOptions,
                poolingOptions,
                socketOptions,
                clientOptions,
                authProvider,
                authInfoProvider,
                new QueryOptions(),
                addressTranslator
                         );

            _session = new Session(cluster, config, "", _controlConnectionProtocolVersion);
        }
Exemple #2
0
 /// <summary>
 /// Creates a new instance. This class is also used to shareable a context across all instance that are created below one Cluster instance.
 /// One configuration instance per Cluster instance.
 /// </summary>
 internal Configuration(Policies policies,
                        ProtocolOptions protocolOptions,
                        PoolingOptions poolingOptions,
                        SocketOptions socketOptions,
                        ClientOptions clientOptions,
                        IAuthProvider authProvider,
                        IAuthInfoProvider authInfoProvider,
                        QueryOptions queryOptions,
                        IAddressTranslator addressTranslator,
                        IStartupOptionsFactory startupOptionsFactory,
                        ISessionFactoryBuilder <IInternalCluster, IInternalSession> sessionFactoryBuilder)
 {
     AddressTranslator     = addressTranslator ?? throw new ArgumentNullException(nameof(addressTranslator));
     QueryOptions          = queryOptions ?? throw new ArgumentNullException(nameof(queryOptions));
     Policies              = policies;
     ProtocolOptions       = protocolOptions;
     PoolingOptions        = poolingOptions;
     SocketOptions         = socketOptions;
     ClientOptions         = clientOptions;
     AuthProvider          = authProvider;
     AuthInfoProvider      = authInfoProvider;
     StartupOptionsFactory = startupOptionsFactory;
     SessionFactoryBuilder = sessionFactoryBuilder;
     // Create the buffer pool with 16KB for small buffers and 256Kb for large buffers.
     // The pool does not eagerly reserve the buffers, so it doesn't take unnecessary memory
     // to create the instance.
     BufferPool = new RecyclableMemoryStreamManager(16 * 1024, 256 * 1024, ProtocolOptions.MaximumFrameLength);
     Timer      = new HashedWheelTimer();
 }
Exemple #3
0
 public QualityAccidentService(
     IAuthInfoProvider authInfoProvider,
     IAppRepositoryBase <QualityAccident> accidentRepository,
     IAppRepositoryBase <QualityAccidentDisposal> disposalRepository,
     //  IAppRepositoryBase<Project> projectRepository,
     IAppDbContextProvider dbContextProvider,
     IDbOperator op,
     IEventBus eventBus,
     IWfEngine wfEngine,
     IProjectHelper projectHelper
     )
 {
     _projectHelper      = projectHelper;
     _authInfoProvider   = authInfoProvider;
     _accidentRepository = accidentRepository;
     _disposalRepository = disposalRepository;
     // _projectRepository = projectRepository;
     _dbContextProvider = dbContextProvider;
     _eventBus          = eventBus;
     _op = op;
     _runtimeProvider   = wfEngine.GetRuntimeProvider();
     _taskProvider      = wfEngine.GetTaskProvider();
     _definitionProvder = wfEngine.GetDefinitionProvider();
     _historyProvider   = wfEngine.GetHistoryProvider();
 }
Exemple #4
0
 /// <summary>
 ///  Uses the provided credentials when connecting to Cassandra hosts. <p> This
 ///  should be used if the Cassandra cluster has been configured to use the
 ///  <c>PasswordAuthenticator</c>. If the the default <c>*
 ///  AllowAllAuthenticator</c> is used instead, using this method has no effect.</p>
 /// </summary>
 /// <param name="username"> the user name to use to login to Cassandra hosts.</param>
 /// <param name="password"> the password corresponding to </param>
 /// <returns>this Builder</returns>
 public Builder WithCredentials(String username, String password)
 {
     _addedAuth        = true;
     _authInfoProvider = new SimpleAuthInfoProvider().Add("username", username).Add("password", password);
     _authProvider     = new PlainTextAuthProvider(username, password);
     return(this);
 }
        internal ControlConnection(Cluster cluster,
                                   IEnumerable<IPAddress> clusterEndpoints,
                                   Policies policies,
                                   ProtocolOptions protocolOptions,
                                   PoolingOptions poolingOptions,
                                   SocketOptions socketOptions,
                                   ClientOptions clientOptions,
                                   IAuthProvider authProvider,
                                   IAuthInfoProvider authInfoProvider)
        {
            _cluster = cluster;
            _reconnectionSchedule = _reconnectionPolicy.NewSchedule();
            _reconnectionTimer = new Timer(ReconnectionClb, null, Timeout.Infinite, Timeout.Infinite);

            var config = new Configuration
            (
                policies,
                protocolOptions,
                poolingOptions,
                socketOptions,
                clientOptions,
                authProvider,
                authInfoProvider,
                new QueryOptions()
            );

            _session = new Session(cluster, config, "", ControlConnectionProtocolVersion);
        }
Exemple #6
0
 /// <summary>
 /// Creates a new instance. This class is also used to shareable a context across all instance that are created below one Cluster instance.
 /// One configuration instance per Cluster instance.
 /// </summary>
 internal Configuration(Policies policies,
                        ProtocolOptions protocolOptions,
                        PoolingOptions poolingOptions,
                        SocketOptions socketOptions,
                        ClientOptions clientOptions,
                        IAuthProvider authProvider,
                        IAuthInfoProvider authInfoProvider,
                        QueryOptions queryOptions,
                        IAddressTranslator addressTranslator)
 {
     if (addressTranslator == null)
     {
         throw new ArgumentNullException("addressTranslator");
     }
     if (queryOptions == null)
     {
         throw new ArgumentNullException("queryOptions");
     }
     _policies          = policies;
     _protocolOptions   = protocolOptions;
     _poolingOptions    = poolingOptions;
     _socketOptions     = socketOptions;
     _clientOptions     = clientOptions;
     _authProvider      = authProvider;
     _authInfoProvider  = authInfoProvider;
     _queryOptions      = queryOptions;
     _addressTranslator = addressTranslator;
 }
 /// <summary>
 /// Creates a new instance. This class is also used to shareable a context across all instance that are created below one Cluster instance.
 /// One configuration instance per Cluster instance.
 /// </summary>
 internal Configuration(Policies policies,
     ProtocolOptions protocolOptions,
     PoolingOptions poolingOptions,
     SocketOptions socketOptions,
     ClientOptions clientOptions,
     IAuthProvider authProvider,
     IAuthInfoProvider authInfoProvider,
     QueryOptions queryOptions,
     IAddressTranslator addressTranslator)
 {
     if (addressTranslator == null)
     {
         throw new ArgumentNullException("addressTranslator");
     }
     if (queryOptions == null)
     {
         throw new ArgumentNullException("queryOptions");
     }
     _policies = policies;
     _protocolOptions = protocolOptions;
     _poolingOptions = poolingOptions;
     _socketOptions = socketOptions;
     _clientOptions = clientOptions;
     _authProvider = authProvider;
     _authInfoProvider = authInfoProvider;
     _queryOptions = queryOptions;
     _addressTranslator = addressTranslator;
 }
Exemple #8
0
 public ProjectService(
     IAppRepositoryBase <Project> projectRepository,
     IAppRepositoryBase <ProjectUnit> projectUnitRepository,
     IAuthInfoProvider authInfoProvider,
     IWfEngine wfEngine,
     IAuthorizationRepositoryBase <User> userRepository,
     IAuthorizationRepositoryBase <UserUnit> userUnitRepository,
     IAppDbContextProvider dbContextProvider,
     IMessagingProvider messagingProvider,
     IProjectHelper projectHelper
     )
 {
     _projectHelper         = projectHelper;
     _messagingProvider     = messagingProvider;
     _authInfoProvider      = authInfoProvider;
     _userRepository        = userRepository;
     _userUnitRepository    = userUnitRepository;
     _runtimeProvider       = wfEngine.GetRuntimeProvider();
     _taskProvider          = wfEngine.GetTaskProvider();
     _definitionProvder     = wfEngine.GetDefinitionProvider();
     _historyProvider       = wfEngine.GetHistoryProvider();
     _dbContextProvider     = dbContextProvider;
     _projectRepository     = projectRepository;
     _projectUnitRepository = projectUnitRepository;
 }
 /// <summary>
 /// Creates a new instance. This class is also used to shareable a context across all instance that are created below one Cluster instance.
 /// One configuration instance per Cluster instance.
 /// </summary>
 internal Configuration(Policies policies,
                        ProtocolOptions protocolOptions,
                        PoolingOptions poolingOptions,
                        SocketOptions socketOptions,
                        ClientOptions clientOptions,
                        IAuthProvider authProvider,
                        IAuthInfoProvider authInfoProvider,
                        QueryOptions queryOptions,
                        IAddressTranslator addressTranslator,
                        IInterceptor interceptor)
 {
     if (addressTranslator == null)
     {
         throw new ArgumentNullException("addressTranslator");
     }
     if (queryOptions == null)
     {
         throw new ArgumentNullException("queryOptions");
     }
     _policies          = policies;
     _protocolOptions   = protocolOptions;
     _poolingOptions    = poolingOptions;
     _socketOptions     = socketOptions;
     _clientOptions     = clientOptions;
     _authProvider      = authProvider;
     _authInfoProvider  = authInfoProvider;
     _queryOptions      = queryOptions;
     _addressTranslator = addressTranslator;
     // Create the buffer pool with 16KB for small buffers and 256Kb for large buffers.
     // The pool does not eagerly reserve the buffers, so it doesn't take unnecessary memory
     // to create the instance.
     _bufferPool  = new RecyclableMemoryStreamManager(16 * 1024, 256 * 1024, ProtocolOptions.MaximumFrameLength);
     _timer       = new HashedWheelTimer();
     _interceptor = interceptor;
 }
        internal Session(Cluster cluster,
                         IEnumerable <IPAddress> clusterEndpoints,
                         Policies policies,
                         ProtocolOptions protocolOptions,
                         PoolingOptions poolingOptions,
                         SocketOptions socketOptions,
                         ClientOptions clientOptions,
                         IAuthInfoProvider authProvider,
                         bool metricsEnabled,
                         string keyspace,
                         Hosts hosts)
        {
            this._cluster = cluster;

            this._protocolOptions = protocolOptions;
            this._poolingOptions  = poolingOptions;
            this._socketOptions   = socketOptions;
            this._clientOptions   = clientOptions;
            this._authProvider    = authProvider;
            this._metricsEnabled  = metricsEnabled;

            this._policies = policies ?? Policies.DefaultPolicies;

            _hosts = hosts;

            foreach (var ep in clusterEndpoints)
            {
                _hosts.AddIfNotExistsOrBringUpIfDown(ep);
            }

            this._policies.LoadBalancingPolicy.Initialize(_cluster);

            _keyspace = keyspace ?? clientOptions.DefaultKeyspace;
        }
        internal CassandraConnection(Session owner, IPAddress serverAddress, ProtocolOptions protocolOptions,
                                     SocketOptions socketOptions, ClientOptions clientOptions,
                                     IAuthInfoProvider authInfoProvider)
        {
            this._owner = owner;
            _bufferingMode = null;
            switch (protocolOptions.Compression)
            {
                case CompressionType.Snappy:
                    _bufferingMode = new FrameBuffering();
                    break;
                case CompressionType.NoCompression:
                    _bufferingMode = clientOptions.WithoutRowSetBuffering ? new NoBuffering() : new FrameBuffering();
                    break;
                default:
                    throw new ArgumentException();
            }

            this._authInfoProvider = authInfoProvider;
            if (protocolOptions.Compression == CompressionType.Snappy)
            {
                _startupOptions.Add("COMPRESSION", "snappy");
                _compressor = new SnappyProtoBufCompressor();
            }
            this._serverAddress = serverAddress;
            this._port = protocolOptions.Port;
            this._queryAbortTimeout = clientOptions.QueryAbortTimeout;
            this._asyncCallAbortTimeout = clientOptions.AsyncCallAbortTimeout;

            this._socketOptions = socketOptions;

            CreateConnection();
            if (IsHealthy)
                BeginReading();
        }
Exemple #12
0
 //private IAppRepositoryBase<ProjectUnit> _projectUnitRepository;
 //private IProjectHelper _projectHelper;
 public ProjectStatisticsService(
     IAppRepositoryBase <Project> projectRepository,
     IAppRepositoryBase <QualityProblem> qualityProblemRepository,
     IAppRepositoryBase <SafetyProblem> safetyProblemRepository,
     //IAppRepositoryBase<ProjectUnit> projectUnitRepository,
     IAuthInfoProvider authInfoProvider,
     IWfEngine wfEngine,
     IAuthorizationRepositoryBase <User> userRepository,
     IAuthorizationRepositoryBase <UserUnit> userUnitRepository,
     //IAppDbContextProvider dbContextProvider,
     //IMessagingProvider messagingProvider,
     IProjectHelper projectHelper
     )
 {
     //_projectHelper = projectHelper;
     //_messagingProvider = messagingProvider;
     _authInfoProvider   = authInfoProvider;
     _userRepository     = userRepository;
     _userUnitRepository = userUnitRepository;
     //_runtimeProvider = wfEngine.GetRuntimeProvider();
     //_taskProvider = wfEngine.GetTaskProvider();
     //_definitionProvder = wfEngine.GetDefinitionProvider();
     //_historyProvider = wfEngine.GetHistoryProvider();
     //_dbContextProvider = dbContextProvider;
     _projectRepository        = projectRepository;
     _qualityProblemRepository = qualityProblemRepository;
     _safetyProblemRepository  = safetyProblemRepository;
     //_projectUnitRepository = projectUnitRepository;
 }
Exemple #13
0
        internal Session(Cluster cluster,
                         Policies policies,
                         ProtocolOptions protocolOptions,
                         PoolingOptions poolingOptions,
                         SocketOptions socketOptions,
                         ClientOptions clientOptions,
                         IAuthProvider authProvider,
                         IAuthInfoProvider authInfoProvider,
                         string keyspace,
                         int binaryProtocolVersion)
        {
            _binaryProtocolVersion = binaryProtocolVersion;
            _cluster = cluster;

            _protocolOptions  = protocolOptions;
            _poolingOptions   = poolingOptions;
            _socketOptions    = socketOptions;
            _clientOptions    = clientOptions;
            _authProvider     = authProvider;
            _authInfoProvider = authInfoProvider;

            Policies = policies ?? Policies.DefaultPolicies;

            Policies.LoadBalancingPolicy.Initialize(_cluster);

            _keyspace = keyspace ?? clientOptions.DefaultKeyspace;

            Guid = Guid.NewGuid();
        }
Exemple #14
0
 public QualityProblemService(
     IAuthInfoProvider authInfoProvider,
     IAppRepositoryBase <QualityProblem> problemRepository,
     IAppRepositoryBase <QualityProblemRectification> rectificationRepository,
     // IAppRepositoryBase<Project> projectRepository,
     IAppDbContextProvider dbContextProvider,
     IDbOperator op,
     IEventBus eventBus,
     IWfEngine wfEngine,
     IProjectHelper projectHelper
     )
 {
     _projectHelper           = projectHelper;
     _authInfoProvider        = authInfoProvider;
     _problemRepository       = problemRepository;
     _rectificationRepository = rectificationRepository;
     //_projectRepository = projectRepository;
     _dbContextProvider = dbContextProvider;
     _eventBus          = eventBus;
     _op = op;
     _runtimeProvider   = wfEngine.GetRuntimeProvider();
     _taskProvider      = wfEngine.GetTaskProvider();
     _definitionProvder = wfEngine.GetDefinitionProvider();
     _historyProvider   = wfEngine.GetHistoryProvider();
 }
Exemple #15
0
 public TaskService(
     IWfEngine wfEgine,
     IAuthInfoProvider authInfoProvider)
 {
     _taskProvider     = wfEgine.GetTaskProvider();
     _historyProvider  = wfEgine.GetHistoryProvider();
     _authInfoProvider = authInfoProvider;
 }
Exemple #16
0
 public ProjectHelper(
     IAppRepositoryBase <Project> projectRepository,
     IAuthInfoProvider authInfoProvider
     )
 {
     _projectRepository = projectRepository;
     _authInfoProvider  = authInfoProvider;
 }
Exemple #17
0
 public UserController(
     IUserService userService,
     IAuthInfoProvider authInfoProvider
     )
 {
     _authInfoProvider = authInfoProvider;
     _userService      = userService;
 }
Exemple #18
0
        /// <summary>
        /// Creates a new instance. This class is also used to shareable a context across all instance that are created below one Cluster instance.
        /// One configuration instance per Cluster instance.
        /// </summary>
        internal Configuration(Policies policies,
                               ProtocolOptions protocolOptions,
                               PoolingOptions poolingOptions,
                               SocketOptions socketOptions,
                               ClientOptions clientOptions,
                               IAuthProvider authProvider,
                               IAuthInfoProvider authInfoProvider,
                               QueryOptions queryOptions,
                               IAddressTranslator addressTranslator,
                               IStartupOptionsFactory startupOptionsFactory,
                               ISessionFactoryBuilder <IInternalCluster, IInternalSession> sessionFactoryBuilder,
                               IReadOnlyDictionary <string, IExecutionProfile> executionProfiles,
                               IRequestOptionsMapper requestOptionsMapper,
                               MetadataSyncOptions metadataSyncOptions,
                               IEndPointResolver endPointResolver,
                               IRequestHandlerFactory requestHandlerFactory         = null,
                               IHostConnectionPoolFactory hostConnectionPoolFactory = null,
                               IRequestExecutionFactory requestExecutionFactory     = null,
                               IConnectionFactory connectionFactory = null,
                               IControlConnectionFactory controlConnectionFactory = null,
                               IPrepareHandlerFactory prepareHandlerFactory       = null,
                               ITimerFactory timerFactory = null)
        {
            AddressTranslator     = addressTranslator ?? throw new ArgumentNullException(nameof(addressTranslator));
            QueryOptions          = queryOptions ?? throw new ArgumentNullException(nameof(queryOptions));
            Policies              = policies;
            ProtocolOptions       = protocolOptions;
            PoolingOptions        = poolingOptions;
            SocketOptions         = socketOptions;
            ClientOptions         = clientOptions;
            AuthProvider          = authProvider;
            AuthInfoProvider      = authInfoProvider;
            StartupOptionsFactory = startupOptionsFactory;
            SessionFactoryBuilder = sessionFactoryBuilder;
            RequestOptionsMapper  = requestOptionsMapper;
            MetadataSyncOptions   = metadataSyncOptions?.Clone() ?? new MetadataSyncOptions();
            DnsResolver           = new DnsResolver();
            EndPointResolver      = endPointResolver ?? new EndPointResolver(DnsResolver, protocolOptions);

            RequestHandlerFactory     = requestHandlerFactory ?? new RequestHandlerFactory();
            HostConnectionPoolFactory = hostConnectionPoolFactory ?? new HostConnectionPoolFactory();
            RequestExecutionFactory   = requestExecutionFactory ?? new RequestExecutionFactory();
            ConnectionFactory         = connectionFactory ?? new ConnectionFactory();
            ControlConnectionFactory  = controlConnectionFactory ?? new ControlConnectionFactory();
            PrepareHandlerFactory     = prepareHandlerFactory ?? new PrepareHandlerFactory();
            TimerFactory = timerFactory ?? new TaskBasedTimerFactory();

            RequestOptions    = RequestOptionsMapper.BuildRequestOptionsDictionary(executionProfiles, policies, socketOptions, clientOptions, queryOptions);
            ExecutionProfiles = BuildExecutionProfilesDictionary(executionProfiles, RequestOptions);

            // Create the buffer pool with 16KB for small buffers and 256Kb for large buffers.
            // The pool does not eagerly reserve the buffers, so it doesn't take unnecessary memory
            // to create the instance.
            BufferPool = new RecyclableMemoryStreamManager(16 * 1024, 256 * 1024, ProtocolOptions.MaximumFrameLength);
            Timer      = new HashedWheelTimer();
        }
Exemple #19
0
 public AccountController(
     IAccountService accountService, IAuthInfoProvider authInfoProvider, IUserService userService,
     IProcessDefinitionService processDefinitionService
     )
 {
     _processDefinitionService = processDefinitionService;
     _accountService           = accountService;
     _authInfoProvider         = authInfoProvider;
     _userService = userService;
 }
Exemple #20
0
 public IdentityService(
     [NotNull] IAuthService authService,
     [NotNull] UserCredentialStorage userCredentialStorage,
     [NotNull] UserSessionStorage userSessionStorage,
     [NotNull] IAuthInfoProvider authInfoProvider)
 {
     _authService           = authService ?? throw new ArgumentNullException(nameof(authService));
     _userCredentialStorage = userCredentialStorage ?? throw new ArgumentNullException(nameof(userCredentialStorage));
     _userSessionStorage    = userSessionStorage ?? throw new ArgumentNullException(nameof(userSessionStorage));
     _authInfoProvider      = authInfoProvider ?? throw new ArgumentNullException(nameof(authInfoProvider));
 }
Exemple #21
0
 public MonthlyPlanService(
     IAuthInfoProvider authInfoProvider,
     IAppRepositoryBase <MonthlyPlan> investmentMonthlyPlanRepository,
     // IAppRepositoryBase<Project> projectRepository
     IProjectHelper projectHelper
     )
 {
     _projectHelper    = projectHelper;
     _authInfoProvider = authInfoProvider;
     _planRepository   = investmentMonthlyPlanRepository;
     // _projectRepository = projectRepository;
 }
Exemple #22
0
 public CalendarService(
     IAuthInfoProvider authInfoProvider,
     IAppRepositoryBase <Calendar> calendarRepository,
     IAuthorizationRepositoryBase <User> userRepository,
     IAuthorizationRepositoryBase <PrivilegedPerson> privilegedPersonRepository
     )
 {
     _authInfoProvider           = authInfoProvider;
     _privilegedPersonRepository = privilegedPersonRepository;
     _calendarRepository         = calendarRepository;
     _userRepository             = userRepository;
 }
Exemple #23
0
 internal Configuration(Policies policies,
                        ProtocolOptions protocolOptions,
                        PoolingOptions poolingOptions,
                        SocketOptions socketOptions,
                        ClientOptions clientOptions,
                        IAuthInfoProvider authProvider)
 {
     this._policies        = policies;
     this._protocolOptions = protocolOptions;
     this._poolingOptions  = poolingOptions;
     this._socketOptions   = socketOptions;
     this._clientOptions   = clientOptions;
     this._authProvider    = authProvider;
 }
 internal Configuration(Policies policies,
                      ProtocolOptions protocolOptions,
                      PoolingOptions poolingOptions,
                      SocketOptions socketOptions,
                      ClientOptions clientOptions,
                      IAuthInfoProvider authProvider)
 {
     this._policies = policies;
     this._protocolOptions = protocolOptions;
     this._poolingOptions = poolingOptions;
     this._socketOptions = socketOptions;
     this._clientOptions = clientOptions;
     this._authProvider = authProvider;
 }
Exemple #25
0
 public ProcessDefinitionService(IWfEngine wfEngine,
                                 IAppDbContextProvider dbContextProvider,
                                 IAppRepositoryBase <RoleProcessDefinition> roleProcessDefinitionRepository,
                                 IWorkflowRepositoryBase <Wf_Re_ProcessDefinition> processDefinitionRepository,
                                 IAuthorizationRepositoryBase <User> userRepository,
                                 IAuthInfoProvider authInfoProvider
                                 )
 {
     _userRepository     = userRepository;
     _authInfoProvider   = authInfoProvider;
     _definitionProvider = wfEngine.GetDefinitionProvider();
     _dbContextProvider  = dbContextProvider;
     _roleProcessDefinitionRepository = roleProcessDefinitionRepository;
     _processDefinitionRepository     = processDefinitionRepository;
 }
Exemple #26
0
 public ContractPaymentService(
     IAuthInfoProvider authInfoProvider,
     IAppRepositoryBase <ContractPayment> contractPaymentRepository,
     IAppDbContextProvider dbContextProvider,
     IWfEngine wfEngine
     )
 {
     _authInfoProvider          = authInfoProvider;
     _contractPaymentRepository = contractPaymentRepository;
     _dbContextProvider         = dbContextProvider;
     _runtimeProvider           = wfEngine.GetRuntimeProvider();
     _taskProvider      = wfEngine.GetTaskProvider();
     _definitionProvder = wfEngine.GetDefinitionProvider();
     _historyProvider   = wfEngine.GetHistoryProvider();
 }
        internal ControlConnection(Cluster cluster,
                                   IEnumerable <IPAddress> clusterEndpoints,
                                   Policies policies,
                                   ProtocolOptions protocolOptions,
                                   PoolingOptions poolingOptions,
                                   SocketOptions socketOptions,
                                   ClientOptions clientOptions,
                                   IAuthInfoProvider authProvider)
        {
            this._cluster = cluster;
            this._reconnectionSchedule = _reconnectionPolicy.NewSchedule();
            this._reconnectionTimer    = new Timer(ReconnectionClb, null, Timeout.Infinite, Timeout.Infinite);

            _session = new Session(cluster, policies, protocolOptions, poolingOptions, socketOptions,
                                   clientOptions, authProvider, "");
        }
        internal ControlConnection(Cluster cluster,
                                   IEnumerable<IPAddress> clusterEndpoints,
                                   Policies policies,
                                   ProtocolOptions protocolOptions,
                                   PoolingOptions poolingOptions,
                                   SocketOptions socketOptions,
                                   ClientOptions clientOptions,
                                   IAuthInfoProvider authProvider)
        {
            this._cluster = cluster;
            this._reconnectionSchedule = _reconnectionPolicy.NewSchedule();
            this._reconnectionTimer = new Timer(ReconnectionClb, null, Timeout.Infinite, Timeout.Infinite);

            _session = new Session(cluster, policies, protocolOptions, poolingOptions, socketOptions,
                                   clientOptions, authProvider, "", false);
        }
 public Configuration(Policies policies,
                      ProtocolOptions protocolOptions,
                      PoolingOptions poolingOptions,
                      SocketOptions socketOptions,
                      ClientOptions clientOptions,
                      IAuthInfoProvider authProvider,
                      bool metricsEnabled)
 {
     this._policies = policies;
     this._protocolOptions = protocolOptions;
     this._poolingOptions = poolingOptions;
     this._socketOptions = socketOptions;
     this._clientOptions = clientOptions;
     this._authProvider = authProvider;
     this._metricsEnabled = metricsEnabled;
 }
        internal ControlConnection(Cluster cluster, 
                                   IEnumerable<IPAddress> clusterEndpoints,
                                   Policies policies,
                                   ProtocolOptions protocolOptions,
                                   PoolingOptions poolingOptions,
                                   SocketOptions socketOptions,
                                   ClientOptions clientOptions,
                                   IAuthInfoProvider authProvider,
                                   bool metricsEnabled)
        {
            this._cluster = cluster;
            this._reconnectionTimer = new Timer(ReconnectionClb, null, Timeout.Infinite, Timeout.Infinite);

            _session = new Session(cluster, clusterEndpoints, policies, protocolOptions, poolingOptions, socketOptions,
                                   clientOptions, authProvider, metricsEnabled, "", _cluster._hosts);
        }
 public Configuration(Policies policies,
                      ProtocolOptions protocolOptions,
                      PoolingOptions poolingOptions,
                      SocketOptions socketOptions,
                      ClientOptions clientOptions,
                      IAuthInfoProvider authProvider,
                      bool metricsEnabled)
 {
     this._policies        = policies;
     this._protocolOptions = protocolOptions;
     this._poolingOptions  = poolingOptions;
     this._socketOptions   = socketOptions;
     this._clientOptions   = clientOptions;
     this._authProvider    = authProvider;
     this._metricsEnabled  = metricsEnabled;
 }
Exemple #32
0
 public EarlyStageService(
     IAuthInfoProvider authInfoProvider,
     IAppRepositoryBase <EarlyStage> earlyStageRepository,
     IAppDbContextProvider dbContextProvider,
     IEventBus eventBus,
     IWfEngine wfEngine
     )
 {
     _authInfoProvider     = authInfoProvider;
     _earlyStageRepository = earlyStageRepository;
     _dbContextProvider    = dbContextProvider;
     _eventBus             = eventBus;
     _runtimeProvider      = wfEngine.GetRuntimeProvider();
     _taskProvider         = wfEngine.GetTaskProvider();
     _definitionProvder    = wfEngine.GetDefinitionProvider();
     _historyProvider      = wfEngine.GetHistoryProvider();
 }
 internal Configuration(Policies policies,
                        ProtocolOptions protocolOptions,
                        PoolingOptions poolingOptions,
                        SocketOptions socketOptions,
                        ClientOptions clientOptions,
                        IAuthProvider authProvider,
                        IAuthInfoProvider authInfoProvider,
                        QueryOptions queryOptions)
 {
     _policies         = policies;
     _protocolOptions  = protocolOptions;
     _poolingOptions   = poolingOptions;
     _socketOptions    = socketOptions;
     _clientOptions    = clientOptions;
     _authProvider     = authProvider;
     _authInfoProvider = authInfoProvider;
     _queryOptions     = queryOptions;
 }
 internal Configuration(Policies policies,
                        ProtocolOptions protocolOptions,
                        PoolingOptions poolingOptions,
                        SocketOptions socketOptions,
                        ClientOptions clientOptions,
                        IAuthProvider authProvider,
                        IAuthInfoProvider authInfoProvider,
                        QueryOptions queryOptions)
 {
     _policies = policies;
     _protocolOptions = protocolOptions;
     _poolingOptions = poolingOptions;
     _socketOptions = socketOptions;
     _clientOptions = clientOptions;
     _authProvider = authProvider;
     _authInfoProvider = authInfoProvider;
     _queryOptions = queryOptions;
 }
Exemple #35
0
 public RecordService(
     IAppRepositoryBase <Record> recordRepository,
     IAuthInfoProvider authInfoProvider,
     IWfEngine wfEngine,
     IAuthorizationRepositoryBase <User> userRepository,
     IAppDbContextProvider dbContextProvider,
     IMessagingProvider messagingProvider)
 {
     _recordRepository  = recordRepository;
     _messagingProvider = messagingProvider;
     _authInfoProvider  = authInfoProvider;
     _userRepository    = userRepository;
     _runtimeProvider   = wfEngine.GetRuntimeProvider();
     _taskProvider      = wfEngine.GetTaskProvider();
     _definitionProvder = wfEngine.GetDefinitionProvider();
     _historyProvider   = wfEngine.GetHistoryProvider();
     _dbContextProvider = dbContextProvider;
 }
Exemple #36
0
 public ProjectTaskService(
     IAppRepositoryBase <ProjectTask> taskRepository,
     IAppRepositoryBase <ProjectGantt> ganttRepository,
     IAuthInfoProvider authInfoProvider,
     IWfEngine wfEngine,
     IAuthorizationRepositoryBase <User> userRepository,
     IAppDbContextProvider dbContextProvider,
     IProjectHelper projectHelper
     )
 {
     _ganttRepository       = ganttRepository;
     _projectHelper         = projectHelper;
     _authInfoProvider      = authInfoProvider;
     _userRepository        = userRepository;
     _runtimeProvider       = wfEngine.GetRuntimeProvider();
     _taskProvider          = wfEngine.GetTaskProvider();
     _definitionProvder     = wfEngine.GetDefinitionProvider();
     _historyProvider       = wfEngine.GetHistoryProvider();
     _dbContextProvider     = dbContextProvider;
     _projectTaskRepository = taskRepository;
 }
Exemple #37
0
        public MemorabiliaRecordService(
            IAuthInfoProvider authInfoProvider,
            IWfEngine wfEngine,
            IAppRepositoryBase <MemorabiliaRecord> recordRepository,
            //IAppRepositoryBase<Project> projectRepository,
            IAppDbContextProvider dbContextProvider,
            IProjectHelper projectHelper


            )
        {
            _projectHelper    = projectHelper;
            _authInfoProvider = authInfoProvider;
            _recordRepository = recordRepository;
            // _projectRepository = projectRepository;
            _dbContextProvider = dbContextProvider;
            _runtimeProvider   = wfEngine.GetRuntimeProvider();
            _taskProvider      = wfEngine.GetTaskProvider();
            _definitionProvder = wfEngine.GetDefinitionProvider();
            _historyProvider   = wfEngine.GetHistoryProvider();
        }
Exemple #38
0
        internal CassandraConnection(Session owner, IPAddress serverAddress, ProtocolOptions protocolOptions,
                                     SocketOptions socketOptions, ClientOptions clientOptions,
                                     IAuthInfoProvider authInfoProvider)
        {
            this._owner    = owner;
            _bufferingMode = null;
            switch (protocolOptions.Compression)
            {
            case CompressionType.Snappy:
                _bufferingMode = new FrameBuffering();
                break;

            case CompressionType.NoCompression:
                _bufferingMode = clientOptions.WithoutRowSetBuffering ? new NoBuffering() : new FrameBuffering();
                break;

            default:
                throw new ArgumentException();
            }

            this._authInfoProvider = authInfoProvider;
            if (protocolOptions.Compression == CompressionType.Snappy)
            {
                _startupOptions.Add("COMPRESSION", "snappy");
                _compressor = new SnappyProtoBufCompressor();
            }
            this._serverAddress         = serverAddress;
            this._port                  = protocolOptions.Port;
            this._queryAbortTimeout     = clientOptions.QueryAbortTimeout;
            this._asyncCallAbortTimeout = clientOptions.AsyncCallAbortTimeout;

            this._socketOptions = socketOptions;

            CreateConnection();
            if (IsHealthy)
            {
                BeginReading();
            }
        }
Exemple #39
0
 /// <summary>
 ///  Uses the provided credentials when connecting to Cassandra hosts.
 ///  <p> This should be used if the Cassandra cluster has been configured to
 ///  use the {@code PasswordAuthenticator}. If the the default 
 ///  <code>AllowAllAuthenticator</code> is used instead, using this 
 ///  method has no effect.</p>
 /// </summary>
 /// <param name="username"> the username to use to login to Cassandra hosts.
 /// <param name="password"> the password corresponding to <code>username</code>.
 ///  </param>
 /// 
 /// <returns>this Builder</returns>
 public Builder WithCredentials(String username, String password)
 {
     this._authProvider = new SimpleAuthInfoProvider().Add("username", username).Add("password",password);
     return this;
 }
Exemple #40
0
        internal Session(Cluster cluster,
                         Policies policies,
                         ProtocolOptions protocolOptions,
                         PoolingOptions poolingOptions,
                         SocketOptions socketOptions,
                         ClientOptions clientOptions,
                         IAuthInfoProvider authProvider,
                         string keyspace, bool init)
        {
            try
            {
                this._cluster = cluster;

                this._protocolOptions = protocolOptions;
                this._poolingOptions = poolingOptions;
                this._socketOptions = socketOptions;
                this._clientOptions = clientOptions;
                this._authProvider = authProvider;

                this._policies = policies ?? Policies.DefaultPolicies;

                this._policies.LoadBalancingPolicy.Initialize(_cluster);

                _keyspace = keyspace ?? clientOptions.DefaultKeyspace;

                Guid = Guid.NewGuid();

                _trashcanCleaner = new Timer(TranscanCleanup, null, Timeout.Infinite, Timeout.Infinite);

                if (init)
                {
                    var ci = this._policies.LoadBalancingPolicy.NewQueryPlan(null).GetEnumerator();
                    if (!ci.MoveNext())
                    {
                        var ex = new NoHostAvailableException(new Dictionary<IPAddress, List<Exception>>());
                        _logger.Error(ex.Message);
                        throw ex;
                    }

                    var triedHosts = new List<IPAddress>();
                    var innerExceptions = new Dictionary<IPAddress, List<Exception>>();
                    int streamId;
                    var con = Connect(ci, triedHosts, innerExceptions, out streamId);
                    con.FreeStreamId(streamId);
                }
            }
            catch
            {
                InternalDispose();
                throw;
            }
        }
Exemple #41
0
        internal Session(Cluster cluster,
                         IEnumerable<IPAddress> clusterEndpoints,
                         Policies policies,
                         ProtocolOptions protocolOptions,
                         PoolingOptions poolingOptions,
                         SocketOptions socketOptions,
                         ClientOptions clientOptions,
                         IAuthInfoProvider authProvider,
                         bool metricsEnabled,
                         string keyspace,
                         Hosts hosts,ControlConnection controlConnection=null)
        {
            this._cluster = cluster;

            this._protocolOptions = protocolOptions;
            this._poolingOptions = poolingOptions;
            this._socketOptions = socketOptions;
            this._clientOptions = clientOptions;
            this._authProvider = authProvider;
            this._metricsEnabled = metricsEnabled;

            this._policies = policies ?? Policies.DefaultPolicies;

            _hosts = hosts ;

            this._controlConnection = controlConnection;

            foreach (var ep in clusterEndpoints)
                _hosts.AddIfNotExistsOrBringUpIfDown(ep, this._policies.ReconnectionPolicy);

            this._policies.LoadBalancingPolicy.Initialize(_cluster);

            _keyspace = keyspace ?? clientOptions.DefaultKeyspace;
        }
 /// <summary>
 ///  Use the provided <code>AuthInfoProvider</code> to connect to Cassandra hosts.
 ///  <p> This is optional if the Cassandra cluster has been configured to not
 ///  require authentication (the default).</p>
 /// </summary>
 /// <param name="authInfoProvider"> the authentication info provider to use
 ///  </param>
 /// 
 /// <returns>this Builder</returns>
 public Builder WithAuthInfoProvider(IAuthInfoProvider authInfoProvider)
 {
     this._authProvider = authInfoProvider;
     return this;
 }
        internal CassandraConnection(Session owner, IPAddress serverAddress, ProtocolOptions protocolOptions,
                                     SocketOptions socketOptions, ClientOptions clientOptions,
                                     IAuthInfoProvider authInfoProvider)
        {
            this.Guid = Guid.NewGuid();
            this._owner = owner;
            _bufferingMode = null;
            switch (protocolOptions.Compression)
            {
                case CompressionType.Snappy:
                    _bufferingMode = new FrameBuffering();
                    break;
                case CompressionType.NoCompression:
                    _bufferingMode = clientOptions.WithoutRowSetBuffering ? new NoBuffering() : new FrameBuffering();
                    break;
                default:
                    throw new ArgumentException();
            }

            this._authInfoProvider = authInfoProvider;
            if (protocolOptions.Compression == CompressionType.Snappy)
            {
                _startupOptions.Add("COMPRESSION", "snappy");
                _compressor = new SnappyProtoBufCompressor();
            }
            this._serverAddress = serverAddress;
            this._port = protocolOptions.Port;
            this._queryAbortTimeout = clientOptions.QueryAbortTimeout;

            this._socketOptions = socketOptions;

            for (int i = 0; i <= sbyte.MaxValue; i++)
                _freeStreamIDs.Push(i);

            _protocolErrorHandlerAction = new Action<ErrorActionParam>((param) =>
               {
                   if (param.AbstractResponse is ErrorResponse)
                       JobFinished(
                           param.Jar,
                           (param.AbstractResponse as ErrorResponse).Output);
               });

            _frameEventCallback.Value = new Action<ResponseFrame>(EventOccured);

            _buffer = new byte[][] {
                    new byte[_bufferingMode.PreferedBufferSize()],
                    new byte[_bufferingMode.PreferedBufferSize()] };

            var newSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            if (_socketOptions.KeepAlive != null)
                newSock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive,
                                        _socketOptions.KeepAlive.Value);

            newSock.SendTimeout = _socketOptions.ConnectTimeoutMillis;

            if (_socketOptions.SoLinger != null)
                newSock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger,
                                        new LingerOption(true, _socketOptions.SoLinger.Value));

            if (_socketOptions.ReceiveBufferSize != null)
                newSock.ReceiveBufferSize = _socketOptions.ReceiveBufferSize.Value;

            if (_socketOptions.SendBufferSize != null)
                newSock.ReceiveBufferSize = _socketOptions.SendBufferSize.Value;

            if (_socketOptions.TcpNoDelay != null)
                newSock.NoDelay = _socketOptions.TcpNoDelay.Value;

            newSock.Connect(new IPEndPoint(_serverAddress, _port));
            _socket = newSock;
            _bufferingMode.Reset();

            if (protocolOptions.SslOptions == null)
                _socketStream = new NetworkStream(_socket);
            else
            {
                string targetHost;
                try
                {
                    targetHost = Dns.GetHostEntry(_serverAddress).HostName;
                }
                catch (SocketException ex)
                {
                    targetHost = serverAddress.ToString();
                    _logger.Error(string.Format("SSL connection: Can not resolve {0} address. Using IP address instead of hostname. This may cause RemoteCertificateNameMismatch error during Cassandra host authentication. Note that Cassandra node SSL certificate's CN(Common Name) must match the Cassandra node hostname.", _serverAddress.ToString()), ex);
                }

                _socketStream = new SslStream(new NetworkStream(_socket), false, new RemoteCertificateValidationCallback(protocolOptions.SslOptions.RemoteCertValidationCallback), null);
                (_socketStream as SslStream).AuthenticateAsClient(targetHost, new X509CertificateCollection(), protocolOptions.SslOptions.SslProtocol, false);
            }

            if (IsHealthy)
                BeginReading();
        }
Exemple #44
0
        internal Session(Cluster cluster,
                         Policies policies,
                         ProtocolOptions protocolOptions,
                         PoolingOptions poolingOptions,
                         SocketOptions socketOptions,
                         ClientOptions clientOptions,
                         IAuthInfoProvider authProvider,
                         string keyspace)
        {
            this._cluster = cluster;

            this._protocolOptions = protocolOptions;
            this._poolingOptions = poolingOptions;
            this._socketOptions = socketOptions;
            this._clientOptions = clientOptions;
            this._authProvider = authProvider;

            this._policies = policies ?? Policies.DefaultPolicies;

            this._policies.LoadBalancingPolicy.Initialize(_cluster);

            _keyspace = keyspace ?? clientOptions.DefaultKeyspace;
        }