Ejemplo n.º 1
0
        /// <summary>
        /// Function to get a remote reference to a PADInt with a given uid.
        /// If the object doesn't exist, then returns null, and warns the client.
        /// </summary>
        /// <param name="uid"></param>
        /// <returns>The remote reference to the PADInt object</returns>
        public static PADInt AccessPADInt(int uid)
        {
            List<PADInt> objectReferences = new List<PADInt>();
            List<string> servers;

            if (_references.ContainsKey(uid))
            {
                Console.WriteLine("The reference for the PADInt " + uid + " was in cache");
                return _references[uid];
            }

            Console.WriteLine("DSTMLib-> calling master to get the servers for the PADInt!");
            servers = _master.GetServers(uid);

            if (servers == null)
            {
                Console.WriteLine("DSTMLib-> ERROR: The PadInt with uid" + uid + " does not exist");
                return null;
            }

            foreach (String server in servers)
            {
                Console.WriteLine("DSTMLib-> connecting to the server " + server);
                ServerInterface chosen = (ServerInterface)Activator.GetObject(typeof(ServerInterface), server);
                objectReferences.Add(chosen.AccessPADInt(uid, _transactionId));

                if (!_serverList.Contains(server))
                    _serverList.Add(server);
            }

            PADInt localCopy = new PADInt(objectReferences, _transactionId, objectReferences[0].UID, objectReferences[0].Value);
            _references.Add(localCopy.UID, localCopy);
            return localCopy;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Function to get a remote reference to a PADInt with a given uid.
        /// If the object doesn't exist, then returns null, and warns the client.
        /// </summary>
        /// <param name="uid"></param>
        /// <returns>The remote reference to the PADInt object</returns>
        public static PADInt AccessPADInt(int uid)
        {
            List <PADInt> objectReferences = new List <PADInt>();
            List <string> servers;

            if (_references.ContainsKey(uid))
            {
                Console.WriteLine("The reference for the PADInt " + uid + " was in cache");
                return(_references[uid]);
            }

            Console.WriteLine("DSTMLib-> calling master to get the servers for the PADInt!");
            servers = _master.GetServers(uid);

            if (servers == null)
            {
                Console.WriteLine("DSTMLib-> ERROR: The PadInt with uid" + uid + " does not exist");
                return(null);
            }

            foreach (String server in servers)
            {
                Console.WriteLine("DSTMLib-> connecting to the server " + server);
                ServerInterface chosen = (ServerInterface)Activator.GetObject(typeof(ServerInterface), server);
                objectReferences.Add(chosen.AccessPADInt(uid, _transactionId));

                if (!_serverList.Contains(server))
                {
                    _serverList.Add(server);
                }
            }

            PADInt localCopy = new PADInt(objectReferences, _transactionId, objectReferences[0].UID, objectReferences[0].Value);

            _references.Add(localCopy.UID, localCopy);
            return(localCopy);
        }
Ejemplo n.º 3
0
        // methods for creating and accessing PADInts

        public static PADInt CreatePADInt(int uid)
        {
            Console.WriteLine("DSTMLib-> calling master to create PADInt!");

            List <PADInt> objectReferences = new List <PADInt>();
            List <string> servers          = new List <string>();
            List <string> locations        = _master.GenerateServers(uid);

            if (locations == null)
            {
                Console.WriteLine("DSTMLib-> ERROR: There is already a PADInt with the uid: " + uid);
                return(null);
            }
            else
            {
                foreach (string server in locations)
                {
                    servers.Add(server);
                }
            }

            foreach (String server in servers)
            {
                ServerInterface tServer = (ServerInterface)Activator.GetObject(typeof(ServerInterface), server);
                objectReferences.Add(tServer.CreatePADInt(uid, servers, _transactionId));

                if (!_serverList.Contains(server))
                {
                    _serverList.Add(server);
                }
            }

            PADInt localCopy = new PADInt(objectReferences, _transactionId, objectReferences[0].UID, objectReferences[0].Value);

            _references.Add(localCopy.UID, localCopy);
            return(localCopy);
        }
Ejemplo n.º 4
0
        private PADInt CreateNewPADInt(int uid, List<string> servers, int transactionId)
        {
            PADInt p = new PADInt(uid, servers);

            _padints.Add(uid, p);

            if (!_transactions.ContainsKey(transactionId))
            {
                _transactions.Add(transactionId, new List<int>());
                _transactions[transactionId].Add(uid);
            }
            else
                _transactions[transactionId].Add(uid);

            return p;
        }
Ejemplo n.º 5
0
        // methods for creating and accessing PADInts
        public static PADInt CreatePADInt(int uid)
        {
            Console.WriteLine("DSTMLib-> calling master to create PADInt!");

            List<PADInt> objectReferences = new List<PADInt>();
            List<string> servers = new List<string>();
            List<string> locations = _master.GenerateServers(uid);

            if (locations == null)
            {
                Console.WriteLine("DSTMLib-> ERROR: There is already a PADInt with the uid: " + uid);
                return null;
            }
            else
            {
                foreach (string server in locations)
                    servers.Add(server);
            }

            foreach (String server in servers)
            {
                ServerInterface tServer = (ServerInterface)Activator.GetObject(typeof(ServerInterface), server);
                objectReferences.Add(tServer.CreatePADInt(uid, servers, _transactionId));

                if (!_serverList.Contains(server))
                    _serverList.Add(server);
            }

            PADInt localCopy = new PADInt(objectReferences, _transactionId, objectReferences[0].UID, objectReferences[0].Value);
            _references.Add(localCopy.UID, localCopy);
            return localCopy;
        }