1 /* -*- mode: java; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=4:tabstop=4:smarttab:
4 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 package com.mysql.cluster.benchmark.tws;
22 import java.io.PrintWriter;
25 abstract class TwsLoad {
28 static protected final PrintWriter out = TwsDriver.out;
29 static protected final PrintWriter err = TwsDriver.err;
32 protected final TwsDriver driver;
33 protected String descr;
35 protected MetaData metaData;
37 protected static String fixedStr = "xxxxxxxxxx"
61 public TwsLoad(TwsDriver driver, MetaData md) {
66 // ----------------------------------------------------------------------
67 // intializers/finalizers
68 // ----------------------------------------------------------------------
70 abstract protected void initProperties();
71 abstract protected void printProperties();
73 public String getDescriptor() {
77 public void init() throws Exception {
82 public void close() throws Exception {
85 public MetaData getMetaData() {
89 // ----------------------------------------------------------------------
90 // benchmark operations
91 // ----------------------------------------------------------------------
93 abstract public void runOperations() throws Exception;
95 // reports an error if a condition is not met
96 static protected final void verify(boolean cond) {
99 throw new RuntimeException("data verification failed.");
102 static protected final void verify(int exp, int act) {
104 throw new RuntimeException("data verification failed:"
105 + " expected = " + exp
106 + ", actual = " + act);
109 static protected final void verify(String exp, String act) {
110 if ((exp == null && act != null)
111 || (exp != null && !exp.equals(act)))
112 throw new RuntimeException("data verification failed:"
113 + " expected = '" + exp + "'"
114 + ", actual = '" + act + "'");
117 // ----------------------------------------------------------------------
118 // datastore operations
119 // ----------------------------------------------------------------------
121 abstract public void initConnection() throws Exception;
122 abstract public void closeConnection() throws Exception;
123 //abstract public void clearPersistenceContext() throws Exception;
124 //abstract public void clearData() throws Exception;