Permalink
Browse files

TestApp for testing.

  • Loading branch information...
1 parent 5e0fab6 commit b4b0d66776208083259a4edd950a48234ecc01a3 @enyim committed Oct 8, 2010
Showing with 336 additions and 0 deletions.
  1. +6 −0 Enyim.Caching.sln
  2. +69 −0 TestApp/App.config
  3. +109 −0 TestApp/Program.cs
  4. +33 −0 TestApp/Properties/AssemblyInfo.cs
  5. +119 −0 TestApp/TestApp.csproj
View
@@ -16,6 +16,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DemoApp", "DemoApp\DemoApp.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NorthScale.Store", "Northscale.Store\NorthScale.Store.csproj", "{708A2350-A26C-444D-B975-8164263951A7}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp", "TestApp\TestApp.csproj", "{607B1927-A964-48B2-AEA3-6810D10A6831}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -38,6 +40,10 @@ Global
{708A2350-A26C-444D-B975-8164263951A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{708A2350-A26C-444D-B975-8164263951A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{708A2350-A26C-444D-B975-8164263951A7}.Release|Any CPU.Build.0 = Release|Any CPU
+ {607B1927-A964-48B2-AEA3-6810D10A6831}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {607B1927-A964-48B2-AEA3-6810D10A6831}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {607B1927-A964-48B2-AEA3-6810D10A6831}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {607B1927-A964-48B2-AEA3-6810D10A6831}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
View
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <configSections>
+ <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
+ <sectionGroup name="enyim.com">
+ <section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection, Enyim.Caching" />
+ </sectionGroup>
+ <section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection, Enyim.Caching" />
+ <section name="northscale" type="NorthScale.Store.Configuration.NorthScaleClientSection, NorthScale.Store" />
+ <section name="membase" type="NorthScale.Store.Configuration.NorthScaleClientSection, NorthScale.Store" />
+ </configSections>
+
+ <northscale>
+ <servers bucket="default">
+ <add uri="http://192.168.2.200:8080/pools/default" />
+ </servers>
+ <socketPool minPoolSize="10" maxPoolSize="100" connectionTimeout="00:00:10" />
+ <locator type="Enyim.Caching.Memcached.DefaultNodeLocator, Enyim.Caching" />
+ </northscale>
+
+ <membase>
+ <servers bucket="mc_pass" userName="A" password="11111111" bucketPassword="pass">
+ <add uri="http://192.168.2.160:8080/pools/default" />
+ </servers>
+ <socketPool connectionTimeout="00:00:02" deadTimeout="00:00:10" />
+ </membase>
+
+ <enyim.com>
+ <memcached>
+ <servers>
+ <add address="192.168.2.200" port="11211" />
+ <add address="192.168.2.202" port="11211" />
+ <add address="192.168.2.204" port="11211" />
+ </servers>
+ <socketPool minPoolSize="10" maxPoolSize="100" connectionTimeout="00:00:10" deadTimeout="00:02:00" />
+ <!--<authentication type="Enyim.Caching.Memcached.PlainTextAuthenticator, Enyim.Caching" userName="demo" password="demo" />-->
+ </memcached>
+ </enyim.com>
+
+ <log4net>
+ <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
+ <layout type="log4net.Layout.PatternLayout,log4net">
+ <param name="ConversionPattern" value="%d [%t] %-5p %c %m%n" />
+ </layout>
+ </appender>
+ <appender name="TraceAppender" type="log4net.Appender.TraceAppender">
+ <layout type="log4net.Layout.PatternLayout,log4net">
+ <param name="ConversionPattern" value="%d [%t] %-5p %c %m%n" />
+ </layout>
+ </appender>
+ <root>
+ <level value="Debug" />
+ <appender-ref ref="TraceAppender" />
+ </root>
+ <logger name="Enyim.Caching.Memcached.PooledSocket">
+ <level value="Info" />
+ </logger>
+ <logger name="Enyim.Caching.Memcached.Protocol">
+ <level value="Info" />
+ </logger>
+ <logger name="NorthScale.Store.VBucketAwareOperationFactory">
+ <level value="Info" />
+ </logger>
+ <logger name="Enyim.Caching.Memcached.MemcachedNode">
+ <level value="Info" />
+ </logger>
+ </log4net>
+
+</configuration>
View
@@ -0,0 +1,109 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Enyim.Caching;
+using Enyim.Caching.Memcached;
+using System.Net;
+using Enyim.Caching.Configuration;
+using NorthScale.Store;
+using NorthScale.Store.Configuration;
+using System.Threading;
+
+namespace DemoApp
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ log4net.Config.XmlConfigurator.Configure();
+
+ // or just initialize the client from code
+ var nscc = new NorthScaleClientConfiguration();
+
+ nscc.SocketPool.ReceiveTimeout = new TimeSpan(0, 0, 2);
+ nscc.SocketPool.DeadTimeout = new TimeSpan(0, 0, 10);
+
+ nscc.Urls.Add(new Uri("http://192.168.2.210:8080/pools/default"));
+ nscc.Urls.Add(new Uri("http://192.168.2.212:8080/pools/default"));
+ nscc.Credentials = new NetworkCredential("A", "11111111");
+ //nscc.BucketPassword = "pass";
+
+ StressTest(new NorthScaleClient(nscc, "default"));
+
+ return;
+
+ var mcc = new MemcachedClientConfiguration();
+ mcc.AddServer("192.168.2.200:11211");
+ //mcc.AddServer("192.168.2.202:11211");
+
+ mcc.SocketPool.ReceiveTimeout = new TimeSpan(0, 0, 4);
+ mcc.SocketPool.ConnectionTimeout = new TimeSpan(0, 0, 4);
+ mcc.SocketPool.DeadTimeout = new TimeSpan(0, 0, 10);
+
+ StressTest(new MemcachedClient(mcc));
+
+ return;
+
+ var nc = new NorthScaleClient(nscc, "content");
+
+ var stats1 = nc.Stats("slabs");
+ foreach (var kvp in stats1.GetRaw("curr_connections"))
+ Console.WriteLine("{0} -> {1}", kvp.Key, kvp.Value);
+
+ var nc2 = new NorthScaleClient(nscc, "content");
+
+ var stats2 = nc2.Stats();
+ foreach (var kvp in stats2.GetRaw("curr_connections"))
+ Console.WriteLine("{0} -> {1}", kvp.Key, kvp.Value);
+ }
+
+ private static void StressTest(MemcachedClient client)
+ {
+ var i = 0;
+ var last = true;
+
+ var progress = @"-\|/".ToCharArray();
+ Console.CursorVisible = false;
+ Dictionary<bool, int> counters = new Dictionary<bool, int>() { { true, 0 }, { false, 0 } };
+
+ while (true)
+ {
+ var key = "Test_Key_" + i;
+ var state = client.Store(StoreMode.Set, key, i) & client.Get<int>(key) == i;
+
+ Action updateTitle = () => Console.Title = "Success: " + counters[true] + " Fail: " + counters[false];
+
+ if (state != last)
+ {
+ Console.ForegroundColor = state ? ConsoleColor.White : ConsoleColor.Red;
+ Console.Write(".");
+
+ counters[state] = 0;
+ last = state;
+
+ updateTitle();
+ }
+ else if (i % 200 == 0)
+ {
+ Console.ForegroundColor = state ? ConsoleColor.White : ConsoleColor.Red;
+
+ Console.Write(progress[(i / 200) % 4]);
+ if (Console.CursorLeft == 0)
+ {
+ Console.CursorLeft = Console.WindowWidth - 1;
+ Console.CursorTop -= 1;
+ }
+ else
+ {
+ Console.CursorLeft -= 1;
+ }
+
+ updateTitle();
+ }
+
+ i++;
+ counters[state] = counters[state] + 1;
+ }
+ }
+ }
+}
@@ -0,0 +1,33 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("DemoApp")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("enyim.com")]
+[assembly: AssemblyProduct("DemoApp")]
+[assembly: AssemblyCopyright("Copyright © enyim.com, Attila Kiskó 2007-2010")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("e5f14fe9-ce0d-4712-bdba-68686f0d65ae")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
View
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{607B1927-A964-48B2-AEA3-6810D10A6831}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>TestApp</RootNamespace>
+ <AssemblyName>testApp</AssemblyName>
+ <SccProjectName>
+ </SccProjectName>
+ <SccLocalPath>
+ </SccLocalPath>
+ <SccAuxPath>
+ </SccAuxPath>
+ <SccProvider>
+ </SccProvider>
+ <FileUpgradeFlags>
+ </FileUpgradeFlags>
+ <OldToolsVersion>3.5</OldToolsVersion>
+ <UpgradeBackupLocation>
+ </UpgradeBackupLocation>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <IsWebBootstrapper>false</IsWebBootstrapper>
+ <PublishUrl>publish\</PublishUrl>
+ <Install>true</Install>
+ <InstallFrom>Disk</InstallFrom>
+ <UpdateEnabled>false</UpdateEnabled>
+ <UpdateMode>Foreground</UpdateMode>
+ <UpdateInterval>7</UpdateInterval>
+ <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+ <UpdatePeriodically>false</UpdatePeriodically>
+ <UpdateRequired>false</UpdateRequired>
+ <MapFileExtensions>true</MapFileExtensions>
+ <ApplicationRevision>0</ApplicationRevision>
+ <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+ <UseApplicationTrust>false</UseApplicationTrust>
+ <BootstrapperEnabled>true</BootstrapperEnabled>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ <UseVSHostingProcess>false</UseVSHostingProcess>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <PropertyGroup>
+ <SignAssembly>false</SignAssembly>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL" />
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config">
+ <SubType>Designer</SubType>
+ </None>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Enyim.Caching\Enyim.Caching.csproj">
+ <Project>{D438C0B3-A168-40B8-BDDD-61F0939DFF35}</Project>
+ <Name>Enyim.Caching</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Northscale.Store\Northscale.Store.csproj">
+ <Project>{708A2350-A26C-444D-B975-8164263951A7}</Project>
+ <Name>Northscale.Store</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5 SP1</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
+ <Visible>False</Visible>
+ <ProductName>Windows Installer 3.1</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>

0 comments on commit b4b0d66

Please sign in to comment.