示例#1
0
        public Ice.ObjectPrx register(string Name, Ice.Object servant, bool icegrid = true)
        {
            // register an object to local Ice adapter and yellowpage service (IceGrid)

            Ice.Identity iceid = Communicator.stringToIdentity(Name);
            logger.Info("Registering: " + Name);//+ " with ice_id: " + iceid.ToString());
            Ice.ObjectPrx proxy;
            try
            {
                proxy = _Adapter.add(servant, iceid);
            }
            catch (Ice.AlreadyRegisteredException ex)
            {
                logger.Error("The name of this holon: " + iceid.ToString() + " is allready used in local adapter");
                //maybe I could try to change name but there is probably something wrong
                throw (ex);
            }

            // It is very important to deregister objects before closing!!
            // Otherwise ghost links are created
            IceGrid.AdminPrx admin = getIceGridAdmin();
            try
            {
                admin.addObjectWithType(proxy, servant.ice_id());
            }
            catch (IceGrid.ObjectExistsException)
            {
                admin.updateObject(proxy);
            }
            _ServantIds.Add(iceid);
            return(proxy);
        }
示例#2
0
 public void _deregister(Ice.Identity iceid)
 {
     IceGrid.AdminPrx admin = getIceGridAdmin();
     try
     {
         admin.removeObject(iceid);
     }
     catch (Exception ex)
     {
         logger.Warn("Could not deregister holon from IceGrid: " + ex);
     }
     _Adapter.remove(iceid);
 }
示例#3
0
    allTestsWithDeploy(TestCommon.Application app)
    {
        Ice.Communicator communicator = app.communicator();
        Console.Out.Write("testing stringToProxy... ");
        Console.Out.Flush();
        Ice.ObjectPrx @base = communicator.stringToProxy("test @ TestAdapter");
        test(@base != null);
        Ice.ObjectPrx @base2 = communicator.stringToProxy("test");
        test(@base2 != null);
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing checked cast... ");
        Console.Out.Flush();
        TestIntfPrx obj = TestIntfPrxHelper.checkedCast(@base);

        test(obj != null);
        test(obj.Equals(@base));
        TestIntfPrx obj2 = TestIntfPrxHelper.checkedCast(@base2);

        test(obj2 != null);
        test(obj2.Equals(@base2));
        Console.Out.WriteLine("ok");

        Console.Out.Write("pinging server... ");
        Console.Out.Flush();
        obj.ice_ping();
        obj2.ice_ping();
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing encoding versioning... ");
        Console.Out.Flush();
        Ice.ObjectPrx base10 = communicator.stringToProxy("test10 @ TestAdapter10");
        test(base10 != null);
        Ice.ObjectPrx base102 = communicator.stringToProxy("test10");
        test(base102 != null);
        try
        {
            base10.ice_ping();
            test(false);
        }
        catch (Ice.NoEndpointException)
        {
        }
        try
        {
            base102.ice_ping();
            test(false);
        }
        catch (Ice.NoEndpointException)
        {
        }
        base10  = base10.ice_encodingVersion(Ice.Util.Encoding_1_0);
        base102 = base102.ice_encodingVersion(Ice.Util.Encoding_1_0);
        base10.ice_ping();
        base102.ice_ping();
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing reference with unknown identity... ");
        Console.Out.Flush();
        try
        {
            communicator.stringToProxy("unknown/unknown").ice_ping();
            test(false);
        }
        catch (Ice.NotRegisteredException ex)
        {
            test(ex.kindOfObject.Equals("object"));
            test(ex.id.Equals("unknown/unknown"));
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing reference with unknown adapter... ");
        Console.Out.Flush();
        try
        {
            communicator.stringToProxy("test @ TestAdapterUnknown").ice_ping();
            test(false);
        }
        catch (Ice.NotRegisteredException ex)
        {
            test(ex.kindOfObject.Equals("object adapter"));
            test(ex.id.Equals("TestAdapterUnknown"));
        }
        Console.Out.WriteLine("ok");

        IceGrid.RegistryPrx registry = IceGrid.RegistryPrxHelper.checkedCast(
            communicator.stringToProxy(communicator.getDefaultLocator().ice_getIdentity().category + "/Registry"));
        test(registry != null);
        IceGrid.AdminSessionPrx session = null;
        try
        {
            session = registry.createAdminSession("foo", "bar");
        }
        catch (IceGrid.PermissionDeniedException)
        {
            test(false);
        }

        session.ice_getConnection().setACM(registry.getACMTimeout(),
                                           Ice.Util.None,
                                           Ice.ACMHeartbeat.HeartbeatAlways);

        IceGrid.AdminPrx admin = session.getAdmin();
        test(admin != null);

        try
        {
            admin.enableServer("server", false);
            admin.stopServer("server");
        }
        catch (IceGrid.ServerNotExistException)
        {
            test(false);
        }
        catch (IceGrid.ServerStopException)
        {
            test(false);
        }
        catch (IceGrid.NodeUnreachableException)
        {
            test(false);
        }

        Console.Out.Write("testing whether server is still reachable... ");
        Console.Out.Flush();
        try
        {
            obj = TestIntfPrxHelper.checkedCast(@base);
            test(false);
        }
        catch (Ice.NoEndpointException)
        {
        }
        try
        {
            obj2 = TestIntfPrxHelper.checkedCast(@base2);
            test(false);
        }
        catch (Ice.NoEndpointException)
        {
        }

        try
        {
            admin.enableServer("server", true);
        }
        catch (IceGrid.ServerNotExistException)
        {
            test(false);
        }
        catch (IceGrid.NodeUnreachableException)
        {
            test(false);
        }

        try
        {
            obj = TestIntfPrxHelper.checkedCast(@base);
        }
        catch (Ice.NoEndpointException)
        {
            test(false);
        }
        try
        {
            obj2 = TestIntfPrxHelper.checkedCast(@base2);
        }
        catch (Ice.NoEndpointException)
        {
            test(false);
        }
        Console.Out.WriteLine("ok");

        try
        {
            admin.stopServer("server");
        }
        catch (IceGrid.ServerNotExistException)
        {
            test(false);
        }
        catch (IceGrid.ServerStopException)
        {
            test(false);
        }
        catch (IceGrid.NodeUnreachableException)
        {
            test(false);
        }

        session.destroy();
    }
示例#4
0
    allTestsWithDeploy(Ice.Communicator communicator)
    {
        Console.Out.Write("testing stringToProxy... ");
        Console.Out.Flush();
        Ice.ObjectPrx @base = communicator.stringToProxy("test @ TestAdapter");
        test(@base != null);
        Ice.ObjectPrx @base2 = communicator.stringToProxy("test");
        test(@base2 != null);
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing checked cast... ");
        Console.Out.Flush();
        TestIntfPrx obj = TestIntfPrxHelper.checkedCast(@base);

        test(obj != null);
        test(obj.Equals(@base));
        TestIntfPrx obj2 = TestIntfPrxHelper.checkedCast(@base2);

        test(obj2 != null);
        test(obj2.Equals(@base2));
        Console.Out.WriteLine("ok");

        Console.Out.Write("pinging server... ");
        Console.Out.Flush();
        obj.ice_ping();
        obj2.ice_ping();
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing encoding versioning... ");
        Console.Out.Flush();
        Ice.ObjectPrx base10 = communicator.stringToProxy("test10 @ TestAdapter10");
        test(base10 != null);
        Ice.ObjectPrx base102 = communicator.stringToProxy("test10");
        test(base102 != null);
        try
        {
            base10.ice_ping();
            test(false);
        }
        catch (Ice.NoEndpointException)
        {
        }
        try
        {
            base102.ice_ping();
            test(false);
        }
        catch (Ice.NoEndpointException)
        {
        }
        base10  = base10.ice_encodingVersion(Ice.Util.Encoding_1_0);
        base102 = base102.ice_encodingVersion(Ice.Util.Encoding_1_0);
        base10.ice_ping();
        base102.ice_ping();
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing reference with unknown identity... ");
        Console.Out.Flush();
        try
        {
            communicator.stringToProxy("unknown/unknown").ice_ping();
            test(false);
        }
        catch (Ice.NotRegisteredException ex)
        {
            test(ex.kindOfObject.Equals("object"));
            test(ex.id.Equals("unknown/unknown"));
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing reference with unknown adapter... ");
        Console.Out.Flush();
        try
        {
            communicator.stringToProxy("test @ TestAdapterUnknown").ice_ping();
            test(false);
        }
        catch (Ice.NotRegisteredException ex)
        {
            test(ex.kindOfObject.Equals("object adapter"));
            test(ex.id.Equals("TestAdapterUnknown"));
        }
        Console.Out.WriteLine("ok");

        IceGrid.RegistryPrx registry = IceGrid.RegistryPrxHelper.checkedCast(
            communicator.stringToProxy("IceGrid/Registry"));
        test(registry != null);
        IceGrid.AdminSessionPrx session = null;
        try
        {
            session = registry.createAdminSession("foo", "bar");
        }
        catch (IceGrid.PermissionDeniedException)
        {
            test(false);
        }

        SessionKeepAliveThread keepAlive = new SessionKeepAliveThread(session, registry.getSessionTimeout() / 2);
        Thread keepAliveThread           = new Thread(new ThreadStart(keepAlive.run));

        keepAliveThread.Start();

        IceGrid.AdminPrx admin = session.getAdmin();
        test(admin != null);

        try
        {
            admin.enableServer("server", false);
            admin.stopServer("server");
        }
        catch (IceGrid.ServerNotExistException)
        {
            test(false);
        }
        catch (IceGrid.ServerStopException)
        {
            test(false);
        }
        catch (IceGrid.NodeUnreachableException)
        {
            test(false);
        }

        Console.Out.Write("testing whether server is still reachable... ");
        Console.Out.Flush();
        try
        {
            obj = TestIntfPrxHelper.checkedCast(@base);
            test(false);
        }
        catch (Ice.NoEndpointException)
        {
        }
        try
        {
            obj2 = TestIntfPrxHelper.checkedCast(@base2);
            test(false);
        }
        catch (Ice.NoEndpointException)
        {
        }

        try
        {
            admin.enableServer("server", true);
        }
        catch (IceGrid.ServerNotExistException)
        {
            test(false);
        }
        catch (IceGrid.NodeUnreachableException)
        {
            test(false);
        }

        try
        {
            obj = TestIntfPrxHelper.checkedCast(@base);
        }
        catch (Ice.NoEndpointException)
        {
            test(false);
        }
        try
        {
            obj2 = TestIntfPrxHelper.checkedCast(@base2);
        }
        catch (Ice.NoEndpointException)
        {
            test(false);
        }
        Console.Out.WriteLine("ok");

        try
        {
            admin.stopServer("server");
        }
        catch (IceGrid.ServerNotExistException)
        {
            test(false);
        }
        catch (IceGrid.ServerStopException)
        {
            test(false);
        }
        catch (IceGrid.NodeUnreachableException)
        {
            test(false);
        }

        keepAlive.terminate();
        keepAliveThread.Join();
        session.destroy();
    }
示例#5
0
 private IceGrid.AdminPrx updateIceGridAdmin()
 {
     _Session = _Registry.createAdminSession("foo", "bar"); //authentication is disable so whatever works
     _Admin   = _Session.getAdmin();
     return(_Admin);
 }
示例#6
0
    allTestsWithDeploy(Test.TestHelper helper)
    {
        Ice.Communicator communicator = helper.communicator();
        Console.Out.Write("testing stringToProxy... ");
        Console.Out.Flush();
        IObjectPrx @base = IObjectPrx.Parse("test @ TestAdapter", communicator);

        test(@base != null);
        IObjectPrx @base2 = IObjectPrx.Parse("test", communicator);

        test(@base2 != null);
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing checked cast... ");
        Console.Out.Flush();
        TestIntfPrx obj = TestIntfPrx.CheckedCast(@base);

        test(obj.Equals(@base));
        TestIntfPrx obj2 = TestIntfPrx.CheckedCast(@base2);

        test(obj2.Equals(@base2));
        Console.Out.WriteLine("ok");

        Console.Out.Write("pinging server... ");
        Console.Out.Flush();
        obj.IcePing();
        obj2.IcePing();
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing encoding versioning... ");
        Console.Out.Flush();
        IObjectPrx base10  = IObjectPrx.Parse("test10 @ TestAdapter10", communicator);
        IObjectPrx base102 = IObjectPrx.Parse("test10", communicator);

        try
        {
            base10.IcePing();
            test(false);
        }
        catch (Ice.NoEndpointException)
        {
        }
        try
        {
            base102.IcePing();
            test(false);
        }
        catch (Ice.NoEndpointException)
        {
        }
        base10  = base10.Clone(encodingVersion: Util.Encoding_1_0);
        base102 = base102.Clone(encodingVersion: Util.Encoding_1_0);
        base10.IcePing();
        base102.IcePing();
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing reference with unknown identity... ");
        Console.Out.Flush();
        try
        {
            IObjectPrx.Parse("unknown/unknown", communicator).IcePing();
            test(false);
        }
        catch (NotRegisteredException ex)
        {
            test(ex.kindOfObject.Equals("object"));
            test(ex.id.Equals("unknown/unknown"));
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing reference with unknown adapter... ");
        Console.Out.Flush();
        try
        {
            IObjectPrx.Parse("test @ TestAdapterUnknown", communicator).IcePing();
            test(false);
        }
        catch (NotRegisteredException ex)
        {
            test(ex.kindOfObject.Equals("object adapter"));
            test(ex.id.Equals("TestAdapterUnknown"));
        }
        Console.Out.WriteLine("ok");

        IceGrid.RegistryPrx registry = IceGrid.RegistryPrx.Parse(
            communicator.getDefaultLocator().Identity.category + "/Registry", communicator);
        IceGrid.AdminSessionPrx session = registry.createAdminSession("foo", "bar");
        session.GetConnection().setACM(registry.getACMTimeout(), null, ACMHeartbeat.HeartbeatAlways);

        IceGrid.AdminPrx admin = session.getAdmin();
        admin.enableServer("server", false);
        admin.stopServer("server");

        Console.Out.Write("testing whether server is still reachable... ");
        Console.Out.Flush();
        try
        {
            obj = TestIntfPrx.CheckedCast(@base);
            test(false);
        }
        catch (Ice.NoEndpointException)
        {
        }
        try
        {
            obj2 = TestIntfPrx.CheckedCast(@base2);
            test(false);
        }
        catch (Ice.NoEndpointException)
        {
        }

        try
        {
            admin.enableServer("server", true);
        }
        catch (IceGrid.ServerNotExistException)
        {
            test(false);
        }
        catch (IceGrid.NodeUnreachableException)
        {
            test(false);
        }

        try
        {
            obj = TestIntfPrx.CheckedCast(@base);
        }
        catch (Ice.NoEndpointException)
        {
            test(false);
        }
        try
        {
            obj2 = TestIntfPrx.CheckedCast(@base2);
        }
        catch (Ice.NoEndpointException)
        {
            test(false);
        }
        Console.Out.WriteLine("ok");

        try
        {
            admin.stopServer("server");
        }
        catch (IceGrid.ServerNotExistException)
        {
            test(false);
        }
        catch (IceGrid.ServerStopException)
        {
            test(false);
        }
        catch (IceGrid.NodeUnreachableException)
        {
            test(false);
        }

        session.destroy();
    }
 private IceGrid.AdminPrx updateIceGridAdmin()
 {
     _Session = _Registry.createAdminSession("foo", "bar"); //authentication is disable so whatever works
     _Admin = _Session.getAdmin();
     return _Admin;
 }