public static void Main(string[] args) { HostName = Dns.GetHostName(); CurrentProcess = Process.GetCurrentProcess(); if (args.Length < 1) { url = "jini://*/*/AIGDemo?locators=RajivPC&groups=Rajiv"; NumberOfJobs = 200; NumberOfTask = 5; } else { url = args[0]; NumberOfJobs = args.Length == 1 ? 1000 : Convert.ToInt32(args[1]); NumberOfTask = args.Length == 2 ? 10 : Convert.ToInt32(args[2]); } Console.WriteLine("*** Connecting to remote space named '" + url + "' From Master..."); SpaceProxy = GigaSpacesFactory.FindSpace(url); MasterHeartbeat masterHeartbeat = new MasterHeartbeat(Timeout); Thread workerThread = new Thread(masterHeartbeat.DoWork); workerThread.Start(); new Master(); }
public Master() { Console.WriteLine(Environment.NewLine + "Welcome to XAP.NET 11 Master!" + Environment.NewLine); try { TxnManager = GigaSpacesFactory.CreateDistributedTransactionManager(); Console.WriteLine("*** Connected to space From Master."); int numOfTrades = TradeSpaceProxy.Count(new Trade()); NumberOfJobs = (int)(numOfTrades / (NumberOfTask * tradesPerTask)); Console.WriteLine("*** NumberOfJobs=" + NumberOfJobs); Console.WriteLine("Rate is: " + (int)(Rate * 100) + "%"); Console.WriteLine(); InitIdsMap(numOfTrades); GenenateJobs(); stopWatch.Stop(); Console.WriteLine(); DisplayResults(); Console.ReadKey(); Console.ReadKey(); Console.WriteLine(Environment.NewLine + "NPV Calculation Example finished successfully!" + Environment.NewLine); } catch (Exception ex) { Console.WriteLine(Environment.NewLine + "NPV Calculation Example failed: " + ex); } }
public void creatVersionedSpace() { // Embedded Space String url = "/./xapTutorialSpace"; // Create the SpaceProxy ISpaceProxy spaceProxy = GigaSpacesFactory.FindSpace(url); spaceProxy.OptimisticLocking = true; }
public void registerProductType() { if (proxy == null) { proxy = GigaSpacesFactory.FindSpace("/./xapTutorialSpace"); service = new CRUDService(proxy); spaceUtility = new SpaceUtility(proxy); userUtil = new UserUtil(proxy); } }
private static void Main(string[] args) { Console.WriteLine("GigaSpaces Data Modeling Example"); Console.WriteLine("--------------------------------"); Console.WriteLine("1. Embedded one-to-one."); Console.WriteLine("2. Embedded one-to-many."); Console.WriteLine("3. Non-Embedded one-to-one."); Console.WriteLine("4. Non-Embedded one-to-many."); Console.WriteLine(); Console.WriteLine("Please enter your selection:"); var selection = Console.ReadLine(); IExamplePattern pattern; switch (selection) { case "1": pattern = new EmbeddedOne2OneExample(); break; case "2": pattern = new EmbeddedOne2ManyExample(); break; case "3": pattern = new NonEmbeddedOne2OneExample(); break; case "4": pattern = new NonEmbeddedOne2ManyExample(); break; default: throw new InvalidOperationException("Select an option within range."); } Console.WriteLine(); Console.WriteLine("Launching space, please wait."); ISpaceProxy proxy = GigaSpacesFactory.FindSpace("/./modeling-data-samples"); Console.WriteLine("--------------------------------------------------------------------------------"); Console.WriteLine("BEGIN EXAMPLE"); Console.WriteLine("--------------------------------------------------------------------------------"); Console.WriteLine(); pattern.Fill(proxy); pattern.QuerySpace(proxy); Console.WriteLine(); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); }
public static void Main(string[] args) { HostName = Dns.GetHostName(); CurrentProcess = Process.GetCurrentProcess(); String url = args[0]; Console.WriteLine("*** Connecting to remote space named '" + url + "' from Worker..."); SpaceProxy = GigaSpacesFactory.FindSpace(url); WorkerHeartbeat masterHeartbeat = new WorkerHeartbeat(Timeout); Thread workerThread = new Thread(masterHeartbeat.DoWork); workerThread.Start(); new Worker(args); }
public Master() { Console.WriteLine(Environment.NewLine + "Welcome to XAP.NET 11 Master!" + Environment.NewLine); try { TxnManager = GigaSpacesFactory.CreateDistributedTransactionManager(); Console.WriteLine("*** Connected to space From Master."); Console.WriteLine(); GenenateJobs(); Console.WriteLine(Environment.NewLine + "Hello World Example finished successfully!" + Environment.NewLine); } catch (Exception ex) { Console.WriteLine(Environment.NewLine + "Hello World Example failed: " + ex); } }
public void readWithTransaction() { ITransactionManager mgr = GigaSpacesFactory.CreateDistributedTransactionManager(); // Create a transaction using the transaction manager: using (ITransaction txn = mgr.Create()) { try { // ... SqlQuery <User> query = new SqlQuery <User> ("Contacts.HOME = '770-123-5555'"); User user = proxy.Read <User> (query, txn, long.MaxValue, ReadModifiers.ExclusiveReadLock); // .... txn.Commit(); } catch (Exception ex) { System.Console.WriteLine(ex.ToString()); // rollback the transaction txn.Abort(); } } }
public void registerProductType() { if (proxy == null) { // Instatiate the embedded space proxy = GigaSpacesFactory.FindSpace("/./xapTutorialSpace");; spaceUtility = new SpaceUtility(proxy); userUtil = new UserUtil(proxy); queryService = new QueryService(proxy); service = new CRUDService(proxy); // Register the Space Document } // Create a user userUtil.loadUsers(); service.registerProductType(); service.createDocumemt(); }
// Transactions public void createPayment() { ITransactionManager mgr = GigaSpacesFactory.CreateDistributedTransactionManager(); // Create a transaction using the transaction manager: ITransaction trn = mgr.Create(); try{ Payment payment = new Payment(); payment.CreatedDate = DateTime.Today; payment.Status = ETransactionStatus.PROCESSED; proxy.Write(payment); // Commit the transaction trn.Commit(); } catch (Exception ex) { System.Console.WriteLine(ex.ToString()); // rollback the transaction trn.Abort(); } }
public static void Main(string[] args) { url = args[0]; Int32 batchSize = 10000; numOfTrades = Convert.ToInt32(args[1]); Console.WriteLine("Connecting to Space:" + url); SpaceProxy = GigaSpacesFactory.FindSpace(url); Console.WriteLine("Inserting " + numOfTrades + " Trades in the space"); Int32 k = 0; Trade[] trades; if (numOfTrades <= batchSize) { trades = new Trade[numOfTrades]; for (int i = 0; i < numOfTrades; i++) { trades[i] = CalculateUtil.generateTrade(i + 1); } SpaceProxy.WriteMultiple(trades); } else { for (int i = 0; i < numOfTrades / batchSize; i++) { trades = new Trade[batchSize]; for (int j = 0; j < batchSize; j++) { trades[j] = CalculateUtil.generateTrade(k + 1); k++; } SpaceProxy.WriteMultiple(trades); } } Console.WriteLine("Press any key to continue..."); Console.ReadKey(); }
public WorkeIO(ISpaceProxy space, ISpaceProxy tradeSpace) { int cacheSize = spaceSize / 5; Random rng = new Random(); Console.WriteLine("*** Worker started in Blocking IO mode."); Console.WriteLine(); proxy = space; tradeProxy = tradeSpace; TimeSpan ts = new TimeSpan(10, 0, 0, 0); IdBasedLocalCacheConfig cacheConfig = new IdBasedLocalCacheConfig(); cacheConfig.EvictionStrategyBuilder = new FifoSegmentEvictionStrategyBuilder(cacheSize, 1000, ts); localCache = GigaSpacesFactory.CreateIdBasedLocalCache(tradeSpace, cacheConfig); HashSet <Object> ids; for (int i = 0; i < cacheSize / cacheBatchSize; i++) { ids = new HashSet <Object>(); for (int j = 0; j < cacheBatchSize; j++) { int rn = rng.Next(1, spaceSize); ids.Add(RngRecursive(rn, rng, ids)); } try { //Console.WriteLine("Reading batch: " + i); localCache.ReadByIds <Trade>(ids.ToArray()); } catch (Exception e) { Console.WriteLine(e.Message); } } Console.WriteLine("*** Cache initializaded."); }
public void init() { proxy = GigaSpacesFactory.FindSpace(url); }