/// <inheritdoc />
        public override CreateSessionResult <IReadOnlyContentSession> CreateReadOnlySession(
            Context context,
            string name,
            ImplicitPin implicitPin)
        {
            return(CreateReadOnlySessionCall.Run(_tracer, new OperationContext(context), name, () =>
            {
                var sessionForStream = ContentStoreForStream.CreateSession(context, name, implicitPin);
                if (!sessionForStream.Succeeded)
                {
                    return new CreateSessionResult <IReadOnlyContentSession>(sessionForStream, "creation of stream content session failed");
                }

                var sessionForPath = ContentStoreForPath.CreateSession(context, name, implicitPin);
                if (!sessionForPath.Succeeded)
                {
                    return new CreateSessionResult <IReadOnlyContentSession>(sessionForPath, "creation of path content session failed");
                }

                var session = new StreamPathContentSession(
                    name,
                    sessionForStream.Session !,
                    sessionForPath.Session !);

                return new CreateSessionResult <IReadOnlyContentSession>(session);
            }));
Exemple #2
0
 /// <inheritdoc />
 public virtual CreateSessionResult <IReadOnlyContentSession> CreateReadOnlySession(Context context, string name, ImplicitPin implicitPin)
 {
     return(CreateReadOnlySessionCall.Run(_tracer, OperationContext(context), name, () =>
     {
         var session = new ReadOnlyFileSystemContentSession(name, Store, implicitPin);
         return new CreateSessionResult <IReadOnlyContentSession>(session);
     }));
 }
Exemple #3
0
        /// <nodoc />
        public CreateSessionResult <IReadOnlyContentSession> CreateReadOnlySession(Context context, string name, ImplicitPin implicitPin)
        {
            return(CreateReadOnlySessionCall.Run((ContentStoreTracer)Tracer, new OperationContext(context), name, () =>
            {
                var localSession = _localContentStore.CreateSession(context, name, implicitPin).ThrowIfFailure();
                var backingSession = _backingContentStore.CreateReadOnlySession(context, name, implicitPin).ThrowIfFailure();

                return new CreateSessionResult <IReadOnlyContentSession>(new MultiLevelReadOnlyContentSession <IReadOnlyContentSession>(name, localSession.Session, backingSession.Session, isLocalWritable: true));
            }));
        }
Exemple #4
0
 /// <inheritdoc />
 public virtual CreateSessionResult <IReadOnlyContentSession> CreateReadOnlySession(
     Context context, string name, ImplicitPin implicitPin)
 {
     return(CreateReadOnlySessionCall.Run(ExecutionTracer, OperationContext(context), name, () =>
     {
         var session = new ReadOnlyServiceClientContentSession(
             name,
             implicitPin,
             Logger,
             FileSystem,
             SessionTracer,
             Configuration);
         return new CreateSessionResult <IReadOnlyContentSession>(session);
     }));
 }
 public override CreateSessionResult <IReadOnlyContentSession> CreateReadOnlySession(
     Context context, string name, ImplicitPin implicitPin)
 {
     return(CreateReadOnlySessionCall.Run(ExecutionTracer, OperationContext(context), name, () =>
     {
         var session = new TestServiceClientContentSession(
             name,
             implicitPin,
             Configuration.RetryPolicy,
             _configuration.DataRootPath,
             _overrideCacheName ?? Configuration.CacheName,
             context.Logger,
             FileSystem,
             Configuration.Scenario,
             this,
             SessionTracer,
             GetRpcConfig());
         return new CreateSessionResult <IReadOnlyContentSession>(session);
     }));
 }
        /// <inheritdoc />
        public CreateSessionResult <IReadOnlyContentSession> CreateReadOnlySession(Context context, string name, ImplicitPin implicitPin)
        {
            return(CreateReadOnlySessionCall.Run(_tracer, OperationContext(context), name, () =>
            {
                CreateSessionResult <IContentSession> innerSessionResult = InnerContentStore.CreateSession(context, name, implicitPin);

                if (innerSessionResult.Succeeded)
                {
                    var session = new ReadOnlyDistributedContentSession <T>(
                        name,
                        innerSessionResult.Session,
                        _contentLocationStore,
                        _distributedCopier,
                        LocalMachineLocation,
                        pinCache: _pinCache,
                        contentTrackerUpdater: _contentTrackerUpdater,
                        settings: _settings);
                    return new CreateSessionResult <IReadOnlyContentSession>(session);
                }

                return new CreateSessionResult <IReadOnlyContentSession>(innerSessionResult, "Could not initialize inner content session with error");
            }));
        }
Exemple #7
0
        /// <nodoc />
        public CreateSessionResult <IReadOnlyContentSession> CreateReadOnlySession(Context context, string name, ImplicitPin implicitPin)
        {
            return(CreateReadOnlySessionCall.Run(Tracer, new OperationContext(context), name, () =>
            {
                var sessions = new Dictionary <string, IReadOnlyContentSession>(StringComparer.OrdinalIgnoreCase);
                foreach (KeyValuePair <string, IContentStore> entry in _drivesWithContentStore)
                {
                    var result = entry.Value.CreateReadOnlySession(context, name, implicitPin);
                    if (!result.Succeeded)
                    {
                        foreach (var session in sessions.Values)
                        {
                            session.Dispose();
                        }

                        return new CreateSessionResult <IReadOnlyContentSession>(result);
                    }
                    sessions.Add(entry.Key, result.Session);
                }

                var multiCacheSession = new MultiplexedReadOnlyContentSession(SessionTracer, sessions, name, _preferredCacheDrive);
                return new CreateSessionResult <IReadOnlyContentSession>(multiCacheSession);
            }));
        }