分布式数据库系统---商旅预定系统的实现(7)

服务总站的构建

        总站在系统中充当着事务处理与协调的角色,每个客户端需要请求之前必须要连接总站。在总站提供的服务中进行处理。而在具体编码实现中,总站的地位与其他几个服务器的低位一致,在调用的时候只需要查找相应总站的方法进行处理。总站功能结构如下:

namespace GlobalService
{
    /// <summary>
    /// 所有事务的执行都需要通过此类的ProcessTransaction()方法执行
    /// 执行的必须条件为:
    /// *1.接受和设置表事务编号 String xid
    /// 2.接受和设置表Car的服务接口实现 ICarRemoteService m_carRemoteService;
    /// 3.接受和设置表Hotel的服务接口实现 IHotelRemoteService m_hotelRemoteService;
    /// 4.接受和设置表Flight的服务接口实现 IFlightRemoteService m_flightRemoteService;
    /// 5.接受和设置表Customer的服务接口实现 IcustomerRemoteService m_customerRemoteService;
    /// 6.接受和设置表Reservation的服务接口实现 IReservationRemoteService m_reservationRemoteService;
    /// *7.接受和设置表TransactionEntity的服务接口实现TransactionEntity m_TransactionEntity;
    /// </summary>
    public class GlobalControlServiceImpl : MarshalByRefObject, IGlobalControlService
    {

总站的参数列表

 

        static void Main(string[] args)
        {
            #region 总站启动
            //TcpServerChannel chanGlobalService = new TcpServerChannel(9991);
            //ChannelServices.RegisterChannel(chanGlobalService, false);
            //RemotingConfiguration.RegisterWellKnownServiceType(typeof(GlobalControlServiceImpl), "Service", WellKnownObjectMode.Singleton);

            BinaryServerFormatterSinkProvider Serverprovider = new BinaryServerFormatterSinkProvider();
            BinaryClientFormatterSinkProvider Clientprovider = new BinaryClientFormatterSinkProvider();
            Serverprovider.TypeFilterLevel = TypeFilterLevel.Full;
            IDictionary props = new Hashtable();
            props["Name"] = "RemoteTCP ";
            props["port"] = "9991";
            TcpChannel chan = new TcpChannel(props, Clientprovider, Serverprovider);
            ChannelServices.RegisterChannel(chan, false);
            RemotingConfiguration.RegisterWellKnownServiceType
                (typeof(GlobalControlServiceImpl), "Service", WellKnownObjectMode.Singleton);
            RemotingConfiguration.RegisterWellKnownServiceType
                (typeof(QueueTransactionServiceImpl), "Queue", WellKnownObjectMode.Singleton);

            Console.WriteLine("总站启动成功...");
            Console.ReadLine();
            #endregion

            #region 总站与CAR表相连
            //TcpClientChannel chan = new TcpClientChannel();
            //ChannelServices.RegisterChannel(chan, false);
            //ICarRemoteService carRemoteservice = (ICarRemoteService)Activator.GetObject(typeof(ICarRemoteService), "tcp://localhost:9999/Search", null);
            #endregion
        }

总站启动代码

 

    由于总站需要操作每一个数据服务集合,所以在接受参数时需要同样接受每一个数据服务集合的接口实现类,保证能正常操作分布的数据集合。


.分服务器和总服务器以及客户端的关系


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值