public override void Start() { _monitors.addMonitorListener(_monitor); _registry.register(IsMaster, new RoleGauge(this, MASTER.equals)); _registry.register(IsAvailable, new RoleGauge(this, s => !UNKNOWN.Equals(s))); _registry.register(SlavePullUpdates, (Gauge <long>)() => _monitor.events.get()); _registry.register(SlavePullUpdateUpToTx, (Gauge <long>)() => _monitor.lastAppliedTxId); }
/// <summary> /// determines, which exception to return to the client based on /// the called method/attribute and on the Exception thrown. /// Make sure to return only exceptions, which are allowed for the thrower; e.g. /// only those specified in the interface for methods and for attributes only system exceptions. /// </summary> private Exception DetermineExceptionToThrow(Exception thrown, MethodBase thrower) { if (thrown is omg.org.CORBA.AbstractCORBASystemException) { return(thrown); // system exceptions are not wrapped or transformed } Exception exceptionToThrow; if ((thrower is MethodInfo) && (!((MethodInfo)thrower).IsSpecialName)) // is a normal method (i.e. no property accessor, ...) { if (ReflectionHelper.IIdlEntityType.IsAssignableFrom(thrower.DeclaringType)) { exceptionToThrow = DetermineIdlExceptionToThrow(thrown, (MethodInfo)thrower); } else { if (ReflectionHelper.IsExceptionInRaiseAttributes(thrown, (MethodInfo)thrower) && (thrown is AbstractUserException)) { exceptionToThrow = thrown; // a .NET method could also use ThrowsIdlException attribute to return non-wrapped exceptions } else { // wrap into generic user exception, because CLS to IDL gen adds this exception to // all methods exceptionToThrow = new GenericUserException(thrown); } } } else if ((thrower is MethodInfo) && (((MethodInfo)thrower).IsSpecialName)) // is a special method (i.e. a property accessor, ...) { exceptionToThrow = new UNKNOWN(190, CompletionStatus.Completed_Yes); } else { // thrower == null means here, that the target method was not determined, // i.e. the request deserialisation was not ok Debug.WriteLine("target method unknown, can't determine what exception client accepts; thrown was: " + thrown); exceptionToThrow = new UNKNOWN(201, CompletionStatus.Completed_No); } return(exceptionToThrow); }
public override string ToString() { StringBuilder __sb = new StringBuilder("LogicalType("); bool __first = true; if (STRING != null && __isset.@STRING) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("STRING: "); __sb.Append(STRING == null ? "<null>" : STRING.ToString()); } if (MAP != null && __isset.MAP) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("MAP: "); __sb.Append(MAP == null ? "<null>" : MAP.ToString()); } if (LIST != null && __isset.LIST) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("LIST: "); __sb.Append(LIST == null ? "<null>" : LIST.ToString()); } if (ENUM != null && __isset.@ENUM) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("ENUM: "); __sb.Append(ENUM == null ? "<null>" : ENUM.ToString()); } if (DECIMAL != null && __isset.@DECIMAL) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("DECIMAL: "); __sb.Append(DECIMAL == null ? "<null>" : DECIMAL.ToString()); } if (DATE != null && __isset.DATE) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("DATE: "); __sb.Append(DATE == null ? "<null>" : DATE.ToString()); } if (TIME != null && __isset.TIME) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("TIME: "); __sb.Append(TIME == null ? "<null>" : TIME.ToString()); } if (TIMESTAMP != null && __isset.TIMESTAMP) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("TIMESTAMP: "); __sb.Append(TIMESTAMP == null ? "<null>" : TIMESTAMP.ToString()); } if (INTEGER != null && __isset.INTEGER) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("INTEGER: "); __sb.Append(INTEGER == null ? "<null>" : INTEGER.ToString()); } if (UNKNOWN != null && __isset.UNKNOWN) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("UNKNOWN: "); __sb.Append(UNKNOWN == null ? "<null>" : UNKNOWN.ToString()); } if (JSON != null && __isset.JSON) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("JSON: "); __sb.Append(JSON == null ? "<null>" : JSON.ToString()); } if (BSON != null && __isset.BSON) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("BSON: "); __sb.Append(BSON == null ? "<null>" : BSON.ToString()); } if (UUID != null && __isset.UUID) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("UUID: "); __sb.Append(UUID == null ? "<null>" : UUID.ToString()); } __sb.Append(")"); return(__sb.ToString()); }
public void Write(TProtocol oprot) { oprot.IncrementRecursionDepth(); try { TStruct struc = new TStruct("LogicalType"); oprot.WriteStructBegin(struc); TField field = new TField(); if (STRING != null && __isset.@STRING) { field.Name = "STRING"; field.Type = TType.Struct; field.ID = 1; oprot.WriteFieldBegin(field); STRING.Write(oprot); oprot.WriteFieldEnd(); } if (MAP != null && __isset.MAP) { field.Name = "MAP"; field.Type = TType.Struct; field.ID = 2; oprot.WriteFieldBegin(field); MAP.Write(oprot); oprot.WriteFieldEnd(); } if (LIST != null && __isset.LIST) { field.Name = "LIST"; field.Type = TType.Struct; field.ID = 3; oprot.WriteFieldBegin(field); LIST.Write(oprot); oprot.WriteFieldEnd(); } if (ENUM != null && __isset.@ENUM) { field.Name = "ENUM"; field.Type = TType.Struct; field.ID = 4; oprot.WriteFieldBegin(field); ENUM.Write(oprot); oprot.WriteFieldEnd(); } if (DECIMAL != null && __isset.@DECIMAL) { field.Name = "DECIMAL"; field.Type = TType.Struct; field.ID = 5; oprot.WriteFieldBegin(field); DECIMAL.Write(oprot); oprot.WriteFieldEnd(); } if (DATE != null && __isset.DATE) { field.Name = "DATE"; field.Type = TType.Struct; field.ID = 6; oprot.WriteFieldBegin(field); DATE.Write(oprot); oprot.WriteFieldEnd(); } if (TIME != null && __isset.TIME) { field.Name = "TIME"; field.Type = TType.Struct; field.ID = 7; oprot.WriteFieldBegin(field); TIME.Write(oprot); oprot.WriteFieldEnd(); } if (TIMESTAMP != null && __isset.TIMESTAMP) { field.Name = "TIMESTAMP"; field.Type = TType.Struct; field.ID = 8; oprot.WriteFieldBegin(field); TIMESTAMP.Write(oprot); oprot.WriteFieldEnd(); } if (INTEGER != null && __isset.INTEGER) { field.Name = "INTEGER"; field.Type = TType.Struct; field.ID = 10; oprot.WriteFieldBegin(field); INTEGER.Write(oprot); oprot.WriteFieldEnd(); } if (UNKNOWN != null && __isset.UNKNOWN) { field.Name = "UNKNOWN"; field.Type = TType.Struct; field.ID = 11; oprot.WriteFieldBegin(field); UNKNOWN.Write(oprot); oprot.WriteFieldEnd(); } if (JSON != null && __isset.JSON) { field.Name = "JSON"; field.Type = TType.Struct; field.ID = 12; oprot.WriteFieldBegin(field); JSON.Write(oprot); oprot.WriteFieldEnd(); } if (BSON != null && __isset.BSON) { field.Name = "BSON"; field.Type = TType.Struct; field.ID = 13; oprot.WriteFieldBegin(field); BSON.Write(oprot); oprot.WriteFieldEnd(); } if (UUID != null && __isset.UUID) { field.Name = "UUID"; field.Type = TType.Struct; field.ID = 14; oprot.WriteFieldBegin(field); UUID.Write(oprot); oprot.WriteFieldEnd(); } oprot.WriteFieldStop(); oprot.WriteStructEnd(); } finally { oprot.DecrementRecursionDepth(); } }
public async Task WriteAsync(TProtocol oprot, CancellationToken cancellationToken) { oprot.IncrementRecursionDepth(); try { var struc = new TStruct("LogicalType"); await oprot.WriteStructBeginAsync(struc, cancellationToken); var field = new TField(); if (STRING != null && __isset.@STRING) { field.Name = "STRING"; field.Type = TType.Struct; field.ID = 1; await oprot.WriteFieldBeginAsync(field, cancellationToken); await STRING.WriteAsync(oprot, cancellationToken); await oprot.WriteFieldEndAsync(cancellationToken); } if (MAP != null && __isset.MAP) { field.Name = "MAP"; field.Type = TType.Struct; field.ID = 2; await oprot.WriteFieldBeginAsync(field, cancellationToken); await MAP.WriteAsync(oprot, cancellationToken); await oprot.WriteFieldEndAsync(cancellationToken); } if (LIST != null && __isset.LIST) { field.Name = "LIST"; field.Type = TType.Struct; field.ID = 3; await oprot.WriteFieldBeginAsync(field, cancellationToken); await LIST.WriteAsync(oprot, cancellationToken); await oprot.WriteFieldEndAsync(cancellationToken); } if (ENUM != null && __isset.@ENUM) { field.Name = "ENUM"; field.Type = TType.Struct; field.ID = 4; await oprot.WriteFieldBeginAsync(field, cancellationToken); await ENUM.WriteAsync(oprot, cancellationToken); await oprot.WriteFieldEndAsync(cancellationToken); } if (DECIMAL != null && __isset.@DECIMAL) { field.Name = "DECIMAL"; field.Type = TType.Struct; field.ID = 5; await oprot.WriteFieldBeginAsync(field, cancellationToken); await DECIMAL.WriteAsync(oprot, cancellationToken); await oprot.WriteFieldEndAsync(cancellationToken); } if (DATE != null && __isset.DATE) { field.Name = "DATE"; field.Type = TType.Struct; field.ID = 6; await oprot.WriteFieldBeginAsync(field, cancellationToken); await DATE.WriteAsync(oprot, cancellationToken); await oprot.WriteFieldEndAsync(cancellationToken); } if (TIME != null && __isset.TIME) { field.Name = "TIME"; field.Type = TType.Struct; field.ID = 7; await oprot.WriteFieldBeginAsync(field, cancellationToken); await TIME.WriteAsync(oprot, cancellationToken); await oprot.WriteFieldEndAsync(cancellationToken); } if (TIMESTAMP != null && __isset.TIMESTAMP) { field.Name = "TIMESTAMP"; field.Type = TType.Struct; field.ID = 8; await oprot.WriteFieldBeginAsync(field, cancellationToken); await TIMESTAMP.WriteAsync(oprot, cancellationToken); await oprot.WriteFieldEndAsync(cancellationToken); } if (INTEGER != null && __isset.INTEGER) { field.Name = "INTEGER"; field.Type = TType.Struct; field.ID = 10; await oprot.WriteFieldBeginAsync(field, cancellationToken); await INTEGER.WriteAsync(oprot, cancellationToken); await oprot.WriteFieldEndAsync(cancellationToken); } if (UNKNOWN != null && __isset.UNKNOWN) { field.Name = "UNKNOWN"; field.Type = TType.Struct; field.ID = 11; await oprot.WriteFieldBeginAsync(field, cancellationToken); await UNKNOWN.WriteAsync(oprot, cancellationToken); await oprot.WriteFieldEndAsync(cancellationToken); } if (JSON != null && __isset.JSON) { field.Name = "JSON"; field.Type = TType.Struct; field.ID = 12; await oprot.WriteFieldBeginAsync(field, cancellationToken); await JSON.WriteAsync(oprot, cancellationToken); await oprot.WriteFieldEndAsync(cancellationToken); } if (BSON != null && __isset.BSON) { field.Name = "BSON"; field.Type = TType.Struct; field.ID = 13; await oprot.WriteFieldBeginAsync(field, cancellationToken); await BSON.WriteAsync(oprot, cancellationToken); await oprot.WriteFieldEndAsync(cancellationToken); } await oprot.WriteFieldStopAsync(cancellationToken); await oprot.WriteStructEndAsync(cancellationToken); } finally { oprot.DecrementRecursionDepth(); } }