Ejemplo n.º 1
0
        public Transport(
            IConnectionConfigurationValues configurationValues,
            IConnection connection,
            IOrientdbSerializer serializer,
            IDateTimeProvider dateTimeProvider         = null,
            IMemoryStreamProvider memoryStreamProvider = null
            )
        {
            ConfigurationValues = configurationValues;
            Connection          = connection ?? new HttpConnection(configurationValues);
            //_serializer = serializer ?? new OrientdbDefaultSerializer();
            _serializer = serializer ?? new OrientdbSerializer();

            _connectionPool = ConfigurationValues.ConnectionPool;

            _dateTimeProvider     = dateTimeProvider ?? new DateTimeProvider();
            _memoryStreamProvider = memoryStreamProvider ?? new MemoryStreamProvider();

            _lastSniff = _dateTimeProvider.Now();

            Settings.Serializer = _serializer;

            _requestHandler = new RequestHandler(Settings, _connectionPool, Connection, _serializer,
                                                 _memoryStreamProvider, this);
            _requestHandlerAsync = new RequestHandlerAsync(Settings, _connectionPool, Connection, _serializer,
                                                           _memoryStreamProvider, this);
            if (_connectionPool.AcceptsUpdates && Settings.SniffsOnStartup)
            {
                Self.SniffClusterState();
            }
        }
Ejemplo n.º 2
0
 public RequestHandler(
     IConnectionConfigurationValues settings,
     IConnectionPool connectionPool,
     IConnection connection,
     IOrientdbSerializer serializer,
     IMemoryStreamProvider memoryStreamProvider,
     ITransportDelegator delegator)
     : base(settings, connection, connectionPool, serializer, memoryStreamProvider, delegator)
 {
 }
Ejemplo n.º 3
0
 public OrientdbClient(
     IConnectionConfigurationValues settings = null,
     IConnection connection         = null,
     ITransport transport           = null,
     IOrientdbSerializer serializer = null
     )
 {
     settings            = settings ?? new ConnectionConfiguration();
     Transport           = transport ?? new Transport(settings, connection, serializer);
     Settings.Serializer = Transport.Serializer;
 }
        protected RequestHandlerBase(
            IConnectionConfigurationValues settings,
            IConnection connection,
            IConnectionPool connectionPool,
            IOrientdbSerializer serializer,
            IMemoryStreamProvider memoryStreamProvider,
            ITransportDelegator delegator)
        {
            _settings             = settings;
            _connection           = connection;
            _connectionPool       = connectionPool;
            _serializer           = serializer;
            _memoryStreamProvider = memoryStreamProvider;
            _delegator            = delegator;

            _throwMaxRetry = !(_connectionPool is SingleNodeConnectionPool);
        }
Ejemplo n.º 5
0
        internal static NameValueCollection ToNameValueCollection(this IDictionary <string, object> dict,
                                                                  IOrientdbSerializer stringifier)
        {
            stringifier.ThrowIfNull("stringifier");
            if (dict == null || dict.Count < 0)
            {
                return(null);
            }

            var nv = new NameValueCollection();

            foreach (var kv in dict.Where(kv => !kv.Key.IsNullOrEmpty()))
            {
                nv.Add(kv.Key, stringifier.Stringify(kv.Value));
            }
            return(nv);
        }
Ejemplo n.º 6
0
        public static IList <Uri> FromStream(IOrientdbResponse response, Stream stream, IOrientdbSerializer serializer)
        {
            var result = serializer.Deserialize <NodeInfoResponse>(stream);
            var l      = new List <Uri>();

            foreach (var kv in result.nodes.Values)
            {
                if (!kv.http_address.IsNullOrEmpty())
                {
                    l.Add(Parse("http", kv.http_address));
                }
                else if (!kv.https_address.IsNullOrEmpty())
                {
                    l.Add(Parse("https", kv.https_address));
                }
                else if (!kv.thrift_address.IsNullOrEmpty())
                {
                    l.Add(Parse("http", kv.thrift_address));
                }
            }
            return(l);
        }