Exemplo n.º 1
0
        internal void Hello(
            string hash,
            [Required, Description("Machine to send Hello request to")] string host,
            [Description("GRPC port on the target machine"), DefaultValue(ServiceConfiguration.GrpcDisabledPort)] int grpcPort,
            [Description("Name of the memory mapped file used to share GRPC port. 'CASaaS GRPC port' if not specified.")] string grpcPortFileName)
        {
            try
            {
                Initialize();

                if (grpcPort == 0)
                {
                    grpcPort = Helpers.GetGrpcPortFromFile(_logger, grpcPortFileName);
                }

                var _channel      = new Channel(host, grpcPort, ChannelCredentials.Insecure);
                var _client       = new ContentServer.ContentServerClient(_channel);
                var helloResponse = _client.Hello(new HelloRequest(), new CallOptions(deadline: DateTime.UtcNow + TimeSpan.FromSeconds(2)));

                _logger.Always("Hello response {0}: {1}", helloResponse.Success ? "succeeded" : "failed", helloResponse.ToString());
            }
            catch (Exception e)
            {
                _logger.Always(e.ToString());
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GrpcCopyClient" /> class.
 /// </summary>
 internal GrpcCopyClient(GrpcCopyClientKey key, int?clientBufferSize)
 {
     GrpcEnvironment.InitializeIfNeeded();
     _channel    = new Channel(key.Host, key.GrpcPort, ChannelCredentials.Insecure, GrpcEnvironment.DefaultConfiguration);
     _client     = new ContentServer.ContentServerClient(_channel);
     _bufferSize = clientBufferSize ?? ContentStore.Grpc.CopyConstants.DefaultBufferSize;
     Key         = key;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GrpcCopyClient" /> class.
 /// </summary>
 private GrpcCopyClient(string host, int grpcPort)
 {
     GrpcEnvironment.InitializeIfNeeded();
     _channel  = new Channel(host, grpcPort, ChannelCredentials.Insecure);
     _client   = new ContentServer.ContentServerClient(_channel);
     _host     = host;
     _grpcPort = grpcPort;
 }
Exemplo n.º 4
0
 /// <nodoc />
 protected GrpcContentClient(
     ServiceClientContentSessionTracer tracer,
     IAbsFileSystem fileSystem,
     ServiceClientRpcConfiguration configuration,
     string?scenario,
     Capabilities capabilities = Capabilities.ContentOnly)
     : base(fileSystem, tracer, configuration, scenario, capabilities)
 {
     Client = new ContentServer.ContentServerClient(Channel);
 }
Exemplo n.º 5
0
 internal GrpcCopyClient(GrpcCopyClientKey key, int?clientBufferSize, int?copyTimeoutInSeconds)
 {
     GrpcEnvironment.InitializeIfNeeded();
     _clock                 = SystemClock.Instance;
     _channel               = new Channel(key.Host, key.GrpcPort, ChannelCredentials.Insecure, GrpcEnvironment.DefaultConfiguration);
     _client                = new ContentServer.ContentServerClient(_channel);
     _bufferSize            = clientBufferSize ?? ContentStore.Grpc.CopyConstants.DefaultBufferSize;
     _copyConnectionTimeout = copyTimeoutInSeconds.HasValue ? TimeSpan.FromSeconds(copyTimeoutInSeconds.Value) : ContentStore.Grpc.CopyConstants.DefaultConnectionTimeoutSeconds;
     Key = key;
 }
 /// <nodoc />
 public GrpcContentClient(
     ServiceClientContentSessionTracer tracer,
     IAbsFileSystem fileSystem,
     ServiceClientRpcConfiguration configuration,
     string scenario,
     Capabilities capabilities = Capabilities.ContentOnly)
     : base(fileSystem, tracer, configuration, scenario, capabilities)
 {
     GrpcEnvironment.InitializeIfNeeded();
     Client = new ContentServer.ContentServerClient(Channel);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GrpcClient" /> class.
 /// </summary>
 public GrpcClient(ServiceClientContentSessionTracer tracer, IAbsFileSystem fileSystem, uint grpcPort, string scenario, TimeSpan?heartbeatInterval = null)
 {
     _tracer     = tracer;
     _fileSystem = fileSystem;
     _grpcPort   = grpcPort;
     _scenario   = scenario;
     GrpcEnvironment.InitializeIfNeeded();
     _channel            = new Channel(GrpcEnvironment.Localhost, (int)grpcPort, ChannelCredentials.Insecure);
     _client             = new ContentServer.ContentServerClient(_channel);
     _clientCapabilities = DefaultClientCapabilities;
     _heartbeatInterval  = heartbeatInterval ?? TimeSpan.FromMinutes(DefaultHeartbeatIntervalMinutes);
 }
Exemplo n.º 8
0
 /// <nodoc />
 public GrpcContentClient(
     ServiceClientContentSessionTracer tracer,
     IAbsFileSystem fileSystem,
     int grpcPort,
     string scenario,
     TimeSpan?heartbeatInterval = null,
     Capabilities capabilities  = Capabilities.ContentOnly)
     : base(fileSystem, tracer, grpcPort, scenario, capabilities, heartbeatInterval)
 {
     GrpcEnvironment.InitializeIfNeeded();
     _client = new ContentServer.ContentServerClient(Channel);
 }
 /// <nodoc />
 public GrpcContentClient(
     ServiceClientContentSessionTracer tracer,
     IAbsFileSystem fileSystem,
     int grpcPort,
     string scenario,
     TimeSpan?heartbeatInterval = null,
     Capabilities capabilities  = Capabilities.ContentOnly)
     : this(tracer, fileSystem, new ServiceClientRpcConfiguration(grpcPort, heartbeatInterval), scenario, capabilities)
 {
     GrpcEnvironment.InitializeIfNeeded();
     Client = new ContentServer.ContentServerClient(Channel);
 }
Exemplo n.º 10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GrpcCopyClient" /> class.
        /// </summary>
        internal GrpcCopyClient(GrpcCopyClientKey key, Configuration config)
        {
            GrpcEnvironment.InitializeIfNeeded();
            _channel    = new Channel(key.Host, key.GrpcPort, ChannelCredentials.Insecure, GrpcEnvironment.DefaultConfiguration);
            _client     = new ContentServer.ContentServerClient(_channel);
            _bufferSize = config.ClientBufferSize ?? ContentStore.Grpc.CopyConstants.DefaultBufferSize;
            var bandwidthSource = config.MinimumBandwidthMbPerSec == null
                ? (IBandwidthLimitSource) new HistoricalBandwidthLimitSource()
                : new ConstantBandwidthLimit(config.MinimumBandwidthMbPerSec.Value);

            _bandwidthChecker = new BandwidthChecker(bandwidthSource, config.BandwidthCheckInterval);
            Key = key;
        }
Exemplo n.º 11
0
        internal GrpcCopyClient(GrpcCopyClientKey key, GrpcCopyClientConfiguration configuration, IClock?clock = null, ByteArrayPool?sharedBufferPool = null)
        {
            Key            = key;
            _configuration = configuration;
            _clock         = clock ?? SystemClock.Instance;

            GrpcEnvironment.WaitUntilInitialized();
            _channel = new Channel(key.Host, key.GrpcPort,
                                   ChannelCredentials.Insecure,
                                   options: GrpcEnvironment.GetClientOptions(_configuration.GrpcCoreClientOptions));

            _client = new ContentServer.ContentServerClient(_channel);

            _bandwidthChecker = new BandwidthChecker(configuration.BandwidthCheckerConfiguration);
            _pool             = sharedBufferPool ?? new ByteArrayPool(_configuration.ClientBufferSizeBytes);
        }
Exemplo n.º 12
0
        internal GrpcCopyClient(Context context, GrpcCopyClientKey key, GrpcCopyClientConfiguration configuration, IClock?clock = null, ByteArrayPool?sharedBufferPool = null)
        {
            Key            = key;
            _configuration = configuration;
            _clock         = clock ?? SystemClock.Instance;

            GrpcEnvironment.WaitUntilInitialized();
            var  channelCreds      = ChannelCredentials.Insecure;
            bool?encryptionEnabled = _configuration.GrpcCoreClientOptions?.EncryptionEnabled;

            Tracer.Info(context, $"Grpc Encryption Enabled = {encryptionEnabled == true}, GRPC Port: {key.GrpcPort}");

            List <ChannelOption> options = new List <ChannelOption>(GrpcEnvironment.GetClientOptions(_configuration.GrpcCoreClientOptions));

            if (encryptionEnabled == true)
            {
                try
                {
                    channelCreds = TryGetSecureChannelCredentials(context, _configuration, out var hostName) ?? ChannelCredentials.Insecure;
                    if (channelCreds != ChannelCredentials.Insecure)
                    {
                        options.Add(new ChannelOption(ChannelOptions.SslTargetNameOverride, hostName));
                    }
                }
                catch (Exception ex)
                {
                    Tracer.Error(context, ex, $"Creating Encrypted Grpc Channel Failed.");
                }
            }

            Tracer.Debug(context, $"Client connecting to {key.Host}:{key.GrpcPort}. Channel Encrypted = {channelCreds != ChannelCredentials.Insecure}");

            _channel = new Channel(key.Host, key.GrpcPort, channelCreds, options: options);
            _client  = new ContentServer.ContentServerClient(_channel);

            _bandwidthChecker = new BandwidthChecker(_configuration.BandwidthCheckerConfiguration);
            _pool             = sharedBufferPool ?? new ByteArrayPool(_configuration.ClientBufferSizeBytes);
        }
Exemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GrpcRepairClient" /> class.
 /// </summary>
 public GrpcRepairClient(uint grpcPort)
 {
     GrpcEnvironment.InitializeIfNeeded();
     _channel = new Channel(GrpcEnvironment.Localhost, (int)grpcPort, ChannelCredentials.Insecure);
     _client  = new ContentServer.ContentServerClient(_channel);
 }
Exemplo n.º 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GrpcCopyClient" /> class.
 /// </summary>
 private GrpcCopyClient(Channel channel)
 {
     GrpcEnvironment.InitializeIfNeeded();
     _client = new ContentServer.ContentServerClient(channel);
 }
Exemplo n.º 15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GrpcCopyClient" /> class.
 /// </summary>
 private GrpcCopyClient(Channel channel, bool useCompression)
 {
     GrpcEnvironment.InitializeIfNeeded();
     _client         = new ContentServer.ContentServerClient(channel);
     _useCompression = useCompression;
 }
Exemplo n.º 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GrpcRepairClient" /> class.
 /// </summary>
 public GrpcRepairClient(uint grpcPort)
 {
     GrpcEnvironment.WaitUntilInitialized();
     _channel = new Channel(GrpcEnvironment.LocalHost, (int)grpcPort, ChannelCredentials.Insecure, GrpcEnvironment.GetClientOptions());
     _client  = new ContentServer.ContentServerClient(_channel);
 }