private static truncOptions GetCompressionTasks(int totalLen, int serviceLen, int contractLen, int uriLen) { truncOptions bitmask = 0; if (totalLen > maxCounterLength) { int workingLen = totalLen; //note: order of if statements important (see spec)! if (workingLen > maxCounterLength && serviceLen > 15) { bitmask |= truncOptions.service15; //compress service name to 16 chars workingLen -= serviceLen - 15; } if (workingLen > maxCounterLength && contractLen > 16) { bitmask |= truncOptions.contract16; //compress contract name to 8 chars workingLen -= contractLen - 16; } if (workingLen > maxCounterLength && uriLen > 31) { bitmask |= truncOptions.uri31; //compress uri to 31 chars } } return(bitmask); }
static truncOptions GetCompressionTasks(int totalLen, int serviceLen, int contractLen, int operationLen, int uriLen) { truncOptions bitmask = 0; if (totalLen > maxCounterLength) { int workingLen = totalLen; //note: order of if statements important (see spec)! if (workingLen > maxCounterLength && serviceLen > 8) { bitmask |= truncOptions.service7; //compress service name to 8 chars workingLen -= serviceLen - 7; } if (workingLen > maxCounterLength && contractLen > 7) { bitmask |= truncOptions.contract7; //compress contract name to 8 chars workingLen -= contractLen - 7; } if (workingLen > maxCounterLength && operationLen > 15) { bitmask |= truncOptions.operation15; //compress operation name to 16 chars workingLen -= operationLen - 15; } if (workingLen > maxCounterLength && uriLen > 32) { bitmask |= truncOptions.uri32; //compress uri to 32 chars } } return(bitmask); }
internal static string CreateFriendlyInstanceName(string service, string contract, string uri) { int totalLen = ((service.Length + contract.Length) + uri.Length) + 2; if (totalLen > 0x40) { int num2 = 0; truncOptions options = GetCompressionTasks(totalLen, service.Length, contract.Length, uri.Length); if ((options & (truncOptions.NoBits | truncOptions.service15)) > truncOptions.NoBits) { num2 = 15; service = PerformanceCountersBase.GetHashedString(service, num2 - 2, (service.Length - num2) + 2, true); } if ((options & truncOptions.contract16) > truncOptions.NoBits) { num2 = 0x10; contract = PerformanceCountersBase.GetHashedString(contract, num2 - 2, (contract.Length - num2) + 2, true); } if ((options & (truncOptions.NoBits | truncOptions.uri31)) > truncOptions.NoBits) { num2 = 0x1f; uri = PerformanceCountersBase.GetHashedString(uri, 0, (uri.Length - num2) + 2, false); } } return(service + "." + contract + "@" + uri.Replace('/', '|')); }
private static truncOptions GetCompressionTasks(int totalLen, int serviceLen, int contractLen, int operationLen, int uriLen) { truncOptions noBits = truncOptions.NoBits; if (totalLen > 0x40) { int num = totalLen; if ((num > 0x40) && (serviceLen > 8)) { noBits |= truncOptions.NoBits | truncOptions.service7; num -= serviceLen - 7; } if ((num > 0x40) && (contractLen > 7)) { noBits |= truncOptions.contract7; num -= contractLen - 7; } if ((num > 0x40) && (operationLen > 15)) { noBits |= truncOptions.NoBits | truncOptions.operation15; num -= operationLen - 15; } if ((num > 0x40) && (uriLen > 0x20)) { noBits |= truncOptions.NoBits | truncOptions.uri32; } } return(noBits); }
internal static string CreateFriendlyInstanceName(ServiceHostBase serviceHost) { string firstAddress; ServiceInfo info = new ServiceInfo(serviceHost); string serviceName = info.ServiceName; if (!TryGetFullVirtualPath(serviceHost, out firstAddress)) { firstAddress = info.FirstAddress; } int totalLen = (serviceName.Length + firstAddress.Length) + 2; if (totalLen > 0x40) { int num2 = 0; truncOptions options = GetCompressionTasks(totalLen, serviceName.Length, firstAddress.Length); if ((options & (truncOptions.NoBits | truncOptions.service32)) > truncOptions.NoBits) { num2 = 0x20; serviceName = PerformanceCountersBase.GetHashedString(serviceName, num2 - 2, (serviceName.Length - num2) + 2, true); } if ((options & (truncOptions.NoBits | truncOptions.uri31)) > truncOptions.NoBits) { num2 = 0x1f; firstAddress = PerformanceCountersBase.GetHashedString(firstAddress, 0, (firstAddress.Length - num2) + 2, false); } } return(serviceName + "@" + firstAddress.Replace('/', '|')); }
private static string GetShortInstanceName(ServiceHostBase serviceHost) { ServiceInfo serviceInfo = new ServiceInfo(serviceHost); string serviceName = serviceInfo.ServiceName; string uri = GetServiceUri(serviceHost, serviceInfo); int length = serviceName.Length + uri.Length + 2; if (length > maxCounterLength) { int count = 0; truncOptions tasks = ServicePerformanceCountersBase.GetCompressionTasks( length, serviceName.Length, uri.Length); //if necessary, compress service name to 8 chars with a 2 char hash code if ((tasks & truncOptions.service32) > 0) { count = 32; serviceName = GetHashedString(serviceName, count - hashLength, serviceName.Length - count + hashLength, true); } //if necessary, compress uri to 36 chars with a 2 char hash code if ((tasks & truncOptions.uri31) > 0) { count = 31; uri = GetHashedString(uri, 0, uri.Length - count + hashLength, false); } } // replace '/' with '|' because perfmon fails when '/' is in perfcounter instance name return(serviceName + "@" + uri.Replace('/', '|')); }
static internal string CreateFriendlyInstanceName(string service, string contract, string operation, string uri) { // instance name is: serviceName.interfaceName.operationName@uri int length = service.Length + contract.Length + operation.Length + uri.Length + 3; if (length > maxCounterLength) { int count = 0; truncOptions tasks = OperationPerformanceCounters.GetCompressionTasks( length, service.Length, contract.Length, operation.Length, uri.Length); //if necessary, compress service name to 5 chars with a 2 char hash code if ((tasks & truncOptions.service7) > 0) { count = 7; service = GetHashedString(service, count - hashLength, service.Length - count + hashLength, true); } //if necessary, compress contract name to 5 chars with a 2 char hash code if ((tasks & truncOptions.contract7) > 0) { count = 7; contract = GetHashedString(contract, count - hashLength, contract.Length - count + hashLength, true); } //if necessary, compress operation name to 13 chars with a 2 char hash code if ((tasks & truncOptions.operation15) > 0) { count = 15; operation = GetHashedString(operation, count - hashLength, operation.Length - count + hashLength, true); } //if necessary, compress uri to 30 chars with a 2 char hash code if ((tasks & truncOptions.uri32) > 0) { count = 32; uri = GetHashedString(uri, 0, uri.Length - count + hashLength, false); } } // replace '/' with '|' because perfmon fails when '/' is in perfcounter instance name return(service + "." + contract + "." + operation + "@" + uri.Replace('/', '|')); }
private static truncOptions GetCompressionTasks(int totalLen, int serviceLen, int uriLen) { truncOptions noBits = truncOptions.NoBits; if (totalLen > 0x40) { int num = totalLen; if ((num > 0x40) && (serviceLen > 0x20)) { noBits |= truncOptions.NoBits | truncOptions.service32; num -= serviceLen - 0x20; } if ((num > 0x40) && (uriLen > 0x1f)) { noBits |= truncOptions.NoBits | truncOptions.uri31; } } return(noBits); }
static truncOptions GetCompressionTasks(int totalLen, int serviceLen, int uriLen) { truncOptions bitmask = 0; if (totalLen > maxCounterLength) { int workingLen = totalLen; //note: order of if statements important (see spec)! if (workingLen > maxCounterLength && serviceLen > 32) { bitmask |= truncOptions.service32; //compress service name to 16 chars workingLen -= serviceLen - 32; } if (workingLen > maxCounterLength && uriLen > 31) { bitmask |= truncOptions.uri31; //compress uri to 31 chars } } return(bitmask); }
static internal string CreateFriendlyInstanceName(ServiceHostBase serviceHost) { // instance name is: serviceName@uri ServiceInfo serviceInfo = new ServiceInfo(serviceHost); string serviceName = serviceInfo.ServiceName; string uri; if (!TryGetFullVirtualPath(serviceHost, out uri)) { uri = serviceInfo.FirstAddress; } int length = serviceName.Length + uri.Length + 2; if (length > maxCounterLength) { int count = 0; truncOptions tasks = ServicePerformanceCountersBase.GetCompressionTasks( length, serviceName.Length, uri.Length); //if necessary, compress service name to 8 chars with a 2 char hash code if ((tasks & truncOptions.service32) > 0) { count = 32; serviceName = GetHashedString(serviceName, count - hashLength, serviceName.Length - count + hashLength, true); } //if necessary, compress uri to 36 chars with a 2 char hash code if ((tasks & truncOptions.uri31) > 0) { count = 31; uri = GetHashedString(uri, 0, uri.Length - count + hashLength, false); } } // replace '/' with '|' because perfmon fails when '/' is in perfcounter instance name return(serviceName + "@" + uri.Replace('/', '|')); }
private static string GetShortInstanceName(string service, string contract, string uri) { int length = service.Length + contract.Length + uri.Length + 2; if (length > maxCounterLength) { int count = 0; truncOptions tasks = EndpointPerformanceCounters.GetCompressionTasks( length, service.Length, contract.Length, uri.Length); //if necessary, compress service name to 13 chars with a 2 char hash code if ((tasks & truncOptions.service15) > 0) { count = 15; service = GetHashedString(service, count - hashLength, service.Length - count + hashLength, true); } //if necessary, compress contract name to 14 chars with a 2 char hash code if ((tasks & truncOptions.contract16) > 0) { count = 16; contract = GetHashedString(contract, count - hashLength, contract.Length - count + hashLength, true); } //if necessary, compress uri to 29 chars with a 2 char hash code if ((tasks & truncOptions.uri31) > 0) { count = 31; uri = GetHashedString(uri, 0, uri.Length - count + hashLength, false); } } // replace '/' with '|' because perfmon fails when '/' is in perfcounter instance name return(service + "." + contract + "@" + uri.Replace('/', '|')); }
private static truncOptions GetCompressionTasks(int totalLen, int serviceLen, int contractLen, int uriLen) { truncOptions noBits = truncOptions.NoBits; if (totalLen > 0x40) { int num = totalLen; if ((num > 0x40) && (serviceLen > 15)) { noBits |= truncOptions.NoBits | truncOptions.service15; num -= serviceLen - 15; } if ((num > 0x40) && (contractLen > 0x10)) { noBits |= truncOptions.contract16; num -= contractLen - 0x10; } if ((num > 0x40) && (uriLen > 0x1f)) { noBits |= truncOptions.NoBits | truncOptions.uri31; } } return(noBits); }