Beispiel #1
0
        //Inicializes a new List of Padints, and requests acess to the master and obtains an available server from it.
        public static bool Init()
        {
            _acessedPadInts = new List<PadInt>();

            //Finds the first port available from portMin to portMax and register a client there.
            int portMin = 2000, portMax = 4000;
            for (int i = portMin; i < portMax; i++)
            {
                if (CheckAvailableServerPort(i))
                {
                    registerClient(i);
                    break;
                }
            }
            //Gets master.
            try
            {
                _master = (RemoteMasterInterface)Activator.GetObject(
                typeof(RemoteMasterInterface),
                "tcp://localhost:" + Interfaces.Constants.MasterPort + "/master");
            }
            catch(TxException e)
            {
                return false;
            }
            if (!requestServer())
                return false;

            _inTransaction = false;

            return true;
        }
Beispiel #2
0
 //Registers this server on the master server.
 internal void regToMaster(int localport)
 {
     _ownURL = "tcp://localhost:" + localport + "/Server";
     _master = (RemoteMasterInterface)Activator.GetObject(
     typeof(RemoteMasterInterface),
     "tcp://localhost:" + Interfaces.Constants.MasterPort + "/master");
     _master.regServer(_ownURL);
 }
Beispiel #3
0
 //Requests a unique transaction timestamp to the master.
 private void requestTransID()
 {
     _master = (RemoteMasterInterface)Activator.GetObject(
     typeof(RemoteMasterInterface),
     "tcp://localhost:" + Interfaces.Constants.MasterPort + "/master");
     //request to the master a Transaction ID
     _master.getTimeStamp();
 }
Beispiel #4
0
        //Creates a transaction and generates a timestamp.
        public Transaction begin()
        {
            checkStatus();
            _master = (RemoteMasterInterface)Activator.GetObject(
            typeof(RemoteMasterInterface),
            "tcp://localhost:" + Interfaces.Constants.MasterPort + "/master");

            try
            {
                DateTime dt = _master.getTimeStamp();
                return( new Transaction(dt, null));
            }
            catch(TxException e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }