예제 #1
0
        public void Fill(ISpaceProxy spaceProxy)
        {
            var author = new Author();

            author.Id       = 2;
            author.LastName = "AuthorX";
            author.BookIds  = new List <int> {
                1, 2, 3
            };
            spaceProxy.Write(author);

            var book1 = new Book();

            book1.AuthorId = 2;
            book1.Title    = "BookX";
            book1.Id       = 1;
            spaceProxy.Write(book1);

            var book2 = new Book();

            book2.AuthorId = 2;
            book2.Title    = "BookY";
            book2.Id       = 2;
            spaceProxy.Write(book2);

            var book3 = new Book();

            book3.AuthorId = 2;
            book3.Title    = "BookZ";
            book3.Id       = 3;
            spaceProxy.Write(book3);
        }
 public void Fill(ISpaceProxy spaceProxy)
 {
     spaceProxy.Write(new Author {
         Id = 1, LastName = "AuthorX", BookId = 3
     });
     spaceProxy.Write(new Book {
         Id = 3, AuthorId = 1, Title = "BookX"
     });
 }
예제 #3
0
    public void notifyTest()
    {
        // Enable this if you do not want to use Annotations
        // service.registerNotifierListener();

        Payment payment = new Payment();

        payment.Status = ETransactionStatus.CANCELLED;

        proxy.Write(payment);
    }
        public Worker(string[] args)
        {
            Console.WriteLine(Environment.NewLine + "Welcome to XAP.NET 11 Worker!" + Environment.NewLine + " hostName=" + HostName + "currentProcess.Id=" + CurrentProcess.Id);

            WorkerProcess workerProcess = new WorkerProcess();

            workerProcess.HostName      = HostName;
            workerProcess.ProcessID     = CurrentProcess.Id;
            workerProcess.ID            = HostName + "=" + CurrentProcess.Id;
            workerProcess.StartDateTime = DateTime.Now;
            SpaceProxy.Write(workerProcess, 5000);

            String ioType = args.Length == 1 ? "NIO" : args[1];

            SleepTime = args.Length == 2 ? 2000 : Convert.ToInt32(args[2]);
            if (ioType.Equals("IO"))
            {
                IEventListenerContainer <Request> eventListenerContainer = EventListenerContainerFactory.CreateContainer <Request>(SpaceProxy, new WorkeIO());
                eventListenerContainer.Start();
            }
            else
            {
                IEventListenerContainer <Request> eventListenerContainer = EventListenerContainerFactory.CreateContainer <Request>(SpaceProxy, new WorkeNIO());
                eventListenerContainer.Start();
            }
        }
예제 #5
0
        public static Job submitJob(int tasks, String serviceName, String functionName, Dictionary <String, String> paramters)
        {
            JobId++;
            Console.WriteLine(" - Executing Job " + JobId);
            JobResult jobResult = new JobResult();

            Request[] requests = new Request[tasks];
            for (int i = 0; i < tasks; i++)
            {
                requests[i]              = new Request();
                requests[i].JobID        = JobId;
                requests[i].TaskID       = ((JobId) + "_" + (i));
                requests[i].Payload      = "PayloadData_" + requests[i].TaskID;
                requests[i].ServiceName  = serviceName;
                requests[i].FunctionName = functionName;
                requests[i].Parameters   = paramters;
            }
            SpaceProxy.WriteMultiple(requests);

            Job job = new Job();

            job.JobID        = JobId;
            job.NumberOfTask = tasks;
            SpaceProxy.Write(job);
            return(job);
        }
예제 #6
0
        public void postPayment()
        {
            // Create a payment
            Payment payment = new Payment();

            payment.CreatedDate   = new DateTime();
            payment.MerchantId    = 1L;
            payment.PaymentAmount = 120.70;
            payment.Status        = ETransactionStatus.NEW;


            Console.WriteLine(payment.Status);

            // write the payment into the space
            proxy.Write(payment);

            Thread.Sleep(10000);

            SqlQuery <Payment> query = new SqlQuery <Payment>("MerchantId=1");

            payment = proxy.Read <Payment>(query);

            Assert.AreEqual(payment.Status, ETransactionStatus.PROCESSED);

            Console.WriteLine(payment.Status);
        }
 public void Fill(ISpaceProxy spaceProxy)
 {
     spaceProxy.Write(new Author {
         LastName = "AuthorX", Book = new Book()
         {
             Title = "BookX"
         }
     });
 }
        public void Fill(ISpaceProxy spaceProxy)
        {
            var author = new Author();

            author.LastName = "AuthorX";
            author.Books    = new List <Book> {
                new Book {
                    Title = "BookY"
                }
            };

            spaceProxy.Write(author);
        }
예제 #9
0
        /// <summary>
        /// Generates and feeds data to the space
        /// </summary>
        private void Feed()
        {
            try
            {
                //Create a proxy to the remote service which provide processing statistics
                ExecutorRemotingProxyBuilder <IProcessorStatisticsProvider> builder = new ExecutorRemotingProxyBuilder <IProcessorStatisticsProvider>(_proxy);
                IProcessorStatisticsProvider processorStatisticsProvider            = builder.CreateProxy();
                int    iteration = 0;
                Random random    = new Random();
                string stages    = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456989";

                while (_started)
                {
                    //Create a new data object with random info and random type
                    String key  = "AA-12345";
                    Data   data = new Data(key, random.Next(DataTypesCount));
                    //data.FlightLegStatus = stages[random.Next(stages.Length)];

                    data.FlightLegStatus = stages[iteration % stages.Length];
                    data.FlightOrigDate  = System.DateTime.Now;
                    data.AirlineCode     = "AA1";
                    data.FlightNumber    = "1865";
                    data.DepatureStation = "JFK";
                    data.DuplicateDepartureStationNumber = 0;
                    data.DuplicateArrivalStationNumber   = 0;

                    Console.WriteLine("Added data object with key {0} and type {1}", data.Key, data.Type);
                    //Feed the data into the cluster
                    _proxy.Write(data);
                    Thread.Sleep(_feedDelay);
                    //Check if should print statistics
                    if (++iteration % PrintStatisticIterCount == 0)
                    {
                        Console.WriteLine("Asking processor of type " + data.Type.Value + " how many objects of that type it has processed");
                        int processedTypes = processorStatisticsProvider.GetProcessObjectCount(data.Type.Value);
                        Console.WriteLine("Received total processed object of type " + data.Type.Value + " is " + processedTypes);
                    }
                }
            }
            catch (SpaceException e)
            {
                Console.WriteLine("Space Error has occured - " + e);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error has occured - " + e);
            }
        }
예제 #10
0
    public void writeUser()
    {
        User user = new User();

        user.Id   = 1L;
        user.Name = "John Smith";
        //	user.setComment(new String[] {"This", "is","a","comment"});
        //	user.Balance=10.5;
        //	user.CreditLimit=1000.00;
        //	user.Status=EAccountStatus.ACTIVE;

        // Write the user to the space
        proxy.Write(user);
    }
예제 #11
0
        public static Job submitJob(int tasks, String serviceName, String functionName, Dictionary <String, String> paramters)
        {
            JobId++;
            Console.WriteLine(" - Executing Job " + JobId);
            JobResult jobResult = new JobResult();

            Request[] requests = new Request[tasks];

            for (int i = 0; i < tasks; i++)
            {
                requests[i]              = new Request();
                requests[i].JobID        = JobId + "";
                requests[i].TaskID       = ((JobId) + "_" + (i));
                requests[i].Payload      = "PayloadData_" + requests[i].TaskID;
                requests[i].ServiceName  = serviceName;
                requests[i].FunctionName = functionName;
                requests[i].Parameters   = paramters;
                requests[i].Priority     = i % 4 + 1;
                requests[i].Rate         = Rate;
                requests[i].TradeIds     = IdsMap[MapIndex];
                MapIndex++;
            }
            try
            {
                SpaceProxy.WriteMultiple(requests);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
                throw e;
            }

            Job job = new Job();

            job.JobID        = JobId + "";
            job.NumberOfTask = tasks;
            SpaceProxy.Write(job);
            return(job);
        }
예제 #12
0
    public void loadUsers()
    {
        User u = new User();

        u.Id          = 1L;
        u.Balance     = 120.90;
        u.CreditLimit = 1500.00;
        u.Name        = "John Dow";
        u.Status      = EAccountStatus.ACTIVE;

        Address a = new Address();

        a.City    = "NYC";
        a.Country = ECountry.USA;
        a.State   = "NY";
        a.Street  = "100th East";
        a.ZipCode = 12345;
        u.Address = a;
        u.addContact(EContactType.HOME, "770-123-5555");

        List <int?> ratings = new List <int?>();

        ratings.Add(1);
        ratings.Add(4);
        u.Ratings = ratings;

        List <Group> groups = new List <Group>();
        Group        g      = new Group();

        g.Id   = 1L;
        g.Name = "Group 1";
        groups.Add(g);
        u.Groups = groups;

        //	u.setComment(new String[] { "existing", "customer" });
        proxy.Write(u);

        u             = new User();
        u.Id          = 2L;
        u.Balance     = 120.90;
        u.CreditLimit = 500.00;
        u.Name        = "Customer 2";
        u.Status      = EAccountStatus.INACTIVE;

        a         = new Address();
        a.City    = "NYC";
        a.Country = ECountry.USA;
        a.State   = "NY";
        a.Street  = "100th East";
        a.ZipCode = 10017;
        u.Address = a;

        ratings = new List <int?>();
        ratings.Add(1);
        ratings.Add(3);
        u.Ratings = ratings;

        proxy.Write(u);

        u             = new User();
        u.Id          = 3L;
        u.Balance     = 120.90;
        u.CreditLimit = 500.00;
        u.Name        = "Customer 2";
        u.Status      = EAccountStatus.BLOCKED;

        a         = new Address();
        a.City    = "NYC";
        a.Country = ECountry.USA;
        a.State   = "NY";
        a.Street  = "100th East";
        a.ZipCode = 12345;
        u.Address = a;

        proxy.Write(u);
    }