示例#1
0
 protected internal NMClientAsyncImpl(string name, NMClient client, NMClientAsync.CallbackHandler
                                      callbackHandler)
     : base(name, client, callbackHandler)
 {
     this.client          = client;
     this.callbackHandler = callbackHandler;
 }
示例#2
0
 protected internal NMClientAsync(string name, NMClient client, NMClientAsync.CallbackHandler
                                  callbackHandler)
     : base(name)
 {
     this.SetClient(client);
     this.SetCallbackHandler(callbackHandler);
 }
示例#3
0
        public Form1()
        {
            InitializeComponent();

            #region Client event
            Client                 = new NMClient(this);
            Client.OnError        += new EventHandler <EventMsgArgs>(Client_OnError);
            Client.OnStop         += new EventHandler(Client_OnStop);
            Client.OnNewClient    += new EventHandler <EventClientArgs>(Client_OnNewClient);
            Client.OnDeleteClient += new EventHandler <EventClientArgs>(Client_OnDeleteClient);
            #endregion
        }
示例#4
0
        public Form1()
        {
            InitializeComponent();

            m_NMClient = new NMClient(this);
            m_NMClient.OnDeleteClient += new EventHandler <EventClientArgs>(NMClient_OnDeleteClient);
            m_NMClient.OnError        += new EventHandler <EventMsgArgs>(NMClient_OnError);
            m_NMClient.OnNewClient    += new EventHandler <EventClientArgs>(NMClient_OnNewClient);
            m_NMClient.OnReseive      += new EventHandler <EventClientMsgArgs>(NMClient_OnReseive);
            m_NMClient.OnStop         += new EventHandler(NMClient_OnStop);

            m_rnd = new Random((int)DateTime.Now.Ticks);
        }
示例#5
0
文件: CS_NMClient.cs 项目: metoer/wpf
        public static Ice.DispatchStatus SendData___(NMClient obj__, IceInternal.Incoming inS__, Ice.Current current__)
        {
            Ice.ObjectImpl.checkMode__(Ice.OperationMode.Normal, current__.mode);
            IceInternal.BasicStream is__ = inS__.startReadParams();
            string strXml;

            strXml = is__.readString();
            inS__.endReadParams();
            int ret__ = obj__.SendData(strXml, current__);

            IceInternal.BasicStream os__ = inS__.startWriteParams__(Ice.FormatType.DefaultFormat);
            os__.writeInt(ret__);
            inS__.endWriteParams__(true);
            return(Ice.DispatchStatus.DispatchOK);
        }
示例#6
0
        /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
        /// <exception cref="System.IO.IOException"/>
        private NMClient MockNMClient(int mode)
        {
            NMClient client = Org.Mockito.Mockito.Mock <NMClient>();

            switch (mode)
            {
            case 0:
            {
                Org.Mockito.Mockito.When(client.StartContainer(Matchers.Any <Container>(), Matchers.Any
                                                               <ContainerLaunchContext>())).ThenReturn(Sharpen.Collections.EmptyMap <string, ByteBuffer
                                                                                                                                     >());
                Org.Mockito.Mockito.When(client.GetContainerStatus(Matchers.Any <ContainerId>(), Matchers.Any
                                                                   <NodeId>())).ThenReturn(recordFactory.NewRecordInstance <ContainerStatus>());
                Org.Mockito.Mockito.DoNothing().When(client).StopContainer(Matchers.Any <ContainerId
                                                                                         >(), Matchers.Any <NodeId>());
                break;
            }

            case 1:
            {
                Org.Mockito.Mockito.DoThrow(RPCUtil.GetRemoteException("Start Exception")).When(client
                                                                                                ).StartContainer(Matchers.Any <Container>(), Matchers.Any <ContainerLaunchContext>
                                                                                                                     ());
                Org.Mockito.Mockito.DoThrow(RPCUtil.GetRemoteException("Query Exception")).When(client
                                                                                                ).GetContainerStatus(Matchers.Any <ContainerId>(), Matchers.Any <NodeId>());
                Org.Mockito.Mockito.DoThrow(RPCUtil.GetRemoteException("Stop Exception")).When(client
                                                                                               ).StopContainer(Matchers.Any <ContainerId>(), Matchers.Any <NodeId>());
                break;
            }

            case 2:
            {
                Org.Mockito.Mockito.When(client.StartContainer(Matchers.Any <Container>(), Matchers.Any
                                                               <ContainerLaunchContext>())).ThenReturn(Sharpen.Collections.EmptyMap <string, ByteBuffer
                                                                                                                                     >());
                Org.Mockito.Mockito.When(client.GetContainerStatus(Matchers.Any <ContainerId>(), Matchers.Any
                                                                   <NodeId>())).ThenReturn(recordFactory.NewRecordInstance <ContainerStatus>());
                Org.Mockito.Mockito.DoThrow(RPCUtil.GetRemoteException("Stop Exception")).When(client
                                                                                               ).StopContainer(Matchers.Any <ContainerId>(), Matchers.Any <NodeId>());
                break;
            }
            }
            return(client);
        }
示例#7
0
        public Form1()
        {
            InitializeComponent();

            NMClient = new NMClient(this);
            NMClient.OnDeleteClient += new EventHandler <EventClientArgs>(NMClient_OnDeleteClient);
            NMClient.OnError        += new EventHandler <EventMsgArgs>(NMClient_OnError);
            NMClient.OnNewClient    += new EventHandler <EventClientArgs>(NMClient_OnNewClient);
            NMClient.OnReseive      += new EventHandler <EventClientMsgArgs>(NMClient_OnReseive);
            NMClient.OnStop         += new EventHandler(NMClient_OnStop);

            for (int I = 2; I < 500; I++)
            {
                (dgSin.Columns[2] as DataGridViewComboBoxColumn).Items.Add((1000.0 / I).ToString());
            }
            cbN.SelectedIndex = 0;

            m_A.Add(10000);
            m_F.Add(Convert.ToDouble((dgSin.Columns[2] as DataGridViewComboBoxColumn).Items[0]));
            dgSin.Rows.Add(dgSin.Rows.Count + 1, 10000, (dgSin.Columns[2] as DataGridViewComboBoxColumn).Items[0]);
        }
示例#8
0
        public virtual void Setup()
        {
            // start minicluster
            conf        = new YarnConfiguration();
            yarnCluster = new MiniYARNCluster(typeof(TestAMRMClient).FullName, nodeCount, 1,
                                              1);
            yarnCluster.Init(conf);
            yarnCluster.Start();
            NUnit.Framework.Assert.IsNotNull(yarnCluster);
            NUnit.Framework.Assert.AreEqual(Service.STATE.Started, yarnCluster.GetServiceState
                                                ());
            // start rm client
            yarnClient = (YarnClientImpl)YarnClient.CreateYarnClient();
            yarnClient.Init(conf);
            yarnClient.Start();
            NUnit.Framework.Assert.IsNotNull(yarnClient);
            NUnit.Framework.Assert.AreEqual(Service.STATE.Started, yarnClient.GetServiceState
                                                ());
            // get node info
            nodeReports = yarnClient.GetNodeReports(NodeState.Running);
            // submit new app
            ApplicationSubmissionContext appContext = yarnClient.CreateApplication().GetApplicationSubmissionContext
                                                          ();
            ApplicationId appId = appContext.GetApplicationId();

            // set the application name
            appContext.SetApplicationName("Test");
            // Set the priority for the application master
            Priority pri = Priority.NewInstance(0);

            appContext.SetPriority(pri);
            // Set the queue to which this application is to be submitted in the RM
            appContext.SetQueue("default");
            // Set up the container launch context for the application master
            ContainerLaunchContext amContainer = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord
                                                 <ContainerLaunchContext>();

            appContext.SetAMContainerSpec(amContainer);
            // unmanaged AM
            appContext.SetUnmanagedAM(true);
            // Create the request to send to the applications manager
            SubmitApplicationRequest appRequest = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord
                                                  <SubmitApplicationRequest>();

            appRequest.SetApplicationSubmissionContext(appContext);
            // Submit the application to the applications manager
            yarnClient.SubmitApplication(appContext);
            // wait for app to start
            int          iterationsLeft = 30;
            RMAppAttempt appAttempt     = null;

            while (iterationsLeft > 0)
            {
                ApplicationReport appReport = yarnClient.GetApplicationReport(appId);
                if (appReport.GetYarnApplicationState() == YarnApplicationState.Accepted)
                {
                    attemptId  = appReport.GetCurrentApplicationAttemptId();
                    appAttempt = yarnCluster.GetResourceManager().GetRMContext().GetRMApps()[attemptId
                                                                                             .GetApplicationId()].GetCurrentAppAttempt();
                    while (true)
                    {
                        if (appAttempt.GetAppAttemptState() == RMAppAttemptState.Launched)
                        {
                            break;
                        }
                    }
                    break;
                }
                Sleep(1000);
                --iterationsLeft;
            }
            if (iterationsLeft == 0)
            {
                NUnit.Framework.Assert.Fail("Application hasn't bee started");
            }
            // Just dig into the ResourceManager and get the AMRMToken just for the sake
            // of testing.
            UserGroupInformation.SetLoginUser(UserGroupInformation.CreateRemoteUser(UserGroupInformation
                                                                                    .GetCurrentUser().GetUserName()));
            UserGroupInformation.GetCurrentUser().AddToken(appAttempt.GetAMRMToken());
            //creating an instance NMTokenCase
            nmTokenCache = new NMTokenCache();
            // start am rm client
            rmClient = (AMRMClientImpl <AMRMClient.ContainerRequest>)AMRMClient.CreateAMRMClient
                       <AMRMClient.ContainerRequest>();
            //setting an instance NMTokenCase
            rmClient.SetNMTokenCache(nmTokenCache);
            rmClient.Init(conf);
            rmClient.Start();
            NUnit.Framework.Assert.IsNotNull(rmClient);
            NUnit.Framework.Assert.AreEqual(Service.STATE.Started, rmClient.GetServiceState()
                                            );
            // start am nm client
            nmClient = (NMClientImpl)NMClient.CreateNMClient();
            //propagating the AMRMClient NMTokenCache instance
            nmClient.SetNMTokenCache(rmClient.GetNMTokenCache());
            nmClient.Init(conf);
            nmClient.Start();
            NUnit.Framework.Assert.IsNotNull(nmClient);
            NUnit.Framework.Assert.AreEqual(Service.STATE.Started, nmClient.GetServiceState()
                                            );
        }
示例#9
0
 public virtual void SetClient(NMClient client)
 {
     this.client = client;
 }