-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGETALL.cs
71 lines (62 loc) · 2.18 KB
/
GETALL.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
67
68
69
70
71
using BeetleX.Buffers;
using System;
using System.Collections.Generic;
using System.Text;
namespace Infinispan.Hotrod.Core.Commands
{
public class GETALL<K, V> : Command
{
public GETALL(Marshaller<K> km, Marshaller<V> vm, ISet<K> keys)
{
KeyMarshaller = km;
ValueMarshaller = vm;
Keys = keys;
NetworkReceive = OnReceive;
}
public Marshaller<K> KeyMarshaller;
public Marshaller<V> ValueMarshaller;
public int Segment = -1;
public ISet<K> Keys { get; set; }
public IDictionary<K, V> Entries;
public override string Name => "GETALL";
public override Byte Code => 0x2F;
internal override void OnExecute(CommandContext ctx)
{
base.OnExecute(ctx);
}
internal override void Execute(CommandContext ctx, InfinispanClient client, PipeStream stream)
{
base.Execute(ctx, client, stream);
Codec.writeVInt(Keys.Count, stream);
foreach (var k in Keys)
{
Codec.writeArray(KeyMarshaller.marshall(k), stream);
}
stream.Flush();
}
public override Result OnReceive(InfinispanRequest request, ResponseStream stream)
{
if (request.ResponseStatus == Codec30.NO_ERROR_STATUS)
{
var resCount = Codec.readVInt(stream);
Entries = new Dictionary<K, V>();
for (var i = 0; i < resCount; i++)
{
K k = KeyMarshaller.unmarshall(Codec.readArray(stream));
V v = ValueMarshaller.unmarshall(Codec.readArray(stream));
Entries.Add(k, v);
}
return new Result { Status = ResultStatus.Completed, ResultType = ResultType.Object };
}
return new Result { Status = ResultStatus.Completed, ResultType = ResultType.Null };
}
internal override TopologyKnoledge getTopologyKnowledgeType()
{
return TopologyKnoledge.SEGMENT;
}
internal override int getSegment()
{
return Segment;
}
}
}