01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.l2.msg;
06:
07: import com.tc.l2.ha.ClusterState;
08: import com.tc.net.groups.GroupMessage;
09: import com.tc.net.protocol.transport.ConnectionID;
10:
11: public class ClusterStateMessageFactory {
12:
13: public static GroupMessage createNextAvailableObjectIDMessage(
14: ClusterState state) {
15: ClusterStateMessage msg = new ClusterStateMessage(
16: ClusterStateMessage.OBJECT_ID);
17: msg.initMessage(state);
18: return msg;
19: }
20:
21: public static GroupMessage createOKResponse(ClusterStateMessage msg) {
22: ClusterStateMessage response = new ClusterStateMessage(
23: ClusterStateMessage.OPERATION_SUCCESS, msg
24: .getMessageID());
25: return response;
26: }
27:
28: public static GroupMessage createNGSplitBrainResponse(
29: ClusterStateMessage msg) {
30: ClusterStateMessage response = new ClusterStateMessage(
31: ClusterStateMessage.OPERATION_FAILED_SPLIT_BRAIN, msg
32: .getMessageID());
33: return response;
34: }
35:
36: public static GroupMessage createClusterStateMessage(
37: ClusterState state) {
38: ClusterStateMessage msg = new ClusterStateMessage(
39: ClusterStateMessage.COMPLETE_STATE);
40: msg.initMessage(state);
41: return msg;
42: }
43:
44: public static GroupMessage createNewConnectionCreatedMessage(
45: ConnectionID connID) {
46: ClusterStateMessage msg = new ClusterStateMessage(
47: ClusterStateMessage.NEW_CONNECTION_CREATED, connID);
48: return msg;
49: }
50:
51: public static GroupMessage createConnectionDestroyedMessage(
52: ConnectionID connID) {
53: ClusterStateMessage msg = new ClusterStateMessage(
54: ClusterStateMessage.CONNECTION_DESTROYED, connID);
55: return msg;
56: }
57:
58: public static GroupMessage createNextAvailableGlobalTransactionIDMessage(
59: ClusterState state) {
60: ClusterStateMessage msg = new ClusterStateMessage(
61: ClusterStateMessage.GLOBAL_TRANSACTION_ID);
62: msg.initMessage(state);
63: return msg;
64: }
65:
66: }
|