internal WrappedApplication(TestApplication _enclosing, int id, long timestamp, string user, int numContainers) { this._enclosing = _enclosing; Configuration conf = new Configuration(); this.dispatcher = new DrainDispatcher(); this.containerTokenIdentifierMap = new Dictionary <ContainerId, ContainerTokenIdentifier >(); this.dispatcher.Init(conf); this.localizerBus = Org.Mockito.Mockito.Mock <EventHandler>(); this.launcherBus = Org.Mockito.Mockito.Mock <EventHandler>(); this.monitorBus = Org.Mockito.Mockito.Mock <EventHandler>(); this.auxBus = Org.Mockito.Mockito.Mock <EventHandler>(); this.containerBus = Org.Mockito.Mockito.Mock <EventHandler>(); this.logAggregationBus = Org.Mockito.Mockito.Mock <EventHandler>(); this.dispatcher.Register(typeof(LocalizationEventType), this.localizerBus); this.dispatcher.Register(typeof(ContainersLauncherEventType), this.launcherBus); this.dispatcher.Register(typeof(ContainersMonitorEventType), this.monitorBus); this.dispatcher.Register(typeof(AuxServicesEventType), this.auxBus); this.dispatcher.Register(typeof(ContainerEventType), this.containerBus); this.dispatcher.Register(typeof(LogHandlerEventType), this.logAggregationBus); this.nmTokenSecretMgr = Org.Mockito.Mockito.Mock <NMTokenSecretManagerInNM>(); this.context = Org.Mockito.Mockito.Mock <Context>(); Org.Mockito.Mockito.When(this.context.GetContainerTokenSecretManager()).ThenReturn (new NMContainerTokenSecretManager(conf)); Org.Mockito.Mockito.When(this.context.GetApplicationACLsManager()).ThenReturn(new ApplicationACLsManager(conf)); Org.Mockito.Mockito.When(this.context.GetNMTokenSecretManager()).ThenReturn(this. nmTokenSecretMgr); // Setting master key MasterKey masterKey = new MasterKeyPBImpl(); masterKey.SetKeyId(123); masterKey.SetBytes(ByteBuffer.Wrap(new byte[] { (123) })); this.context.GetContainerTokenSecretManager().SetMasterKey(masterKey); this.user = user; this.appId = BuilderUtils.NewApplicationId(timestamp, id); this.app = new ApplicationImpl(this.dispatcher, this.user, this.appId, null, this .context); this.containers = new AList <Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Container.Container >(); for (int i = 0; i < numContainers; i++) { Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Container.Container container = this._enclosing.CreateMockedContainer(this.appId, i); this.containers.AddItem(container); long currentTime = Runtime.CurrentTimeMillis(); ContainerTokenIdentifier identifier = new ContainerTokenIdentifier(container.GetContainerId (), string.Empty, string.Empty, null, currentTime + 2000, masterKey.GetKeyId(), currentTime, Priority.NewInstance(0), 0); this.containerTokenIdentifierMap[identifier.GetContainerID()] = identifier; this.context.GetContainerTokenSecretManager().StartContainerSuccessful(identifier ); NUnit.Framework.Assert.IsFalse(this.context.GetContainerTokenSecretManager().IsValidStartContainerRequest (identifier)); } this.dispatcher.Start(); }
public ContainerInitMatcher(TestApplication _enclosing, ContainerId cId) { this._enclosing = _enclosing; this.cId = cId; }