1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| package org.jboss.cache.statetransfer; |
8 |
| |
9 |
| import org.jboss.cache.CacheImpl; |
10 |
| import org.jboss.cache.Fqn; |
11 |
| import org.jboss.cache.Version; |
12 |
| |
13 |
| import java.io.IOException; |
14 |
| import java.io.ObjectInputStream; |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| |
21 |
| |
22 |
| |
23 |
| public abstract class StateTransferFactory |
24 |
| { |
25 |
| private static final short RV_200 = Version.getVersionShort("2.0.0"); |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
728
| public static StateTransferGenerator
|
35 |
| getStateTransferGenerator(CacheImpl cache) |
36 |
| { |
37 |
728
| short version = cache.getConfiguration().getReplicationVersion();
|
38 |
| |
39 |
| |
40 |
| |
41 |
728
| if (version < RV_200 && version > 0)
|
42 |
0
| throw new IllegalStateException("State transfer with cache replication version < 2.0.0 not supported");
|
43 |
| else |
44 |
728
| return new DefaultStateTransferGenerator(cache);
|
45 |
| } |
46 |
| |
47 |
734
| public static StateTransferIntegrator getStateTransferIntegrator(ObjectInputStream in, Fqn fqn, CacheImpl cache)
|
48 |
| throws Exception |
49 |
| { |
50 |
734
| short version = 0;
|
51 |
734
| try
|
52 |
| { |
53 |
734
| version = (Short) cache.getMarshaller().objectFromObjectStream(in);
|
54 |
| } |
55 |
| catch (IOException io) |
56 |
| { |
57 |
| |
58 |
4
| try
|
59 |
| { |
60 |
4
| in.close();
|
61 |
| } |
62 |
| catch (IOException ignored) {} |
63 |
4
| throw new IllegalStateException("Stream corrupted ", io);
|
64 |
| } |
65 |
| |
66 |
| |
67 |
| |
68 |
730
| if (version < RV_200 && version > 0)
|
69 |
0
| throw new IllegalStateException("State transfer with cache replication version < 2.0.0 not supported");
|
70 |
| else |
71 |
730
| return new DefaultStateTransferIntegrator(fqn, cache);
|
72 |
| } |
73 |
| |
74 |
| } |