Esempio n. 1
0
 internal static void UpdateAndLogServiceEndpoint(ILogger logger, ServiceEndpoint endpoint)
 {
     LoadBalanceUtils.SetDataContractSerializerBehavior(endpoint.Contract);
     logger.LogVerbose("Connected endpoint {0} with binding {1} and contract {2} with session mode {3}", new object[]
     {
         endpoint.Address,
         endpoint.Binding.Name,
         endpoint.Contract.Name,
         endpoint.Contract.SessionMode
     });
     foreach (OperationDescription operationDescription in endpoint.Contract.Operations)
     {
         logger.LogVerbose("Operation:: {0}, {1}, {2}", new object[]
         {
             operationDescription.Name,
             operationDescription.ProtectionLevel,
             operationDescription.Behaviors.Find <DataContractSerializerOperationBehavior>()
         });
         foreach (MessageDescription messageDescription in operationDescription.Messages)
         {
             logger.LogVerbose("Operation[{0}]::Message({1}, {2})", new object[]
             {
                 operationDescription.Name,
                 messageDescription.Action,
                 messageDescription.MessageType
             });
         }
     }
 }
        private ServiceHost StartServiceEndpoint(object serviceInstance, ServiceEndpointAddress serviceAddress)
        {
            AnchorUtil.ThrowOnNullArgument(serviceInstance, "serviceInstance");
            ServiceHost result;

            try
            {
                ServiceHost serviceHost = new ServiceHost(serviceInstance, serviceAddress.GetBaseUris());
                serviceHost.AddDefaultEndpoints();
                this.logger.Log(MigrationEventType.Verbose, "Opening service host for {0}, with service type {1} and namespace {2}.", new object[]
                {
                    serviceHost.Description.Name,
                    serviceHost.Description.ServiceType.FullName,
                    serviceHost.Description.Namespace
                });
                ServiceDebugBehavior serviceDebugBehavior = serviceHost.Description.Behaviors.Find <ServiceDebugBehavior>();
                if (serviceDebugBehavior == null)
                {
                    serviceDebugBehavior = new ServiceDebugBehavior();
                    serviceHost.Description.Behaviors.Add(serviceDebugBehavior);
                }
                serviceDebugBehavior.IncludeExceptionDetailInFaults = true;
                foreach (System.ServiceModel.Description.ServiceEndpoint serviceEndpoint in serviceHost.Description.Endpoints)
                {
                    NetTcpBinding netTcpBinding = serviceEndpoint.Binding as NetTcpBinding;
                    if (netTcpBinding != null)
                    {
                        netTcpBinding.MaxReceivedMessageSize = 10485760L;
                        netTcpBinding.ReceiveTimeout         = TimeSpan.FromMinutes(10.0);
                        netTcpBinding.SendTimeout            = TimeSpan.FromMinutes(10.0);
                    }
                    this.logger.LogVerbose("Using binging: {0} ({1})", new object[]
                    {
                        serviceEndpoint.Binding.Name,
                        serviceEndpoint.Binding.MessageVersion
                    });
                    LoadBalanceUtils.UpdateAndLogServiceEndpoint(this.logger, serviceEndpoint);
                }
                serviceHost.Open();
                result = serviceHost;
            }
            catch (Exception exception)
            {
                this.logger.LogError(exception, "Failed to register endpoint for service {0}", new object[]
                {
                    serviceInstance.GetType().Name
                });
                throw;
            }
            return(result);
        }
Esempio n. 3
0
        public void InjectMoves(Guid targetDatabase, BatchName batchName, IList <LoadEntity> loadEntityList, bool throwIfNotValid = false)
        {
            this.logger.Log(MigrationEventType.Information, "Injecting {0} moves into database '{1}' with batch name '{2}'.", new object[]
            {
                loadEntityList.Count,
                targetDatabase,
                batchName
            });
            TopologyExtractorFactoryContextPool topologyExtractorFactoryContextPool = this.serviceContext.TopologyExtractorFactoryContextPool;
            IList <Guid> nonMovableOrgsList         = LoadBalanceUtils.GetNonMovableOrgsList(this.settings);
            TopologyExtractorFactoryContext context = topologyExtractorFactoryContextPool.GetContext(this.clientFactory, null, nonMovableOrgsList, this.logger);
            TopologyExtractorFactory        entitySelectorFactory = context.GetEntitySelectorFactory();
            LoadContainer database = entitySelectorFactory.GetExtractor(this.directoryProvider.GetDatabase(targetDatabase)).ExtractTopology();

            this.InjectMoves(database, batchName, loadEntityList, throwIfNotValid);
        }