├── .gitignore
├── .nuget
├── NuGet.Config
├── NuGet.exe
└── NuGet.targets
├── Gridsum.NHBaseThrift.sln
├── LICENSE
├── NHBaseThrift
├── Analyzing
│ ├── AnalyseResult.cs
│ ├── Analyser.cs
│ ├── GetObjectAnalyseResult.cs
│ ├── GetObjectIntellectTypeAnalyser.cs
│ ├── IAnalyseResult.cs
│ ├── IThriftProtocolTypeAnalyser.cs
│ ├── ThriftProtocolTypeAnalyser.cs
│ ├── ToBytesAnalyseResult.cs
│ ├── ToBytesAnalyseSet.cs
│ └── ToBytesIntellectTypeAnalyser.cs
├── Attributes
│ └── ThriftPropertyAttribute.cs
├── Client
│ ├── HBaseClient.cs
│ ├── HTable.cs
│ ├── IHBaseClient.cs
│ ├── IHTable.cs
│ └── Scanner.cs
├── Comparator
│ ├── ByteArrayComparator.cs
│ └── IByteArrayComparator.cs
├── Consts.cs
├── Contracts
│ ├── IThriftObject.cs
│ └── ThriftObject.cs
├── Engine
│ └── ThriftObjectEngine.cs
├── Enums
│ ├── CompareResult.cs
│ ├── GetObjectResultTypes.cs
│ ├── MessageTypes.cs
│ └── PropertyTypes.cs
├── Exceptions
│ ├── AlreadyExistsException.cs
│ ├── BadFormatException.cs
│ ├── CommunicationFailException.cs
│ ├── CommunicationTimeoutException.cs
│ ├── DefineNoMeaningException.cs
│ ├── ExceptionMessage.cs
│ ├── IOErrorException.cs
│ ├── IPMappingFailException.cs
│ ├── IllegalArgumentException.cs
│ ├── IncorrectCalculationException.cs
│ ├── NoConnectionException.cs
│ ├── PropertyNullValueException.cs
│ ├── RegionNotFoundException.cs
│ ├── SpecificKeyNotExistsException.cs
│ ├── UnexpectedValueException.cs
│ ├── UnknownObjectTypeException.cs
│ └── ZooKeeperInitializationException.cs
├── Global.cs
├── Gridsum.NHBaseThrift.csproj
├── HTableRegionManager.cs
├── Helpers
│ ├── DynamicHelper.cs
│ ├── ExtensionMethods.cs
│ ├── FixedTypeManager.cs
│ ├── InstanceHelper.cs
│ ├── ThriftObjectArrayHelper.cs
│ └── TypeConversionHelper.cs
├── HostMappingManager.cs
├── IHTableRegionManager.cs
├── IHostMappingManager.cs
├── Messages
│ ├── AtomicIncrementRequestMessage.cs
│ ├── AtomicIncrementResponseMessage.cs
│ ├── CreateTableRequestMessage.cs
│ ├── CreateTableResponseMessage.cs
│ ├── DeleteTableRequestMessage.cs
│ ├── DeleteTableResponseMessage.cs
│ ├── DisableTableRequestMessage.cs
│ ├── DisableTableResponseMessage.cs
│ ├── EnableTableRequestMessage.cs
│ ├── EnableTableResponseMessage.cs
│ ├── GetRowRequestMessage.cs
│ ├── GetRowResponseMessage.cs
│ ├── GetRowWithColumnsRequestMessage.cs
│ ├── GetRowWithColumnsResponseMessage.cs
│ ├── GetTableNamesRequestMessage.cs
│ ├── GetTableNamesResponseMessage.cs
│ ├── GetTableRegionsRequestMessage.cs
│ ├── GetTableRegionsResponseMessage.cs
│ ├── InsertNewRowRequestMessage.cs
│ ├── InsertNewRowResponseMessage.cs
│ ├── InsertNewRowsRequestMessage.cs
│ ├── InsertNewRowsResponseMessage.cs
│ ├── IsTableEnableRequestMessage.cs
│ ├── IsTableEnableResponseMessage.cs
│ ├── ScannerCloseRequestMessage.cs
│ ├── ScannerCloseResponseMessage.cs
│ ├── ScannerGetListRequestMessage.cs
│ ├── ScannerGetListResponseMessage.cs
│ ├── ScannerGetRequestMessage.cs
│ ├── ScannerGetResponseMessage.cs
│ ├── ScannerOpenWithStopRequestMessage.cs
│ ├── ScannerOpenWithStopResponseMessage.cs
│ └── ThriftMessage.cs
├── NHBaseThrift.nuspec
├── Network
│ ├── Agents
│ │ ├── IClientConnectionAgent.cs
│ │ ├── IConnectionAgent.cs
│ │ └── ThriftConnectionAgent.cs
│ ├── ConnectionPool.cs
│ ├── ConnectionSet.cs
│ ├── INetworkDataContainer.cs
│ ├── NetworkDataCheckResult.cs
│ ├── NetworkDataContainer.cs
│ ├── RamdomConnectionSet.cs
│ ├── SequentialConnectionSet.cs
│ ├── ThriftProtocolConnectionPool.cs
│ ├── ThriftProtocolSegmentDataParser.cs
│ ├── ThriftProtocolStack.cs
│ ├── ThriftSegmentNode.cs
│ └── Transactions
│ │ ├── ThriftMessageTransaction.cs
│ │ └── ThriftMessageTransactionManager.cs
├── Objects
│ ├── AlreadyExistsError.cs
│ ├── BatchMutation.cs
│ ├── Cell.cs
│ ├── Column.cs
│ ├── ColumnDescriptor.cs
│ ├── ColumnInfo.cs
│ ├── IOError.cs
│ ├── IllegalArgumentError.cs
│ ├── MessageIdentity.cs
│ ├── Mutation.cs
│ ├── Region.cs
│ └── RowInfo.cs
├── Properties
│ └── AssemblyInfo.cs
├── Proxies
│ ├── IMemorySegment.cs
│ ├── IMemorySegmentProxy.cs
│ ├── MemoryPosition.cs
│ ├── MemorySegment.cs
│ ├── MemorySegmentProxy.cs
│ ├── MemorySegmentProxyFactory.cs
│ ├── Size.cs
│ └── ThriftProtocolMemoryAllotter.cs
├── RegionInfo.cs
├── Stubs
│ ├── IPropertySetStub.cs
│ ├── IPropertyStub.cs
│ ├── PropertySetStubHelper.cs
│ ├── PropertyStubHelper.cs
│ └── VT.cs
├── TypeProcessors
│ ├── BoolThriftTypeProcessor.cs
│ ├── ByteArrayThriftTypeProcessor.cs
│ ├── ByteThriftTypeProcessor.cs
│ ├── IThriftTypeProcessor.cs
│ ├── Int16ThriftTypeProcessor.cs
│ ├── Int32ThriftTypeProcessor.cs
│ ├── Int64ThriftTypeProcessor.cs
│ ├── MapStringCellThriftTypeProcessor.cs
│ ├── MapStringStringThriftTypeProcessor.cs
│ ├── Maps
│ │ ├── ArrayTypeProcessorMapping.cs
│ │ └── ThriftTypeProcessorMapping.cs
│ ├── MessageIdentityTypeProcessor.cs
│ ├── StringArrayThriftTypeProcessor.cs
│ ├── StringThriftTypeProcessor.cs
│ └── ThriftTypeProcessor.cs
├── ZooKeeperWatcher.cs
├── app.config
└── packages.config
├── Original
├── IThrift
│ ├── AlreadyExists.cs
│ ├── App.config
│ ├── BatchMutation.cs
│ ├── ColumnDescriptor.cs
│ ├── Hbase.cs
│ ├── IOError.cs
│ ├── IThrift.csproj
│ ├── IllegalArgument.cs
│ ├── Mutation.cs
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── TAppend.cs
│ ├── TCell.cs
│ ├── TColumn.cs
│ ├── TIncrement.cs
│ ├── TRegionInfo.cs
│ ├── TRowResult.cs
│ └── TScan.cs
├── NHBaseThrift.BatchInsertTest
│ ├── App.config
│ ├── NHBaseThrift.BatchInsertTest.csproj
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── host.mapping
└── Thrift
│ ├── Collections
│ ├── TCollections.cs
│ └── THashSet.cs
│ ├── Properties
│ ├── AssemblyInfo.WP7.cs
│ └── AssemblyInfo.cs
│ ├── Protocol
│ ├── TAbstractBase.cs
│ ├── TBase.cs
│ ├── TBase64Utils.cs
│ ├── TBinaryProtocol.cs
│ ├── TCompactProtocol.cs
│ ├── TField.cs
│ ├── TJSONProtocol.cs
│ ├── TList.cs
│ ├── TMap.cs
│ ├── TMessage.cs
│ ├── TMessageType.cs
│ ├── TMultiplexedProcessor.cs
│ ├── TMultiplexedProtocol.cs
│ ├── TProtocol.cs
│ ├── TProtocolDecorator.cs
│ ├── TProtocolException.cs
│ ├── TProtocolFactory.cs
│ ├── TProtocolUtil.cs
│ ├── TSet.cs
│ ├── TStruct.cs
│ └── TType.cs
│ ├── Server
│ ├── TServer.cs
│ ├── TServerEventHandler.cs
│ ├── TSimpleServer.cs
│ ├── TThreadPoolServer.cs
│ └── TThreadedServer.cs
│ ├── TApplicationException.cs
│ ├── TException.cs
│ ├── TProcessor.cs
│ ├── Thrift.WP7.csproj
│ ├── Thrift.csproj
│ ├── Thrift.sln
│ └── Transport
│ ├── TBufferedTransport.cs
│ ├── TFramedTransport.cs
│ ├── THttpClient.cs
│ ├── THttpHandler.cs
│ ├── TMemoryBuffer.cs
│ ├── TNamedPipeClientTransport.cs
│ ├── TNamedPipeServerTransport.cs
│ ├── TServerSocket.cs
│ ├── TServerTransport.cs
│ ├── TSilverlightSocket.cs
│ ├── TSocket.cs
│ ├── TStreamTransport.cs
│ ├── TTLSServerSocket.cs
│ ├── TTLSSocket.cs
│ ├── TTransport.cs
│ ├── TTransportException.cs
│ └── TTransportFactory.cs
├── README.cn.md
└── README.md
/.nuget/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.nuget/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gridsum/NHBaseAPI/d9c5a7f4af8b54555e497a20a587d0edc81a12a0/.nuget/NuGet.exe
--------------------------------------------------------------------------------
/Gridsum.NHBaseThrift.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.21005.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gridsum.NHBaseThrift", "NHBaseThrift\Gridsum.NHBaseThrift.csproj", "{BCD9FF49-D6E8-4C64-825C-A39414BB27F9}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Original Thrift Test Projects", "Original Thrift Test Projects", "{799E1F72-4C4C-43BB-9A26-6FB4409BD770}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IThrift", "Original\IThrift\IThrift.csproj", "{CC1EBC28-692E-4652-A794-AF07439EDEB4}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHBaseThrift.BatchInsertTest", "Original\NHBaseThrift.BatchInsertTest\NHBaseThrift.BatchInsertTest.csproj", "{823F8932-20DD-433C-81D1-8C4A36641504}"
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Thrift", "Original\Thrift\Thrift.csproj", "{499EB63C-D74C-47E8-AE48-A2FC94538E9D}"
15 | EndProject
16 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{C0FC8A41-120B-4672-9C05-2DAE8B3B85B7}"
17 | ProjectSection(SolutionItems) = preProject
18 | .nuget\NuGet.Config = .nuget\NuGet.Config
19 | .nuget\NuGet.exe = .nuget\NuGet.exe
20 | .nuget\NuGet.targets = .nuget\NuGet.targets
21 | EndProjectSection
22 | EndProject
23 | Global
24 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
25 | Debug|Any CPU = Debug|Any CPU
26 | Release|Any CPU = Release|Any CPU
27 | EndGlobalSection
28 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
29 | {BCD9FF49-D6E8-4C64-825C-A39414BB27F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
30 | {BCD9FF49-D6E8-4C64-825C-A39414BB27F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
31 | {BCD9FF49-D6E8-4C64-825C-A39414BB27F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
32 | {BCD9FF49-D6E8-4C64-825C-A39414BB27F9}.Release|Any CPU.Build.0 = Release|Any CPU
33 | {CC1EBC28-692E-4652-A794-AF07439EDEB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
34 | {CC1EBC28-692E-4652-A794-AF07439EDEB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
35 | {CC1EBC28-692E-4652-A794-AF07439EDEB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
36 | {CC1EBC28-692E-4652-A794-AF07439EDEB4}.Release|Any CPU.Build.0 = Release|Any CPU
37 | {823F8932-20DD-433C-81D1-8C4A36641504}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
38 | {823F8932-20DD-433C-81D1-8C4A36641504}.Debug|Any CPU.Build.0 = Debug|Any CPU
39 | {823F8932-20DD-433C-81D1-8C4A36641504}.Release|Any CPU.ActiveCfg = Release|Any CPU
40 | {823F8932-20DD-433C-81D1-8C4A36641504}.Release|Any CPU.Build.0 = Release|Any CPU
41 | {499EB63C-D74C-47E8-AE48-A2FC94538E9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
42 | {499EB63C-D74C-47E8-AE48-A2FC94538E9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
43 | {499EB63C-D74C-47E8-AE48-A2FC94538E9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
44 | {499EB63C-D74C-47E8-AE48-A2FC94538E9D}.Release|Any CPU.Build.0 = Release|Any CPU
45 | EndGlobalSection
46 | GlobalSection(SolutionProperties) = preSolution
47 | HideSolutionNode = FALSE
48 | EndGlobalSection
49 | GlobalSection(NestedProjects) = preSolution
50 | {CC1EBC28-692E-4652-A794-AF07439EDEB4} = {799E1F72-4C4C-43BB-9A26-6FB4409BD770}
51 | {823F8932-20DD-433C-81D1-8C4A36641504} = {799E1F72-4C4C-43BB-9A26-6FB4409BD770}
52 | {499EB63C-D74C-47E8-AE48-A2FC94538E9D} = {799E1F72-4C4C-43BB-9A26-6FB4409BD770}
53 | EndGlobalSection
54 | EndGlobal
55 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 gridsum
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/NHBaseThrift/Analyzing/AnalyseResult.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using Gridsum.NHBaseThrift.Attributes;
3 | using Gridsum.NHBaseThrift.Stubs;
4 |
5 | namespace Gridsum.NHBaseThrift.Analyzing
6 | {
7 | ///
8 | /// 只能类型分析结果,提供了相关的基本操作。
9 | ///
10 | public class AnalyseResult : IAnalyseResult
11 | {
12 | private VT _vtStruct;
13 | ///
14 | /// 获取值类型标示
15 | ///
16 | internal bool VT { get; private set; }
17 | ///
18 | /// 获取或设置属性信息
19 | ///
20 | internal PropertyInfo Property { get; set; }
21 | ///
22 | /// 获取或设置智能属性标签
23 | ///
24 | internal ThriftPropertyAttribute Attribute { get; set; }
25 | ///
26 | /// 获取或设置内部VT结构
27 | ///
28 | internal VT VTStruct
29 | {
30 | get { return _vtStruct; }
31 | set
32 | {
33 | _vtStruct = value;
34 | VT = _vtStruct != null;
35 | }
36 | }
37 |
38 | ///
39 | /// 获取或设置一个值,该指标是了当前属性是否已经达到了完整缓存
40 | ///
41 | internal bool HasCacheFinished { get; set; }
42 |
43 | ///
44 | /// 获取或设置字段是否为可空字段类型
45 | ///
46 | public bool Nullable { get; set; }
47 | }
48 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Analyzing/Analyser.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift.Analyzing
2 | {
3 | internal static class Analyser
4 | {
5 | public static ToBytesIntellectTypeAnalyser ToBytesAnalyser = new ToBytesIntellectTypeAnalyser();
6 | public static GetObjectIntellectTypeAnalyser GetObjectAnalyser = new GetObjectIntellectTypeAnalyser();
7 | }
8 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Analyzing/GetObjectAnalyseResult.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gridsum/NHBaseAPI/d9c5a7f4af8b54555e497a20a587d0edc81a12a0/NHBaseThrift/Analyzing/GetObjectAnalyseResult.cs
--------------------------------------------------------------------------------
/NHBaseThrift/Analyzing/GetObjectIntellectTypeAnalyser.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gridsum/NHBaseAPI/d9c5a7f4af8b54555e497a20a587d0edc81a12a0/NHBaseThrift/Analyzing/GetObjectIntellectTypeAnalyser.cs
--------------------------------------------------------------------------------
/NHBaseThrift/Analyzing/IAnalyseResult.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gridsum/NHBaseAPI/d9c5a7f4af8b54555e497a20a587d0edc81a12a0/NHBaseThrift/Analyzing/IAnalyseResult.cs
--------------------------------------------------------------------------------
/NHBaseThrift/Analyzing/IThriftProtocolTypeAnalyser.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gridsum/NHBaseAPI/d9c5a7f4af8b54555e497a20a587d0edc81a12a0/NHBaseThrift/Analyzing/IThriftProtocolTypeAnalyser.cs
--------------------------------------------------------------------------------
/NHBaseThrift/Analyzing/ThriftProtocolTypeAnalyser.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Concurrent;
3 | using Gridsum.NHBaseThrift.Helpers;
4 | using Gridsum.NHBaseThrift.Stubs;
5 |
6 | namespace Gridsum.NHBaseThrift.Analyzing
7 | {
8 | ///
9 | /// 类型分析器,提供了相关的基本操作。
10 | ///
11 | internal abstract class ThriftProtocolTypeAnalyser : IThriftProtocolTypeAnalyser
12 | {
13 | #region Members.
14 |
15 | protected ConcurrentDictionary _result = new ConcurrentDictionary();
16 |
17 | #endregion
18 |
19 | #region Methods..
20 |
21 | ///
22 | /// 获取指定对象
23 | ///
24 | /// 类型编号
25 | /// 返回分析结果
26 | protected T GetObject(string token)
27 | {
28 | T result;
29 | return _result.TryGetValue(token, out result) ? result : default(T);
30 | }
31 |
32 | ///
33 | /// 注册一个分析结果
34 | ///
35 | /// 类型编号
36 | /// 分析结果
37 | protected void RegistAnalyseResult(string token, T result)
38 | {
39 | if (_result.ContainsKey(token)) return;
40 | if (!_result.TryAdd(token, result))
41 | throw new Exception("Cannot regist an analyze result! #type token: " + token);
42 | }
43 |
44 | #endregion
45 |
46 | #region Implementation of IIntellectTypeAnalyser
47 |
48 | ///
49 | /// 分析一个类型中的Thrift协议属性
50 | ///
51 | /// 要分析的类型
52 | /// 返回分析的结果
53 | public abstract T Analyse(K type);
54 |
55 | ///
56 | /// 清空当前所有的分析结果
57 | ///
58 | public void Clear()
59 | {
60 | _result.Clear();
61 | }
62 |
63 |
64 | protected VT GetVT(Type type)
65 | {
66 | Type innerType;
67 | if (type.IsEnum) return FixedTypeManager.IsVT(type.GetEnumUnderlyingType());
68 | if ((innerType = Nullable.GetUnderlyingType(type)) != null) return FixedTypeManager.IsVT(innerType);
69 | return FixedTypeManager.IsVT(type);
70 | }
71 |
72 | #endregion
73 | }
74 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Analyzing/ToBytesAnalyseResult.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gridsum/NHBaseAPI/d9c5a7f4af8b54555e497a20a587d0edc81a12a0/NHBaseThrift/Analyzing/ToBytesAnalyseResult.cs
--------------------------------------------------------------------------------
/NHBaseThrift/Analyzing/ToBytesAnalyseSet.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift.Analyzing
2 | {
3 | ///
4 | /// 序列化分析结果集
5 | ///
6 | internal sealed class ToBytesAnalyseSet
7 | {
8 | #region Constructor
9 |
10 | ///
11 | /// 序列化分析结果集
12 | ///
13 | /// 初始化长度
14 | public ToBytesAnalyseSet(int initSize)
15 | {
16 | InitializeSize = initSize;
17 | }
18 |
19 | #endregion
20 |
21 | #region Members
22 |
23 | ///
24 | /// 预计算智能字段存档
25 | ///
26 | public ToBytesAnalyseResult[] AnalyseProperties { get; set; }
27 | ///
28 | /// 获取或设置指定类型参与运算的初始化长度
29 | /// * 这个长度是当前类型所有可预算字段长度的总和再外加上一些辅助数据
30 | ///
31 | public int InitializeSize { get; private set; }
32 |
33 | #endregion
34 | }
35 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Analyzing/ToBytesIntellectTypeAnalyser.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gridsum/NHBaseAPI/d9c5a7f4af8b54555e497a20a587d0edc81a12a0/NHBaseThrift/Analyzing/ToBytesIntellectTypeAnalyser.cs
--------------------------------------------------------------------------------
/NHBaseThrift/Attributes/ThriftPropertyAttribute.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Enums;
2 |
3 | namespace Gridsum.NHBaseThrift.Attributes
4 | {
5 | ///
6 | /// Thrift Protocol Member's Attribute
7 | ///
8 | public class ThriftPropertyAttribute : System.Attribute
9 | {
10 | #region Constructor.
11 |
12 | ///
13 | /// Thrift Protocol Member's Attribute
14 | ///
15 | /// Property ID
16 | /// Property Type
17 | /// A flag indicated that whether applies Thrift's TField binary format while serializing.
18 | public ThriftPropertyAttribute(short id, PropertyTypes propertyType, bool needWriteOverheads = true)
19 | {
20 | _propertyType = propertyType;
21 | _id = id;
22 | NeedWriteOverheads = needWriteOverheads;
23 | }
24 |
25 | #endregion
26 |
27 | #region Members.
28 |
29 | private readonly short _id;
30 | private readonly PropertyTypes _propertyType;
31 |
32 | ///
33 | /// Gets unique property id for current Thrift object.
34 | ///
35 | public short Id
36 | {
37 | get { return _id; }
38 | }
39 |
40 | ///
41 | /// Gets property type
42 | ///
43 | public PropertyTypes PropertyType
44 | {
45 | get { return _propertyType; }
46 | }
47 |
48 | ///
49 | /// Gets or sets a value indicated that whether this value is required.
50 | ///
51 | public bool Optional { get; set; }
52 |
53 | ///
54 | /// Gets or sets a flag indicated that whether applies Thrift's TField binary format while serializing.
55 | /// By default this value is: true
56 | ///
57 | ///
58 | /// Thrift protocol TField's overhead (3 bytes).
59 | /// -----------------------------------
60 | ///
61 | /// Field-Type | Field-ID
62 | /// \---- 1 ---/\---- 2 ----/
63 | ///
64 | public bool NeedWriteOverheads { get; set; }
65 |
66 | #endregion
67 | }
68 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Client/IHBaseClient.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Gridsum.NHBaseThrift.Exceptions;
4 | using Gridsum.NHBaseThrift.Objects;
5 |
6 | namespace Gridsum.NHBaseThrift.Client
7 | {
8 | ///
9 | /// HBase客户端
10 | ///
11 | public interface IHBaseClient
12 | {
13 | #region Methods.
14 |
15 | ///
16 | /// 创建一个HBase表
17 | ///
18 | /// 表名
19 | /// 列簇名称信息
20 | /// 如果创建成功,则返回可以操作该表的实例
21 | /// 表已经存在
22 | /// IO错误
23 | /// 参数错误
24 | /// 参数不能为空
25 | /// 通信超时
26 | /// 通信失败
27 | /// 内部无任何可用的远程连接异常,这通常代表无法连接到任何一台远程服务器
28 | IHTable CreateTable(string tableName, params string[] columnFamilies);
29 | ///
30 | /// 创建一个HBase表
31 | ///
32 | /// 表名
33 | /// 表描述符
34 | /// 如果创建成功,则返回可以操作该表的实例
35 | /// 表已经存在
36 | /// IO错误
37 | /// 参数错误
38 | /// 参数不能为空
39 | /// 通信超时
40 | /// 通信失败
41 | /// 内部无任何可用的远程连接异常,这通常代表无法连接到任何一台远程服务器
42 | IHTable CreateTable(string tableName, params ColumnDescriptor[] descriptors);
43 | ///
44 | /// 获取一个HBase表的操作接口
45 | ///
46 | /// 表名
47 | /// 如果获取成功,则返回可以操作该表的实例
48 | IHTable GetTable(string tableName);
49 | ///
50 | /// 删除一个HBase表
51 | ///
52 | /// 表名
53 | /// 参数不能为空
54 | /// 通信超时
55 | /// 通信失败
56 | void DeleteTable(string tableName);
57 | ///
58 | /// 获取HBase中所有的表名信息
59 | ///
60 | /// 返回所有的表名
61 | /// IO错误
62 | /// 通信超时
63 | /// 通信失败
64 | List GetTableNames();
65 | ///
66 | /// 获取HBase中RegionServer的数量
67 | ///
68 | /// 返回HBase中RegionServer的数量
69 | int GetRegionServerNumber();
70 |
71 | #endregion
72 | }
73 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Client/Scanner.cs:
--------------------------------------------------------------------------------
1 | using System.Net;
2 | using Gridsum.NHBaseThrift.Exceptions;
3 | using Gridsum.NHBaseThrift.Objects;
4 | using KJFramework.Tracing;
5 |
6 | namespace Gridsum.NHBaseThrift.Client
7 | {
8 | ///
9 | /// Scanner查询器
10 | ///
11 | public class Scanner
12 | {
13 | #region Members.
14 |
15 | private readonly int BatchSize;
16 | private readonly int _scannerId;
17 | private readonly IPEndPoint _iep;
18 | private readonly HBaseClient _client;
19 | private static readonly ITracing _tracing = TracingManager.GetTracing(typeof(Scanner));
20 |
21 | #endregion
22 |
23 | #region Constructor
24 |
25 | ///
26 | /// Scanner查询器
27 | ///
28 | /// scannerId
29 | /// 单次从数据库获取的行数
30 | /// Hbase客户端
31 | /// 网络端点
32 | public Scanner(int scannerId, HBaseClient client, IPEndPoint iep,int batchSize = 1)
33 | {
34 | _scannerId = scannerId;
35 | _client = client;
36 | _iep = iep;
37 | BatchSize = batchSize;
38 | }
39 |
40 | #endregion
41 |
42 | #region Methods.
43 |
44 | ///
45 | /// 获取下一行数据。当返回null时为止
46 | ///
47 | /// IO错误
48 | /// 通信超时
49 | /// 通信失败
50 | /// 返回下一行数据
51 | public RowInfo GetNext()
52 | {
53 | RowInfo[] infos = _client.GetRowsFromScanner(_scannerId, BatchSize, _iep);
54 | if (infos == null || infos.Length == 0)
55 | {
56 | _client.ScannerClose(_scannerId, _iep);
57 | return null;
58 | }
59 | return infos[0];
60 | }
61 |
62 | #endregion
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/NHBaseThrift/Comparator/ByteArrayComparator.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Enums;
2 |
3 | namespace Gridsum.NHBaseThrift.Comparator
4 | {
5 | ///
6 | /// 字节数组比较器
7 | ///
8 | public class ByteArrayComparator : IByteArrayComparator
9 | {
10 | #region Methods.
11 |
12 | ///
13 | /// 按字节比较两字符串.
14 | /// *两字符串按字节逐位比较
15 | /// *如果对应位置上arr1的字节大于等于arr2的字节就返回true
16 | /// *如果对应位置上arr1的字节小于arr2的字节就返回true
17 | ///
18 | /// arr1大于arr2
19 | public CompareResult Compare(byte[] arr1, byte[] arr2)
20 | {
21 | if (arr1 == arr2) return CompareResult.Eq;
22 | if (arr1 == null && arr2 != null) return CompareResult.Lt;
23 | if (arr2 == null && arr1 != null) return CompareResult.Gt;
24 | int len = ((arr1.Length > arr2.Length) ? arr2.Length : arr1.Length);
25 | for (int i = 0; i < len; i++)
26 | {
27 | if (arr1[i] > arr2[i]) return CompareResult.Gt;
28 | if (arr1[i] < arr2[i]) return CompareResult.Lt;
29 | }
30 | if (arr1.Length > arr2.Length) return CompareResult.Gt;
31 | if (arr1.Length < arr2.Length) return CompareResult.Lt;
32 | return CompareResult.Eq;
33 | }
34 |
35 | #endregion
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/NHBaseThrift/Comparator/IByteArrayComparator.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Enums;
2 |
3 | namespace Gridsum.NHBaseThrift.Comparator
4 | {
5 | ///
6 | /// 比较接口
7 | ///
8 | public interface IByteArrayComparator
9 | {
10 | ///
11 | /// 按字节比较两字符串.
12 | /// *两字符串按字节逐位比较
13 | /// *如果对应位置上arr1的字节大于等于arr2的字节就返回true
14 | /// *如果对应位置上arr1的字节小于arr2的字节就返回true
15 | ///
16 | /// arr1大于arr2
17 | CompareResult Compare(byte[] arr1, byte[] arr2);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/NHBaseThrift/Consts.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift
2 | {
3 | internal class Consts
4 | {
5 | public const string ThriftObjectFullName = "Gridsum.NHBaseThrift.Contracts.IThriftObject";
6 | }
7 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Contracts/IThriftObject.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift.Contracts
2 | {
3 | ///
4 | /// Thrift object interface
5 | ///
6 | public interface IThriftObject
7 | {
8 | #region Members.
9 |
10 | ///
11 | /// Gets serialized value.
12 | ///
13 | byte[] Body { get; }
14 | ///
15 | /// Gets a status value which indicated whether it had completed serialization.
16 | ///
17 | bool IsBind { get; }
18 |
19 | #endregion
20 |
21 | #region Methods.
22 |
23 | ///
24 | /// Serialize current Thrift object into data buffer.
25 | ///
26 | void Bind();
27 |
28 | #endregion
29 | }
30 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Enums/CompareResult.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift.Enums
2 | {
3 | ///
4 | /// 比较结果
5 | ///
6 | public enum CompareResult : byte
7 | {
8 | ///
9 | /// 相等
10 | ///
11 | Eq = 0x00,
12 | ///
13 | /// 大于
14 | ///
15 | Lt = 0x01,
16 | ///
17 | /// 小于
18 | ///
19 | Gt = 0x02
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/NHBaseThrift/Enums/GetObjectResultTypes.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift.Enums
2 | {
3 | ///
4 | /// 解析Thrift协议对象的结果类型
5 | ///
6 | public enum GetObjectResultTypes : byte
7 | {
8 | ///
9 | /// 当前填充的原始数据还不足以解析出一个完整的Thrift协议对象
10 | ///
11 | NotEnoughData = 0x00,
12 | ///
13 | /// 解析成功
14 | ///
15 | Succeed = 0x01,
16 | ///
17 | /// 解析失败, 错误的数据格式
18 | ///
19 | BadFormat = 0x02,
20 | ///
21 | /// 解析失败, 位置的协议对象类型
22 | ///
23 | UnknownObjectType = 0x03
24 |
25 | }
26 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Enums/MessageTypes.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift.Enums
2 | {
3 | ///
4 | /// Message operation types in Thrift protocol.
5 | ///
6 | public enum MessageTypes
7 | {
8 | Call = 1,
9 | Reply = 2,
10 | Exception = 3,
11 | Oneway = 4
12 | }
13 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Enums/PropertyTypes.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift.Enums
2 | {
3 | ///
4 | /// Thrift Property's Type
5 | ///
6 | public enum PropertyTypes : byte
7 | {
8 | Stop = 0,
9 | Void = 1,
10 | Bool = 2,
11 | Byte = 3,
12 | Double = 4,
13 | I16 = 6,
14 | I32 = 8,
15 | I64 = 10,
16 | String = 11,
17 | Struct = 12,
18 | Map = 13,
19 | Set = 14,
20 | List = 15
21 | }
22 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Exceptions/AlreadyExistsException.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift.Exceptions
2 | {
3 | ///
4 | /// 已经存在指定资源异常
5 | ///
6 | public class AlreadyExistsException : System.Exception
7 | {
8 | #region Constructor
9 |
10 | ///
11 | /// 已经存在指定资源异常
12 | ///
13 | /// 错误消息
14 | public AlreadyExistsException(string message)
15 | : base(message)
16 | {
17 |
18 | }
19 |
20 | #endregion
21 | }
22 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Exceptions/BadFormatException.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift.Exceptions
2 | {
3 | ///
4 | /// Thrift协议栈解析消息时报出的脏协议格式异常
5 | ///
6 | public class BadFormatException : System.Exception
7 | {
8 | }
9 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Exceptions/CommunicationFailException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Gridsum.NHBaseThrift.Exceptions
4 | {
5 | ///
6 | /// 通信失败异常
7 | ///
8 | public class CommunicationFailException : Exception
9 | {
10 | #region Constructor.
11 |
12 | ///
13 | /// 通信失败异常
14 | ///
15 | public CommunicationFailException(int seqId)
16 | : base(String.Format("#Transation SEQ ID: {0} had timeout.", seqId))
17 | {
18 |
19 | }
20 |
21 | #endregion
22 | }
23 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Exceptions/CommunicationTimeoutException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Gridsum.NHBaseThrift.Exceptions
4 | {
5 | ///
6 | /// 通信超时异常
7 | ///
8 | public class CommunicationTimeoutException : Exception
9 | {
10 | #region Constructor.
11 |
12 | ///
13 | /// 通信超时异常
14 | ///
15 | public CommunicationTimeoutException(int seqId) : base(String.Format("#Transation SEQ ID: {0} had timeout.", seqId))
16 | {
17 |
18 | }
19 |
20 | #endregion
21 | }
22 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Exceptions/DefineNoMeaningException.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift.Exceptions
2 | {
3 | ///
4 | /// 定义无意义异常
5 | ///
6 | public class DefineNoMeaningException : System.Exception
7 | {
8 | #region Constructor
9 |
10 | ///
11 | /// 定义无意义异常
12 | ///
13 | /// 错误消息
14 | public DefineNoMeaningException(string message)
15 | : base(message)
16 | {
17 |
18 | }
19 |
20 | #endregion
21 | }
22 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Exceptions/ExceptionMessage.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift.Exceptions
2 | {
3 | ///
4 | /// 异常信息静态存储结构
5 | ///
6 | internal static class ExceptionMessage
7 | {
8 | ///
9 | /// 字段值为空的错误提示语
10 | ///
11 | public const string EX_PROPERTY_VALUE = "#Id: {0}\r\n#Property: {1}\r\n#Type: {2}\r\ncannot be serialize, because Attribute.IsRequire = true and property.value is null!";
12 | public const string EX_NOT_SUPPORTED_VALUE = "#Id: {0}\r\n#Property: {1}\r\n#Type: {2}\r\ncurrent message framework cannot support this type!";
13 | public const string EX_NOT_SUPPORTED_VALUE_TEMPORARY = "#Type: {0}\r\ncurrent message framework cannot support this type!";
14 | public const string EX_NO_MEANING_VALUE = "#Id: {0}\r\n#Property: {1}\r\n#Type: {2}\r\nthere is no meaning for set AllowDefaultNull = true with a NON value type or NULLABLE type property!";
15 | public const string EX_VT_FIND_NOT_PROCESSOR = "#Id: {0}\r\n#Property: {1}\r\n#Type: {2}\r\nVT didn't find processor!";
16 | public const string EX_METHOD_ACCESS = "#Detect class permission failed! Pls make sure current class {0} has *PUBLIC* declare permission";
17 | public const string EX_UNEXPRECTED_VALUE = "#Id: {0}\r\n#Property: {1}.\r\nThere was a unexpected NULL value occurred in Blob Type.";
18 | }
19 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Exceptions/IOErrorException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Gridsum.NHBaseThrift.Exceptions
4 | {
5 | ///
6 | /// An IOError exception signals that an error occurred communicating to the Hbase master or an Hbase region server. Also used to return more general Hbase error conditions.
7 | ///
8 | class IOErrorException : Exception
9 | {
10 | #region Constructor
11 |
12 | ///
13 | /// An IOError exception signals that an error occurred communicating to the Hbase master or an Hbase region server. Also used to return more general Hbase error conditions.
14 | ///
15 | /// error message
16 | public IOErrorException(string message)
17 | : base(message)
18 | {
19 |
20 | }
21 |
22 | #endregion
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/NHBaseThrift/Exceptions/IPMappingFailException.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift.Exceptions
2 | {
3 | ///
4 | /// 找不到主机名对应的IP地址异常
5 | ///
6 | public class IPMappingFailException : System.Exception
7 | {
8 | #region Constructor
9 |
10 | ///
11 | /// 找不到主机名对应的IP地址异常
12 | ///
13 | /// 错误消息
14 | public IPMappingFailException(string message)
15 | : base(message)
16 | {
17 |
18 | }
19 |
20 | #endregion
21 | }
22 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Exceptions/IllegalArgumentException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Gridsum.NHBaseThrift.Exceptions
4 | {
5 | ///
6 | /// An IllegalArgument exception indicates an illegal or invalid argument was passed into a procedure.
7 | ///
8 | class IllegalArgumentException : Exception
9 | {
10 | #region Constructor
11 |
12 | ///
13 | /// An IllegalArgument exception indicates an illegal or invalid argument was passed into a procedure.
14 | ///
15 | /// error message
16 | public IllegalArgumentException(string message)
17 | : base(message)
18 | {
19 |
20 | }
21 |
22 | #endregion
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/NHBaseThrift/Exceptions/IncorrectCalculationException.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift.Exceptions
2 | {
3 | ///
4 | /// 网络数据内部计算出错异常
5 | ///
6 | public class IncorrectCalculationException : System.Exception
7 | {
8 | #region Constructor
9 |
10 | ///
11 | /// 网络数据内部计算出异常
12 | ///
13 | /// 错误消息
14 | public IncorrectCalculationException(string message)
15 | : base(message)
16 | {
17 |
18 | }
19 |
20 | #endregion
21 | }
22 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Exceptions/NoConnectionException.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift.Exceptions
2 | {
3 | ///
4 | /// 无任何可用链接异常
5 | ///
6 | public class NoConnectionException : System.Exception
7 | {
8 | }
9 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Exceptions/PropertyNullValueException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Gridsum.NHBaseThrift.Exceptions
4 | {
5 | ///
6 | /// 字段值为空异常
7 | /// * 仅当Attribute.IsRequire = true && Value == null 时触发
8 | ///
9 | [Serializable]
10 | public class PropertyNullValueException : System.Exception
11 | {
12 | #region Constructor
13 |
14 | ///
15 | /// 字段值为空异常
16 | /// * 仅当Attribute.IsRequire = true && Value == null 时触发
17 | ///
18 | public PropertyNullValueException(string message)
19 | : base(message)
20 | {
21 |
22 | }
23 |
24 | #endregion
25 | }
26 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Exceptions/RegionNotFoundException.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift.Exceptions
2 | {
3 | ///
4 | /// Region无法被计算的异常
5 | ///
6 | public class RegionNotFoundException : System.Exception
7 | {
8 | #region Constructor
9 |
10 | ///
11 | /// 已经存在指定资源异常
12 | ///
13 | /// 错误消息
14 | public RegionNotFoundException(string message)
15 | : base(message)
16 | {
17 |
18 | }
19 |
20 | #endregion
21 | }
22 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Exceptions/SpecificKeyNotExistsException.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift.Exceptions
2 | {
3 | ///
4 | /// 指定的key不存在异常
5 | ///
6 | public class SpecificKeyNotExistsException : System.Exception
7 | {
8 | #region Constructor
9 |
10 | ///
11 | /// 指定的key不存在异常
12 | ///
13 | /// 错误消息
14 | public SpecificKeyNotExistsException(string message)
15 | : base(message)
16 | {
17 |
18 | }
19 |
20 | #endregion
21 | }
22 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Exceptions/UnexpectedValueException.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift.Exceptions
2 | {
3 | ///
4 | /// 未期待的结果异常
5 | ///
6 | public class UnexpectedValueException : System.Exception
7 | {
8 | #region Constructor
9 |
10 | ///
11 | /// 未期待的结果异常
12 | ///
13 | /// 错误消息
14 | public UnexpectedValueException(string message)
15 | : base(message)
16 | {
17 |
18 | }
19 |
20 | #endregion
21 | }
22 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Exceptions/UnknownObjectTypeException.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift.Exceptions
2 | {
3 | ///
4 | /// Thrift协议栈解析消息时报出的位置对象类型异常
5 | ///
6 | public class UnknownObjectTypeException : System.Exception
7 | {
8 | }
9 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Exceptions/ZooKeeperInitializationException.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift.Exceptions
2 | {
3 | ///
4 | /// 初始化远程ZooKeeper状态出错异常
5 | ///
6 | public class ZooKeeperInitializationException : System.Exception
7 | {
8 | }
9 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Global.cs:
--------------------------------------------------------------------------------
1 | using System.Configuration;
2 |
3 | namespace Gridsum.NHBaseThrift
4 | {
5 | ///
6 | /// 内部全局变量
7 | ///
8 | internal static class Global
9 | {
10 | #region Members.
11 |
12 | ///
13 | /// 标记一个值,说明了当前Thrift协议框架在产生网络通信时是否需要记录批量插入请求的信息到日志文件中
14 | /// * 我们强烈不建议开启此项,因为在批量插入的消息中可能包含了非常大的数据,这些数据所产生的IO量是很大的,这将会直接的拖慢系统运行速度
15 | ///
16 | public static bool NeedLogBatchInsert = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["LOG_BATCH_INSERT"]);
17 | ///
18 | /// 是否允许在内部出现错误时在日志中打印出网络错误所包含的详细信息
19 | ///
20 | public static bool AllowedPrintDumpInfo;
21 | ///
22 | /// 批量插入消息的简易版提示
23 | ///
24 | public static string BatchInsertNotification = "/*Batch Insert Message (We've ignored concrete information here for saving IO.)*/";
25 |
26 | #endregion
27 | }
28 | }
--------------------------------------------------------------------------------
/NHBaseThrift/HTableRegionManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Net;
4 | using Gridsum.NHBaseThrift.Comparator;
5 | using Gridsum.NHBaseThrift.Exceptions;
6 | using Gridsum.NHBaseThrift.Objects;
7 |
8 | namespace Gridsum.NHBaseThrift
9 | {
10 | ///
11 | /// HBase表区域分布管理器
12 | ///
13 | internal class HTableRegionManager : IHTableRegionManager
14 | {
15 | #region Constructor.
16 |
17 | ///
18 | /// HBase表区域分布管理器
19 | ///
20 | /// 表原始的Region分布范围
21 | /// 主机名/IP映射管理器
22 | /// 主机名找不到IP
23 | public HTableRegionManager(Region[] regions, IHostMappingManager hostMappingManager)
24 | {
25 | _hostMappingManager = hostMappingManager;
26 | for (int i = 0; i < regions.Length; i++)
27 | {
28 | Region region = regions[i];
29 | RegionInfo regionInfo = new RegionInfo
30 | {
31 | StartKey = region.StartKey,
32 | EndKey = region.EndKey,
33 | Id = region.Id,
34 | Name = region.Name,
35 | Version = region.Version,
36 | Comparator = _comparator
37 | };
38 | string ip = _hostMappingManager.GetIPAddressByHostName(region.ServerName);
39 | if (string.IsNullOrEmpty(ip)) throw new IPMappingFailException("#Couldn't found any IP address can match this host: " + region.ServerName);
40 | regionInfo.Address = new IPEndPoint(IPAddress.Parse(ip), region.Port);
41 | _regions.Add(regionInfo);
42 | }
43 | }
44 |
45 | #endregion
46 |
47 | #region Members.
48 |
49 | private List _regions = new List();
50 | private readonly IHostMappingManager _hostMappingManager;
51 | private static readonly IByteArrayComparator _comparator = new ByteArrayComparator();
52 |
53 | #endregion
54 |
55 | #region Methods.
56 |
57 | ///
58 | /// 根据一个指定的行键来确定远程Region服务器地址
59 | ///
60 | /// 行键
61 | /// 返回对应的Region服务器地址
62 | /// 参数不能为空
63 | /// 找不到对应的RegionServer
64 | public IPEndPoint GetRegionByRowKey(byte[] rowKey)
65 | {
66 | if (_regions.Count == 0) throw new RegionNotFoundException("#We couldn't match any remote region server by given Row-Key: " + rowKey);
67 | //byte[] data = Encoding.UTF8.GetBytes(rowKey);
68 | if (_regions.Count == 1 && _regions[0].IsMatch(rowKey)) return _regions[0].Address;
69 | foreach (RegionInfo region in _regions)
70 | if (region.IsMatch(rowKey)) return region.Address;
71 | throw new RegionNotFoundException("#We couldn't match any remote region server by given Row-Key: " + rowKey);
72 | }
73 |
74 | #endregion
75 | }
76 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Helpers/ExtensionMethods.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift.Helpers
2 | {
3 | ///
4 | /// 类型扩展方法
5 | ///
6 | internal static class ExtensionMethods
7 | {
8 | #region Methods.
9 |
10 | ///
11 | /// 转换到大字节序
12 | ///
13 | /// 需要转换的数值
14 | public unsafe static short ToBigEndian(this short value)
15 | {
16 | byte* ptmpValue = stackalloc byte[2];
17 | ptmpValue[0] = (byte)(0xff & (value >> 8));
18 | ptmpValue[1] = (byte)(0xff & value);
19 | return *(short*)ptmpValue;
20 | }
21 |
22 | ///
23 | /// 转换到小字节序
24 | ///
25 | /// 需要转换的数值
26 | public unsafe static short ToLittleEndian(this short value)
27 | {
28 | byte* ptmpValue = (byte*)&value;
29 | return (short) (((ptmpValue[0] & 0xff) << 8) | ((ptmpValue[1] & 0xff)));
30 | }
31 |
32 | ///
33 | /// 转换到大字节序
34 | ///
35 | /// 需要转换的数值
36 | public unsafe static int ToBigEndian(this int value)
37 | {
38 | byte* ptmpValue = stackalloc byte[4];
39 | ptmpValue[0] = (byte)(0xff & (value >> 24));
40 | ptmpValue[1] = (byte)(0xff & (value >> 16));
41 | ptmpValue[2] = (byte)(0xff & (value >> 8));
42 | ptmpValue[3] = (byte)(0xff & value);
43 | return *(int*) ptmpValue;
44 | }
45 |
46 | ///
47 | /// 转换到小字节序
48 | ///
49 | /// 需要转换的数值
50 | public unsafe static int ToLittleEndian(this int value)
51 | {
52 | byte* ptmpValue = (byte*)&value;
53 | return ((ptmpValue[0] & 0xff) << 24) | ((ptmpValue[1] & 0xff) << 16) | ((ptmpValue[2] & 0xff) << 8) | ((ptmpValue[3] & 0xff));
54 | }
55 |
56 | ///
57 | /// 转换到大字节序
58 | ///
59 | /// 需要转换的数值
60 | public unsafe static long ToBigEndian(this long value)
61 | {
62 | byte* ptmpValue = stackalloc byte[8];
63 | ptmpValue[0] = (byte)(0xff & (value >> 56));
64 | ptmpValue[1] = (byte)(0xff & (value >> 48));
65 | ptmpValue[2] = (byte)(0xff & (value >> 40));
66 | ptmpValue[3] = (byte)(0xff & (value >> 32));
67 | ptmpValue[4] = (byte)(0xff & (value >> 24));
68 | ptmpValue[5] = (byte)(0xff & (value >> 16));
69 | ptmpValue[6] = (byte)(0xff & (value >> 8));
70 | ptmpValue[7] = (byte)(0xff & value);
71 | return *(long*)ptmpValue;
72 | }
73 |
74 |
75 | ///
76 | /// 转换到小字节序
77 | ///
78 | /// 需要转换的数值
79 | public unsafe static long ToLittleEndian(this long value)
80 | {
81 | byte* ptmpValue = (byte*)&value;
82 | return (
83 | ((ptmpValue[0] & 0xff) << 56) |
84 | ((ptmpValue[1] & 0xff) << 48) |
85 | ((ptmpValue[2] & 0xff) << 40) |
86 | ((ptmpValue[3] & 0xff) << 32) |
87 | ((ptmpValue[4] & 0xff) << 24) |
88 | ((ptmpValue[5] & 0xff) << 16) |
89 | ((ptmpValue[6] & 0xff) << 8) |
90 | ptmpValue[7] & 0xff);
91 | }
92 |
93 | #endregion
94 | }
95 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Helpers/FixedTypeManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Net;
4 | using Gridsum.NHBaseThrift.Stubs;
5 |
6 | namespace Gridsum.NHBaseThrift.Helpers
7 | {
8 | ///
9 | /// 固定类型管理器,为固定字节数序列化/反序列化的能力提供基础支持
10 | ///
11 | public static class FixedTypeManager
12 | {
13 | #region Constructor.
14 |
15 | ///
16 | /// 固定类型管理器,为固定字节数序列化/反序列化的能力提供基础支持
17 | ///
18 | static FixedTypeManager()
19 | {
20 | _vt = new Dictionary();
21 | _vt.Add(typeof(bool).FullName, new VT { Size = 1 });
22 | _vt.Add(typeof(char).FullName, new VT { Size = 1 });
23 | _vt.Add(typeof(byte).FullName, new VT { Size = 1 });
24 | _vt.Add(typeof(sbyte).FullName, new VT { Size = 1 });
25 | _vt.Add(typeof(decimal).FullName, new VT { Size = 16 });
26 | _vt.Add(typeof(short).FullName, new VT { Size = 2 });
27 | _vt.Add(typeof(ushort).FullName, new VT { Size = 2 });
28 | _vt.Add(typeof(float).FullName, new VT { Size = 4 });
29 | _vt.Add(typeof(int).FullName, new VT { Size = 4 });
30 | _vt.Add(typeof(uint).FullName, new VT { Size = 4 });
31 | _vt.Add(typeof(ulong).FullName, new VT { Size = 8 });
32 | _vt.Add(typeof(long).FullName, new VT { Size = 8 });
33 | _vt.Add(typeof(double).FullName, new VT { Size = 8 });
34 | _vt.Add(typeof(DateTime).FullName, new VT { Size = 8 });
35 | _vt.Add(typeof(IntPtr).FullName, new VT { Size = 4 });
36 | _vt.Add(typeof(Guid).FullName, new VT { Size = 16 });
37 | _vt.Add(typeof(IPEndPoint).FullName, new VT { Size = 12 });
38 | _vt.Add(typeof(TimeSpan).FullName, new VT { Size = 8 });
39 | }
40 |
41 | #endregion
42 |
43 | #region Members.
44 |
45 | private static readonly Dictionary _vt;
46 |
47 | #endregion
48 |
49 | #region Methods.
50 |
51 | ///
52 | /// 判断一个指定类型是否支持固定字节数序列化/反序列化
53 | ///
54 | /// 要检测的类型
55 | ///
56 | public static VT IsVT(Type type)
57 | {
58 | if (type == null) throw new ArgumentNullException("type");
59 | VT vt;
60 | return _vt.TryGetValue(type.FullName, out vt) ? vt : null;
61 | }
62 |
63 | ///
64 | /// 将一个类型添加为支持固定字节数的序列化/反序列化
65 | /// * 请在程序初始化的时候调用此方法
66 | ///
67 | /// 需要添加的类型
68 | /// 固定字节数
69 | /// 返回添加后的状态
70 | /// 参数不能为空
71 | /// 参数错误
72 | public static bool Add(Type type, int size)
73 | {
74 | if (type == null) throw new ArgumentNullException("type");
75 | if (size <= 0) throw new ArgumentException("Illegal parameter: #size.");
76 | if (_vt.ContainsKey(type.FullName)) return false;
77 | _vt.Add(type.FullName, new VT { Size = size });
78 | return true;
79 | }
80 |
81 | #endregion
82 | }
83 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Helpers/ThriftObjectArrayHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Concurrent;
3 | using System.Reflection;
4 | using System.Reflection.Emit;
5 | using Gridsum.NHBaseThrift.Contracts;
6 |
7 | namespace Gridsum.NHBaseThrift.Helpers
8 | {
9 | ///
10 | /// 智能类型数组帮助器
11 | ///
12 | internal static class ThriftObjectArrayHelper
13 | {
14 | #region Members
15 |
16 | private static readonly ConcurrentDictionary _methods = new ConcurrentDictionary();
17 |
18 | #endregion
19 |
20 | #region Methods
21 |
22 | ///
23 | /// 获取指定类型的功能函数
24 | ///
25 | /// 数组类型
26 | /// 数组元素类型
27 | /// 返回一个功能函数
28 | public static Func GetFunc(Type type)
29 | where T : ThriftObject
30 | {
31 | object obj;
32 | string fullname = type.FullName;
33 | if (_methods.TryGetValue(fullname, out obj)) return (Func) obj;
34 | //create cache method.
35 | DynamicMethod dynamicMethod = new DynamicMethod(string.Format("CreateArrayInstnaceBy: {0}", fullname),
36 | MethodAttributes.Public | MethodAttributes.Static,
37 | CallingConventions.Standard, type,
38 | new[] {typeof (int)}, typeof (object), true);
39 | ILGenerator generator = dynamicMethod.GetILGenerator();
40 | generator.Emit(OpCodes.Ldarg_0);
41 | generator.Emit(OpCodes.Newarr, type.GetElementType());
42 | generator.Emit(OpCodes.Ret);
43 | Func func = (Func) dynamicMethod.CreateDelegate(typeof (Func));
44 | if (!_methods.TryAdd(fullname, func))
45 | throw new InvalidOperationException("#Cannot add specific func to ConcurrentDictionary");
46 | return func;
47 | }
48 |
49 | #endregion
50 | }
51 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Helpers/TypeConversionHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 |
4 | namespace Gridsum.NHBaseThrift.Helpers
5 | {
6 | ///
7 | /// 类型转换帮助类
8 | ///
9 | public static class TypeConversionHelper
10 | {
11 | #region Methods.
12 |
13 | ///
14 | /// byte数组转换为long类型
15 | ///
16 | /// byte数组
17 | /// long类型结果
18 | public static long ByteArraryTolong(byte[] bytes)
19 | {
20 | return BitConverter.ToInt64(bytes, 0).ToLittleEndian();
21 | }
22 |
23 | ///
24 | /// byte数组转换为string类型
25 | ///
26 | /// byte数组
27 | /// string类型结果
28 | public static string ByteArraryToString(byte[] bytes)
29 | {
30 | return Encoding.UTF8.GetString(bytes);
31 | }
32 |
33 | ///
34 | /// string类型转换为byte数组类型
35 | ///
36 | /// string
37 | /// byte数组类型结果
38 | public static byte[] StringToByteArray(string str)
39 | {
40 | return Encoding.UTF8.GetBytes(str);
41 | }
42 |
43 | #endregion
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/NHBaseThrift/HostMappingManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Net;
7 |
8 | namespace Gridsum.NHBaseThrift
9 | {
10 | ///
11 | /// HOST名称映射管理器
12 | ///
13 | internal class HostMappingManager : IHostMappingManager
14 | {
15 | #region Constructor.
16 |
17 | ///
18 | /// HOST名称映射管理器
19 | ///
20 | public HostMappingManager()
21 | {
22 | InitializeHostMappingInformation();
23 | }
24 |
25 | #endregion
26 |
27 | #region Members.
28 |
29 | private readonly Dictionary _hostAddresses = new Dictionary();
30 |
31 | #endregion
32 |
33 | #region Methods.
34 |
35 | ///
36 | /// 根据一个主机名获取IP映射关系
37 | ///
38 | /// 主机名
39 | /// 返回对应的IP地址
40 | public string GetIPAddressByHostName(string hostName)
41 | {
42 | string address;
43 | if (_hostAddresses.TryGetValue(hostName, out address)) return address;
44 | IPAddress[] addresses = Dns.GetHostAddresses(hostName);
45 | if (addresses != null) return addresses[0].MapToIPv4().ToString();
46 | //actually this return value will never be uses because of an exception occured before.
47 | return null;
48 | }
49 |
50 | private void InitializeHostMappingInformation()
51 | {
52 | //FORMAT: HOST IP
53 | DirectoryInfo directoryInfo = (new FileInfo(Process.GetCurrentProcess().MainModule.FileName)).Directory;
54 | if (directoryInfo == null) throw new Exception("HostMapping file path is null");
55 | string[] files = directoryInfo.GetFiles("host.mapping").Select(x => x.FullName).ToArray();
56 | if (files.Length == 0) return;
57 | if (files.Length > 1) throw new Exception("#Confused by multiple \"host.mapping\" files we've founded.");
58 | string[] lines = File.ReadAllLines(files[0]);
59 | if (lines.Length == 0) return;
60 | foreach (string line in lines)
61 | {
62 | string[] content = line.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
63 | _hostAddresses[content[0]] = content[1];
64 | }
65 | }
66 |
67 | #endregion
68 | }
69 | }
--------------------------------------------------------------------------------
/NHBaseThrift/IHTableRegionManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net;
3 |
4 | namespace Gridsum.NHBaseThrift
5 | {
6 | ///
7 | /// HBase表区域分布管理器接口
8 | ///
9 | public interface IHTableRegionManager
10 | {
11 | #region Methods.
12 |
13 | ///
14 | /// 根据一个指定的行键来确定远程Region服务器地址
15 | ///
16 | /// 行键
17 | /// 返回对应的Region服务器地址
18 | /// 参数不能为空
19 | IPEndPoint GetRegionByRowKey(byte[] rowKey);
20 |
21 | #endregion
22 | }
23 | }
--------------------------------------------------------------------------------
/NHBaseThrift/IHostMappingManager.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift
2 | {
3 | ///
4 | /// HOST名称映射管理器接口
5 | ///
6 | internal interface IHostMappingManager
7 | {
8 | #region Methods.
9 |
10 | ///
11 | /// 根据一个主机名获取IP映射关系
12 | ///
13 | /// 主机名
14 | /// 返回对应的IP地址
15 | string GetIPAddressByHostName(string hostName);
16 |
17 | #endregion
18 | }
19 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/AtomicIncrementRequestMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// Atomically increment the column value specified. Returns the next value post increment.
9 | ///
10 | public class AtomicIncrementRequestMessage : ThriftMessage
11 | {
12 | #region Constructor.
13 |
14 | ///
15 | /// Atomically increment the column value specified. Returns the next value post increment.
16 | ///
17 | public AtomicIncrementRequestMessage()
18 | {
19 | uint version = VERSION_1 | (uint)(MessageTypes.Call);
20 | Identity = new MessageIdentity
21 | {
22 | Command = "atomicIncrement",
23 | Version = (int)version
24 | };
25 | Identity.CommandLength = (uint) Identity.Command.Length;
26 | }
27 |
28 | #endregion
29 |
30 | #region Members.
31 |
32 | ///
33 | /// Gets or sets table name.
34 | ///
35 | [ThriftProperty(1, PropertyTypes.String)]
36 | public string TableName { get; set; }
37 | ///
38 | /// Gets or sets Rowkey.
39 | ///
40 | [ThriftProperty(2, PropertyTypes.String)]
41 | public byte[] RowKey { get; set; }
42 | ///
43 | /// Gets or sets Column.
44 | ///
45 | [ThriftProperty(3, PropertyTypes.String)]
46 | public string Column { get; set; }
47 | ///
48 | /// Gets or sets Value.
49 | ///
50 | [ThriftProperty(4, PropertyTypes.I64)]
51 | public long Value { get; set; }
52 |
53 | #endregion
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/AtomicIncrementResponseMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// Atomically increment the column value specified. Returns the next value post increment.
9 | ///
10 | public class AtomicIncrementResponseMessage : ThriftMessage
11 | {
12 | #region Constructor.
13 |
14 | ///
15 | /// Atomically increment the column value specified. Returns the next value post increment.
16 | ///
17 | public AtomicIncrementResponseMessage()
18 | {
19 | uint version = VERSION_1 | (uint)(MessageTypes.Reply);
20 | Identity = new MessageIdentity
21 | {
22 | Command = "atomicIncrement",
23 | Version = (int)version
24 | };
25 | Identity.CommandLength = (uint) Identity.Command.Length;
26 | }
27 |
28 | #endregion
29 |
30 | #region Members.
31 |
32 | ///
33 | /// Get or set the next value post increment
34 | ///
35 | [ThriftProperty(0, PropertyTypes.I64)]
36 | public long Success { get; set; }
37 | ///
38 | /// Get or set IOError
39 | ///
40 | [ThriftProperty(1, PropertyTypes.String)]
41 | public IOError IOErrorMessage { get; set; }
42 | ///
43 | /// Get or set IllegalArgumentError
44 | ///
45 | [ThriftProperty(2, PropertyTypes.String)]
46 | public IllegalArgumentError IllegalArgumentErrorMessage { get; set; }
47 |
48 | #endregion
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/CreateTableRequestMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// Request mesasge for creating HBase table command.
9 | ///
10 | public class CreateTableRequestMessage : ThriftMessage
11 | {
12 | #region Constructor.
13 |
14 | ///
15 | /// Request mesasge for creating HBase table command.
16 | ///
17 | public CreateTableRequestMessage()
18 | {
19 | uint version = VERSION_1 | (uint)(MessageTypes.Call);
20 | Identity = new MessageIdentity
21 | {
22 | Command = "createTable",
23 | Version = (int)version
24 | };
25 | Identity.CommandLength = (uint) Identity.Command.Length;
26 | }
27 |
28 | #endregion
29 |
30 | #region Members.
31 |
32 | ///
33 | /// Gets or sets HBase table name you want to create.
34 | ///
35 | [ThriftProperty(1, PropertyTypes.String)]
36 | public string TableName { get; set; }
37 | ///
38 | /// Gets or sets HBase table's column families you want use.
39 | ///
40 | [ThriftProperty(2, PropertyTypes.List)]
41 | public ColumnDescriptor[] ColumnFamilies { get; set; }
42 |
43 | #endregion
44 | }
45 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/CreateTableResponseMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// 创建HBase表的应答消息
9 | ///
10 | public class CreateTableResponseMessage : ThriftMessage
11 | {
12 | #region Constructor.
13 |
14 | ///
15 | /// 创建HBase表的应答消息
16 | ///
17 | public CreateTableResponseMessage()
18 | {
19 | uint version = VERSION_1 | (uint)(MessageTypes.Reply);
20 | Identity = new MessageIdentity
21 | {
22 | Command = "createTable",
23 | Version = (int)version
24 | };
25 | Identity.CommandLength = (uint) Identity.Command.Length;
26 | }
27 |
28 | #endregion
29 |
30 | #region Members.
31 |
32 | ///
33 | /// 获取或设置IO错误信息
34 | ///
35 | [ThriftProperty(1, PropertyTypes.String)]
36 | public IOError IOErrorMessage { get; set; }
37 | ///
38 | /// 获取或设置参数非法错误信息
39 | ///
40 | [ThriftProperty(2, PropertyTypes.String)]
41 | public IllegalArgumentError IllegalArgumentErrorMessage { get; set; }
42 | ///
43 | /// 获取或设置资源已经存在错误信息
44 | ///
45 | [ThriftProperty(3, PropertyTypes.String)]
46 | public AlreadyExistsError AlreadyExistsErrorMessage { get; set; }
47 |
48 | #endregion
49 | }
50 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/DeleteTableRequestMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// Request mesasge for deleting HBase table command.
9 | ///
10 | public class DeleteTableRequestMessage : ThriftMessage
11 | {
12 | #region Constructor.
13 |
14 | ///
15 | /// Request mesasge for deleting HBase table command.
16 | ///
17 | public DeleteTableRequestMessage()
18 | {
19 | uint version = VERSION_1 | (uint)(MessageTypes.Call);
20 | Identity = new MessageIdentity
21 | {
22 | Command = "deleteTable",
23 | Version = (int)version
24 | };
25 | Identity.CommandLength = (uint) Identity.Command.Length;
26 | }
27 |
28 | #endregion
29 |
30 | #region Members.
31 |
32 | ///
33 | /// Gets or sets HBase table name you want to delete.
34 | ///
35 | [ThriftProperty(1, PropertyTypes.String)]
36 | public string TableName { get; set; }
37 |
38 | #endregion
39 | }
40 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/DeleteTableResponseMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// 删除HBase表的应答消息
9 | ///
10 | public class DeleteTableResponseMessage : ThriftMessage
11 | {
12 | #region Constructor.
13 |
14 | ///
15 | /// 删除HBase表的应答消息
16 | ///
17 | public DeleteTableResponseMessage()
18 | {
19 | uint version = VERSION_1 | (uint)(MessageTypes.Reply);
20 | Identity = new MessageIdentity
21 | {
22 | Command = "deleteTable",
23 | Version = (int)version
24 | };
25 | Identity.CommandLength = (uint) Identity.Command.Length;
26 | }
27 |
28 | #endregion
29 |
30 | #region Members.
31 |
32 | ///
33 | /// 获取或设置IO错误信息
34 | ///
35 | [ThriftProperty(1, PropertyTypes.String)]
36 | public IOError IOErrorMessage { get; set; }
37 |
38 | #endregion
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/DisableTableRequestMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// Request mesasge for disable HBase table command.
9 | ///
10 | public class DisableTableRequestMessage : ThriftMessage
11 | {
12 | #region Constructor.
13 |
14 | ///
15 | /// Request mesasge for disable HBase table command.
16 | ///
17 | public DisableTableRequestMessage()
18 | {
19 | uint version = VERSION_1 | (uint)(MessageTypes.Call);
20 | Identity = new MessageIdentity
21 | {
22 | Command = "disableTable",
23 | Version = (int)version
24 | };
25 | Identity.CommandLength = (uint)Identity.Command.Length;
26 | }
27 |
28 | #endregion
29 |
30 | #region Members.
31 |
32 | ///
33 | /// Gets or sets HBase table name you want to disable.
34 | ///
35 | [ThriftProperty(1, PropertyTypes.String)]
36 | public string TableName { get; set; }
37 |
38 | #endregion
39 | }
40 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/DisableTableResponseMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// 关闭表操作应答
9 | ///
10 | public class DisableTableResponseMessage : ThriftMessage
11 | {
12 | #region Constructor.
13 |
14 | ///
15 | /// 关闭表操作应答
16 | ///
17 | public DisableTableResponseMessage()
18 | {
19 | uint version = VERSION_1 | (uint)(MessageTypes.Reply);
20 | Identity = new MessageIdentity
21 | {
22 | Command = "disableTable",
23 | Version = (int)version
24 | };
25 | Identity.CommandLength = (uint) Identity.Command.Length;
26 | }
27 |
28 | #endregion
29 |
30 | #region Members.
31 |
32 | ///
33 | /// 获取或设置IO错误信息
34 | ///
35 | [ThriftProperty(1, PropertyTypes.String)]
36 | public IOError IOErrorMessage { get; set; }
37 |
38 | #endregion
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/EnableTableRequestMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// Request mesasge for enable HBase table command.
9 | ///
10 | public class EnableTableRequestMessage : ThriftMessage
11 | {
12 | #region Constructor.
13 |
14 | ///
15 | /// Request mesasge for enable HBase table command.
16 | ///
17 | public EnableTableRequestMessage()
18 | {
19 | uint version = VERSION_1 | (uint)(MessageTypes.Call);
20 | Identity = new MessageIdentity
21 | {
22 | Command = "enableTable",
23 | Version = (int)version
24 | };
25 | Identity.CommandLength = (uint)Identity.Command.Length;
26 | }
27 |
28 | #endregion
29 |
30 | #region Members.
31 |
32 | ///
33 | /// Gets or sets HBase table name you want to disable.
34 | ///
35 | [ThriftProperty(1, PropertyTypes.String)]
36 | public string TableName { get; set; }
37 |
38 | #endregion
39 | }
40 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/EnableTableResponseMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// Response mesasge for enable HBase table command.
9 | ///
10 | public class EnableTableResponseMessage : ThriftMessage
11 | {
12 | #region Constructor.
13 |
14 | ///
15 | /// Response mesasge for enable HBase table command.
16 | ///
17 | public EnableTableResponseMessage()
18 | {
19 | uint version = VERSION_1 | (uint)(MessageTypes.Reply);
20 | Identity = new MessageIdentity
21 | {
22 | Command = "enableTable",
23 | Version = (int)version
24 | };
25 | Identity.CommandLength = (uint) Identity.Command.Length;
26 | }
27 |
28 | #endregion
29 |
30 | #region Members.
31 |
32 | ///
33 | /// 获取或设置IO错误信息
34 | ///
35 | [ThriftProperty(1, PropertyTypes.String)]
36 | public string IOErrorMessage { get; set; }
37 |
38 | #endregion
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/GetRowRequestMessage.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Gridsum.NHBaseThrift.Attributes;
3 | using Gridsum.NHBaseThrift.Enums;
4 | using Gridsum.NHBaseThrift.Objects;
5 |
6 | namespace Gridsum.NHBaseThrift.Messages
7 | {
8 | ///
9 | /// 获取一行数据请求
10 | ///
11 | public class GetRowRequestMessage : ThriftMessage
12 | {
13 |
14 | #region Constructor.
15 |
16 | ///
17 | /// Request mesasge for inserting a new row into specified HBase table.
18 | ///
19 | public GetRowRequestMessage()
20 | {
21 | uint version = VERSION_1 | (uint)(MessageTypes.Call);
22 | Identity = new MessageIdentity
23 | {
24 | Command = "getRow",
25 | Version = (int)version
26 | };
27 | Identity.CommandLength = (uint)Identity.Command.Length;
28 | }
29 |
30 | #endregion
31 |
32 | #region Members.
33 |
34 | ///
35 | /// Gets or sets HBase table name you want to create.
36 | ///
37 | [ThriftProperty(1, PropertyTypes.String)]
38 | public string TableName { get; set; }
39 | ///
40 | /// Gets or sets HBase table name you want to create.
41 | ///
42 | [ThriftProperty(2, PropertyTypes.String)]
43 | public byte[] RowKey { get; set; }
44 | ///
45 | /// Gets or sets HBase table's column families you want use.
46 | ///
47 | [ThriftProperty(3, PropertyTypes.Map)]
48 | public Dictionary Attributes { get; set; }
49 |
50 | #endregion
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/GetRowResponseMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// 获取一行数据应答
9 | ///
10 | public class GetRowResponseMessage : ThriftMessage
11 | {
12 |
13 | #region Constructor.
14 |
15 | ///
16 | /// Request mesasge for inserting a new row into specified HBase table.
17 | ///
18 | public GetRowResponseMessage()
19 | {
20 | uint version = VERSION_1 | (uint)(MessageTypes.Call);
21 | Identity = new MessageIdentity
22 | {
23 | Command = "getRow",
24 | Version = (int)version
25 | };
26 | Identity.CommandLength = (uint)Identity.Command.Length;
27 | }
28 |
29 | #endregion
30 |
31 | #region Members.
32 |
33 | ///
34 | /// 获取或设置行信息
35 | ///
36 | [ThriftProperty(0, PropertyTypes.List)]
37 | public RowInfo[] RowInfos { get; set; }
38 | ///
39 | /// 获取或设置IO错误信息
40 | ///
41 | [ThriftProperty(1, PropertyTypes.String)]
42 | public IOError IOErrorMessage { get; set; }
43 |
44 | #endregion
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/GetRowWithColumnsRequestMessage.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Gridsum.NHBaseThrift.Attributes;
3 | using Gridsum.NHBaseThrift.Enums;
4 | using Gridsum.NHBaseThrift.Objects;
5 |
6 | namespace Gridsum.NHBaseThrift.Messages
7 | {
8 | ///
9 | /// 获取指定行指定列请求
10 | ///
11 | public class GetRowWithColumnsRequestMessage : ThriftMessage
12 | {
13 | #region Constructor.
14 |
15 | ///
16 | /// Request mesasge for creating HBase table command.
17 | ///
18 | public GetRowWithColumnsRequestMessage()
19 | {
20 | uint version = VERSION_1 | (uint)(MessageTypes.Call);
21 | Identity = new MessageIdentity
22 | {
23 | Command = "getRowWithColumns",
24 | Version = (int)version
25 | };
26 | Identity.CommandLength = (uint) Identity.Command.Length;
27 | }
28 |
29 | #endregion
30 |
31 | #region Members.
32 |
33 |
34 | ///
35 | /// Gets or sets HBase table name you want to create.
36 | ///
37 | [ThriftProperty(1, PropertyTypes.String)]
38 | public string TableName { get; set; }
39 | ///
40 | /// Gets or sets HBase table name you want to create.
41 | ///
42 | [ThriftProperty(2, PropertyTypes.String)]
43 | public byte[] RowKey { get; set; }
44 | ///
45 | /// Gets or sets List of columns to return, null for all columns
46 | ///
47 | [ThriftProperty(3, PropertyTypes.List)]
48 | public string[] Columns { get; set; }
49 | ///
50 | /// Gets or sets HBase table's column families you want use.
51 | ///
52 | [ThriftProperty(4, PropertyTypes.Map)]
53 | public Dictionary Attributes { get; set; }
54 |
55 | #endregion
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/GetRowWithColumnsResponseMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// 获取指定行指定列应答
9 | ///
10 | public class GetRowWithColumnsResponseMessage : ThriftMessage
11 | {
12 | #region Constructor.
13 |
14 | ///
15 | /// Request mesasge for creating HBase table command.
16 | ///
17 | public GetRowWithColumnsResponseMessage()
18 | {
19 | uint version = VERSION_1 | (uint)(MessageTypes.Reply);
20 | Identity = new MessageIdentity
21 | {
22 | Command = "getRowWithColumns",
23 | Version = (int)version
24 | };
25 | Identity.CommandLength = (uint) Identity.Command.Length;
26 | }
27 |
28 | #endregion
29 |
30 | #region Members.
31 |
32 | ///
33 | /// 获取或设置行信息
34 | ///
35 | [ThriftProperty(0, PropertyTypes.List)]
36 | public RowInfo[] RowInfos { get; set; }
37 |
38 | ///
39 | /// 获取或设置IO错误信息
40 | ///
41 | [ThriftProperty(1, PropertyTypes.String)]
42 | public IOError IOErrorMessage { get; set; }
43 |
44 | #endregion
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/GetTableNamesRequestMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Enums;
2 | using Gridsum.NHBaseThrift.Objects;
3 |
4 | namespace Gridsum.NHBaseThrift.Messages
5 | {
6 | ///
7 | /// 获取目前HBase内部所有的表名请求消息
8 | ///
9 | public class GetTableNamesRequestMessage : ThriftMessage
10 | {
11 | #region Constructor.
12 |
13 | ///
14 | /// 获取目前HBase内部所有的表名请求消息
15 | ///
16 | public GetTableNamesRequestMessage()
17 | {
18 | uint version = VERSION_1 | (uint)(MessageTypes.Call);
19 | Identity = new MessageIdentity
20 | {
21 | Command = "getTableNames",
22 | Version = (int)version
23 | };
24 | Identity.CommandLength = (uint) Identity.Command.Length;
25 | }
26 |
27 | #endregion
28 | }
29 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/GetTableNamesResponseMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// 获取目前HBase内部所有的表名应答消息
9 | ///
10 | public class GetTableNamesResponseMessage : ThriftMessage
11 | {
12 | #region Constructor.
13 |
14 | ///
15 | /// 获取目前HBase内部所有的表名请求消息
16 | ///
17 | public GetTableNamesResponseMessage()
18 | {
19 | uint version = VERSION_1 | (uint)(MessageTypes.Call);
20 | Identity = new MessageIdentity
21 | {
22 | Command = "getTableNames",
23 | Version = (int)version
24 | };
25 | Identity.CommandLength = (uint) Identity.Command.Length;
26 | }
27 |
28 | #endregion
29 |
30 | #region Members.
31 |
32 | ///
33 | /// 获取或设置HBase中所有的表名
34 | ///
35 | [ThriftProperty(0, PropertyTypes.List)]
36 | public string[] Tables { get; set; }
37 | ///
38 | /// 获取或设置IO错误信息
39 | ///
40 | [ThriftProperty(1, PropertyTypes.String)]
41 | public IOError IOErrorMessage { get; set; }
42 |
43 | #endregion
44 | }
45 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/GetTableRegionsRequestMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// 获取一个表所分布在HBase的区域范围请求消息
9 | ///
10 | public class GetTableRegionsRequestMessage : ThriftMessage
11 | {
12 | #region Constructor.
13 |
14 | ///
15 | /// 获取一个表所分布在HBase的区域范围请求消息
16 | ///
17 | public GetTableRegionsRequestMessage()
18 | {
19 | uint version = VERSION_1 | (uint)(MessageTypes.Call);
20 | Identity = new MessageIdentity
21 | {
22 | Command = "getTableRegions",
23 | Version = (int)version
24 | };
25 | Identity.CommandLength = (uint) Identity.Command.Length;
26 | }
27 |
28 | #endregion
29 |
30 | #region Members.
31 |
32 | ///
33 | /// 获取或设置表名
34 | ///
35 | [ThriftProperty(1, PropertyTypes.String)]
36 | public string TableName { get; set; }
37 |
38 | #endregion
39 | }
40 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/GetTableRegionsResponseMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// 获取一个表所分布在HBase的区域范围应答消息
9 | ///
10 | public class GetTableRegionsResponseMessage : ThriftMessage
11 | {
12 | #region Constructor.
13 |
14 | ///
15 | /// 获取一个表所分布在HBase的区域范围应答消息
16 | ///
17 | public GetTableRegionsResponseMessage()
18 | {
19 | uint version = VERSION_1 | (uint)(MessageTypes.Reply);
20 | Identity = new MessageIdentity
21 | {
22 | Command = "getTableRegions",
23 | Version = (int)version
24 | };
25 | Identity.CommandLength = (uint) Identity.Command.Length;
26 | }
27 |
28 | #endregion
29 |
30 | #region Members.
31 |
32 | ///
33 | /// 获取或设置Region分布信息列表
34 | ///
35 | [ThriftProperty(0, PropertyTypes.List)]
36 | public Region[] Regions { get; set; }
37 | ///
38 | /// 获取或设置IO错误信息
39 | ///
40 | [ThriftProperty(1, PropertyTypes.String)]
41 | public IOError IOErrorMessage { get; set; }
42 |
43 | #endregion
44 | }
45 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/InsertNewRowRequestMessage.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Gridsum.NHBaseThrift.Attributes;
3 | using Gridsum.NHBaseThrift.Enums;
4 | using Gridsum.NHBaseThrift.Objects;
5 |
6 | namespace Gridsum.NHBaseThrift.Messages
7 | {
8 | ///
9 | /// Request mesasge for inserting a new row into specified HBase table.
10 | ///
11 | public class InsertNewRowRequestMessage : ThriftMessage
12 | {
13 | #region Constructor.
14 |
15 | ///
16 | /// Request mesasge for inserting a new row into specified HBase table.
17 | ///
18 | public InsertNewRowRequestMessage()
19 | {
20 | uint version = VERSION_1 | (uint)(MessageTypes.Call);
21 | Identity = new MessageIdentity
22 | {
23 | Command = "mutateRow",
24 | Version = (int)version
25 | };
26 | Identity.CommandLength = (uint)Identity.Command.Length;
27 | }
28 |
29 | #endregion
30 |
31 | #region Members.
32 |
33 | ///
34 | /// Gets or sets HBase table name you want to create.
35 | ///
36 | [ThriftProperty(1, PropertyTypes.String)]
37 | public string TableName { get; set; }
38 | ///
39 | /// Gets or sets HBase table name you want to create.
40 | ///
41 | [ThriftProperty(2, PropertyTypes.String)]
42 | public byte[] RowKey { get; set; }
43 | ///
44 | /// Gets or sets HBase table's column families you want use.
45 | ///
46 | [ThriftProperty(3, PropertyTypes.List)]
47 | public Mutation[] Mutations { get; set; }
48 | ///
49 | /// Gets or sets HBase table's column families you want use.
50 | ///
51 | [ThriftProperty(4, PropertyTypes.Map)]
52 | public Dictionary Attributes { get; set; }
53 |
54 | #endregion
55 | }
56 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/InsertNewRowResponseMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// Response mesasge for inserting a new row into specified HBase table.
9 | ///
10 | public class InsertNewRowResponseMessage : ThriftMessage
11 | {
12 | #region Constructor.
13 |
14 | ///
15 | /// Request mesasge for inserting a new row into specified HBase table.
16 | ///
17 | public InsertNewRowResponseMessage()
18 | {
19 | uint version = VERSION_1 | (uint)(MessageTypes.Reply);
20 | Identity = new MessageIdentity
21 | {
22 | Command = "mutateRow",
23 | Version = (int)version
24 | };
25 | Identity.CommandLength = (uint) Identity.Command.Length;
26 | }
27 |
28 | #endregion
29 |
30 | #region Members.
31 |
32 | ///
33 | /// 获取或设置IO错误信息
34 | ///
35 | [ThriftProperty(1, PropertyTypes.String)]
36 | public IOError IOErrorMessage { get; set; }
37 | ///
38 | /// 获取或设置参数非法错误信息
39 | ///
40 | [ThriftProperty(2, PropertyTypes.String)]
41 | public IllegalArgumentError IllegalArgumentErrorMessage { get; set; }
42 |
43 | #endregion
44 |
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/InsertNewRowsRequestMessage.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Gridsum.NHBaseThrift.Attributes;
3 | using Gridsum.NHBaseThrift.Enums;
4 | using Gridsum.NHBaseThrift.Objects;
5 |
6 | namespace Gridsum.NHBaseThrift.Messages
7 | {
8 | ///
9 | /// 插入行集合请求
10 | ///
11 | public class InsertNewRowsRequestMessage : ThriftMessage
12 | {
13 | #region Constructor.
14 |
15 | ///
16 | /// 插入行集合请求
17 | ///
18 | public InsertNewRowsRequestMessage()
19 | {
20 | uint version = VERSION_1 | (uint)(MessageTypes.Call);
21 | Identity = new MessageIdentity
22 | {
23 | Command = "mutateRows",
24 | Version = (int)version
25 | };
26 | Identity.CommandLength = (uint) Identity.Command.Length;
27 | }
28 |
29 | #endregion
30 |
31 | #region Members.
32 |
33 | ///
34 | /// 获取或设置表名
35 | ///
36 | [ThriftProperty(1, PropertyTypes.String)]
37 | public string TableName { get; set; }
38 |
39 | ///
40 | /// 获取或设置行集合
41 | ///
42 | [ThriftProperty(2, PropertyTypes.List)]
43 | public BatchMutation[] RowBatch { get; set; }
44 |
45 | ///
46 | /// 获取或设置行集合属性
47 | ///
48 |
49 | [ThriftProperty(3, PropertyTypes.Map)]
50 | public Dictionary Attributes { get; set; }
51 |
52 | #endregion
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/InsertNewRowsResponseMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// 插入行集合应答
9 | ///
10 | public class InsertNewRowsResponseMessage : ThriftMessage
11 | {
12 | #region Constructor.
13 |
14 | ///
15 | /// 插入行集合应答
16 | ///
17 | public InsertNewRowsResponseMessage()
18 | {
19 | uint version = VERSION_1 | (uint)(MessageTypes.Reply);
20 | Identity = new MessageIdentity
21 | {
22 | Command = "mutateRows",
23 | Version = (int)version
24 | };
25 | Identity.CommandLength = (uint) Identity.Command.Length;
26 | }
27 |
28 | #endregion
29 |
30 | #region Members.
31 |
32 | ///
33 | /// 获取或设置IO错误信息
34 | ///
35 | [ThriftProperty(1, PropertyTypes.String)]
36 | public IOError IOErrorMessage { get; set; }
37 | ///
38 | /// 获取或设置参数非法错误信息
39 | ///
40 | [ThriftProperty(2, PropertyTypes.String)]
41 | public IllegalArgumentError IllegalArgumentErrorMessage { get; set; }
42 |
43 | #endregion
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/IsTableEnableRequestMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// 获取一个表是否已经启用的请求消息
9 | ///
10 | public class IsTableEnableRequestMessage : ThriftMessage
11 | {
12 | #region Constructor.
13 |
14 | ///
15 | /// 获取一个表所分布在HBase的区域范围请求消息
16 | ///
17 | public IsTableEnableRequestMessage()
18 | {
19 | uint version = VERSION_1 | (uint)(MessageTypes.Call);
20 | Identity = new MessageIdentity
21 | {
22 | Command = "isTableEnabled",
23 | Version = (int)version
24 | };
25 | Identity.CommandLength = (uint) Identity.Command.Length;
26 | }
27 |
28 | #endregion
29 |
30 | #region Members.
31 |
32 | ///
33 | /// 获取或设置表名
34 | ///
35 | [ThriftProperty(1, PropertyTypes.String)]
36 | public string TableName { get; set; }
37 |
38 | #endregion
39 | }
40 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/IsTableEnableResponseMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// 获取一个表是否已经启用的应答消息
9 | ///
10 | public class IsTableEnableResponseMessage : ThriftMessage
11 | {
12 | #region Constructor.
13 |
14 | ///
15 | /// 获取一个表所分布在HBase的区域范围应答消息
16 | ///
17 | public IsTableEnableResponseMessage()
18 | {
19 | uint version = VERSION_1 | (uint)(MessageTypes.Call);
20 | Identity = new MessageIdentity
21 | {
22 | Command = "isTableEnabled",
23 | Version = (int)version
24 | };
25 | Identity.CommandLength = (uint) Identity.Command.Length;
26 | }
27 |
28 | #endregion
29 |
30 | #region Members.
31 |
32 | ///
33 | /// 获取或设置表名
34 | ///
35 | [ThriftProperty(0, PropertyTypes.Bool)]
36 | public bool IsEnable { get; set; }
37 | ///
38 | /// 获取或设置IO错误信息
39 | ///
40 | [ThriftProperty(1, PropertyTypes.String)]
41 | public IOError IOErrorMessage { get; set; }
42 |
43 | #endregion
44 | }
45 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/ScannerCloseRequestMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// 回收Scanner资源请求
9 | ///
10 | public class ScannerCloseRequestMessage : ThriftMessage
11 | {
12 | #region Constructor.
13 |
14 | ///
15 | /// Request mesasge for close scanner command.
16 | ///
17 | public ScannerCloseRequestMessage()
18 | {
19 | uint version = VERSION_1 | (uint)(MessageTypes.Call);
20 | Identity = new MessageIdentity
21 | {
22 | Command = "scannerClose",
23 | Version = (int)version
24 | };
25 | Identity.CommandLength = (uint)Identity.Command.Length;
26 | }
27 |
28 | #endregion
29 |
30 | #region Members.
31 |
32 | ///
33 | /// 获取或设置ScannerID
34 | ///
35 | [ThriftProperty(1, PropertyTypes.I32)]
36 | public int ScannerId { get; set; }
37 |
38 | #endregion
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/ScannerCloseResponseMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// 回收Scanner资源应答
9 | ///
10 | public class ScannerCloseResponseMessage : ThriftMessage
11 | {
12 | #region Constructor.
13 |
14 | ///
15 | /// Request mesasge for close scanner command.
16 | ///
17 | public ScannerCloseResponseMessage()
18 | {
19 | uint version = VERSION_1 | (uint)(MessageTypes.Call);
20 | Identity = new MessageIdentity
21 | {
22 | Command = "scannerClose",
23 | Version = (int)version
24 | };
25 | Identity.CommandLength = (uint)Identity.Command.Length;
26 | }
27 |
28 | #endregion
29 |
30 | #region Members.
31 |
32 | ///
33 | /// 获取或设置IO错误信息
34 | ///
35 | [ThriftProperty(1, PropertyTypes.String)]
36 | public IOError IOErrorMessage { get; set; }
37 | ///
38 | /// 获取或设置参数非法错误信息
39 | ///
40 | [ThriftProperty(2, PropertyTypes.String)]
41 | public IllegalArgumentError IllegalArgumentErrorMessage { get; set; }
42 |
43 | #endregion
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/ScannerGetListRequestMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// 根据scanner获取一批数据请求
9 | ///
10 | public class ScannerGetListRequestMessage : ThriftMessage
11 | {
12 |
13 | #region Constructor.
14 |
15 | ///
16 | /// Request mesasge for scaning a row list.
17 | ///
18 | public ScannerGetListRequestMessage()
19 | {
20 | uint version = VERSION_1 | (uint)(MessageTypes.Call);
21 | Identity = new MessageIdentity
22 | {
23 | Command = "scannerGetList",
24 | Version = (int)version
25 | };
26 | Identity.CommandLength = (uint)Identity.Command.Length;
27 | }
28 |
29 | #endregion
30 |
31 | #region Members.
32 |
33 | ///
34 | /// Gets or sets scanner id you want to use.
35 | ///
36 | [ThriftProperty(1, PropertyTypes.I32)]
37 | public int Id { get; set; }
38 | ///
39 | /// Gets or sets rows count you want to get.
40 | ///
41 | [ThriftProperty(2, PropertyTypes.I32)]
42 | public int RowsCount { get; set; }
43 |
44 | #endregion
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/ScannerGetListResponseMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// 根据scanner获取一批数据请求
9 | ///
10 | public class ScannerGetListResponseMessage : ThriftMessage
11 | {
12 | #region Constructor.
13 |
14 | ///
15 | /// Request mesasge for scaning a row list.
16 | ///
17 | public ScannerGetListResponseMessage()
18 | {
19 | uint version = VERSION_1 | (uint)(MessageTypes.Call);
20 | Identity = new MessageIdentity
21 | {
22 | Command = "scannerGetList",
23 | Version = (int)version
24 | };
25 | Identity.CommandLength = (uint)Identity.Command.Length;
26 | }
27 |
28 | #endregion
29 |
30 | #region Members.
31 |
32 | ///
33 | /// 获取或设置行信息
34 | ///
35 | [ThriftProperty(0, PropertyTypes.List)]
36 | public RowInfo[] RowInfos { get; set; }
37 | ///
38 | /// 获取或设置IO错误信息
39 | ///
40 | [ThriftProperty(1, PropertyTypes.String)]
41 | public IOError IOErrorMessage { get; set; }
42 | ///
43 | /// 获取或设置参数非法错误信息
44 | ///
45 | [ThriftProperty(2, PropertyTypes.String)]
46 | public IllegalArgumentError IllegalArgumentErrorMessage { get; set; }
47 |
48 | #endregion
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/ScannerGetRequestMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// 根据scanner获取一批数据请求
9 | ///
10 | public class ScannerGetRequestMessage : ThriftMessage
11 | {
12 |
13 | #region Constructor.
14 |
15 | ///
16 | /// Request mesasge for scaning a row list.
17 | ///
18 | public ScannerGetRequestMessage()
19 | {
20 | uint version = VERSION_1 | (uint)(MessageTypes.Call);
21 | Identity = new MessageIdentity
22 | {
23 | Command = "scannerGet",
24 | Version = (int)version
25 | };
26 | Identity.CommandLength = (uint)Identity.Command.Length;
27 | }
28 |
29 | #endregion
30 |
31 | #region Members.
32 |
33 | ///
34 | /// Gets or sets scanner id you want to use.
35 | ///
36 | [ThriftProperty(1, PropertyTypes.I32)]
37 | public int Id { get; set; }
38 |
39 | #endregion
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/ScannerGetResponseMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// 根据scanner获取一批数据请求
9 | ///
10 | public class ScannerGetResponseMessage : ThriftMessage
11 | {
12 |
13 | #region Constructor.
14 |
15 | ///
16 | /// Request mesasge for scaning a row list.
17 | ///
18 | public ScannerGetResponseMessage()
19 | {
20 | uint version = VERSION_1 | (uint)(MessageTypes.Call);
21 | Identity = new MessageIdentity
22 | {
23 | Command = "scannerGet",
24 | Version = (int)version
25 | };
26 | Identity.CommandLength = (uint)Identity.Command.Length;
27 | }
28 |
29 | #endregion
30 |
31 | #region Members.
32 |
33 | ///
34 | /// 获取或设置行信息
35 | ///
36 | [ThriftProperty(0, PropertyTypes.List)]
37 | public RowInfo[] RowInfos { get; set; }
38 | ///
39 | /// 获取或设置IO错误信息
40 | ///
41 | [ThriftProperty(1, PropertyTypes.String)]
42 | public IOError IOErrorMessage { get; set; }
43 | ///
44 | /// 获取或设置参数非法错误信息
45 | ///
46 | [ThriftProperty(2, PropertyTypes.String)]
47 | public IllegalArgumentError IllegalArgumentErrorMessage { get; set; }
48 |
49 | #endregion
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/ScannerOpenWithStopRequestMessage.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Gridsum.NHBaseThrift.Attributes;
3 | using Gridsum.NHBaseThrift.Enums;
4 | using Gridsum.NHBaseThrift.Objects;
5 |
6 | namespace Gridsum.NHBaseThrift.Messages
7 | {
8 | ///
9 | /// Get a scanner on the current table starting and stopping at the specified rows.
10 | /// ending at the last row in the table. Return the specified columns.
11 | ///
12 | public class ScannerOpenWithStopRequestMessage : ThriftMessage
13 | {
14 | #region Constructor.
15 |
16 | ///
17 | /// Get a scanner on the current table starting and stopping at the specified rows.
18 | /// ending at the last row in the table. Return the specified columns.
19 | ///
20 | public ScannerOpenWithStopRequestMessage()
21 | {
22 | uint version = VERSION_1 | (uint)(MessageTypes.Call);
23 | Identity = new MessageIdentity
24 | {
25 | Command = "scannerOpenWithStop",
26 | Version = (int)version
27 | };
28 | Identity.CommandLength = (uint)Identity.Command.Length;
29 | }
30 |
31 | #endregion
32 |
33 | #region Members.
34 |
35 | ///
36 | /// 获取或设置表名
37 | ///
38 | [ThriftProperty(1, PropertyTypes.String)]
39 | public string TableName { get; set; }
40 |
41 | ///
42 | /// 获取或设置开始RowKey
43 | ///
44 | [ThriftProperty(2, PropertyTypes.String)]
45 | public byte[] StartRow { get; set; }
46 |
47 | ///
48 | /// 获取或设置终止RowKey
49 | ///
50 | [ThriftProperty(3, PropertyTypes.String)]
51 | public byte[] EndRow { get; set; }
52 |
53 | ///
54 | /// 获取或设置可选列名
55 | ///
56 | [ThriftProperty(4, PropertyTypes.List)]
57 | public string[] Columns { get; set; }
58 |
59 | ///
60 | /// 获取或设置Atrribute
61 | ///
62 | [ThriftProperty(5, PropertyTypes.Map)]
63 | public Dictionary Attribute { get; set; }
64 |
65 | #endregion
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/ScannerOpenWithStopResponseMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Enums;
3 | using Gridsum.NHBaseThrift.Objects;
4 |
5 | namespace Gridsum.NHBaseThrift.Messages
6 | {
7 | ///
8 | /// 按照RowKey范围查询数据应答
9 | ///
10 | public class ScannerOpenWithStopResponseMessage : ThriftMessage
11 | {
12 | #region Constructor.
13 |
14 | ///
15 | /// 按照RowKey范围查询数据应答
16 | ///
17 | public ScannerOpenWithStopResponseMessage()
18 | {
19 | uint version = VERSION_1 | (uint)(MessageTypes.Reply);
20 | Identity = new MessageIdentity
21 | {
22 | Command = "scannerOpenWithStop",
23 | Version = (int)version
24 | };
25 | Identity.CommandLength = (uint) Identity.Command.Length;
26 | }
27 |
28 | #endregion
29 |
30 | #region Members.
31 |
32 |
33 | ///
34 | /// 获取或设置表名
35 | ///
36 | [ThriftProperty(0, PropertyTypes.I32)]
37 | public int ScannerId { get; set; }
38 | ///
39 | /// 获取或设置IO错误信息
40 | ///
41 | [ThriftProperty(1, PropertyTypes.String)]
42 | public IOError IOErrorMessage { get; set; }
43 |
44 | #endregion
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/NHBaseThrift/Messages/ThriftMessage.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Contracts;
3 | using Gridsum.NHBaseThrift.Enums;
4 | using Gridsum.NHBaseThrift.Objects;
5 |
6 | namespace Gridsum.NHBaseThrift.Messages
7 | {
8 | ///
9 | /// Thrift network communication message.
10 | ///
11 | public class ThriftMessage : ThriftObject
12 | {
13 | #region Members.
14 |
15 | protected const uint VERSION_1 = 0x80010000;
16 |
17 | ///
18 | /// Gets current Thrift communication message's identity.
19 | ///
20 | [ThriftProperty(-1, PropertyTypes.Struct, false)]
21 | public MessageIdentity Identity { get; internal set; }
22 |
23 | #endregion
24 | }
25 | }
--------------------------------------------------------------------------------
/NHBaseThrift/NHBaseThrift.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Gridsum.NHBaseAPI
5 | $version$
6 | Gridsum.NHBaseAPI
7 | Kevin Yang,Zhishen Cui,Kexin Li
8 | Kevin Yang,Zhishen Cui,Kexin Li
9 | http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE
10 | http://PROJECT_URL_HERE_OR_DELETE_THIS_LINE
11 | http://ICON_URL_HERE_OR_DELETE_THIS_LINE
12 | false
13 | HBase .NET client library
14 | Hostmapping linux compatibility support
15 | Copyright 2015
16 | HBase Thrift
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/NHBaseThrift/Network/Agents/IClientConnectionAgent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Gridsum.NHBaseThrift.Messages;
3 | using Gridsum.NHBaseThrift.Network.Transactions;
4 | using KJFramework.EventArgs;
5 | using KJFramework.Net.Channels;
6 | using KJFramework.Net.Transaction;
7 |
8 | namespace Gridsum.NHBaseThrift.Network.Agents
9 | {
10 | ///
11 | /// 客户端代理器元接口
12 | ///
13 | public interface IThriftConnectionAgent : IConnectionAgent
14 | {
15 | ///
16 | /// 获取消息事务管理器
17 | ///
18 | ThriftMessageTransactionManager TransactionManager { get; }
19 | ///
20 | /// 获取内部的通信信道
21 | ///
22 | ///
23 | IMessageTransportChannel GetChannel();
24 | ///
25 | /// 创建一个新的事务
26 | ///
27 | /// 返回一个针对客户端的新事物
28 | ThriftMessageTransaction CreateTransaction();
29 | ///
30 | /// 新的事物创建被创建时激活此事件
31 | ///
32 | event EventHandler>> NewTransaction;
33 | }
34 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Network/Agents/IConnectionAgent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Gridsum.NHBaseThrift.Network.Agents
4 | {
5 | ///
6 | /// 连接代理器,提供了相关的基本操作
7 | ///
8 | public interface IConnectionAgent
9 | {
10 | ///
11 | /// 获取或设置附属属性
12 | ///
13 | Object Tag { get; set; }
14 | ///
15 | /// 主动关闭连接代理器
16 | /// * 主动关闭的行为将会关闭内部的通信信道连接
17 | ///
18 | void Close();
19 | ///
20 | /// 断开事件
21 | ///
22 | event EventHandler Disconnected;
23 | }
24 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Network/Agents/ThriftConnectionAgent.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gridsum/NHBaseAPI/d9c5a7f4af8b54555e497a20a587d0edc81a12a0/NHBaseThrift/Network/Agents/ThriftConnectionAgent.cs
--------------------------------------------------------------------------------
/NHBaseThrift/Network/NetworkDataCheckResult.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift.Network
2 | {
3 | ///
4 | /// 网络数据内部检查结果
5 | ///
6 | internal struct NetworkDataCheckResult
7 | {
8 | #region Members.
9 |
10 | ///
11 | /// 获取指定数据长度所涉及的内存片段个数
12 | ///
13 | public int SegmentCount;
14 |
15 | #endregion
16 | }
17 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Network/NetworkDataContainer.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gridsum/NHBaseAPI/d9c5a7f4af8b54555e497a20a587d0edc81a12a0/NHBaseThrift/Network/NetworkDataContainer.cs
--------------------------------------------------------------------------------
/NHBaseThrift/Network/RamdomConnectionSet.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net;
3 | using Gridsum.NHBaseThrift.Messages;
4 | using Gridsum.NHBaseThrift.Network.Agents;
5 | using KJFramework.Net.ProtocolStacks;
6 |
7 | namespace Gridsum.NHBaseThrift.Network
8 | {
9 | ///
10 | /// 支持随机算法的连接容器
11 | ///
12 | /// 存放的连接类型
13 | internal class RamdomConnectionSet : ConnectionSet
14 | {
15 | #region Constructor.
16 |
17 | ///
18 | /// 支持随机算法的连接容器
19 | ///
20 | /// 存放的连接类型
21 | public RamdomConnectionSet(int min, int max, Tuple, object> tuple, Func, object, IThriftConnectionAgent> createFunc)
22 | : base(min, max, tuple, createFunc)
23 | {
24 | }
25 |
26 | #endregion
27 |
28 | #region Methods.
29 |
30 | ///
31 | /// 返回一个当前连接容器中的存活连接
32 | ///
33 | ///
34 | public override IThriftConnectionAgent InnerGetConnection()
35 | {
36 | lock (_lockObj)
37 | {
38 | ushort value = (ushort) ((DateTime.Now.Ticks & 0x3FFF)%_connections.Count);
39 | return _connections[value];
40 | }
41 | }
42 |
43 | #endregion
44 | }
45 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Network/SequentialConnectionSet.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net;
3 | using Gridsum.NHBaseThrift.Messages;
4 | using Gridsum.NHBaseThrift.Network.Agents;
5 | using KJFramework.Net.ProtocolStacks;
6 |
7 | namespace Gridsum.NHBaseThrift.Network
8 | {
9 | ///
10 | /// 支持顺序算法的连接容器
11 | ///
12 | /// 存放的连接类型
13 | internal class SequentialConnectionSet : ConnectionSet
14 | {
15 | #region Constructor.
16 |
17 | ///
18 | /// 支持顺序算法的连接容器
19 | ///
20 | /// 存放的连接类型
21 | public SequentialConnectionSet(int min, int max, Tuple, object> tuple, Func, object, IThriftConnectionAgent> createFunc)
22 | : base(min, max, tuple, createFunc)
23 | {
24 | }
25 |
26 | #endregion
27 |
28 | #region Members.
29 |
30 | private int _sequenceIndex;
31 |
32 | #endregion
33 |
34 | ///
35 | /// 根据不同算法,获取一个当前连接容器中的存活连接
36 | ///
37 | /// 返回一个当前连接容器中的存活连接
38 | public override IThriftConnectionAgent InnerGetConnection()
39 | {
40 | lock (_lockObj)
41 | {
42 | if (_sequenceIndex < _connections.Count) return _connections[_sequenceIndex++];
43 | if (_connections.Count == 0) return null;
44 | return _connections[(_sequenceIndex = 0)];
45 | }
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Network/ThriftProtocolConnectionPool.cs:
--------------------------------------------------------------------------------
1 | using System.Net;
2 | using Gridsum.NHBaseThrift.Messages;
3 | using Gridsum.NHBaseThrift.Network.Agents;
4 | using Gridsum.NHBaseThrift.Network.Transactions;
5 | using KJFramework.Net.ProtocolStacks;
6 |
7 | namespace Gridsum.NHBaseThrift.Network
8 | {
9 | ///
10 | /// 系统连接池,仅供系统内部使用
11 | /// *key = xxxxxxx(IP):xxxxx(Port)
12 | /// *demo = 127.0.0.1:8588
13 | ///
14 | public class ThriftProtocolConnectionPool : ConnectionPool
15 | {
16 | #region Constructor.
17 |
18 | ///
19 | /// 系统连接池,仅供系统内部使用
20 | /// *key = xxxxxxx(IP):xxxxx(Port)
21 | /// *demo = 127.0.0.1:8588
22 | ///
23 | /// 最小连接数
24 | /// 最大连接数
25 | public ThriftProtocolConnectionPool(int minConnection, int maxConnection)
26 | : base(minConnection, maxConnection)
27 | {
28 |
29 | }
30 |
31 | #endregion
32 |
33 | #region Methods
34 |
35 | ///
36 | /// 获取具有指定标示的连接代理器,如果具有该条件的代理器不存在,则会创建一个新的代理器
37 | ///
38 | /// 连接标示
39 | /// 服务角色编号
40 | /// 连接所承载的协议栈
41 | /// 事务管理器
42 | /// 如果返回null, 则表示当前无法连接到目标远程终结点地址
43 | public IThriftConnectionAgent GetChannel(string key, string roleId, IProtocolStack protocolStack, ThriftMessageTransactionManager transactionManager)
44 | {
45 | string fullKey = string.Format("{0}#{1}", roleId, key);
46 | return base.GetChannel(key, fullKey, protocolStack, transactionManager);
47 | }
48 |
49 | ///
50 | /// 创建一个新的服务器端连接代理器,并将其注册到当前的连接池中
51 | ///
52 | /// 要创建连接的远程终结点地址
53 | /// 协议栈
54 | /// 网络事务管理器
55 | /// 返回已经创建好的服务器端连接代理器
56 | protected override IThriftConnectionAgent CreateAgent(IPEndPoint iep, IProtocolStack protocolStack, object transactionManager)
57 | {
58 | return ThriftConnectionAgent.Create(iep, protocolStack, (ThriftMessageTransactionManager)transactionManager);
59 | }
60 |
61 | #endregion
62 | }
63 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Network/ThriftSegmentNode.cs:
--------------------------------------------------------------------------------
1 | using KJFramework.Net.Channels.Events;
2 | using KJFramework.Net.Channels.Objects;
3 |
4 | namespace Gridsum.NHBaseThrift.Network
5 | {
6 | ///
7 | /// Thrift网络协议内部所使用的内存片段
8 | ///
9 | internal class ThriftSegmentNode : SegmentNode
10 | {
11 | #region Constructor.
12 |
13 | ///
14 | /// Thrift网络协议内部所使用的内存片段
15 | ///
16 | /// Socket接收到的内存片段
17 | public ThriftSegmentNode(SegmentReceiveEventArgs value)
18 | : base(value)
19 | {
20 | }
21 |
22 | #endregion
23 |
24 | #region Members.
25 |
26 | ///
27 | /// 获取或设置上一个节点
28 | ///
29 | public SegmentNode Previous { get; set; }
30 |
31 | #endregion
32 | }
33 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Objects/AlreadyExistsError.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Contracts;
3 | using Gridsum.NHBaseThrift.Enums;
4 |
5 | namespace Gridsum.NHBaseThrift.Objects
6 | {
7 | ///
8 | /// 已经存在资源的错误信息对象,来自于Thrift协议的RSP消息
9 | ///
10 | public class AlreadyExistsError : ThriftObject
11 | {
12 | #region Members.
13 |
14 | ///
15 | /// 获取或设置错误原因
16 | ///
17 | [ThriftProperty(1, PropertyTypes.String)]
18 | public string Reason { get; set; }
19 |
20 | #endregion
21 | }
22 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Objects/BatchMutation.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Contracts;
3 | using Gridsum.NHBaseThrift.Enums;
4 |
5 | namespace Gridsum.NHBaseThrift.Objects
6 | {
7 | ///
8 | /// BatchMutation
9 | ///
10 | public class BatchMutation : ThriftObject
11 | {
12 | #region Members.
13 |
14 | ///
15 | /// Gets or sets
16 | ///
17 | [ThriftProperty(1, PropertyTypes.String)]
18 | public byte[] RowKey { get; set; }
19 | ///
20 | /// Gets or sets
21 | ///
22 | [ThriftProperty(2, PropertyTypes.List)]
23 | public Mutation[] Mutations { get; set; }
24 |
25 | #endregion
26 | }
27 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Objects/Cell.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Contracts;
3 | using Gridsum.NHBaseThrift.Enums;
4 |
5 | namespace Gridsum.NHBaseThrift.Objects
6 | {
7 | ///
8 | /// Cell
9 | ///
10 | public class Cell : ThriftObject
11 | {
12 | #region Members.
13 |
14 | ///
15 | /// Gets or sets specified cell value.
16 | ///
17 | [ThriftProperty(1, PropertyTypes.String)]
18 | public byte[] Value { get; set; }
19 | ///
20 | /// Gets or sets timestamp.
21 | ///
22 | [ThriftProperty(2, PropertyTypes.I64)]
23 | public long Timestamp { get; set; }
24 |
25 | #endregion
26 | }
27 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Objects/Column.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Contracts;
3 | using Gridsum.NHBaseThrift.Enums;
4 |
5 | namespace Gridsum.NHBaseThrift.Objects
6 | {
7 | ///
8 | /// Column
9 | ///
10 | public class Column : ThriftObject
11 | {
12 | #region Members.
13 |
14 | ///
15 | /// Gets or sets column's name.
16 | ///
17 | [ThriftProperty(1, PropertyTypes.String)]
18 | public string Name { get; set; }
19 | ///
20 | /// Gets or sets cell information.
21 | ///
22 | [ThriftProperty(2, PropertyTypes.Struct)]
23 | public Cell Cell { get; set; }
24 |
25 | #endregion
26 | }
27 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Objects/ColumnDescriptor.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Contracts;
3 | using Gridsum.NHBaseThrift.Enums;
4 |
5 | namespace Gridsum.NHBaseThrift.Objects
6 | {
7 | ///
8 | /// Column Descriptor
9 | ///
10 | public class ColumnDescriptor : ThriftObject
11 | {
12 | #region Constructor.
13 |
14 | ///
15 | /// Column Descriptor
16 | ///
17 | public ColumnDescriptor()
18 | {
19 | MaxVersions = 3;
20 | Compression = "NONE";
21 | BloomFilterTypes = "NONE";
22 | TimeToLive = 0x7fffffff;
23 | }
24 |
25 | #endregion
26 |
27 | #region Members.
28 |
29 | ///
30 | /// Gets or sets column name
31 | ///
32 | [ThriftProperty(1, PropertyTypes.String)]
33 | public string Name { get; set; }
34 | ///
35 | /// Gets or sets MaxVersions
36 | ///
37 | [ThriftProperty(2, PropertyTypes.I32)]
38 | public int MaxVersions { get; set; }
39 | ///
40 | /// Gets or sets Compression
41 | ///
42 | [ThriftProperty(3, PropertyTypes.String)]
43 | public string Compression { get; set; }
44 | ///
45 | /// Gets or sets InMemory
46 | ///
47 | [ThriftProperty(4, PropertyTypes.Bool)]
48 | public bool InMemory { get; set; }
49 | ///
50 | /// Gets or sets BloomFilterTypes
51 | ///
52 | [ThriftProperty(5, PropertyTypes.String)]
53 | public string BloomFilterTypes { get; set; }
54 | ///
55 | /// Gets or sets BloomFilterVectorSize
56 | ///
57 | [ThriftProperty(6, PropertyTypes.I32)]
58 | public int BloomFilterVectorSize { get; set; }
59 | ///
60 | /// Gets or sets BloomFilterNbHashes
61 | ///
62 | [ThriftProperty(7, PropertyTypes.I32)]
63 | public int BloomFilterNbHashes { get; set; }
64 | ///
65 | /// Gets or sets BlockCacheEnabled
66 | ///
67 | [ThriftProperty(8, PropertyTypes.Bool)]
68 | public bool BlockCacheEnabled { get; set; }
69 | ///
70 | /// Gets or sets TimeToLive
71 | ///
72 | [ThriftProperty(9, PropertyTypes.I32)]
73 | public int TimeToLive { get; set; }
74 |
75 | #endregion
76 | }
77 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Objects/ColumnInfo.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift.Objects
2 | {
3 | ///
4 | /// 新数据列信息对象
5 | ///
6 | public class ColumnInfo
7 | {
8 | #region Members.
9 |
10 | ///
11 | /// 获取或设置列簇信息
12 | ///
13 | public string ColumnFamily { get; set; }
14 | ///
15 | /// 获取或设置列名
16 | ///
17 | public string ColumnName { get; set; }
18 | ///
19 | /// 获取或设置列值
20 | ///
21 | public byte[] Value { get; set; }
22 |
23 | #endregion
24 | }
25 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Objects/IOError.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Contracts;
3 | using Gridsum.NHBaseThrift.Enums;
4 |
5 | namespace Gridsum.NHBaseThrift.Objects
6 | {
7 | ///
8 | /// IO错误信息对象,来自于Thrift协议的RSP消息
9 | ///
10 | public class IOError : ThriftObject
11 | {
12 | #region Members.
13 |
14 | ///
15 | /// 获取或设置错误原因
16 | ///
17 | [ThriftProperty(1, PropertyTypes.String)]
18 | public string Reason { get; set; }
19 |
20 | #endregion
21 | }
22 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Objects/IllegalArgumentError.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Contracts;
3 | using Gridsum.NHBaseThrift.Enums;
4 |
5 | namespace Gridsum.NHBaseThrift.Objects
6 | {
7 | ///
8 | /// 参数错误信息对象,来自于Thrift协议的RSP消息
9 | ///
10 | public class IllegalArgumentError : ThriftObject
11 | {
12 | #region Members.
13 |
14 | ///
15 | /// 获取或设置错误原因
16 | ///
17 | [ThriftProperty(1, PropertyTypes.String)]
18 | public string Reason { get; set; }
19 |
20 | #endregion
21 | }
22 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Objects/MessageIdentity.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift.Objects
2 | {
3 | ///
4 | /// Thrift message head.
5 | ///
6 | ///
7 | /// Version | Command-Length | Command | Sequence-ID
8 | /// \-- 4 --/\--------- 4 -------/ \--- N ----/\------ 4 -----/
9 | ///
10 | public class MessageIdentity
11 | {
12 | #region Members.
13 |
14 | ///
15 | /// Gets or sets current applied Thrift protocol version.
16 | ///
17 | public int Version { get; set; }
18 | ///
19 | /// Gets or sets current Thrift protocol command total length.
20 | ///
21 | public uint CommandLength { get; set; }
22 | ///
23 | /// Gets or sets current used Thrift communication command.
24 | ///
25 | public string Command { get; set; }
26 | ///
27 | /// Gets or sets a automatically increments value that which indicated a unqiue message id on the same TCP connection.
28 | ///
29 | public uint SequenceId { get; set; }
30 |
31 | #endregion
32 |
33 | #region Methods.
34 |
35 | ///
36 | /// Returns a string that represents the current object.
37 | ///
38 | ///
39 | /// A string that represents the current object.
40 | ///
41 | /// 2
42 | public override string ToString()
43 | {
44 | return string.Format("(VER={0}, CMD-LEN={1}, CMD={2}, SEQID={3})", Version, CommandLength, Command, SequenceId);
45 | }
46 |
47 | #endregion
48 | }
49 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Objects/Mutation.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Contracts;
3 | using Gridsum.NHBaseThrift.Enums;
4 |
5 | namespace Gridsum.NHBaseThrift.Objects
6 | {
7 | ///
8 | /// 列对象
9 | ///
10 | public class Mutation : ThriftObject
11 | {
12 | #region Constructor.
13 |
14 | ///
15 | /// Mutation
16 | ///
17 | public Mutation()
18 | {
19 | WriteToWAL = true;
20 | }
21 |
22 | #endregion
23 |
24 | #region Members.
25 |
26 | ///
27 | /// Gets or sets IsDelete
28 | ///
29 | [ThriftProperty(1, PropertyTypes.Bool)]
30 | public bool IsDelete { get; set; }
31 | ///
32 | /// Gets or sets ColumnName
33 | ///
34 | [ThriftProperty(2, PropertyTypes.String)]
35 | public string ColumnName { get; set; }
36 | ///
37 | /// Gets or sets Value
38 | ///
39 | [ThriftProperty(3, PropertyTypes.String)]
40 | public byte[] Value { get; set; }
41 | ///
42 | /// Gets or sets WAL
43 | ///
44 | [ThriftProperty(4, PropertyTypes.Bool)]
45 | public bool WriteToWAL { get; set; }
46 |
47 | #endregion
48 | }
49 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Objects/Region.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Attributes;
2 | using Gridsum.NHBaseThrift.Contracts;
3 | using Gridsum.NHBaseThrift.Enums;
4 |
5 | namespace Gridsum.NHBaseThrift.Objects
6 | {
7 | ///
8 | /// 区域信息
9 | ///
10 | public class Region : ThriftObject
11 | {
12 | #region Members.
13 |
14 | ///
15 | /// 获取或设置行键开始数据
16 | ///
17 | [ThriftProperty(1, PropertyTypes.String)]
18 | public byte[] StartKey { get; set; }
19 | ///
20 | /// 获取或设置行键结束位置
21 | ///
22 | [ThriftProperty(2, PropertyTypes.String)]
23 | public byte[] EndKey { get; set; }
24 | ///
25 | /// 获取或设置编号信息
26 | ///
27 | [ThriftProperty(3, PropertyTypes.I64)]
28 | public long Id { get; set; }
29 | ///
30 | /// 获取或设置名称
31 | ///
32 | [ThriftProperty(4, PropertyTypes.String)]
33 | public string Name { get; set; }
34 | ///
35 | /// 获取或设置版本信息
36 | ///
37 | [ThriftProperty(5, PropertyTypes.Byte)]
38 | public byte Version { get; set; }
39 | ///
40 | /// 获取或设置服务器名称
41 | ///
42 | [ThriftProperty(6, PropertyTypes.String)]
43 | public string ServerName { get; set; }
44 | ///
45 | /// 获取或设置服务器通信端口
46 | ///
47 | [ThriftProperty(7, PropertyTypes.I32)]
48 | public int Port { get; set; }
49 |
50 | #endregion
51 | }
52 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Objects/RowInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Gridsum.NHBaseThrift.Attributes;
3 | using Gridsum.NHBaseThrift.Contracts;
4 | using Gridsum.NHBaseThrift.Enums;
5 |
6 | namespace Gridsum.NHBaseThrift.Objects
7 | {
8 | ///
9 | /// Row info
10 | ///
11 | public class RowInfo : ThriftObject
12 | {
13 | #region Members.
14 |
15 | ///
16 | /// 获取或设置行键
17 | ///
18 | [ThriftProperty(1, PropertyTypes.String)]
19 | public byte[] RowKey { get; set; }
20 | ///
21 | /// 获取或设置列信息
22 | ///
23 | [ThriftProperty(2, PropertyTypes.Map)]
24 | public Dictionary Columns { get; set; }
25 | ///
26 | /// 获取或设置有序列信息
27 | ///
28 | [ThriftProperty(3, PropertyTypes.List)]
29 | public Column[] SortedColumns { get; set; }
30 |
31 | #endregion
32 | }
33 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的常规信息通过以下
6 | // 特性集控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Gridsum.NHBaseThrift")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Gridsum")]
12 | [assembly: AssemblyProduct("NHBaseAPI")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 | [assembly: InternalsVisibleTo("NHBaseThrift.UnitTests")]
17 |
18 | // 将 ComVisible 设置为 false 使此程序集中的类型
19 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
20 | // 则将该类型上的 ComVisible 特性设置为 true。
21 | [assembly: ComVisible(false)]
22 |
23 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
24 | [assembly: Guid("e710acb6-5205-4623-9fea-e5f9752ffd7b")]
25 |
26 | // 程序集的版本信息由下面四个值组成:
27 | //
28 | // 主版本
29 | // 次版本
30 | // 生成号
31 | // 修订号
32 | //
33 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
34 | // 方法是按如下所示使用“*”:
35 | // [assembly: AssemblyVersion("1.0.*")]
36 | [assembly: AssemblyVersion("1.0.3.1")]
37 | [assembly: AssemblyFileVersion("1.0.3.1")]
38 |
--------------------------------------------------------------------------------
/NHBaseThrift/Proxies/IMemorySegmentProxy.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gridsum/NHBaseAPI/d9c5a7f4af8b54555e497a20a587d0edc81a12a0/NHBaseThrift/Proxies/IMemorySegmentProxy.cs
--------------------------------------------------------------------------------
/NHBaseThrift/Proxies/MemoryPosition.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | namespace Gridsum.NHBaseThrift.Proxies
4 | {
5 | ///
6 | /// 内存位置基础结构
7 | ///
8 | [StructLayout(LayoutKind.Sequential)]
9 | public struct MemoryPosition
10 | {
11 | #region Constructor
12 |
13 | ///
14 | /// 内存位置基础结构
15 | ///
16 | /// 内存片段索引
17 | /// 内存片段偏移
18 | public MemoryPosition(int index, uint offset)
19 | {
20 | SegmentIndex = index;
21 | SegmentOffset = offset;
22 | }
23 |
24 | #endregion
25 |
26 | #region Members
27 |
28 | ///
29 | /// 内存片段索引
30 | ///
31 | public int SegmentIndex;
32 | ///
33 | /// 内存片段偏移
34 | ///
35 | public uint SegmentOffset;
36 |
37 | #endregion
38 |
39 | #region Methods
40 |
41 | ///
42 | /// 计算截止位置与开始位置之间的距离
43 | ///
44 | /// 内存段数量
45 | /// 起始位置
46 | /// 截止位置
47 | /// 返回它们之间所差的距离
48 | public static int CalcLength(int segmentCount, MemoryPosition start, MemoryPosition end)
49 | {
50 | return (int) (((end.SegmentIndex)*ThriftProtocolMemoryAllotter.SegmentSize + end.SegmentOffset) -
51 | ((start.SegmentIndex)*ThriftProtocolMemoryAllotter.SegmentSize + start.SegmentOffset));
52 | }
53 |
54 | #endregion
55 | }
56 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Proxies/MemorySegment.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gridsum/NHBaseAPI/d9c5a7f4af8b54555e497a20a587d0edc81a12a0/NHBaseThrift/Proxies/MemorySegment.cs
--------------------------------------------------------------------------------
/NHBaseThrift/Proxies/MemorySegmentProxy.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gridsum/NHBaseAPI/d9c5a7f4af8b54555e497a20a587d0edc81a12a0/NHBaseThrift/Proxies/MemorySegmentProxy.cs
--------------------------------------------------------------------------------
/NHBaseThrift/Proxies/MemorySegmentProxyFactory.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift.Proxies
2 | {
3 | ///
4 | /// 内存段代理器工厂
5 | ///
6 | public static class MemorySegmentProxyFactory
7 | {
8 | #region Methods
9 |
10 | ///
11 | /// 创建一个新的内存段代理器
12 | ///
13 | /// 返回
14 | public static IMemorySegmentProxy Create()
15 | {
16 | return new MemorySegmentProxy();
17 | }
18 |
19 | #endregion
20 | }
21 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Proxies/Size.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Gridsum.NHBaseThrift.Proxies
4 | {
5 | ///
6 | /// 内部用来保存每一个数据类型大小的容器
7 | ///
8 | internal static class Size
9 | {
10 | public const uint Bool = sizeof (bool);
11 | public const uint Char = sizeof (char);
12 | public const uint Byte = sizeof (byte);
13 | public const uint SByte = sizeof (sbyte);
14 | public const uint Decimal = sizeof (decimal);
15 | public const uint Int16 = sizeof (short);
16 | public const uint UInt16 = sizeof (ushort);
17 | public const uint Float = sizeof (float);
18 | public const uint Int32 = sizeof (int);
19 | public const uint UInt32 = sizeof (uint);
20 | public const uint UInt64 = sizeof (ulong);
21 | public const uint Int64 = sizeof (long);
22 | public const uint Double = sizeof (double);
23 | public const uint DateTime = sizeof (long);
24 | public const uint IntPtr = sizeof (int);
25 | public static readonly unsafe uint Guid = (uint) sizeof(Guid);
26 | public const uint BitFlag = 1;
27 | public const uint IPEndPoint = sizeof (long) + sizeof (int);
28 | public static readonly unsafe uint TimeSpan = (uint) sizeof (TimeSpan);
29 | }
30 | }
--------------------------------------------------------------------------------
/NHBaseThrift/RegionInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Net;
2 | using Gridsum.NHBaseThrift.Comparator;
3 | using Gridsum.NHBaseThrift.Enums;
4 |
5 | namespace Gridsum.NHBaseThrift
6 | {
7 | ///
8 | /// 业务对象,用于存储远程Region服务器信息
9 | ///
10 | internal class RegionInfo
11 | {
12 | #region Members.
13 |
14 | ///
15 | /// 获取或设置行键开始数据
16 | ///
17 | public byte[] StartKey { get; set; }
18 | ///
19 | /// 获取或设置行键结束位置
20 | ///
21 | public byte[] EndKey { get; set; }
22 | ///
23 | /// 获取或设置编号信息
24 | ///
25 | public long Id { get; set; }
26 | ///
27 | /// 获取或设置名称
28 | ///
29 | public string Name { get; set; }
30 | ///
31 | /// 获取或设置版本信息
32 | ///
33 | public byte Version { get; set; }
34 | ///
35 | /// 获取或设置远程服务器地址
36 | ///
37 | public IPEndPoint Address { get; set; }
38 | ///
39 | /// 获取或设置字符数组比较器
40 | ///
41 | public IByteArrayComparator Comparator { get; set; }
42 |
43 | #endregion
44 |
45 | #region Methods.
46 |
47 | ///
48 | /// 检查指定行键是否符合当前RegionServer的范围
49 | ///
50 | /// 行键
51 | /// 如果返回True, 则证明传入的行键符合当前的RegionServer数据分布范围
52 | public bool IsMatch(byte[] rowKey)
53 | {
54 | if ((StartKey == null || StartKey.Length == 0) && (EndKey == null || EndKey.Length == 0)) return true;
55 | if ((EndKey == null || EndKey.Length == 0) && ((Comparator.Compare(StartKey, rowKey) == CompareResult.Lt) || (Comparator.Compare(StartKey, rowKey) == CompareResult.Eq))) return true;
56 | if ((StartKey == null || StartKey.Length == 0) && ((Comparator.Compare(EndKey, rowKey) == CompareResult.Gt) || (Comparator.Compare(EndKey, rowKey) == CompareResult.Eq))) return true;
57 | if (((Comparator.Compare(EndKey, rowKey) == CompareResult.Gt) || (Comparator.Compare(EndKey, rowKey) == CompareResult.Eq)) &&
58 | ((Comparator.Compare(StartKey, rowKey) == CompareResult.Lt) || (Comparator.Compare(StartKey, rowKey) == CompareResult.Eq)))
59 | return true;
60 | return false;
61 | }
62 |
63 | #endregion
64 | }
65 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Stubs/IPropertySetStub.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | namespace Gridsum.NHBaseThrift.Stubs
4 | {
5 | ///
6 | /// 字段处理器存根接口
7 | ///
8 | public interface IPropertySetStub
9 | {
10 | #region Methods.
11 |
12 | ///
13 | /// 初始化
14 | ///
15 | /// 字段GetGet method
16 | void Initialize(MethodInfo method);
17 |
18 | ///
19 | /// 设置字段值
20 | ///
21 | /// 字段类型
22 | /// 字段所属类实例
23 | /// 字段的值
24 | /// 返回字段值
25 | void Set(object target, T value);
26 |
27 | #endregion
28 | }
29 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Stubs/IPropertyStub.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | namespace Gridsum.NHBaseThrift.Stubs
4 | {
5 | ///
6 | /// 字段处理器存根接口
7 | ///
8 | public interface IPropertyStub
9 | {
10 | #region Methods.
11 |
12 | ///
13 | /// 初始化
14 | ///
15 | /// 字段GetGet method
16 | void Initialize(MethodInfo method);
17 | ///
18 | /// 获取字段值
19 | ///
20 | /// 字段类型
21 | /// 字段所属类实例
22 | /// 返回字段值
23 | T Get(object target);
24 |
25 | #endregion
26 | }
27 | }
--------------------------------------------------------------------------------
/NHBaseThrift/Stubs/VT.cs:
--------------------------------------------------------------------------------
1 | namespace Gridsum.NHBaseThrift.Stubs
2 | {
3 | ///
4 | /// 固定字节类型的基础支持
5 | ///
6 | public class VT
7 | {
8 | ///
9 | /// 获取或设置固定字节数
10 | ///
11 | public int Size { get; set; }
12 | }
13 | }
--------------------------------------------------------------------------------
/NHBaseThrift/TypeProcessors/BoolThriftTypeProcessor.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gridsum/NHBaseAPI/d9c5a7f4af8b54555e497a20a587d0edc81a12a0/NHBaseThrift/TypeProcessors/BoolThriftTypeProcessor.cs
--------------------------------------------------------------------------------
/NHBaseThrift/TypeProcessors/ByteArrayThriftTypeProcessor.cs:
--------------------------------------------------------------------------------
1 | using Gridsum.NHBaseThrift.Analyzing;
2 | using Gridsum.NHBaseThrift.Attributes;
3 | using Gridsum.NHBaseThrift.Enums;
4 | using Gridsum.NHBaseThrift.Helpers;
5 | using Gridsum.NHBaseThrift.Network;
6 | using Gridsum.NHBaseThrift.Proxies;
7 |
8 | namespace Gridsum.NHBaseThrift.TypeProcessors
9 | {
10 | ///
11 | /// 字节数组类型Thrift协议字段处理器,提供了相关的基本操作
12 | ///
13 | public class ByteArrayThriftTypeProcessor : ThriftTypeProcessor
14 | {
15 | #region Constructor.
16 |
17 | ///
18 | /// 字节数组类型Thrift协议字段处理器,提供了相关的基本操作
19 | ///
20 | public ByteArrayThriftTypeProcessor()
21 | {
22 | _supportedType = typeof(byte[]);
23 | _expectedDataSize = -1;
24 | }
25 |
26 | #endregion
27 |
28 | #region Overrides of IntellectTypeProcessor
29 |
30 | ///
31 | /// 从第三方客户数据转换为元数据
32 | ///
33 | /// 内存片段代理器
34 | /// 字段属性
35 | /// 分析结果
36 | /// 目标对象实例
37 | /// 当前写入的值是否为数组元素标示
38 | public override void Process(IMemorySegmentProxy proxy, ThriftPropertyAttribute attribute, ToBytesAnalyseResult analyseResult, object target, bool isArrayElement = false, bool isNullable = false)
39 | {
40 | byte[] value = analyseResult.GetValue(target);
41 | proxy.WriteSByte((sbyte)attribute.PropertyType);
42 | proxy.WriteInt16(attribute.Id.ToBigEndian());
43 |
44 | //proxy.WriteByte((byte)PropertyTypes.String);
45 | proxy.WriteInt32(value.Length.ToBigEndian());
46 | proxy.WriteMemory(value, 0, (uint) value.Length);
47 | }
48 |
49 | ///
50 | /// 从元数据转换为第三方客户数据
51 | ///
52 | /// 目标对象
53 | /// 分析结果
54 | /// 网络数据容器
55 | public override GetObjectResultTypes Process(object instance, GetObjectAnalyseResult result, INetworkDataContainer container)
56 | {
57 | int count;
58 | if (!container.TryReadInt32(out count)) return GetObjectResultTypes.NotEnoughData;
59 | count = count.ToLittleEndian();
60 | byte[] value;
61 | if (!container.TryReadBinaryData(count, out value)) return GetObjectResultTypes.NotEnoughData;
62 | result.SetValue(instance, value);
63 | return GetObjectResultTypes.Succeed;
64 | }
65 |
66 | #endregion
67 | }
68 | }
--------------------------------------------------------------------------------
/NHBaseThrift/TypeProcessors/ByteThriftTypeProcessor.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gridsum/NHBaseAPI/d9c5a7f4af8b54555e497a20a587d0edc81a12a0/NHBaseThrift/TypeProcessors/ByteThriftTypeProcessor.cs
--------------------------------------------------------------------------------
/NHBaseThrift/TypeProcessors/IThriftTypeProcessor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Gridsum.NHBaseThrift.Analyzing;
3 | using Gridsum.NHBaseThrift.Attributes;
4 | using Gridsum.NHBaseThrift.Enums;
5 | using Gridsum.NHBaseThrift.Network;
6 | using Gridsum.NHBaseThrift.Proxies;
7 |
8 | namespace Gridsum.NHBaseThrift.TypeProcessors
9 | {
10 | ///
11 | /// Thrift协议中所使用类型的处理器
12 | ///
13 | public interface IThriftTypeProcessor
14 | {
15 | #region Members.
16 |
17 | ///
18 | /// 获取支持的类型
19 | ///
20 | Type SupportedType { get; }
21 | ///
22 | /// 获取一个值,该值标示了当从原始byte数组解析成为此类型时所期望传入的最小可用数据长度
23 | /// * 如果是动态的则设置 -1即可
24 | ///
25 | int ExpectedDataSize { get; }
26 |
27 | #endregion
28 |
29 | #region Methods.
30 |
31 | ///
32 | /// 从第三方客户数据转换为元数据
33 | ///
34 | /// 内存片段代理器
35 | /// 字段属性
36 | /// 分析结果
37 | /// 目标对象实例
38 | /// 当前写入的值是否为数组元素标示
39 | /// 是否为可空字段标示
40 | void Process(IMemorySegmentProxy proxy, ThriftPropertyAttribute attribute, ToBytesAnalyseResult analyseResult, object target, bool isArrayElement = false, bool isNullable = false);
41 | ///
42 | /// 从元数据转换为第三方客户数据
43 | ///
44 | /// 目标对象
45 | /// 分析结果
46 | /// 网络数据容器
47 | GetObjectResultTypes Process(object instance, GetObjectAnalyseResult result, INetworkDataContainer container);
48 | ///
49 | /// 尝试检查一下当前所需要解析的数据可用长度是否满足此类型的解析需求
50 | /// * 此方法只有当ExpectedDataSize = -1时才会被调用
51 | ///
52 | /// 网络数据容器
53 | ///
54 | bool HasEnoughData(INetworkDataContainer container);
55 |
56 | #endregion
57 | }
58 | }
--------------------------------------------------------------------------------
/NHBaseThrift/TypeProcessors/Int16ThriftTypeProcessor.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gridsum/NHBaseAPI/d9c5a7f4af8b54555e497a20a587d0edc81a12a0/NHBaseThrift/TypeProcessors/Int16ThriftTypeProcessor.cs
--------------------------------------------------------------------------------
/NHBaseThrift/TypeProcessors/Int32ThriftTypeProcessor.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gridsum/NHBaseAPI/d9c5a7f4af8b54555e497a20a587d0edc81a12a0/NHBaseThrift/TypeProcessors/Int32ThriftTypeProcessor.cs
--------------------------------------------------------------------------------
/NHBaseThrift/TypeProcessors/Int64ThriftTypeProcessor.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gridsum/NHBaseAPI/d9c5a7f4af8b54555e497a20a587d0edc81a12a0/NHBaseThrift/TypeProcessors/Int64ThriftTypeProcessor.cs
--------------------------------------------------------------------------------
/NHBaseThrift/TypeProcessors/Maps/ArrayTypeProcessorMapping.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gridsum/NHBaseAPI/d9c5a7f4af8b54555e497a20a587d0edc81a12a0/NHBaseThrift/TypeProcessors/Maps/ArrayTypeProcessorMapping.cs
--------------------------------------------------------------------------------
/NHBaseThrift/TypeProcessors/Maps/ThriftTypeProcessorMapping.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gridsum/NHBaseAPI/d9c5a7f4af8b54555e497a20a587d0edc81a12a0/NHBaseThrift/TypeProcessors/Maps/ThriftTypeProcessorMapping.cs
--------------------------------------------------------------------------------
/NHBaseThrift/TypeProcessors/MessageIdentityTypeProcessor.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gridsum/NHBaseAPI/d9c5a7f4af8b54555e497a20a587d0edc81a12a0/NHBaseThrift/TypeProcessors/MessageIdentityTypeProcessor.cs
--------------------------------------------------------------------------------
/NHBaseThrift/TypeProcessors/StringArrayThriftTypeProcessor.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 | using Gridsum.NHBaseThrift.Analyzing;
3 | using Gridsum.NHBaseThrift.Attributes;
4 | using Gridsum.NHBaseThrift.Enums;
5 | using Gridsum.NHBaseThrift.Helpers;
6 | using Gridsum.NHBaseThrift.Network;
7 | using Gridsum.NHBaseThrift.Proxies;
8 |
9 | namespace Gridsum.NHBaseThrift.TypeProcessors
10 | {
11 | ///
12 | /// String数组类型Thrift协议字段处理器,提供了相关的基本操作
13 | ///
14 | public class StringArrayThriftTypeProcessor : ThriftTypeProcessor
15 | {
16 | #region Constructor.
17 |
18 | ///
19 | /// String数组类型Thrift协议字段处理器,提供了相关的基本操作
20 | ///
21 | public StringArrayThriftTypeProcessor()
22 | {
23 | _supportedType = typeof(string[]);
24 | _expectedDataSize = -1;
25 | }
26 |
27 | #endregion
28 |
29 | #region Overrides of IntellectTypeProcessor
30 |
31 | ///
32 | /// 从第三方客户数据转换为元数据
33 | ///
34 | /// 内存片段代理器
35 | /// 字段属性
36 | /// 分析结果
37 | /// 目标对象实例
38 | /// 当前写入的值是否为数组元素标示
39 | public override void Process(IMemorySegmentProxy proxy, ThriftPropertyAttribute attribute, ToBytesAnalyseResult analyseResult, object target, bool isArrayElement = false, bool isNullable = false)
40 | {
41 | string[] value = analyseResult.GetValue(target);
42 | proxy.WriteSByte((sbyte)attribute.PropertyType);
43 | proxy.WriteInt16(attribute.Id.ToBigEndian());
44 |
45 | proxy.WriteByte((byte)PropertyTypes.String);
46 | proxy.WriteInt32(value.Length.ToBigEndian());
47 | foreach (string data in value)
48 | {
49 | byte[] bytes = Encoding.UTF8.GetBytes(data);
50 | proxy.WriteInt32(bytes.Length.ToBigEndian());
51 | proxy.WriteMemory(bytes, 0, (uint)data.Length);
52 | }
53 | }
54 |
55 | ///
56 | /// 从元数据转换为第三方客户数据
57 | ///
58 | /// 目标对象
59 | /// 分析结果
60 | /// 网络数据容器
61 | public override GetObjectResultTypes Process(object instance, GetObjectAnalyseResult result, INetworkDataContainer container)
62 | {
63 | byte type;
64 | int count;
65 | if (!container.TryReadByte(out type)) return GetObjectResultTypes.NotEnoughData;
66 | if (!container.TryReadInt32(out count)) return GetObjectResultTypes.NotEnoughData;
67 | count = count.ToLittleEndian();
68 | string[] value = new string[count];
69 | for (int i = 0; i < count; i++)
70 | {
71 | int length;
72 | if (!container.TryReadInt32(out length)) return GetObjectResultTypes.NotEnoughData;
73 | length = length.ToLittleEndian();
74 | string content;
75 | if (!container.TryReadString(Encoding.UTF8, length, out content)) return GetObjectResultTypes.NotEnoughData;
76 | value[i] = content;
77 | }
78 | result.SetValue(instance, value);
79 | return GetObjectResultTypes.Succeed;
80 | }
81 |
82 | #endregion
83 | }
84 | }
--------------------------------------------------------------------------------
/NHBaseThrift/TypeProcessors/StringThriftTypeProcessor.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gridsum/NHBaseAPI/d9c5a7f4af8b54555e497a20a587d0edc81a12a0/NHBaseThrift/TypeProcessors/StringThriftTypeProcessor.cs
--------------------------------------------------------------------------------
/NHBaseThrift/TypeProcessors/ThriftTypeProcessor.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gridsum/NHBaseAPI/d9c5a7f4af8b54555e497a20a587d0edc81a12a0/NHBaseThrift/TypeProcessors/ThriftTypeProcessor.cs
--------------------------------------------------------------------------------
/NHBaseThrift/ZooKeeperWatcher.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using ZooKeeperNet;
3 |
4 | namespace Gridsum.NHBaseThrift
5 | {
6 | ///
7 | /// ZooKeeper所使用的通知观察器
8 | ///
9 | public class ZooKeeperWatcher : IWatcher
10 | {
11 | #region Constructor.
12 |
13 | ///
14 | /// ZooKeeper所使用的通知观察器
15 | ///
16 | public ZooKeeperWatcher(Action callback)
17 | {
18 | if(callback == null) throw new ArgumentNullException("callback");
19 | _callback = callback;
20 | }
21 |
22 | #endregion
23 |
24 | #region Members.
25 |
26 | private readonly Action _callback;
27 |
28 | #endregion
29 |
30 | #region Methods.
31 |
32 | ///
33 | /// 通知
34 | ///
35 | /// 被观察的事件
36 | public void Process(WatchedEvent watchedEvent)
37 | {
38 | _callback(watchedEvent);
39 | }
40 |
41 | #endregion
42 | }
43 | }
--------------------------------------------------------------------------------
/NHBaseThrift/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/NHBaseThrift/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Original/IThrift/AlreadyExists.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Autogenerated by Thrift Compiler (0.9.2)
3 | *
4 | * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5 | * @generated
6 | */
7 | using System;
8 | using System.Collections;
9 | using System.Collections.Generic;
10 | using System.Text;
11 | using System.IO;
12 | using Thrift;
13 | using Thrift.Collections;
14 | using System.Runtime.Serialization;
15 | using Thrift.Protocol;
16 | using Thrift.Transport;
17 |
18 |
19 | ///
20 | /// An AlreadyExists exceptions signals that a table with the specified
21 | /// name already exists
22 | ///
23 | #if !SILVERLIGHT
24 | [Serializable]
25 | #endif
26 | public partial class AlreadyExists : TException, TBase
27 | {
28 | private string _message;
29 |
30 | public string Message
31 | {
32 | get
33 | {
34 | return _message;
35 | }
36 | set
37 | {
38 | __isset.message = true;
39 | this._message = value;
40 | }
41 | }
42 |
43 |
44 | public Isset __isset;
45 | #if !SILVERLIGHT
46 | [Serializable]
47 | #endif
48 | public struct Isset {
49 | public bool message;
50 | }
51 |
52 | public AlreadyExists() {
53 | }
54 |
55 | public void Read (TProtocol iprot)
56 | {
57 | TField field;
58 | iprot.ReadStructBegin();
59 | while (true)
60 | {
61 | field = iprot.ReadFieldBegin();
62 | if (field.Type == TType.Stop) {
63 | break;
64 | }
65 | switch (field.ID)
66 | {
67 | case 1:
68 | if (field.Type == TType.String) {
69 | Message = iprot.ReadString();
70 | } else {
71 | TProtocolUtil.Skip(iprot, field.Type);
72 | }
73 | break;
74 | default:
75 | TProtocolUtil.Skip(iprot, field.Type);
76 | break;
77 | }
78 | iprot.ReadFieldEnd();
79 | }
80 | iprot.ReadStructEnd();
81 | }
82 |
83 | public void Write(TProtocol oprot) {
84 | TStruct struc = new TStruct("AlreadyExists");
85 | oprot.WriteStructBegin(struc);
86 | TField field = new TField();
87 | if (Message != null && __isset.message) {
88 | field.Name = "message";
89 | field.Type = TType.String;
90 | field.ID = 1;
91 | oprot.WriteFieldBegin(field);
92 | oprot.WriteString(Message);
93 | oprot.WriteFieldEnd();
94 | }
95 | oprot.WriteFieldStop();
96 | oprot.WriteStructEnd();
97 | }
98 |
99 | public override string ToString() {
100 | StringBuilder __sb = new StringBuilder("AlreadyExists(");
101 | bool __first = true;
102 | if (Message != null && __isset.message) {
103 | if(!__first) { __sb.Append(", "); }
104 | __first = false;
105 | __sb.Append("Message: ");
106 | __sb.Append(Message);
107 | }
108 | __sb.Append(")");
109 | return __sb.ToString();
110 | }
111 |
112 | }
113 |
114 |
--------------------------------------------------------------------------------
/Original/IThrift/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Original/IThrift/IOError.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Autogenerated by Thrift Compiler (0.9.2)
3 | *
4 | * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5 | * @generated
6 | */
7 | using System;
8 | using System.Collections;
9 | using System.Collections.Generic;
10 | using System.Text;
11 | using System.IO;
12 | using Thrift;
13 | using Thrift.Collections;
14 | using System.Runtime.Serialization;
15 | using Thrift.Protocol;
16 | using Thrift.Transport;
17 |
18 |
19 | ///
20 | /// An IOError exception signals that an error occurred communicating
21 | /// to the Hbase master or an Hbase region server. Also used to return
22 | /// more general Hbase error conditions.
23 | ///
24 | #if !SILVERLIGHT
25 | [Serializable]
26 | #endif
27 | public partial class IOError : TException, TBase
28 | {
29 | private string _message;
30 |
31 | public string Message
32 | {
33 | get
34 | {
35 | return _message;
36 | }
37 | set
38 | {
39 | __isset.message = true;
40 | this._message = value;
41 | }
42 | }
43 |
44 |
45 | public Isset __isset;
46 | #if !SILVERLIGHT
47 | [Serializable]
48 | #endif
49 | public struct Isset {
50 | public bool message;
51 | }
52 |
53 | public IOError() {
54 | }
55 |
56 | public void Read (TProtocol iprot)
57 | {
58 | TField field;
59 | iprot.ReadStructBegin();
60 | while (true)
61 | {
62 | field = iprot.ReadFieldBegin();
63 | if (field.Type == TType.Stop) {
64 | break;
65 | }
66 | switch (field.ID)
67 | {
68 | case 1:
69 | if (field.Type == TType.String) {
70 | Message = iprot.ReadString();
71 | } else {
72 | TProtocolUtil.Skip(iprot, field.Type);
73 | }
74 | break;
75 | default:
76 | TProtocolUtil.Skip(iprot, field.Type);
77 | break;
78 | }
79 | iprot.ReadFieldEnd();
80 | }
81 | iprot.ReadStructEnd();
82 | }
83 |
84 | public void Write(TProtocol oprot) {
85 | TStruct struc = new TStruct("IOError");
86 | oprot.WriteStructBegin(struc);
87 | TField field = new TField();
88 | if (Message != null && __isset.message) {
89 | field.Name = "message";
90 | field.Type = TType.String;
91 | field.ID = 1;
92 | oprot.WriteFieldBegin(field);
93 | oprot.WriteString(Message);
94 | oprot.WriteFieldEnd();
95 | }
96 | oprot.WriteFieldStop();
97 | oprot.WriteStructEnd();
98 | }
99 |
100 | public override string ToString() {
101 | StringBuilder __sb = new StringBuilder("IOError(");
102 | bool __first = true;
103 | if (Message != null && __isset.message) {
104 | if(!__first) { __sb.Append(", "); }
105 | __first = false;
106 | __sb.Append("Message: ");
107 | __sb.Append(Message);
108 | }
109 | __sb.Append(")");
110 | return __sb.ToString();
111 | }
112 |
113 | }
114 |
115 |
--------------------------------------------------------------------------------
/Original/IThrift/IThrift.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {CC1EBC28-692E-4652-A794-AF07439EDEB4}
8 | Exe
9 | Properties
10 | IThrift
11 | IThrift
12 | v4.5
13 | 512
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 | {499eb63c-d74c-47e8-ae48-a2fc94538e9d}
67 | Thrift
68 |
69 |
70 |
71 |
78 |
--------------------------------------------------------------------------------
/Original/IThrift/IllegalArgument.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Autogenerated by Thrift Compiler (0.9.2)
3 | *
4 | * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5 | * @generated
6 | */
7 | using System;
8 | using System.Collections;
9 | using System.Collections.Generic;
10 | using System.Text;
11 | using System.IO;
12 | using Thrift;
13 | using Thrift.Collections;
14 | using System.Runtime.Serialization;
15 | using Thrift.Protocol;
16 | using Thrift.Transport;
17 |
18 |
19 | ///
20 | /// An IllegalArgument exception indicates an illegal or invalid
21 | /// argument was passed into a procedure.
22 | ///
23 | #if !SILVERLIGHT
24 | [Serializable]
25 | #endif
26 | public partial class IllegalArgument : TException, TBase
27 | {
28 | private string _message;
29 |
30 | public string Message
31 | {
32 | get
33 | {
34 | return _message;
35 | }
36 | set
37 | {
38 | __isset.message = true;
39 | this._message = value;
40 | }
41 | }
42 |
43 |
44 | public Isset __isset;
45 | #if !SILVERLIGHT
46 | [Serializable]
47 | #endif
48 | public struct Isset {
49 | public bool message;
50 | }
51 |
52 | public IllegalArgument() {
53 | }
54 |
55 | public void Read (TProtocol iprot)
56 | {
57 | TField field;
58 | iprot.ReadStructBegin();
59 | while (true)
60 | {
61 | field = iprot.ReadFieldBegin();
62 | if (field.Type == TType.Stop) {
63 | break;
64 | }
65 | switch (field.ID)
66 | {
67 | case 1:
68 | if (field.Type == TType.String) {
69 | Message = iprot.ReadString();
70 | } else {
71 | TProtocolUtil.Skip(iprot, field.Type);
72 | }
73 | break;
74 | default:
75 | TProtocolUtil.Skip(iprot, field.Type);
76 | break;
77 | }
78 | iprot.ReadFieldEnd();
79 | }
80 | iprot.ReadStructEnd();
81 | }
82 |
83 | public void Write(TProtocol oprot) {
84 | TStruct struc = new TStruct("IllegalArgument");
85 | oprot.WriteStructBegin(struc);
86 | TField field = new TField();
87 | if (Message != null && __isset.message) {
88 | field.Name = "message";
89 | field.Type = TType.String;
90 | field.ID = 1;
91 | oprot.WriteFieldBegin(field);
92 | oprot.WriteString(Message);
93 | oprot.WriteFieldEnd();
94 | }
95 | oprot.WriteFieldStop();
96 | oprot.WriteStructEnd();
97 | }
98 |
99 | public override string ToString() {
100 | StringBuilder __sb = new StringBuilder("IllegalArgument(");
101 | bool __first = true;
102 | if (Message != null && __isset.message) {
103 | if(!__first) { __sb.Append(", "); }
104 | __first = false;
105 | __sb.Append("Message: ");
106 | __sb.Append(Message);
107 | }
108 | __sb.Append(")");
109 | return __sb.ToString();
110 | }
111 |
112 | }
113 |
114 |
--------------------------------------------------------------------------------
/Original/IThrift/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace IThrift
8 | {
9 | class Program
10 | {
11 | static void Main(string[] args)
12 | {
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Original/IThrift/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的常规信息通过以下
6 | // 特性集控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("IThrift")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("IThrift")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 使此程序集中的类型
18 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | // 则将该类型上的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("21a9e1c5-1087-4bb8-a4a8-d9a3e4bacc9b")]
24 |
25 | // 程序集的版本信息由下面四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Original/NHBaseThrift.BatchInsertTest/NHBaseThrift.BatchInsertTest.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {823F8932-20DD-433C-81D1-8C4A36641504}
8 | Exe
9 | Properties
10 | NHBaseThrift.BatchInsertTest
11 | NHBaseThrift.BatchInsertTest
12 | v4.5
13 | 512
14 |
15 |
16 | x64
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 | false
25 | true
26 |
27 |
28 | AnyCPU
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | Always
55 |
56 |
57 |
58 |
59 | {bcd9ff49-d6e8-4c64-825c-a39414bb27f9}
60 | Gridsum.NHBaseThrift
61 |
62 |
63 |
64 |
71 |
--------------------------------------------------------------------------------
/Original/NHBaseThrift.BatchInsertTest/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的常规信息通过以下
6 | // 特性集控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("NHBaseThrift.BatchInsertTest")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("NHBaseThrift.BatchInsertTest")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 使此程序集中的类型
18 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | // 则将该类型上的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("c1b3c00b-3701-4955-95f6-d1ef1e22009a")]
24 |
25 | // 程序集的版本信息由下面四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Original/NHBaseThrift.BatchInsertTest/host.mapping:
--------------------------------------------------------------------------------
1 | gs-server-v-127 10.200.200.56
2 | gs-server-v-128 10.200.200.57
3 | gs-server-v-129 10.200.200.58
--------------------------------------------------------------------------------
/Original/Thrift/Collections/TCollections.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 | using System;
20 | using System.Collections;
21 |
22 | namespace Thrift.Collections
23 | {
24 | public class TCollections
25 | {
26 | ///
27 | /// This will return true if the two collections are value-wise the same.
28 | /// If the collection contains a collection, the collections will be compared using this method.
29 | ///
30 | public static bool Equals (IEnumerable first, IEnumerable second)
31 | {
32 | if (first == null && second == null)
33 | {
34 | return true;
35 | }
36 | if (first == null || second == null)
37 | {
38 | return false;
39 | }
40 | IEnumerator fiter = first.GetEnumerator ();
41 | IEnumerator siter = second.GetEnumerator ();
42 |
43 | bool fnext = fiter.MoveNext ();
44 | bool snext = siter.MoveNext ();
45 | while (fnext && snext)
46 | {
47 | IEnumerable fenum = fiter.Current as IEnumerable;
48 | IEnumerable senum = siter.Current as IEnumerable;
49 | if (fenum != null && senum != null)
50 | {
51 | if (!Equals(fenum, senum))
52 | {
53 | return false;
54 | }
55 | }
56 | else if (fenum == null ^ senum == null)
57 | {
58 | return false;
59 | }
60 | else if (!Equals(fiter.Current, siter.Current))
61 | {
62 | return false;
63 | }
64 | fnext = fiter.MoveNext();
65 | snext = siter.MoveNext();
66 | }
67 |
68 | return fnext == snext;
69 | }
70 |
71 | ///
72 | /// This returns a hashcode based on the value of the enumerable.
73 | ///
74 | public static int GetHashCode (IEnumerable enumerable)
75 | {
76 | if (enumerable == null)
77 | {
78 | return 0;
79 | }
80 |
81 | int hashcode = 0;
82 | foreach (Object obj in enumerable)
83 | {
84 | IEnumerable enum2 = obj as IEnumerable;
85 | int objHash = enum2 == null ? obj.GetHashCode () : GetHashCode (enum2);
86 | unchecked
87 | {
88 | hashcode = (hashcode * 397) ^ (objHash);
89 | }
90 | }
91 | return hashcode;
92 | }
93 | }
94 | }
--------------------------------------------------------------------------------
/Original/Thrift/Properties/AssemblyInfo.WP7.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | using System.Reflection;
21 | using System.Runtime.CompilerServices;
22 | using System.Runtime.InteropServices;
23 |
24 | // General Information about an assembly is controlled through the following
25 | // set of attributes. Change these attribute values to modify the information
26 | // associated with an assembly.
27 | [assembly: AssemblyTitle("Thrift.WP7")]
28 | [assembly: AssemblyDescription("C# bindings for the Apache Thrift RPC system")]
29 | [assembly: AssemblyConfiguration("")]
30 | [assembly: AssemblyCompany("The Apache Software Foundation")]
31 | [assembly: AssemblyProduct("Thrift")]
32 | [assembly: AssemblyCopyright("The Apache Software Foundation")]
33 | [assembly: AssemblyTrademark("")]
34 | [assembly: AssemblyCulture("")]
35 | //@TODO where to put License information?
36 |
37 | // Setting ComVisible to false makes the types in this assembly not visible
38 | // to COM components. If you need to access a type in this assembly from
39 | // COM, set the ComVisible attribute to true on that type.
40 | [assembly: ComVisible(false)]
41 |
42 | // The following GUID is for the ID of the typelib if this project is exposed to COM
43 | [assembly: Guid("a343f89c-57dd-4fa8-a9c6-35391cd5f655")]
44 |
45 | // Version information for an assembly consists of the following four values:
46 | //
47 | // Major Version
48 | // Minor Version
49 | // Build Number
50 | // Revision
51 | //
52 | // You can specify all the values or you can default the Build and Revision Numbers
53 | // by using the '*' as shown below:
54 | [assembly: AssemblyVersion("0.9.2.0")]
55 | [assembly: AssemblyFileVersion("0.9.2.0")]
56 |
--------------------------------------------------------------------------------
/Original/Thrift/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | using System.Reflection;
21 | using System.Runtime.CompilerServices;
22 | using System.Runtime.InteropServices;
23 |
24 | // General Information about an assembly is controlled through the following
25 | // set of attributes. Change these attribute values to modify the information
26 | // associated with an assembly.
27 | [assembly: AssemblyTitle("Thrift")]
28 | [assembly: AssemblyDescription("C# bindings for the Apache Thrift RPC system")]
29 | [assembly: AssemblyConfiguration("")]
30 | [assembly: AssemblyCompany("The Apache Software Foundation")]
31 | [assembly: AssemblyProduct("Thrift")]
32 | [assembly: AssemblyCopyright("The Apache Software Foundation")]
33 | [assembly: AssemblyTrademark("")]
34 | [assembly: AssemblyCulture("")]
35 | //@TODO where to put License information?
36 |
37 | // Setting ComVisible to false makes the types in this assembly not visible
38 | // to COM components. If you need to access a type in this assembly from
39 | // COM, set the ComVisible attribute to true on that type.
40 | [assembly: ComVisible(false)]
41 |
42 | // The following GUID is for the ID of the typelib if this project is exposed to COM
43 | [assembly: Guid("df3f8ef0-e0a3-4c86-a65b-8ec84e016b1d")]
44 |
45 | // Version information for an assembly consists of the following four values:
46 | //
47 | // Major Version
48 | // Minor Version
49 | // Build Number
50 | // Revision
51 | //
52 | // You can specify all the values or you can default the Build and Revision Numbers
53 | // by using the '*' as shown below:
54 | [assembly: AssemblyVersion("0.9.2.0")]
55 | [assembly: AssemblyFileVersion("0.9.2.0")]
56 |
--------------------------------------------------------------------------------
/Original/Thrift/Protocol/TAbstractBase.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | namespace Thrift.Protocol
21 | {
22 | public interface TAbstractBase
23 | {
24 | ///
25 | /// Writes the objects out to the protocol
26 | ///
27 | void Write(TProtocol tProtocol);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Original/Thrift/Protocol/TBase.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | namespace Thrift.Protocol
21 | {
22 | public interface TBase : TAbstractBase
23 | {
24 | ///
25 | /// Reads the TObject from the given input protocol.
26 | ///
27 | void Read(TProtocol tProtocol);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Original/Thrift/Protocol/TField.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | *
19 | * Contains some contributions under the Thrift Software License.
20 | * Please see doc/old-thrift-license.txt in the Thrift distribution for
21 | * details.
22 | */
23 |
24 | using System;
25 | using System.Collections.Generic;
26 | using System.Text;
27 |
28 | namespace Thrift.Protocol
29 | {
30 | public struct TField
31 | {
32 | private string name;
33 | private TType type;
34 | private short id;
35 |
36 | public TField(string name, TType type, short id)
37 | :this()
38 | {
39 | this.name = name;
40 | this.type = type;
41 | this.id = id;
42 | }
43 |
44 | public string Name
45 | {
46 | get { return name; }
47 | set { name = value; }
48 | }
49 |
50 | public TType Type
51 | {
52 | get { return type; }
53 | set { type = value; }
54 | }
55 |
56 | public short ID
57 | {
58 | get { return id; }
59 | set { id = value; }
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Original/Thrift/Protocol/TList.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | *
19 | * Contains some contributions under the Thrift Software License.
20 | * Please see doc/old-thrift-license.txt in the Thrift distribution for
21 | * details.
22 | */
23 |
24 | using System;
25 | using System.Collections.Generic;
26 | using System.Text;
27 |
28 | namespace Thrift.Protocol
29 | {
30 | public struct TList
31 | {
32 | private TType elementType;
33 | private int count;
34 |
35 | public TList(TType elementType, int count)
36 | :this()
37 | {
38 | this.elementType = elementType;
39 | this.count = count;
40 | }
41 |
42 | public TType ElementType
43 | {
44 | get { return elementType; }
45 | set { elementType = value; }
46 | }
47 |
48 | public int Count
49 | {
50 | get { return count; }
51 | set { count = value; }
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/Original/Thrift/Protocol/TMap.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | *
19 | * Contains some contributions under the Thrift Software License.
20 | * Please see doc/old-thrift-license.txt in the Thrift distribution for
21 | * details.
22 | */
23 |
24 | using System;
25 | using System.Collections.Generic;
26 | using System.Text;
27 |
28 | namespace Thrift.Protocol
29 | {
30 | public struct TMap
31 | {
32 | private TType keyType;
33 | private TType valueType;
34 | private int count;
35 |
36 | public TMap(TType keyType, TType valueType, int count)
37 | :this()
38 | {
39 | this.keyType = keyType;
40 | this.valueType = valueType;
41 | this.count = count;
42 | }
43 |
44 | public TType KeyType
45 | {
46 | get { return keyType; }
47 | set { keyType = value; }
48 | }
49 |
50 | public TType ValueType
51 | {
52 | get { return valueType; }
53 | set { valueType = value; }
54 | }
55 |
56 | public int Count
57 | {
58 | get { return count; }
59 | set { count = value; }
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Original/Thrift/Protocol/TMessage.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | *
19 | * Contains some contributions under the Thrift Software License.
20 | * Please see doc/old-thrift-license.txt in the Thrift distribution for
21 | * details.
22 | */
23 |
24 | using System;
25 | using System.Collections.Generic;
26 | using System.Text;
27 |
28 | namespace Thrift.Protocol
29 | {
30 | public struct TMessage
31 | {
32 | private string name;
33 | private TMessageType type;
34 | private int seqID;
35 |
36 | public TMessage(string name, TMessageType type, int seqid)
37 | :this()
38 | {
39 | this.name = name;
40 | this.type = type;
41 | this.seqID = seqid;
42 | }
43 |
44 | public string Name
45 | {
46 | get { return name; }
47 | set { name = value; }
48 | }
49 |
50 | public TMessageType Type
51 | {
52 | get { return type; }
53 | set { type = value; }
54 | }
55 |
56 | public int SeqID
57 | {
58 | get { return seqID; }
59 | set { seqID = value; }
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Original/Thrift/Protocol/TMessageType.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | using System;
21 |
22 | namespace Thrift.Protocol
23 | {
24 | public enum TMessageType
25 | {
26 | Call = 1,
27 | Reply = 2,
28 | Exception = 3,
29 | Oneway = 4
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Original/Thrift/Protocol/TProtocol.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gridsum/NHBaseAPI/d9c5a7f4af8b54555e497a20a587d0edc81a12a0/Original/Thrift/Protocol/TProtocol.cs
--------------------------------------------------------------------------------
/Original/Thrift/Protocol/TProtocolException.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | *
19 | * Contains some contributions under the Thrift Software License.
20 | * Please see doc/old-thrift-license.txt in the Thrift distribution for
21 | * details.
22 | */
23 |
24 | using System;
25 |
26 | namespace Thrift.Protocol
27 | {
28 | public class TProtocolException : TException
29 | {
30 | public const int UNKNOWN = 0;
31 | public const int INVALID_DATA = 1;
32 | public const int NEGATIVE_SIZE = 2;
33 | public const int SIZE_LIMIT = 3;
34 | public const int BAD_VERSION = 4;
35 | public const int NOT_IMPLEMENTED = 5;
36 | public const int DEPTH_LIMIT = 6;
37 |
38 | protected int type_ = UNKNOWN;
39 |
40 | public TProtocolException()
41 | : base()
42 | {
43 | }
44 |
45 | public TProtocolException(int type)
46 | : base()
47 | {
48 | type_ = type;
49 | }
50 |
51 | public TProtocolException(int type, String message)
52 | : base(message)
53 | {
54 | type_ = type;
55 | }
56 |
57 | public TProtocolException(String message)
58 | : base(message)
59 | {
60 | }
61 |
62 | public int getType()
63 | {
64 | return type_;
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/Original/Thrift/Protocol/TProtocolFactory.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | *
19 | * Contains some contributions under the Thrift Software License.
20 | * Please see doc/old-thrift-license.txt in the Thrift distribution for
21 | * details.
22 | */
23 |
24 | using System;
25 | using Thrift.Transport;
26 |
27 | namespace Thrift.Protocol
28 | {
29 | public interface TProtocolFactory
30 | {
31 | TProtocol GetProtocol(TTransport trans);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Original/Thrift/Protocol/TSet.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | *
19 | * Contains some contributions under the Thrift Software License.
20 | * Please see doc/old-thrift-license.txt in the Thrift distribution for
21 | * details.
22 | */
23 |
24 | using System;
25 | using System.Collections.Generic;
26 | using System.Text;
27 |
28 | namespace Thrift.Protocol
29 | {
30 | public struct TSet
31 | {
32 | private TType elementType;
33 | private int count;
34 |
35 | public TSet(TType elementType, int count)
36 | :this()
37 | {
38 | this.elementType = elementType;
39 | this.count = count;
40 | }
41 |
42 | public TSet(TList list)
43 | : this(list.ElementType, list.Count)
44 | {
45 | }
46 |
47 | public TType ElementType
48 | {
49 | get { return elementType; }
50 | set { elementType = value; }
51 | }
52 |
53 | public int Count
54 | {
55 | get { return count; }
56 | set { count = value; }
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/Original/Thrift/Protocol/TStruct.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | *
19 | * Contains some contributions under the Thrift Software License.
20 | * Please see doc/old-thrift-license.txt in the Thrift distribution for
21 | * details.
22 | */
23 |
24 | using System;
25 | using System.Collections.Generic;
26 | using System.Text;
27 |
28 | namespace Thrift.Protocol
29 | {
30 | public struct TStruct
31 | {
32 | private string name;
33 |
34 | public TStruct(string name)
35 | :this()
36 | {
37 | this.name = name;
38 | }
39 |
40 | public string Name
41 | {
42 | get { return name; }
43 | set { name = value; }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Original/Thrift/Protocol/TType.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | *
19 | * Contains some contributions under the Thrift Software License.
20 | * Please see doc/old-thrift-license.txt in the Thrift distribution for
21 | * details.
22 | */
23 |
24 | using System;
25 |
26 | namespace Thrift.Protocol
27 | {
28 | public enum TType : byte
29 | {
30 | Stop = 0,
31 | Void = 1,
32 | Bool = 2,
33 | Byte = 3,
34 | Double = 4,
35 | I16 = 6,
36 | I32 = 8,
37 | I64 = 10,
38 | String = 11,
39 | Struct = 12,
40 | Map = 13,
41 | Set = 14,
42 | List = 15
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Original/Thrift/Server/TServerEventHandler.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | *
19 | * Contains some contributions under the Thrift Software License.
20 | * Please see doc/old-thrift-license.txt in the Thrift distribution for
21 | * details.
22 | */
23 |
24 | using System;
25 |
26 | namespace Thrift.Server
27 | {
28 | ///
29 | /// Interface implemented by server users to handle events from the server
30 | ///
31 | public interface TServerEventHandler
32 | {
33 | ///
34 | /// Called before the server begins */
35 | ///
36 | void preServe();
37 | ///
38 | /// Called when a new client has connected and is about to being processing */
39 | ///
40 | Object createContext(Thrift.Protocol.TProtocol input, Thrift.Protocol.TProtocol output);
41 | ///
42 | /// Called when a client has finished request-handling to delete server context */
43 | ///
44 | void deleteContext(Object serverContext, Thrift.Protocol.TProtocol input, Thrift.Protocol.TProtocol output);
45 | ///
46 | /// Called when a client is about to call the processor */
47 | ///
48 | void processContext(Object serverContext, Thrift.Transport.TTransport transport);
49 | };
50 | }
51 |
--------------------------------------------------------------------------------
/Original/Thrift/TException.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | *
19 | * Contains some contributions under the Thrift Software License.
20 | * Please see doc/old-thrift-license.txt in the Thrift distribution for
21 | * details.
22 | */
23 |
24 | using System;
25 |
26 | namespace Thrift
27 | {
28 | public class TException : Exception
29 | {
30 | public TException()
31 | {
32 | }
33 |
34 | public TException( string message)
35 | : base(message)
36 | {
37 | }
38 |
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Original/Thrift/TProcessor.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | *
19 | * Contains some contributions under the Thrift Software License.
20 | * Please see doc/old-thrift-license.txt in the Thrift distribution for
21 | * details.
22 | */
23 |
24 | using System;
25 | using Thrift.Protocol;
26 |
27 | namespace Thrift
28 | {
29 | public interface TProcessor
30 | {
31 | bool Process(TProtocol iprot, TProtocol oprot);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Original/Thrift/Thrift.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Thrift", "Thrift.csproj", "{499EB63C-D74C-47E8-AE48-A2FC94538E9D}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ThriftTest", "..\test\ThriftTest\ThriftTest.csproj", "{48DD757F-CA95-4DD7-BDA4-58DB6F108C2C}"
7 | ProjectSection(ProjectDependencies) = postProject
8 | {499EB63C-D74C-47E8-AE48-A2FC94538E9D} = {499EB63C-D74C-47E8-AE48-A2FC94538E9D}
9 | EndProjectSection
10 | EndProject
11 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ThriftMSBuildTask", "..\ThriftMSBuildTask\ThriftMSBuildTask.csproj", "{EC0A0231-66EA-4593-A792-C6CA3BB8668E}"
12 | EndProject
13 | Global
14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
15 | Debug|Any CPU = Debug|Any CPU
16 | Release|Any CPU = Release|Any CPU
17 | EndGlobalSection
18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
19 | {499EB63C-D74C-47E8-AE48-A2FC94538E9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20 | {499EB63C-D74C-47E8-AE48-A2FC94538E9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
21 | {499EB63C-D74C-47E8-AE48-A2FC94538E9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
22 | {499EB63C-D74C-47E8-AE48-A2FC94538E9D}.Release|Any CPU.Build.0 = Release|Any CPU
23 | {48DD757F-CA95-4DD7-BDA4-58DB6F108C2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24 | {48DD757F-CA95-4DD7-BDA4-58DB6F108C2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
25 | {48DD757F-CA95-4DD7-BDA4-58DB6F108C2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
26 | {48DD757F-CA95-4DD7-BDA4-58DB6F108C2C}.Release|Any CPU.Build.0 = Release|Any CPU
27 | {EC0A0231-66EA-4593-A792-C6CA3BB8668E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28 | {EC0A0231-66EA-4593-A792-C6CA3BB8668E}.Debug|Any CPU.Build.0 = Debug|Any CPU
29 | {EC0A0231-66EA-4593-A792-C6CA3BB8668E}.Release|Any CPU.ActiveCfg = Release|Any CPU
30 | {EC0A0231-66EA-4593-A792-C6CA3BB8668E}.Release|Any CPU.Build.0 = Release|Any CPU
31 | EndGlobalSection
32 | GlobalSection(MonoDevelopProperties) = preSolution
33 | StartupItem = Thrift.csproj
34 | EndGlobalSection
35 | GlobalSection(SolutionProperties) = preSolution
36 | HideSolutionNode = FALSE
37 | EndGlobalSection
38 | EndGlobal
39 |
--------------------------------------------------------------------------------
/Original/Thrift/Transport/TMemoryBuffer.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | using System;
21 | using System.IO;
22 | using System.Reflection;
23 | using Thrift.Protocol;
24 |
25 | namespace Thrift.Transport {
26 | public class TMemoryBuffer : TTransport {
27 |
28 | private readonly MemoryStream byteStream;
29 |
30 | public TMemoryBuffer() {
31 | byteStream = new MemoryStream();
32 | }
33 |
34 | public TMemoryBuffer(byte[] buf) {
35 | byteStream = new MemoryStream(buf);
36 | }
37 |
38 | public override void Open() {
39 | /** do nothing **/
40 | }
41 |
42 | public override void Close() {
43 | /** do nothing **/
44 | }
45 |
46 | public override int Read(byte[] buf, int off, int len) {
47 | return byteStream.Read(buf, off, len);
48 | }
49 |
50 | public override void Write(byte[] buf, int off, int len) {
51 | byteStream.Write(buf, off, len);
52 | }
53 |
54 | public byte[] GetBuffer() {
55 | return byteStream.ToArray();
56 | }
57 |
58 |
59 | public override bool IsOpen {
60 | get { return true; }
61 | }
62 |
63 | public static byte[] Serialize(TAbstractBase s) {
64 | var t = new TMemoryBuffer();
65 | var p = new TBinaryProtocol(t);
66 |
67 | s.Write(p);
68 |
69 | return t.GetBuffer();
70 | }
71 |
72 | public static T DeSerialize(byte[] buf) where T : TAbstractBase {
73 | var trans = new TMemoryBuffer(buf);
74 | var p = new TBinaryProtocol(trans);
75 | if (typeof (TBase).IsAssignableFrom(typeof (T))) {
76 | var method = typeof (T).GetMethod("Read", BindingFlags.Instance | BindingFlags.Public);
77 | var t = Activator.CreateInstance();
78 | method.Invoke(t, new object[] {p});
79 | return t;
80 | } else {
81 | var method = typeof (T).GetMethod("Read", BindingFlags.Static | BindingFlags.Public);
82 | return (T) method.Invoke(null, new object[] {p});
83 | }
84 | }
85 |
86 | private bool _IsDisposed;
87 |
88 | // IDisposable
89 | protected override void Dispose(bool disposing) {
90 | if (!_IsDisposed) {
91 | if (disposing) {
92 | if (byteStream != null)
93 | byteStream.Dispose();
94 | }
95 | }
96 | _IsDisposed = true;
97 | }
98 | }
99 | }
--------------------------------------------------------------------------------
/Original/Thrift/Transport/TNamedPipeClientTransport.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | *
19 | * Contains some contributions under the Thrift Software License.
20 | * Please see doc/old-thrift-license.txt in the Thrift distribution for
21 | * details.
22 | */
23 |
24 | using System.IO.Pipes;
25 |
26 | namespace Thrift.Transport
27 | {
28 | public class TNamedPipeClientTransport : TTransport
29 | {
30 | private NamedPipeClientStream client;
31 | private string ServerName;
32 | private string PipeName;
33 |
34 | public TNamedPipeClientTransport(string pipe)
35 | {
36 | ServerName = ".";
37 | PipeName = pipe;
38 | }
39 |
40 | public TNamedPipeClientTransport(string server, string pipe)
41 | {
42 | ServerName = (server != "") ? server : ".";
43 | PipeName = pipe;
44 | }
45 |
46 | public override bool IsOpen
47 | {
48 | get { return client != null && client.IsConnected; }
49 | }
50 |
51 | public override void Open()
52 | {
53 | if (IsOpen)
54 | {
55 | throw new TTransportException(TTransportException.ExceptionType.AlreadyOpen);
56 | }
57 | client = new NamedPipeClientStream(ServerName, PipeName, PipeDirection.InOut, PipeOptions.None);
58 | client.Connect();
59 | }
60 |
61 | public override void Close()
62 | {
63 | if (client != null)
64 | {
65 | client.Close();
66 | client = null;
67 | }
68 | }
69 |
70 | public override int Read(byte[] buf, int off, int len)
71 | {
72 | if (client == null)
73 | {
74 | throw new TTransportException(TTransportException.ExceptionType.NotOpen);
75 | }
76 |
77 | return client.Read(buf, off, len);
78 | }
79 |
80 | public override void Write(byte[] buf, int off, int len)
81 | {
82 | if (client == null)
83 | {
84 | throw new TTransportException(TTransportException.ExceptionType.NotOpen);
85 | }
86 |
87 | client.Write(buf, off, len);
88 | }
89 |
90 | protected override void Dispose(bool disposing)
91 | {
92 | client.Dispose();
93 | }
94 | }
95 | }
--------------------------------------------------------------------------------
/Original/Thrift/Transport/TServerTransport.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | *
19 | * Contains some contributions under the Thrift Software License.
20 | * Please see doc/old-thrift-license.txt in the Thrift distribution for
21 | * details.
22 | */
23 |
24 | using System;
25 |
26 | namespace Thrift.Transport
27 | {
28 | public abstract class TServerTransport
29 | {
30 | public abstract void Listen();
31 | public abstract void Close();
32 | protected abstract TTransport AcceptImpl();
33 |
34 | public TTransport Accept()
35 | {
36 | TTransport transport = AcceptImpl();
37 | if (transport == null) {
38 | throw new TTransportException("accept() may not return NULL");
39 | }
40 | return transport;
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Original/Thrift/Transport/TTransportException.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | *
19 | * Contains some contributions under the Thrift Software License.
20 | * Please see doc/old-thrift-license.txt in the Thrift distribution for
21 | * details.
22 | */
23 |
24 | using System;
25 |
26 | namespace Thrift.Transport
27 | {
28 | public class TTransportException : TException
29 | {
30 | protected ExceptionType type;
31 |
32 | public TTransportException()
33 | : base()
34 | {
35 | }
36 |
37 | public TTransportException(ExceptionType type)
38 | : this()
39 | {
40 | this.type = type;
41 | }
42 |
43 | public TTransportException(ExceptionType type, string message)
44 | : base(message)
45 | {
46 | this.type = type;
47 | }
48 |
49 | public TTransportException(string message)
50 | : base(message)
51 | {
52 | }
53 |
54 | public ExceptionType Type
55 | {
56 | get { return type; }
57 | }
58 |
59 | public enum ExceptionType
60 | {
61 | Unknown,
62 | NotOpen,
63 | AlreadyOpen,
64 | TimedOut,
65 | EndOfFile
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/Original/Thrift/Transport/TTransportFactory.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | *
19 | * Contains some contributions under the Thrift Software License.
20 | * Please see doc/old-thrift-license.txt in the Thrift distribution for
21 | * details.
22 | */
23 |
24 | using System;
25 |
26 | namespace Thrift.Transport
27 | {
28 | ///
29 | /// From Mark Slee & Aditya Agarwal of Facebook:
30 | /// Factory class used to create wrapped instance of Transports.
31 | /// This is used primarily in servers, which get Transports from
32 | /// a ServerTransport and then may want to mutate them (i.e. create
33 | /// a BufferedTransport from the underlying base transport)
34 | ///
35 | public class TTransportFactory
36 | {
37 | public virtual TTransport GetTransport(TTransport trans)
38 | {
39 | return trans;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------