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.test.activepassive;
06:
07: public class ActivePassiveTestSetupManager {
08:
09: private int serverCount;
10: private long serverCrashWaitTimeInSec = 15;
11: private int maxCrashCount = Integer.MAX_VALUE;
12: private ActivePassiveSharedDataMode activePassiveMode;
13: private ActivePassivePersistenceMode persistenceMode;
14: private ActivePassiveCrashMode crashMode;
15:
16: public void setServerCount(int count) {
17: if (count < 2) {
18: throw new AssertionError(
19: "Server count must be 2 or more: count=[" + count
20: + "]");
21: }
22: serverCount = count;
23: }
24:
25: public int getServerCount() {
26: return serverCount;
27: }
28:
29: public void setServerCrashMode(String mode) {
30: crashMode = new ActivePassiveCrashMode(mode);
31: }
32:
33: public void setMaxCrashCount(int count) {
34: if (count < 0) {
35: throw new AssertionError(
36: "Max crash count should not be a neg number");
37: }
38: maxCrashCount = count;
39: }
40:
41: public int getMaxCrashCount() {
42: return maxCrashCount;
43: }
44:
45: public String getServerCrashMode() {
46: if (crashMode == null) {
47: throw new AssertionError("Server crash mode was not set.");
48: }
49: return crashMode.getMode();
50: }
51:
52: public void setServerShareDataMode(String mode) {
53: activePassiveMode = new ActivePassiveSharedDataMode(mode);
54: }
55:
56: public boolean isNetworkShare() {
57: if (activePassiveMode == null) {
58: throw new AssertionError("Server share mode was not set.");
59: }
60: return activePassiveMode.isNetworkShare();
61: }
62:
63: public void setServerPersistenceMode(String mode) {
64: persistenceMode = new ActivePassivePersistenceMode(mode);
65: }
66:
67: public String getServerPersistenceMode() {
68: if (persistenceMode == null) {
69: throw new AssertionError(
70: "Server persistence mode was not set.");
71: }
72: return persistenceMode.getMode();
73: }
74:
75: public void setServerCrashWaitTimeInSec(long time) {
76: if (time < 0) {
77: throw new AssertionError(
78: "Wait time should not be a negative number.");
79: }
80: serverCrashWaitTimeInSec = time;
81: }
82:
83: public long getServerCrashWaitTimeInSec() {
84: return serverCrashWaitTimeInSec;
85: }
86:
87: }
|