//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void stopDoesNotThrowWhenMasterCommunicationThrowsComException() public virtual void StopDoesNotThrowWhenMasterCommunicationThrowsComException() { ComException error = new ComException("Communication failure"); when(_master.endLockSession(Null, anyBoolean())).thenThrow(error); _client.stop(); _logProvider.assertExactly(inLog(typeof(SlaveLocksClient)).warn(equalTo("Unable to stop lock session on master"), CoreMatchers.instanceOf(typeof(DistributedLockFailureException)))); }
public static IAds GetAds(string path) { object ppObject = null; int hr = ADsOpenObject(path, null, null, 1, ref IID_IAds, out ppObject); if (ppObject == null) { throw ComException.BuildComException(hr); } return(ppObject as IAds); }
public static IDirectorySearch GetDirectorySearcher(string path) { object ppObject = null; int hr = ADsOpenObject(path, null, null, 1, ref IID_IDirectorySearch, out ppObject); if (ppObject == null) { throw ComException.BuildComException(hr); } return(ppObject as IDirectorySearch); }
public override void Handle(ComException exception) { exception.TraceComException(_log, "MasterClientResolver.handle"); if (exception is IllegalProtocolVersionException) { _log.info("Handling " + exception + ", will pick new master client"); IllegalProtocolVersionException illegalProtocolVersion = ( IllegalProtocolVersionException )exception; ProtocolVersion requiredProtocolVersion = new ProtocolVersion(illegalProtocolVersion.Received, ProtocolVersion.INTERNAL_PROTOCOL_VERSION); GetFor(requiredProtocolVersion); } else if (exception is InvalidEpochException) { _log.info("Handling " + exception + ", will go to PENDING and ask for election"); _invalidEpochHandler.handle(); } else { _log.debug("Ignoring " + exception + "."); } }
private void MakeSureTxHasBeenInitialized() { try { _availabilityGuard.checkAvailable(); } catch (UnavailableException e) { throw new TransientDatabaseFailureException("Database not available", e); } if (!_initialized) { try { using (Response <Void> ignored = _master.newLockSession(NewRequestContextFor(_client))) { // Lock session is initialized on master at this point } } catch (Exception exception) { // Temporary wrapping, we should review the exception structure of the Locks API to allow this to // not use runtime exceptions here. ComException e; if (exception is ComException) { e = ( ComException )exception; } else { e = new ComException(exception); } throw new DistributedLockFailureException("Failed to start a new lock session on master", _master, e); } _initialized = true; } }
//////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// private Boolean InitialCollection() { try { if (directoryEntry.Properties.Count > 0) { Object kluge = directoryEntry.NativeObject; directoryEntry.AuthenticationType = AuthenticationTypes.Secure; directorySearcher = new DirectorySearcher(directoryEntry); netbiosName = directoryEntry.Name.Remove(0, 3); domainName = ((String)directoryEntry.Properties["distinguishedName"].Value).Remove(0, 3).Replace(",DC=", "."); Console.WriteLine("Using {0} ({1})", domainName, netbiosName); return(true); } return(false); } catch (System.Runtime.InteropServices.COMException ComException) { Console.WriteLine("Connection Failed: "); Console.WriteLine(ComException.ToString()); return(false); } }