public void TestEvents()
        {
            // start the ProxyService on just one cluster node
            IInvocationService invocationService = RestartProxy(null);

            // put data items into inner cache to generate events
            INamedCache testCache = GetCache("proxy-stop-test");

            testCache.Clear();
            for (int i = 0; i < SOME_DATA; i++)
            {
                testCache.Add("TestKey" + i, i);
            }

            // create listener for CQC
            TestCQCListener listener = new TestCQCListener(SOME_DATA);

            // instantiate the CQC, will start the test running.
            theCQC = new ContinuousQueryCache(testCache, AlwaysFilter.Instance, listener);

            // instantiate a service listener to receive memberLeft event
            fMemberLeft = false;
            testCache.CacheService.MemberLeft += new MemberEventHandler(OnMemberLeft);

            // allow test time to complete.
            DateTime endTime = DateTime.Now.AddSeconds(30);

            while (listener.GetActualTotal() < SOME_DATA && (DateTime.Now < endTime))
            {
                Thread.Sleep(250);
            }

            // check listener received the correct number of events.
            Assert.AreEqual(SOME_DATA, listener.GetActualTotal());
            listener.ResetActualTotal();

            // restart proxy
            RestartProxy(invocationService);

            endTime = DateTime.Now.AddSeconds(30);
            while (!fMemberLeft && (DateTime.Now < endTime))
            {
                Thread.Sleep(250);
            }

            // ping the CQC to make it realize the cache needs restart.
            theCQC.Contains("junkstuff");

            // allow test time to complete.
            endTime = DateTime.Now.AddSeconds(30);
            while (listener.GetActualTotal() < SOME_DATA && (DateTime.Now < endTime))
            {
                Thread.Sleep(250);
            }

            Assert.AreEqual(SOME_DATA, listener.GetActualTotal());
        }
Пример #2
0
 public MainPageController(
     IAnalysisService analysisService,
     IEndpointFactory endpointFactory,
     IInvocationService invocationService,
     IEndpointCache endpointCache)
 {
     _analysisService   = analysisService;
     _endpointFactory   = endpointFactory;
     _invocationService = invocationService;
     _endpointCache     = endpointCache;
 }
        public void TestRemoteInvocationOnCache()
        {
            Console.WriteLine(Directory.GetCurrentDirectory());

            IInvocationService service = (IInvocationService)CacheFactory.GetService("RemoteInvocationServiceSSL");

            Assert.IsNotNull(service);

            IDictionary result = service.Query(new EmptyInvocable(), null);

            Assert.IsNotNull(result);
        }
Пример #4
0
        public static void AccessInvocationService()
        {
            Console.WriteLine("------InvocationService access control example " +
                              "begins------");
            Console.WriteLine();

            // Someone with writer role can run invocables
            IPrincipal principal = SecurityExampleHelper.Login("JohnWhorfin");

            try
            {
                Thread.CurrentPrincipal = principal;
                IInvocationService service = (IInvocationService)
                                             CacheFactory.GetService(SecurityExampleHelper.INVOCATION_SERVICE_NAME);

                service.Query(new ExampleInvocable(), null);
                Console.WriteLine();
                Console.WriteLine("    Success: Correctly allowed to " +
                                  "use the invocation service");
                Console.WriteLine();
            }
            catch (Exception e)
            {
                // get exception if not allowed to perform the operation
                Console.WriteLine(e.StackTrace);
            }

            // Someone with reader role cannot cannot run invocables
            principal = SecurityExampleHelper.Login("JohnBigboote");

            try
            {
                Thread.CurrentPrincipal = principal;
                IInvocationService service = (IInvocationService)
                                             CacheFactory.GetService(SecurityExampleHelper.INVOCATION_SERVICE_NAME);

                service.Query(new ExampleInvocable(), null);
            }
            catch (Exception e)
            {
                // get exception if not allowed to perform the operation
                Console.WriteLine();
                Console.WriteLine("    Success: Correctly unable to " +
                                  "use the invocation service");
                Console.WriteLine();
            }

            Console.WriteLine();
            Console.WriteLine("------InvocationService access control example " +
                              "completed------");
        }
Пример #5
0
        public void TestJmxConnectionInformation()
        {
            IConfigurableCacheFactory ccf = CacheFactory.ConfigurableCacheFactory;
            IXmlDocument config           = XmlHelper.LoadXml("assembly://Coherence.Tests/Tangosol.Resources/s4hc-cache-config.xml");

            ccf.Config = config;
            IInvocationService service = (IInvocationService)CacheFactory.GetService("RemoteInvocationService");
            IMember            member  = ((DefaultConfigurableCacheFactory)ccf).OperationalContext.LocalMember;

            MBeanInvocable invocable = new MBeanInvocable();

            IDictionary result = service.Query(invocable, null);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.Count, 1);

            Assert.IsNotNull(result[member]);

            service.Shutdown();
        }
        /**
         * utility method to stop and restart the proxy.
         */
        private IInvocationService RestartProxy(IInvocationService service)
        {
            if (service == null)
            {
                service = (IInvocationService)CacheFactory.GetService("ExtendTcpProxyControlService");
            }

            ProxyStopInvocable invocable = new ProxyStopInvocable();

            invocable.ProxyServiceName = "ExtendTcpProxyServiceCOH8230";
            try
            {
                Object result = service.Query(invocable, null);
            }
            catch (Exception /* e */)
            {
                // ignore
            }

            return(service);
        }
Пример #7
0
        public void TestMemberRemoteInvocation()
        {
            IConfigurableCacheFactory ccf = CacheFactory.ConfigurableCacheFactory;
            IXmlDocument config           = XmlHelper.LoadXml("assembly://Coherence.Tests/Tangosol.Resources/s4hc-cache-config.xml");

            ccf.Config = config;
            IInvocationService service = (IInvocationService)CacheFactory.GetService("RemoteInvocationService");

            IMember member = new LocalMember();

            member.MachineName = "machine1";
            member.MemberName  = "member1";
            member.ProcessName = "process1";
            member.RackName    = "rack1";
            member.RoleName    = "role1";
            member.SiteName    = "site1";

            POFObjectInvocable invocable = new POFObjectInvocable();

            invocable.PofObject = member;

            IDictionary result = service.Query(invocable, null);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.Count, 1);
            IMember copy = (IMember)result[((DefaultConfigurableCacheFactory)CacheFactory
                                            .ConfigurableCacheFactory).OperationalContext.LocalMember];

            Assert.AreEqual(member.MachineName, copy.MachineName);
            Assert.AreEqual(member.MemberName, copy.MemberName);
            Assert.AreEqual(member.ProcessName, copy.ProcessName);
            Assert.AreEqual(member.RackName, copy.RackName);
            Assert.AreEqual(member.RoleName, copy.RoleName);
            Assert.AreEqual(member.SiteName, copy.SiteName);

            service.Shutdown();
        }
Пример #8
0
        public void TestCompositeKeyRemoteInvocation()
        {
            IConfigurableCacheFactory ccf = CacheFactory.ConfigurableCacheFactory;
            IXmlDocument config           = XmlHelper.LoadXml("assembly://Coherence.Tests/Tangosol.Resources/s4hc-cache-config.xml");

            ccf.Config = config;
            IInvocationService service = (IInvocationService)CacheFactory.GetService("RemoteInvocationService");

            CompositeKey       key       = new CompositeKey("abc", "xyz");
            POFObjectInvocable invocable = new POFObjectInvocable();

            invocable.PofObject = key;

            IDictionary result = service.Query(invocable, null);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.Count, 1);
            CompositeKey copy = (CompositeKey)result[((DefaultConfigurableCacheFactory)
                                                      CacheFactory.ConfigurableCacheFactory).OperationalContext.LocalMember];

            Assert.AreEqual(key, copy);

            service.Shutdown();
        }
Пример #9
0
 /// <summary>
 /// Called by the <see cref="IInvocationService"/> exactly once on
 /// this <see cref="IInvocable"/> object as part of its
 /// initialization.
 /// </summary>
 /// <remarks>
 /// <b>Note:</b> implementations of the <b>IInvocable</b> interface
 /// that store the service reference must do so only in a transient
 /// field.
 /// </remarks>
 /// <param name="service">
 /// The containing <b>InvocationService</b>.
 /// </param>
 public virtual void Init(IInvocationService service)
 {
     Service = service;
 }
Пример #10
0
 public void Init(IInvocationService service)
 {
 }