public ModelViewer(ITagContainer diContainer) { this.diContainer = diContainer; device = diContainer.GetTag <GraphicsDevice>(); resourcePool = diContainer.GetTag <IResourcePool>(); textureLoader = diContainer.GetTag <IAssetLoader <Texture> >(); Window = diContainer.GetTag <WindowContainer>().NewWindow("Model Viewer"); Window.InitialBounds = new Rect(float.NaN, float.NaN, 1100.0f, 600.0f); Window.AddTag(this); editor = new TwoColumnEditorTag(Window, diContainer); var onceAction = new OnceAction(); Window.AddTag(onceAction); Window.OnContent += onceAction.Invoke; var menuBar = new MenuBarWindowTag(Window); menuBar.AddButton("Open", HandleMenuOpen); fbArea = Window.GetTag <FramebufferArea>(); fbArea.OnResize += HandleResize; fbArea.OnRender += HandleRender; modelMaterialEdit = new ModelMaterialEdit(Window, diContainer); diContainer.GetTag <OpenDocumentSet>().AddEditor(this); openFileModal = new OpenFileModal(diContainer); openFileModal.Filter = "*.dff"; openFileModal.IsFilterChangeable = false; openFileModal.OnOpenedResource += Load; imGuiRenderer = Window.Container.ImGuiRenderer; locationBuffer = new LocationBuffer(device); AddDisposable(locationBuffer); var localDiContainer = diContainer.ExtendedWith(locationBuffer); camera = new Camera(localDiContainer); AddDisposable(camera); controls = new OrbitControlsTag(Window, camera.Location, localDiContainer); AddDisposable(controls); gridRenderer = new DebugGridRenderer(diContainer); gridRenderer.Material.LinkTransformsTo(camera); gridRenderer.Material.World.Ref = Matrix4x4.Identity; AddDisposable(gridRenderer); triangleRenderer = new DebugTriangleLineRenderer(diContainer); triangleRenderer.Material.LinkTransformsTo(camera); triangleRenderer.Material.World.Ref = Matrix4x4.Identity; AddDisposable(triangleRenderer); planeRenderer = new DebugPlaneRenderer(diContainer); planeRenderer.Material.LinkTransformsTo(camera); planeRenderer.Material.World.Ref = Matrix4x4.Identity; AddDisposable(planeRenderer); editor.AddInfoSection("Statistics", HandleStatisticsContent); editor.AddInfoSection("Materials", HandleMaterialsContent); editor.AddInfoSection("Skeleton", HandleSkeletonContent); editor.AddInfoSection("Collision", HandleCollisionContent); }
public CombinedDirectory(IResourcePool pool, IResource?parent, FilePath path, IEnumerable <IResource> sources) { this.sources = sources.ToArray(); Path = path; Pool = pool; Parent = parent; }
public Scheduler(ITagContainer diContainer) { this.diContainer = diContainer; options = diContainer.GetTag <Options>(); resourcePool = diContainer.GetTag <IResourcePool>(); graphicsDevice = diContainer.GetTag <GraphicsDevice>(); sceneMetadataBuilder = new SceneMetadataBuilder(diContainer); bgTileRenderer = new BackgroundTileRenderer(options); for (int i = 0; i < options.Renderers; i++) { rendererQueue.Enqueue(new MapTileRenderer(diContainer)); } ProgressSteps = new[] { stepScenesFound, stepScenesLoaded, stepTilesEmpty, stepTilesRendered, stepTilesEncoded, stepTilesOptimized, stepTilesOutput, stepScenesMeta, stepMetaOutput, stepBgTilesRendered }; output = CreateOutput(options); var outputDisposable = output as IDisposable; if (outputDisposable != null) { AddDisposable(outputDisposable); } }
// Look for a device in a machine, and if not found, keep trying for 3 minutes static IDevice GetDevice(IResourcePool rootPool, string machineName, string regexStr) { Regex deviceRegex = new Regex(regexStr, RegexOptions.IgnoreCase); int numAttempts = 1; DateTime endTime = DateTime.Now.AddSeconds(180); while (DateTime.Now < endTime) { IResource machine = rootPool.GetResourceByName(machineName); Console.WriteLine("Looking for device '{0}' in machine '{1}' (machine has {2} devices)", regexStr, machineName, machine.GetDevices().Length); foreach (IDevice d in machine.GetDevices()) { if (deviceRegex.IsMatch(d.FriendlyName)) { Console.WriteLine("Found device '{0}'", d.FriendlyName); return(d); } } Console.WriteLine("Device not found"); if (numAttempts % 5 == 0) { ResetMachine(rootPool, machineName, true); } else { System.Threading.Thread.Sleep(5000); } numAttempts++; } Console.WriteLine("Error: device '{0}' not found", deviceRegex); return(null); }
// Wait for a machine to show up in the data store static void FindMachine(IResourcePool rootPool, string machineName) { Console.WriteLine("Looking for machine '{0}'", machineName); IResource machine = null; while (true) { try { machine = rootPool.GetResourceByName(machineName); } catch (Exception e) { Console.WriteLine("Warning: " + e.Message); } // Make sure the machine is valid if (machine != null && machine.OperatingSystem != null && machine.OperatingSystem.Length > 0 && machine.ProcessorArchitecture != null && machine.ProcessorArchitecture.Length > 0 && machine.GetDevices().Length > 0) { break; } System.Threading.Thread.Sleep(1000); } Console.WriteLine("Client machine '{0}' found ({1}, {2})", machineName, machine.OperatingSystem, machine.ProcessorArchitecture); }
public static IEmulatedEthernetPortSettingData GetDefaultFromResourcePool(IResourcePool resource) { ManagementObject managementObject = (ManagementObject)null; using (ManagementObjectCollection related = ((IWMICommon)resource).Object.GetRelated("Msvm_AllocationCapabilities", "Msvm_ElementCapabilities", (string)null, (string)null, (string)null, (string)null, false, (EnumerationOptions)null)) { using (ManagementObject firstElement = related.GetFirstElement()) { foreach (ManagementObject relationship in firstElement.GetRelationships("Msvm_SettingsDefineCapabilities")) { if ((int)(ushort)relationship["ValueRole"] == 0) { managementObject = relationship; break; } relationship.Dispose(); } } } if (managementObject == null) { throw new HyperVException("Unable to find the default settings for the resource"); } string path = (string)managementObject["PartComponent"]; managementObject.Dispose(); ManagementObject instance = new ManagementObject(path); instance.Scope = ((IWMICommon)resource).Scope; instance.Get(); return((IEmulatedEthernetPortSettingData) new EmulatedEthernetPortSettingData(instance)); }
public void parentIsSetCorrectly([ValueSource(nameof(testPools))] IResourcePool pool) => VisitResources(pool, res => { foreach (var child in res) { Assert.AreEqual(res, child.Parent); } });
public static async Task TestConcurrent(IResourcePool <int, Nothing> pool, int clients) { async Task Call() { int resource = -1; try { do { resource = pool.Acquire(); } while (resource < 0); await Task.Delay(_random.Next(10, 100)); } finally { pool.Release(resource); var stats = pool.Stats(); Assert.Equal(stats.Allocations, stats.Evictions + stats.Idle + stats.InUse); } } var tasks = new List <Task>(); for (var i = 0; i < clients; i++) { var task = Task.Run(Call); tasks.Add(task); } await Task.WhenAll(tasks); Assert.Equal(pool.Stats().Idle, pool.Size); }
private void TakeFromPool(IResourcePool <T> pool, CancellationToken cancelToken) { try { T res = pool.Acquire(cancelToken); _myPool.Add(res); } catch (OperationCanceledException) { } }
public void openContent([ValueSource(nameof(testPools))] IResourcePool pool) => VisitResources(pool, res => { using var stream = res.OpenContent(); if (res.Type == ResourceType.File) { Assert.IsNotNull(stream); Assert.IsTrue(stream !.CanRead);
// Wait for a machine to show up in the data store static void FindMachine(IResourcePool rootPool, string machineName) { Console.WriteLine("Looking for machine '{0}'", machineName); IResource machine = null; while (true) { try { machine = rootPool.GetResourceByName(machineName); } catch (Exception e) { Console.WriteLine("Warning: " + e.Message); } // Make sure the machine is valid if (machine != null && machine.OperatingSystem != null && machine.OperatingSystem.Length > 0 && machine.ProcessorArchitecture != null && machine.ProcessorArchitecture.Length > 0 && machine.GetDevices().Length > 0) break; System.Threading.Thread.Sleep(1000); } Console.WriteLine("Client machine '{0}' found ({1}, {2})", machineName, machine.OperatingSystem, machine.ProcessorArchitecture); }
private readonly Sampler fontSampler; // a linear, non-bleeding sampler public UITileSheet(ITagContainer diContainer) { this.diContainer = diContainer; ui = diContainer.GetTag <UI>(); graphicsDevice = diContainer.GetTag <GraphicsDevice>(); resourceFactory = diContainer.GetTag <ResourceFactory>(); resourcePool = diContainer.GetTag <IResourcePool>(); Manage(diContainer.GetTag <DefaultEcs.World>()); linearSampler = resourceFactory.CreateSampler(new SamplerDescription( SamplerAddressMode.Clamp, SamplerAddressMode.Clamp, SamplerAddressMode.Clamp, SamplerFilter.MinLinear_MagLinear_MipLinear, comparisonKind: null, 0, 0, 0, 0, SamplerBorderColor.TransparentBlack)); fontSampler = resourceFactory.CreateSampler(new SamplerDescription( SamplerAddressMode.Clamp, SamplerAddressMode.Clamp, SamplerAddressMode.Clamp, SamplerFilter.MinLinear_MagLinear_MipLinear, comparisonKind: null, 0, 0, 0, 0, SamplerBorderColor.TransparentBlack)); }
public static IStorageAllocationSettingData GetDefaultVirtualHardDiskStorageAllocationSettingData(IComputerSystem host) { using (IResourcePool resource = ResourcePool.Query(host, "ResourceSubType = 'Microsoft:Hyper-V:Virtual Hard Disk' and Primordial = True").FirstOrDefault <IResourcePool>()) { Invariant.ArgumentNotNull((object)resource, "Couldn't find the resource pool for Virtual Hard Disk"); return(StorageAllocationSettingData.GetDefaultFromResourcePool(resource)); } }
public void WaitAndRealese(PeerHandler handler, IResourcePool <PeerHandler> returnPool, int waitSeconds) { Task.Factory.StartNew(() => { PeerHandler h = handler; Thread.Sleep(waitSeconds); returnPool.Realese(h); }); }
public static IEmulatedEthernetPortSettingData GetDefaultLegacyAdapter(IComputerSystem host) { IResourcePool resource = ResourcePool.Query(host, "ResourceSubType = 'Microsoft:Hyper-V:Emulated Ethernet Port' and Primordial = True").FirstOrDefault <IResourcePool>(); Invariant.ArgumentNotNull((object)resource, "Legacy Adapter not found"); using (resource) return(EmulatedEthernetPortSettingData.GetDefaultFromResourcePool(resource)); }
public static IResourceAllocationSettingData GetDefaultEmulatedIDEController(IComputerSystem host) { IResourcePool resource = ResourcePool.Query(host, "ResourceSubType = 'Microsoft:Hyper-V:Emulated IDE Controller' and Primordial = True").FirstOrDefault <IResourcePool>(); Invariant.ArgumentNotNull((object)resource, "Emulated IDE Controller"); using (resource) return(ResourceAllocationSettingData.GetDefaultFromResourcePool(resource)); }
public static IResourceAllocationSettingData GetDefaultSyntheticDVDDrive(IComputerSystem host) { IResourcePool resource = ResourcePool.Query(host, "ResourceSubType = 'Microsoft:Hyper-V:Synthetic DVD Drive' and Primordial = True").FirstOrDefault <IResourcePool>(); Invariant.ArgumentNotNull((object)resource, "Synthetic DVD Drive not found"); using (resource) return(ResourceAllocationSettingData.GetDefaultFromResourcePool(resource)); }
public CouchbasePooledSocket(IResourcePool pool, Socket socket) { _isAlive = true; _pool = pool; _socket = socket; _instanceId = Guid.NewGuid(); _stream = new NetworkStream(socket, true); }
public void AwaitBitfield(PeerHandler handler, IResourcePool <PeerHandler> returnPool, int awaitSeconds, int triesCount = 1) { ManualResetEventSlim eventReset = new ManualResetEventSlim(); handler.OnBitfield += h => eventReset.Set(); AwaitHandler(eventReset, handler, returnPool, awaitSeconds, triesCount); }
public ServerActor( Resources resources, Filters filters, int port, Configuration.SizingConf sizing, Configuration.TimingConf timing, string channelMailboxTypeName) { var start = DateExtensions.GetCurrentMillis(); _filters = filters; _dispatcherPoolIndex = 0; _world = Stage.World; _requestsMissingContent = new Dictionary <string, RequestResponseHttpContext>(); _maxMessageSize = sizing.MaxMessageSize; try { _responseBufferPool = new ConsumerByteBufferPool( ElasticResourcePool <IConsumerByteBuffer, Nothing> .Config.Of(sizing.MaxBufferPoolSize), sizing.MaxMessageSize); _dispatcherPool = new IDispatcher[sizing.DispatcherPoolSize]; for (int idx = 0; idx < sizing.DispatcherPoolSize; ++idx) { _dispatcherPool[idx] = Dispatcher.StartWith(Stage, resources); } _channel = ServerRequestResponseChannelFactory.Start( Stage, Stage.World.AddressFactory.WithHighId(ChannelName), channelMailboxTypeName, this, port, ChannelName, sizing.ProcessorPoolSize, sizing.MaxBufferPoolSize, sizing.MaxMessageSize, timing.ProbeInterval, timing.ProbeTimeout); var end = DateExtensions.GetCurrentMillis(); Logger.Info($"Server {ServerName} is listening on port: {port} started in {end - start} ms"); _requestMissingContentTimeout = timing.RequestMissingContentTimeout; LogResourceMappings(resources); } catch (Exception e) { var message = $"Failed to start server because: {e.Message}"; Logger.Error(message, e); throw new InvalidOperationException(message); } }
public UIBitmap(ITagContainer diContainer) { this.diContainer = diContainer; ui = diContainer.GetTag <UI>(); graphicsDevice = diContainer.GetTag <GraphicsDevice>(); resourceFactory = diContainer.GetTag <ResourceFactory>(); resourcePool = diContainer.GetTag <IResourcePool>(); Manage(diContainer.GetTag <DefaultEcs.World>()); }
public void Accept(IResourcePool <ArraySegment <byte> > visitor) { _bufferManager = visitor; _writeEventArgs = new SocketAsyncEventArgs(); var taken = visitor.Take(out _writeBuffer); Contract.Assert(taken); _writeEventArgs.SetBuffer(_writeBuffer.Array, _writeBuffer.Offset, _writeBuffer.Count); }
public void resourcesTypesInSplit([ValueSource(nameof(testPools))] IResourcePool pool) => VisitResources(pool, res => { foreach (var file in res.Files) { Assert.AreEqual(ResourceType.File, file.Type); } foreach (var dir in res.Directories) { Assert.AreEqual(ResourceType.Directory, dir.Type); } });
public static ulong GetMaxConsumableResource(IComputerSystem host) { using (IResourcePool resourcePool = ResourcePool.Query(host, "ResourceType = 4").FirstOrDefault <IResourcePool>()) { if (resourcePool == null) { throw new HyperVException("Unable to find the default settings for the Memory resource"); } return(resourcePool.MaxConsumableResource); } }
public CouchbaseNode(IPEndPoint endpoint, Uri couchApiBase, ICouchbaseClientConfiguration config, ISaslAuthenticationProvider provider) { var uriBuilder = new UriBuilder(couchApiBase); uriBuilder.Path = Path.Combine(uriBuilder.Path, "_design"); _config = config; _client = config.CreateHttpClient(uriBuilder.Uri); _client.RetryCount = config.RetryCount; _endpoint = endpoint; _pool = new SocketPool(this, config.SocketPool, provider); }
private void VisitResources(IResourcePool pool, Action <IResource> action) { void visit(IResource res) { action(res); foreach (var child in res) { visit(child); } } visit(pool.Root); }
public ConnectionHub(BtClient client, IPEndPoint endPoint, IResourcePool <Peer> peerPool, PeerStateCache stateCache) { _client = client; _peerPool = peerPool; _stateCache = stateCache; _myPool = new BlockingCollection <PeerHandler>(); _listenerTask = new Task(StartListener); _listener = new TcpListener(endPoint); _connectedIps = new SortedSet <string>(); _isListenerStopped = false; _myCancelTokenSource = new CancellationTokenSource(); }
public EffectEditor(ITagContainer diContainer) { device = diContainer.GetTag <GraphicsDevice>(); resourcePool = diContainer.GetTag <IResourcePool>(); gameTime = diContainer.GetTag <GameTime>(); Window = diContainer.GetTag <WindowContainer>().NewWindow("Effect Editor"); Window.InitialBounds = new Rect(float.NaN, float.NaN, 1100f, 600f); Window.AddTag(this); editor = new TwoColumnEditorTag(Window, diContainer); var onceAction = new OnceAction(); Window.AddTag(onceAction); Window.OnContent += onceAction.Invoke; var menuBar = new MenuBarWindowTag(Window); menuBar.AddButton("Open", HandleMenuOpen); fbArea = Window.GetTag <FramebufferArea>(); fbArea.OnResize += HandleResize; fbArea.OnRender += HandleRender; diContainer.GetTag <OpenDocumentSet>().AddEditor(this); openFileModal = new OpenFileModal(diContainer) { Filter = "*.ed", IsFilterChangeable = false }; openFileModal.OnOpenedResource += Load; locationBuffer = new LocationBuffer(device); this.diContainer = diContainer.ExtendedWith(locationBuffer); AddDisposable(this.diContainer); this.diContainer.AddTag(camera = new Camera(this.diContainer)); this.diContainer.AddTag <IQuadMeshBuffer <EffectVertex> >(new DynamicQuadMeshBuffer <EffectVertex>(device.ResourceFactory, 1024)); this.diContainer.AddTag <IQuadMeshBuffer <SparkVertex> >(new DynamicQuadMeshBuffer <SparkVertex>(device.ResourceFactory, 256)); controls = new OrbitControlsTag(Window, camera.Location, this.diContainer); AddDisposable(controls); gridRenderer = new DebugGridRenderer(this.diContainer); gridRenderer.Material.LinkTransformsTo(camera); gridRenderer.Material.World.Ref = Matrix4x4.Identity; AddDisposable(gridRenderer); AddDisposable(textureLoader = new CachedAssetLoader <Texture>(new TextureAssetLoader(diContainer))); AddDisposable(clumpLoader = new CachedClumpAssetLoader(diContainer)); this.diContainer.AddTag <IAssetLoader <Texture> >(textureLoader); this.diContainer.AddTag <IAssetLoader <ClumpBuffers> >(clumpLoader); editor.AddInfoSection("Info", HandleInfoContent); editor.AddInfoSection("Playback", HandlePlaybackContent); }
public ActorEditor(ITagContainer diContainer) { this.diContainer = diContainer; device = diContainer.GetTag <GraphicsDevice>(); resourcePool = diContainer.GetTag <IResourcePool>(); Window = diContainer.GetTag <WindowContainer>().NewWindow("Actor Editor"); Window.InitialBounds = new Rect(float.NaN, float.NaN, 1100.0f, 600.0f); Window.AddTag(this); editor = new TwoColumnEditorTag(Window, diContainer); var onceAction = new OnceAction(); Window.AddTag(onceAction); Window.OnContent += onceAction.Invoke; var menuBar = new MenuBarWindowTag(Window); menuBar.AddButton("Open", HandleMenuOpen); fbArea = Window.GetTag <FramebufferArea>(); fbArea.OnResize += HandleResize; fbArea.OnRender += HandleRender; diContainer.GetTag <OpenDocumentSet>().AddEditor(this); openFileModal = new OpenFileModal(diContainer); openFileModal.Filter = "*.aed"; openFileModal.IsFilterChangeable = false; openFileModal.OnOpenedResource += Load; locationBuffer = new LocationBuffer(device); AddDisposable(locationBuffer); localDiContainer = diContainer.ExtendedWith(locationBuffer); camera = new Camera(localDiContainer); AddDisposable(camera); controls = new OrbitControlsTag(Window, camera.Location, localDiContainer); AddDisposable(controls); localDiContainer.AddTag(camera); gridRenderer = new DebugGridRenderer(diContainer); gridRenderer.Material.LinkTransformsTo(camera); gridRenderer.Material.World.Ref = Matrix4x4.Identity; AddDisposable(gridRenderer); localDiContainer.AddTag <IStandardTransformMaterial>(gridRenderer.Material); editor.AddInfoSection("Info", HandleInfoContent); editor.AddInfoSection("Animation Playback", HandlePlaybackContent); editor.AddInfoSection("Body animations", () => HandlePartContent(false, () => body?.AnimationsContent() ?? false), false); editor.AddInfoSection("Wings animations", () => HandlePartContent(true, () => wings?.AnimationsContent() ?? false), false); editor.AddInfoSection("Body skeleton", () => HandlePartContent(false, () => body?.skeletonRenderer.Content() ?? false), false); editor.AddInfoSection("Wings skeleton", () => HandlePartContent(true, () => wings?.skeletonRenderer.Content() ?? false), false); editor.AddInfoSection("Head IK", HandleHeadIKContent, false); }
public void content([ValueSource(nameof(testPools))] IResourcePool pool) { Stream?getFileContent(IResource dir, string file) => dir.Files .SingleOrDefault(f => f.Path.Parts.Last() == file) ?.OpenContent(); var a = pool.Root.Directories.Single(); var b = a.Directories.Single(d => d.Path.Parts.Last() == "b"); var c = a.Directories.Single(d => d.Path.Parts.Last() == "c"); MyAssert.Equals("42", getFileContent(pool.Root, "answer.txt")); MyAssert.Equals("Hello World!", getFileContent(pool.Root, "hello.txt")); MyAssert.Equals("1337", getFileContent(b, "content.txt")); MyAssert.Equals("Zanzarah", getFileContent(c, "content.txt")); }
public SceneEditor(ITagContainer diContainer) { this.diContainer = diContainer; resourcePool = diContainer.GetTag <IResourcePool>(); Window = diContainer.GetTag <WindowContainer>().NewWindow("Scene Editor"); Window.AddTag(this); Window.InitialBounds = new Rect(float.NaN, float.NaN, 1100.0f, 600.0f); editor = new TwoColumnEditorTag(Window, diContainer); var onceAction = new OnceAction(); Window.AddTag(onceAction); Window.OnContent += onceAction.Invoke; locationBuffer = new LocationBuffer(diContainer.GetTag <GraphicsDevice>()); AddDisposable(locationBuffer); var menuBar = new MenuBarWindowTag(Window); menuBar.AddButton("Open", HandleMenuOpen); openFileModal = new OpenFileModal(diContainer); openFileModal.Filter = "*.scn"; openFileModal.IsFilterChangeable = false; openFileModal.OnOpenedResource += Load; camera = new Camera(diContainer.ExtendedWith(locationBuffer)); AddDisposable(camera); controls = new FlyControlsTag(Window, camera.Location, diContainer); gridRenderer = new DebugGridRenderer(diContainer); gridRenderer.Material.LinkTransformsTo(camera); gridRenderer.Material.World.Ref = Matrix4x4.Identity; AddDisposable(gridRenderer); fbArea = Window.GetTag <FramebufferArea>(); fbArea.OnResize += HandleResize; fbArea.OnRender += camera.Update; fbArea.OnRender += locationBuffer.Update; fbArea.OnRender += gridRenderer.Render; localDiContainer = diContainer .FallbackTo(Window) .ExtendedWith(this, Window, gridRenderer, locationBuffer) .AddTag <IAssetLoader <Texture> >(new CachedAssetLoader <Texture>(diContainer.GetTag <IAssetLoader <Texture> >())) .AddTag <IAssetLoader <ClumpBuffers> >(new CachedClumpAssetLoader(diContainer)) .AddTag(camera); new DatasetComponent(localDiContainer); new WorldComponent(localDiContainer); new ModelComponent(localDiContainer); new FOModelComponent(localDiContainer); new TriggerComponent(localDiContainer); new SelectionComponent(localDiContainer); }
public void SetUp() { var port = int.Parse(ConfigurationManager.AppSettings["port"]); var address = ConfigurationManager.AppSettings["address"]; IPAddress ipAddress; if (!IPAddress.TryParse(address, out ipAddress)) { throw new ArgumentException("endpoint"); } //Use defaults var endpoint = new IPEndPoint(ipAddress, port); var config = new SocketPoolConfiguration(); var node = new CouchbaseNode(endpoint, config); _pool = new SocketPool(node, config); }
// Set the machine's status to 'Reset' and optionally wait for it to become ready static void ResetMachine(IResourcePool rootPool, string machineName, bool wait) { Console.WriteLine("Resetting machine '{0}'", machineName); IResource machine; while (true) { try { machine = rootPool.GetResourceByName(machineName); machine.ChangeResourceStatus("Reset"); break; } catch (Exception e) { Console.WriteLine("Warning: " + e.Message); System.Threading.Thread.Sleep(5000); } } if (wait) { Console.WriteLine("Waiting for machine '{0}' to be ready", machineName); while (machine.Status != "Ready") { try { machine = rootPool.GetResourceByName(machineName); } catch (Exception e) { Console.WriteLine("Warning: " + e.Message); } System.Threading.Thread.Sleep(1000); } Console.WriteLine("Machine '{0}' is ready", machineName); } }
public void SetUp() { var factory = new Func<IResourcePool, Connection>(x => null); var store = new QueueStore(); _pool = new ConnectionPool(factory, store); }
// Look for a device in a machine, and if not found, keep trying for 3 minutes static IDevice GetDevice(IResourcePool rootPool, string machineName, string regexStr) { Regex deviceRegex = new Regex(regexStr, RegexOptions.IgnoreCase); int numAttempts = 1; DateTime endTime = DateTime.Now.AddSeconds(180); while (DateTime.Now < endTime) { IResource machine = rootPool.GetResourceByName(machineName); Console.WriteLine("Looking for device '{0}' in machine '{1}' (machine has {2} devices)", regexStr, machineName, machine.GetDevices().Length); foreach (IDevice d in machine.GetDevices()) { if (deviceRegex.IsMatch(d.FriendlyName)) { Console.WriteLine("Found device '{0}'", d.FriendlyName); return d; } } Console.WriteLine("Device not found"); if (numAttempts % 5 == 0) ResetMachine(rootPool, machineName, true); else System.Threading.Thread.Sleep(5000); numAttempts++; } Console.WriteLine("Error: device '{0}' not found", deviceRegex); return null; }
public void Test_Construction() { var factory = new Func<IResourcePool, IResource>(x => new FakeResource()); var store = new FakeStoreStrategy(); _pool = new FakeResourcePool(factory, store); }
public CouchbaseNode(IPEndPoint endpoint, ISocketPoolConfiguration config) { _endpoint = endpoint; _pool = new SocketPool(this, config); }
public CouchbaseNode(IPEndPoint endpoint, ISocketPoolConfiguration config, ISaslAuthenticationProvider provider) { _endpoint = endpoint; _pool = new SocketPool(this, config, provider); }