Commit 6b3c2bb4 by mahaisong

fix:理清设计思路、调试在6的情况下,动态index的方法是否都能正常执行及1000个并发的压力性能。全部通过。

parent c5f64ae8
D:\smallproject\10.Paul需求-JSON贝格ES导入本地ES\ImportLocalES\HTCommon\bin\Debug\HTCommon.dll.config
D:\smallproject\10.Paul需求-JSON贝格ES导入本地ES\ImportLocalES\HTCommon\bin\Debug\HTCommon.dll.config
......@@ -264,10 +264,12 @@ D:\网盘下载\MinderES\MinderES\HTCommon\obj\Debug\HTCommon.csproj.CoreCompile
D:\网盘下载\MinderES\MinderES\HTCommon\obj\Debug\HTCommon.dll
D:\网盘下载\MinderES\MinderES\HTCommon\obj\Debug\HTCommon.pdb
D:\smallproject\10.Paul需求-JSON贝格ES导入本地ES\MinderES\HTCommon\obj\Debug\HTCommon.csprojResolveAssemblyReference.cache
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\obj\Debug\HTCommon.csproj.CoreCompileInputs.cache
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\Elasticsearch.Net2_5_8.xml
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\Nest.dll
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\HTCommon.dll.config
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\HTCommon.dll
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\HTCommon.pdb
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\Elasticsearch.Net.dll
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\Elasticsearch.Net2_5_8.dll
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\EntityFramework.dll
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\EntityFramework.SqlServer.dll
......@@ -327,11 +329,14 @@ D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\ServiceStack
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\ServiceStack.ServiceInterface.dll
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\ServiceStack.Text.dll
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\Lucene.Net.dll
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\Elasticsearch.Net2_5_8.xml
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\Elasticsearch.Net.pdb
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\Elasticsearch.Net.xml
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\EntityFramework.xml
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\EntityFramework.SqlServer.xml
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\HtmlAgilityPack.pdb
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\HtmlAgilityPack.xml
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\Nest.pdb
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\Nest.xml
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\Nest2_5_8.xml
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\Newtonsoft.Json.xml
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\NPOI.xml
......@@ -339,13 +344,8 @@ D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\ServiceStack
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\ServiceStack.Text.xml
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\zh-Hans\EntityFramework.resources.dll
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\zh-Hans\EntityFramework.SqlServer.resources.dll
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\obj\Debug\HTCommon.csprojAssemblyReference.cache
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\obj\Debug\HTCommon.csproj.CoreCompileInputs.cache
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\obj\Debug\HTCommon.csproj.CopyComplete
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\obj\Debug\HTCommon.dll
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\obj\Debug\HTCommon.pdb
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\Elasticsearch.Net.dll
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\Nest.dll
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\Elasticsearch.Net.pdb
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\Elasticsearch.Net.xml
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\Nest.pdb
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\bin\Debug\Nest.xml
D:\smallproject\12.ES支持2-6多版本\TestUnit\HTCommon\obj\Debug\HTCommon.csprojAssemblyReference.cache
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
......@@ -7,8 +7,14 @@
<connectionStrings>
<add name="ESDatabase" connectionString="host=test_version;port=9200;defaultIndex=test_version6;requesttimeout=30000;provider=2" />
<!--<add name="ESDatabase" connectionString="host=test_version;port=9200;defaultIndex=test_version6;requesttimeout=30000" providerName="6" />
<add name="6MinderESDatabase" connectionString="host=test_version;port=9200;defaultIndex=test_version6;requesttimeout=30000" />
<add name="2localESDatabase" connectionString="host=localhost;port=9200;defaultIndex=test_version2;requesttimeout=30000" />
<add name="2localESDatabase" connectionString="host=localhost;port=9200;defaultIndex=test_version2;requesttimeout=30000" />-->
</connectionStrings>
......
using Elasticsearch.Net;
using Elasticsearch.Net;
......@@ -84,6 +84,8 @@ namespace TestTwoES2_6.ES6_1_0
DefaultIndex = index;
ConnectSetting = new ConnectionSettings(pool).DefaultIndex(index).DisableDirectStreaming();
}
private static String GetValueByName(Dictionary<String, String> nvPair, String name, String defaultValue)
......
using System;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestTwoES2_6.TestBcuzNugError
{
public class ConnectManager
{
// internal const string NameParameterName = "ESDatabase";
// internal const string host = "host"; //可能出现多个链接。 "|"分割。
// internal const string port = "port";
// internal const string defaultIndex = "defaultIndex";
// internal const string provider = "provider";
// // An array to hold the keywords
// internal static readonly string[] ValidKeywords = new[]
// {
// NameParameterName,
// host,
// port,
// defaultIndex,
// provider
// };
// internal const string ProviderConnectionStringParameterName = "provider connection string";
// private const string EntityClientProviderName = "Nest.ElasticClient";
// private readonly object _connectionStringLock = new object();
// private static readonly ESConnectionOptions _emptyConnectionOptions = new ESConnectionOptions(String.Empty, new string[0]);
// private ESConnectionOptions _userConnectionOptions;
// private ESConnectionOptions _effectiveConnectionOptions;
// public ConnectManager(string connectionString)
// {
// ChangeConnectionString(connectionString);
// }
////[SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
// public string ConnectionString
// {
// get
// {
// if (_userConnectionOptions == null)
// {
// return "连接字符串为空。";
// }
// var userConnectionString = _userConnectionOptions.UsersConnectionString;
// return userConnectionString;
// }
// set
// {
// ChangeConnectionString(value);
// }
// }
// private void ChangeConnectionString(string newConnectionString)
// {
// var userConnectionOptions = _emptyConnectionOptions;
// if (!String.IsNullOrEmpty(newConnectionString))
// {
// userConnectionOptions = new ESConnectionOptions(newConnectionString, ValidKeywords);
// }
// if (!userConnectionOptions.IsEmpty)
// {
// // Find the named connection from the configuration, then extract the settings
// var setting = ConfigurationManager.ConnectionStrings[namedConnection];
// effectiveConnectionOptions = new ESConnectionOptions(
// setting.ConnectionString, ValidKeywords);
// ValidateValueForTheKeyword(effectiveConnectionOptions,MetadataParameterName);
// var providerName = ValidateValueForTheKeyword(
// effectiveConnectionOptions, ESConnectionStringBuilder.ProviderParameterName);
// // Get the correct provider factory
// factory = DbConfiguration.DependencyResolver.GetService<DbProviderFactory>(providerName);
// // Create the underlying provider specific connection and give it the connection string from the ESConnectionOptions object
// storeConnection = GetStoreConnection(factory);
// try
// {
// // When the value of 'Provider Connection String' is null, it means it has not been present in the entity connection string at all.
// // Providers should still be able handle empty connection strings since those may be explicitly passed by clients.
// var providerConnectionString =
// effectiveConnectionOptions[ESConnectionStringBuilder.ProviderConnectionStringParameterName];
// if (providerConnectionString != null)
// {
// DbInterception.Dispatch.Connection.SetConnectionString(
// storeConnection,
// new DbConnectionPropertyInterceptionContext<string>(InterceptionContext).WithValue(providerConnectionString));
// }
// }
// catch (Exception e)
// {
// if (e.IsCatchableExceptionType())
// {
// throw new EntityException(Strings.EntityClient_ProviderSpecificError(@"ConnectionString"), e);
// }
// throw;
// }
// }
// // This lock is to ensure that the connection string matches with the provider connection and metadata workspace that's being
// // managed by this EntityConnection, so states in this connection object are not messed up.
// // It's not for security, but just to help reduce user error.
// lock (_connectionStringLock)
// {
// // Now we have sufficient information and verified the configuration string is good, use them for this connection object
// // Failure should not occur from this point to the end of this method
// _providerFactory = factory;
// _metadataWorkspace = null;
// ClearTransactions();
// UnsubscribeFromStoreConnectionStateChangeEvents();
// _storeConnection = storeConnection;
// SubscribeToStoreConnectionStateChangeEvents();
// // Remembers the connection options objects with the connection string set by the user
// _userConnectionOptions = userConnectionOptions;
// _effectiveConnectionOptions = effectiveConnectionOptions;
// }
// }
// private static string ValidateValueForTheKeyword(
// ESConnectionOptions effectiveConnectionOptions,
// string keywordName)
// {
// var keywordValue = effectiveConnectionOptions[keywordName];
// if (!string.IsNullOrEmpty(keywordValue))
// {
// keywordValue = keywordValue.Trim(); // be nice to user, always trim the value
// }
// // Check that we have a non-null and non-empty value for the keyword
// if (string.IsNullOrEmpty(keywordValue))
// {
// throw new ArgumentException("字符串中KEY" + keywordName + "报错");
// }
// return keywordValue;
// }
}
}
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestTwoES2_6.TestBcuzNugError
{
internal class DebugCheck
{
[Conditional("DEBUG")]
public static void NotNull<T>(T value) where T : class
{
Debug.Assert(value != null);
}
[Conditional("DEBUG")]
public static void NotNull<T>(T? value) where T : struct
{
Debug.Assert(value != null);
}
[Conditional("DEBUG")]
public static void NotEmpty(string value)
{
Debug.Assert(!string.IsNullOrWhiteSpace(value));
}
}
}
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestTwoES2_6.TestBcuzNugError
{
internal sealed class NameValuePair
{
private NameValuePair _next;
internal NameValuePair Next
{
get { return _next; }
set
{
if ((null != _next)
|| (null == value))
{
throw new InvalidOperationException("");
}
_next = value;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
......@@ -90,6 +90,10 @@
<Compile Include="PerformanceUtility.cs" />
<Compile Include="Program1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestBcuzNugError\ConnectManager.cs" />
<Compile Include="TestBcuzNugError\ESConnectionOptions.cs" />
<Compile Include="TestBcuzNugError\DebugCheck.cs" />
<Compile Include="TestBcuzNugError\NameValuePair.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config">
......
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
......@@ -7,8 +7,14 @@
<connectionStrings>
<add name="ESDatabase" connectionString="host=test_version;port=9200;defaultIndex=test_version6;requesttimeout=30000;provider=2" />
<!--<add name="ESDatabase" connectionString="host=test_version;port=9200;defaultIndex=test_version6;requesttimeout=30000" providerName="6" />
<add name="6MinderESDatabase" connectionString="host=test_version;port=9200;defaultIndex=test_version6;requesttimeout=30000" />
<add name="2localESDatabase" connectionString="host=localhost;port=9200;defaultIndex=test_version2;requesttimeout=30000" />
<add name="2localESDatabase" connectionString="host=localhost;port=9200;defaultIndex=test_version2;requesttimeout=30000" />-->
</connectionStrings>
......
043d87f8d664dffcb652a9a10e582f84240a0a79
cfc6e0ba14a8310895a1f631576e0913083f7176
043d87f8d664dffcb652a9a10e582f84240a0a79
cfc6e0ba14a8310895a1f631576e0913083f7176
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
\ No newline at end of file
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestES6_2
{
class Program
{
static void Main(string[] args)
{
}
}
}
using System.Reflection;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("TestES6-2")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TestES6-2")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("107f4379-d24e-47d6-b4bf-00d49f8f49b7")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{107F4379-D24E-47D6-B4BF-00D49F8F49B7}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>TestES6_2</RootNamespace>
<AssemblyName>TestES6-2</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
++ "b/12.ES\346\224\257\346\214\2012-6\345\244\232\347\211\210\346\234\254/TestUnit/TestUnit/TestES6-2/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs"
++ "b/12.ES\346\224\257\346\214\2012-6\345\244\232\347\211\210\346\234\254/TestUnit/TestUnit/TestES6-2/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs"
++ "b/12.ES\346\224\257\346\214\2012-6\345\244\232\347\211\210\346\234\254/TestUnit/TestUnit/TestES6-2/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs"
02d941efbc43fafdca26cfd3c70cc077be835e19
02d941efbc43fafdca26cfd3c70cc077be835e19


......@@ -9,9 +9,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elasticsearch.Net2_5_8", ".
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nest2_5_8", "..\elasticsearch-net-2.5.8\src\Nest\Nest2_5_8.csproj", "{17B93E80-9267-4F75-8423-63E5291A3A8F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elasticsearch.Net", "..\elasticsearch-net-6.1.0\src\Elasticsearch.Net\Elasticsearch.Net.csproj", "{B3B09BBA-6F8E-4D12-BDCC-36BD847C730E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elasticsearch.Net", "..\elasticsearch-net-6.1.0\src\Elasticsearch.Net\Elasticsearch.Net.csproj", "{B3B09BBA-6F8E-4D12-BDCC-36BD847C730E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nest", "..\elasticsearch-net-6.1.0\src\Nest\Nest.csproj", "{4E2ECE6B-5527-4BCB-819C-5387FED6DAC3}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nest", "..\elasticsearch-net-6.1.0\src\Nest\Nest.csproj", "{4E2ECE6B-5527-4BCB-819C-5387FED6DAC3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HTCommon", "..\HTCommon\HTCommon.csproj", "{E497051E-61E1-4247-93D3-7929A8C8B7F6}"
EndProject
......@@ -19,6 +19,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestTwoES2-6", "..\TestTwoE
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestProject", "..\UnitTestProject\UnitTestProject.csproj", "{CCBB6A99-9FB1-441C-AE3B-B406A2A26DD9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestES6-2", "TestES6-2\TestES6-2.csproj", "{107F4379-D24E-47D6-B4BF-00D49F8F49B7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -125,6 +127,18 @@ Global
{CCBB6A99-9FB1-441C-AE3B-B406A2A26DD9}.Release|x64.Build.0 = Release|Any CPU
{CCBB6A99-9FB1-441C-AE3B-B406A2A26DD9}.Release|x86.ActiveCfg = Release|Any CPU
{CCBB6A99-9FB1-441C-AE3B-B406A2A26DD9}.Release|x86.Build.0 = Release|Any CPU
{107F4379-D24E-47D6-B4BF-00D49F8F49B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{107F4379-D24E-47D6-B4BF-00D49F8F49B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{107F4379-D24E-47D6-B4BF-00D49F8F49B7}.Debug|x64.ActiveCfg = Debug|Any CPU
{107F4379-D24E-47D6-B4BF-00D49F8F49B7}.Debug|x64.Build.0 = Debug|Any CPU
{107F4379-D24E-47D6-B4BF-00D49F8F49B7}.Debug|x86.ActiveCfg = Debug|Any CPU
{107F4379-D24E-47D6-B4BF-00D49F8F49B7}.Debug|x86.Build.0 = Debug|Any CPU
{107F4379-D24E-47D6-B4BF-00D49F8F49B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{107F4379-D24E-47D6-B4BF-00D49F8F49B7}.Release|Any CPU.Build.0 = Release|Any CPU
{107F4379-D24E-47D6-B4BF-00D49F8F49B7}.Release|x64.ActiveCfg = Release|Any CPU
{107F4379-D24E-47D6-B4BF-00D49F8F49B7}.Release|x64.Build.0 = Release|Any CPU
{107F4379-D24E-47D6-B4BF-00D49F8F49B7}.Release|x86.ActiveCfg = Release|Any CPU
{107F4379-D24E-47D6-B4BF-00D49F8F49B7}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
......@@ -7,17 +7,17 @@
<connectionStrings>
<add name="2localESDatabase" connectionString="host=127.0.0.1;port=9200;defaultIndex=test_version2;requesttimeout=30000" />
<!--<add name="2localESDatabase" connectionString="host=127.0.0.1;port=9200;defaultIndex=test_version2;requesttimeout=30000" />-->
<!--<add name="2localESDatabase" connectionString="host=minder;port=9200;defaultIndex=test_version6;requesttimeout=30000" />-->
<!--<add name="6MinderESDatabase" connectionString="host=minder;port=9200;defaultIndex=test_version6;requesttimeout=30000" />-->
<add name="6MinderESDatabase" connectionString="host=minder;port=9200;defaultIndex=test_version6;requesttimeout=30000" />
<add name="6MinderESDatabase" connectionString="host=127.0.0.1;port=9200;defaultIndex=test_version2;requesttimeout=30000" />
<!--<add name="6MinderESDatabase" connectionString="host=127.0.0.1;port=9200;defaultIndex=test_version2;requesttimeout=30000" />-->
......
using System;
using System;
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using HTCommon.Data;
using Nest2_5_8;
//using Nest2_5_8;
using Nest;
namespace UnitTestProject.TestES.TestES2
......@@ -119,6 +119,21 @@ namespace UnitTestProject.TestES.TestES2
[TestMethod]
public void Search()
{
//动态index测试
//var node = new Uri("http://minder:9200");
//var settings = new ConnectionSettings(node);
//var client = new ElasticClient(settings);
//client.Search<HTCommon.Data6.Item>();
// Nest.SearchDescriptor<HTCommon.Data6.Item> builder2 = new Nest.SearchDescriptor<HTCommon.Data6.Item>()
// .Query(q => q.MatchAll()).Index((Indices)typeof(HTCommon.Data6.Item));
//// Nest.ISearchResponse<> rep2 =
//内部调用 SearchDetail
......
using Elasticsearch.Net;
using Elasticsearch.Net;
using Nest;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Text.RegularExpressions;
namespace UnitTestProject.TestES
{
public sealed class ESClientConfigureManager
{
public static List<Uri> Uris { get; private set; }
/// <summary>
/// ES连接设置
/// </summary>
public static ConnectionSettings ConnectSetting { get; private set; }
private const String ConnectionStringIndex = "6MinderESDatabase";
private const String HostIndex = "host";
private const String PortIndex = "port";
private const String DefaultIndexIndex = "defaultIndex";
static ESClientConfigureManager()
{
String connectionString = ConfigurationManager.ConnectionStrings[ConnectionStringIndex].ConnectionString;
String[] namedValues = connectionString.Split(';');
Dictionary<String, String> nvPair = new Dictionary<String, String>();
foreach (String nv in namedValues)
{
String[] pair = nv.Split('=');
nvPair[pair[0]] = pair[1];
}
String _url = GetValueByName(nvPair, HostIndex, "tank.palaspom.com|mech.palaspom.com");
String _port = GetValueByName(nvPair, PortIndex, "19235");
//支持多Uri模式,要求多个链接使用 | 分隔,在分隔后数量相同的情况下按照顺序一一对应,如果其中一方仅有一个则使用它对应对方所有部分
string[] urls = _url.Split('|');
string[] ports = _port.Split('|');
if (urls == null || ports == null || urls.Length < 1 || ports.Length < 1)
throw new Exception("Unable get the elasticsearch config pool setting.");
Uris = new List<Uri>();
if (urls.Length == ports.Length)
{
for (int i = 0; i < urls.Length; i++)
{
String formattedUrl = Regex.IsMatch(urls[i], @"://") ? urls[i] : String.Format("http://{0}", urls[i]);
Uris.Add(new Uri(String.Format("{0}:{1}", formattedUrl, ports[i])));
}
}
else if (urls.Length > 1 && ports.Length == 1)
{
for (int i = 0; i < urls.Length; i++)
{
String formattedUrl = Regex.IsMatch(urls[i], @"://") ? urls[i] : String.Format("http://{0}", urls[i]);
Uris.Add(new Uri(String.Format("{0}:{1}", formattedUrl, ports[0])));
}
}
else if (urls.Length == 1 && ports.Length > 1)
{
String formattedUrl = Regex.IsMatch(urls[0], @"://") ? urls[0] : String.Format("http://{0}", urls[0]);
for (int i = 0; i < ports.Length; i++)
{
Uris.Add(new Uri(String.Format("{0}:{1}", formattedUrl, ports[i])));
}
}
else
{
throw new Exception("The elasticsearch config pool setting is error.");
}
var pool = new StaticConnectionPool(Uris);
ConnectSetting = new ConnectionSettings(pool).DisableDirectStreaming();
//ConnectSetting = new ConnectionSettings(pool).DefaultIndex("test_version6").DisableDirectStreaming().EnableHttpCompression();
}
private static String GetValueByName(Dictionary<String, String> nvPair, String name, String defaultValue)
{
String value = null;
if (nvPair.TryGetValue(name, out value))
{
return value;
}
return defaultValue;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
......@@ -59,6 +59,7 @@
<HintPath>..\packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Configuration.Install" />
</ItemGroup>
<Choose>
......@@ -89,6 +90,7 @@
<Compile Include="TestES\TestES2\ESAccess.cs" />
<Compile Include="TestES\TestES2\ESItemAccess.cs" />
<Compile Include="TestES\TestES6\ES6.cs" />
<Compile Include="TestES\TestES6\ESClientConfigureManager.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config">
......
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
......@@ -7,8 +7,14 @@
<connectionStrings>
<add name="ESDatabase" connectionString="host=test_version;port=9200;defaultIndex=test_version6;requesttimeout=30000;provider=2" />
<!--<add name="ESDatabase" connectionString="host=test_version;port=9200;defaultIndex=test_version6;requesttimeout=30000" providerName="6" />
<add name="6MinderESDatabase" connectionString="host=test_version;port=9200;defaultIndex=test_version6;requesttimeout=30000" />
<add name="2localESDatabase" connectionString="host=localhost;port=9200;defaultIndex=test_version2;requesttimeout=30000" />
<add name="2localESDatabase" connectionString="host=localhost;port=9200;defaultIndex=test_version2;requesttimeout=30000" />-->
</connectionStrings>
......
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
......@@ -7,17 +7,17 @@
<connectionStrings>
<add name="2localESDatabase" connectionString="host=127.0.0.1;port=9200;defaultIndex=test_version2;requesttimeout=30000" />
<!--<add name="2localESDatabase" connectionString="host=127.0.0.1;port=9200;defaultIndex=test_version2;requesttimeout=30000" />-->
<!--<add name="2localESDatabase" connectionString="host=minder;port=9200;defaultIndex=test_version6;requesttimeout=30000" />-->
<!--<add name="6MinderESDatabase" connectionString="host=minder;port=9200;defaultIndex=test_version6;requesttimeout=30000" />-->
<add name="6MinderESDatabase" connectionString="host=minder;port=9200;defaultIndex=test_version6;requesttimeout=30000" />
<add name="6MinderESDatabase" connectionString="host=127.0.0.1;port=9200;defaultIndex=test_version2;requesttimeout=30000" />
<!--<add name="6MinderESDatabase" connectionString="host=127.0.0.1;port=9200;defaultIndex=test_version2;requesttimeout=30000" />-->
......
52e149e9cc4fec00eefaac2a0d3e5fac38b5cd04
95629e2ac04e9d3473c98b5aefb86d1c73a79a7e
52e149e9cc4fec00eefaac2a0d3e5fac38b5cd04
95629e2ac04e9d3473c98b5aefb86d1c73a79a7e
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment