| 1 |
import java.util.*; |
| 2 |
import java.io.*; |
| 3 |
import java.net.*; |
| 4 |
|
| 5 |
import okuyama.imdst.util.*; |
| 6 |
import okuyama.imdst.client.OkuyamaClient; |
| 7 |
import okuyama.imdst.client.OkuyamaResultSet; |
| 8 |
import okuyama.base.lang.BatchException; |
| 9 |
|
| 10 |
public class TestSock { |
| 11 |
public static void main(String[] args) { |
| 12 |
try { |
| 13 |
|
| 14 |
if (args == null || args.length ==0) { |
| 15 |
|
| 16 |
System.out.println("{キー値を自動で繰り返し数分変動させて登録} コマンド引数{args[0]=1, args[1]=マスタノードサーバIP, args[2]=マスタノードサーバPort番号, args[3]=登録件数}"); |
| 17 |
System.out.println("{キー値を自動で繰り返し数分変動させて登録} コマンド引数{args[0]=1.1, args[1]=マスタノードサーバIP, args[2]=マスタノードサーバPort番号, args[3]=登録Key値, args[4]=登録Value値}"); |
| 18 |
System.out.println("{キー値を自動で繰り返し数分変動させて登録} コマンド引数{args[0]=1.2, args[1]=\"マスタノードサーバIP:マスタノードサーバPort番号,スレーブマスタノードサーバIP:スレーブマスタノードサーバPort番号\", args[2]=登録件数}"); |
| 19 |
System.out.println("{キー値を自動で繰り返し数分変動させて取得} コマンド引数{args[0]=2, args[1]=マスタノードサーバIP, args[2]=マスタノードサーバPort番号, args[3]=取得回数}"); |
| 20 |
System.out.println("{キー値を自動で繰り返し数分変動させて取得} コマンド引数{args[0]=2.1, args[1]=マスタノードサーバIP, args[2]=マスタノードサーバPort番号, args[3]=取得したいKey値}"); |
| 21 |
System.out.println("{キー値を自動で繰り返し数分変動させて取得} コマンド引数{args[0]=2.2, args[1]=\"マスタノードサーバIP:マスタノードサーバPort番号,スレーブマスタノードサーバIP:スレーブマスタノードサーバPort番号\", args[2]=取得回数}"); |
| 22 |
System.out.println("{キー値を自動で繰り返し数分変動させて取得} コマンド引数{args[0]=2.22, args[1]=\"マスタノードサーバIP:マスタノードサーバPort番号,スレーブマスタノードサーバIP:スレーブマスタノードサーバPort番号\", args[2]=Key値}"); |
| 23 |
System.out.println("{キー値を指定してスクリプト実行し取得} コマンド引数{args[0]=2.3, args[1]=マスタノードサーバIP, args[2]=マスタノードサーバPort番号, args[3]=取得Key値, args[4]=実行スクリプトコード}"); |
| 24 |
System.out.println("{Tagを4パターンで自動的に変動させてキー値は自動変動で登録} コマンド引数{args[0]=3, args[1]=マスタノードサーバIP, args[2]=マスタノードサーバPort番号, args[3]=登録件数}"); |
| 25 |
System.out.println("{指定したTagで関連するキー値を指定回数取得} コマンド引数{args[0]=4, args[1]=マスタノードサーバIP, args[2]=マスタノードサーバPort番号, args[3]=取得回数, args[4]=指定Tag値 (tag1 or tag2 or tag3 or tag4)}, args[5]=Key値として存在しない値の取得有無 true=tag値として登録された過去があればkey値は返す false=Key値が存在しなければ返さない"); |
| 26 |
System.out.println("{指定したファイルをバイナリデータとして指定したキー値で保存する} コマンド引数{args[0]=5, args[1]=マスタノードサーバIP, args[2]=マスタノードサーバPort番号, args[3]=登録回数, args[4]=ファイルパス, args[5]=キー値}"); |
| 27 |
System.out.println("{指定したキー値でバイナリデータを取得してファイル化する} コマンド引数{args[0]=6, args[1]=マスタノードサーバIP, args[2]=マスタノードサーバPort番号, args[3]=取得回数, args[4]=作成ファイルパス, args[5]=キー値}"); |
| 28 |
System.out.println("{キー値を自動で繰り返し数分変動させて削除} コマンド引数{args[0]=7, args[1]=マスタノードサーバIP, args[2]=マスタノードサーバPort番号, args[3]=削除回数}"); |
| 29 |
System.out.println("{キー値を指定してデータを削除} コマンド引数{args[0]=8, args[1]=マスタノードサーバIP, args[2]=マスタノードサーバPort番号, args[3]=削除したいKey値}"); |
| 30 |
System.out.println("{トランザクションを開始する} コマンド引数{args[0]=9, args[1]=マスタノードサーバIP, args[2]=マスタノードサーバPort番号}"); |
| 31 |
System.out.println("{Transactionを開始してデータをLock後、データを更新、取得し、Lockを解除} コマンド引数{args[0]=10, args[1]=マスタノードサーバIP, args[2]=マスタノードサーバPort番号. args[3]=Key値, args[4]=Lock取得維持時間, args[5]=Lock取得待ち時間}"); |
| 32 |
System.out.println("{一度登録した値はエラーとなる} コマンド引数{args[0]=11, args[1]=マスタノードサーバIP, args[2]=マスタノードサーバPort番号. args[3]=Key値, args[4]=Value値}"); |
| 33 |
System.exit(0); |
| 34 |
} |
| 35 |
|
| 36 |
if (args[0].equals("1")) { |
| 37 |
|
| 38 |
int port = Integer.parseInt(args[2]); |
| 39 |
// OkuyamaClientを使用してデータを保存(Tagなし) |
| 40 |
|
| 41 |
// クライアントインスタンスを作成 |
| 42 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 43 |
|
| 44 |
// マスタサーバに接続 |
| 45 |
okuyamaClient.connect(args[1], port); |
| 46 |
|
| 47 |
Random rnd = new Random(); |
| 48 |
StringBuilder strBuf =null; |
| 49 |
if (args.length > 4) { |
| 50 |
strBuf = new StringBuilder(120*10); |
| 51 |
for (int i = 0; i < 50000; i++) { |
| 52 |
strBuf.append(rnd.nextInt(1999999999)); |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
long start = new Date().getTime(); |
| 57 |
for (int i = 0; i < Integer.parseInt(args[3]);i++) { |
| 58 |
// データ登録 |
| 59 |
if (args.length > 5) { |
| 60 |
if (!okuyamaClient.setValue("datasavekey_" + args[4] + "_" + new Integer(i).toString(), "savedatavaluestr0987654321" + strBuf.toString() + "_" + args[4] + "_" + new Integer(i).toString(), new Integer(args[5]))) { |
| 61 |
System.out.println("OkuyamaClient - error"); |
| 62 |
} else { |
| 63 |
System.out.println("Store[" + "datasavekey_" + args[4] + "_" + new Integer(i).toString() + "]"); |
| 64 |
} |
| 65 |
} else if (args.length > 4) { |
| 66 |
|
| 67 |
if (!okuyamaClient.setValue("datasavekey_" + args[4] + "_" + new Integer(i).toString(), "savedatavaluestr0987654321" + strBuf.toString() + "_" + args[4] + "_" + new Integer(i).toString())) { |
| 68 |
System.out.println("OkuyamaClient - error"); |
| 69 |
} else { |
| 70 |
//System.out.println("Store[" + "datasavekey_" + args[4] + "_" + new Integer(i).toString() + "]"); |
| 71 |
} |
| 72 |
} else { |
| 73 |
|
| 74 |
if (!okuyamaClient.setValue("datasavekey_" + new Integer(i).toString(), "savedatavaluestr_" + new Integer(i).toString())) { |
| 75 |
System.out.println("OkuyamaClient - error"); |
| 76 |
} |
| 77 |
} |
| 78 |
if ((i % 1000) == 0) System.out.println(i); |
| 79 |
} |
| 80 |
|
| 81 |
if (args.length > 4) { |
| 82 |
|
| 83 |
for (int i = 0; i < Integer.parseInt(args[3]);i++) { |
| 84 |
Object[] ret = okuyamaClient.getValue("datasavekey_" + args[4] + "_" + new Integer(i).toString()); |
| 85 |
if (ret[0].equals("true")) { |
| 86 |
// データ有り |
| 87 |
if (!ret[1].equals("savedatavaluestr0987654321" + strBuf.toString() + "_" + args[4] + "_" + new Integer(i).toString())) { |
| 88 |
System.out.println("Error - Key=[" + "datasavekey_" + args[4] + "_" + new Integer(i).toString() + "] Value=[" + ret[1] + "]"); |
| 89 |
} |
| 90 |
} else if (ret[0].equals("false")) { |
| 91 |
System.out.println("データなし"); |
| 92 |
} else if (ret[0].equals("error")) { |
| 93 |
System.out.println(ret[1]); |
| 94 |
} |
| 95 |
} |
| 96 |
} |
| 97 |
long end = new Date().getTime(); |
| 98 |
System.out.println((end - start) + "milli second"); |
| 99 |
|
| 100 |
okuyamaClient.close(); |
| 101 |
} if (args[0].equals("1.1")) { |
| 102 |
|
| 103 |
int port = Integer.parseInt(args[2]); |
| 104 |
// OkuyamaClientを使用してデータを保存(Tagなし) |
| 105 |
|
| 106 |
// クライアントインスタンスを作成 |
| 107 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 108 |
|
| 109 |
// マスタサーバに接続 |
| 110 |
okuyamaClient.connect(args[1], port); |
| 111 |
|
| 112 |
|
| 113 |
long start = new Date().getTime(); |
| 114 |
if (args.length > 5) { |
| 115 |
if (!okuyamaClient.setValue(args[3], args[4], new Integer(args[5]))) { |
| 116 |
//if (!okuyamaClient.setValue("datasavekey_" + new Integer(i).toString(), "savedatavaluestr_" + new Integer(i).toString())) { |
| 117 |
System.out.println("OkuyamaClient - error"); |
| 118 |
} |
| 119 |
} else { |
| 120 |
if (!okuyamaClient.setValue(args[3], args[4])) { |
| 121 |
//if (!okuyamaClient.setValue("datasavekey_" + new Integer(i).toString(), "savedatavaluestr_" + new Integer(i).toString())) { |
| 122 |
System.out.println("OkuyamaClient - error"); |
| 123 |
} |
| 124 |
} |
| 125 |
long end = new Date().getTime(); |
| 126 |
System.out.println((end - start) + "milli second"); |
| 127 |
|
| 128 |
okuyamaClient.close(); |
| 129 |
|
| 130 |
} if (args[0].equals("1.11")) { |
| 131 |
|
| 132 |
int port = Integer.parseInt(args[2]); |
| 133 |
// OkuyamaClientを使用してデータを保存(Tagなし) |
| 134 |
|
| 135 |
// クライアントインスタンスを作成 |
| 136 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 137 |
|
| 138 |
// マスタサーバに接続 |
| 139 |
okuyamaClient.connect(args[1], port); |
| 140 |
|
| 141 |
|
| 142 |
if (!okuyamaClient.sendByteValue(args[3], args[4].getBytes())) { |
| 143 |
System.out.println("OkuyamaClient - error"); |
| 144 |
} |
| 145 |
long start = new Date().getTime(); |
| 146 |
for (int idx = 0; idx < Integer.parseInt(args[5]); idx++) { |
| 147 |
if (!okuyamaClient.sendByteValue(args[3] + "_" + idx, (args[4] + "_" + idx).getBytes())) { |
| 148 |
System.out.println("OkuyamaClient - error"); |
| 149 |
} |
| 150 |
} |
| 151 |
long end = new Date().getTime(); |
| 152 |
System.out.println((end - start) + "milli second"); |
| 153 |
|
| 154 |
okuyamaClient.close(); |
| 155 |
} else if (args[0].equals("1.2")) { |
| 156 |
// AutoConnectionモード |
| 157 |
// クライアントインスタンスを作成 |
| 158 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 159 |
|
| 160 |
// マスタサーバに接続 |
| 161 |
String[] infos = args[1].split(","); |
| 162 |
okuyamaClient.setConnectionInfos(infos); |
| 163 |
okuyamaClient.autoConnect(); |
| 164 |
|
| 165 |
long start = new Date().getTime(); |
| 166 |
for (int i = 0; i < Integer.parseInt(args[2]);i++) { |
| 167 |
// データ登録 |
| 168 |
if (!okuyamaClient.setValue("datasavekey_" + new Integer(i).toString(), "savedatavaluestr_" + new Integer(i).toString())) { |
| 169 |
System.out.println("OkuyamaClient - error"); |
| 170 |
} |
| 171 |
} |
| 172 |
long end = new Date().getTime(); |
| 173 |
System.out.println((end - start) + "milli second"); |
| 174 |
|
| 175 |
okuyamaClient.close(); |
| 176 |
} if (args[0].equals("1.3")) { |
| 177 |
|
| 178 |
int port = Integer.parseInt(args[2]); |
| 179 |
// OkuyamaClientを使用してデータを保存(Tagなし) |
| 180 |
|
| 181 |
// クライアントインスタンスを作成 |
| 182 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 183 |
|
| 184 |
// マスタサーバに接続 |
| 185 |
okuyamaClient.connect(args[1], port); |
| 186 |
|
| 187 |
StringBuffer bufs = new StringBuffer(); |
| 188 |
|
| 189 |
int idx = 0; |
| 190 |
|
| 191 |
for (int i = 0; i < Integer.parseInt(args[4]); i++) { |
| 192 |
if (idx == 0) { |
| 193 |
bufs.append("a"); |
| 194 |
idx++; |
| 195 |
} else if (idx == 1) { |
| 196 |
bufs.append("b"); |
| 197 |
idx++; |
| 198 |
} else if (idx == 2) { |
| 199 |
bufs.append("c"); |
| 200 |
idx++; |
| 201 |
} else if (idx == 3) { |
| 202 |
bufs.append("d"); |
| 203 |
idx++; |
| 204 |
} else if (idx == 4) { |
| 205 |
bufs.append("e"); |
| 206 |
idx = 0; |
| 207 |
} |
| 208 |
} |
| 209 |
|
| 210 |
|
| 211 |
long start = new Date().getTime(); |
| 212 |
|
| 213 |
if (!okuyamaClient.setValue(args[3], bufs.toString())) { |
| 214 |
//if (!okuyamaClient.setValue("datasavekey_" + new Integer(i).toString(), "savedatavaluestr_" + new Integer(i).toString())) { |
| 215 |
System.out.println("OkuyamaClient - error"); |
| 216 |
} |
| 217 |
long end = new Date().getTime(); |
| 218 |
System.out.println((end - start) + "milli second"); |
| 219 |
|
| 220 |
okuyamaClient.close(); |
| 221 |
} else if (args[0].equals("2")) { |
| 222 |
|
| 223 |
int port = Integer.parseInt(args[2]); |
| 224 |
// OkuyamaClientを使用してデータを取得(Keyのみ) |
| 225 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 226 |
okuyamaClient.connect(args[1], port); |
| 227 |
String[] ret = null; |
| 228 |
|
| 229 |
long start = new Date().getTime(); |
| 230 |
if (args.length > 4) { |
| 231 |
for (int i = 0; i < Integer.parseInt(args[3]);i++) { |
| 232 |
ret = okuyamaClient.getValue("datasavekey_" + args[4] + "_" + new Integer(i).toString()); |
| 233 |
if (ret[0].equals("true")) { |
| 234 |
// データ有り |
| 235 |
System.out.println(ret[1]); |
| 236 |
} else if (ret[0].equals("false")) { |
| 237 |
System.out.println("データなし"); |
| 238 |
} else if (ret[0].equals("error")) { |
| 239 |
System.out.println(ret[1]); |
| 240 |
} |
| 241 |
} |
| 242 |
} else { |
| 243 |
for (int i = 0; i < Integer.parseInt(args[3]);i++) { |
| 244 |
ret = okuyamaClient.getValue("datasavekey_" + new Integer(i).toString()); |
| 245 |
if (ret[0].equals("true")) { |
| 246 |
// データ有り |
| 247 |
System.out.println(ret[1]); |
| 248 |
} else if (ret[0].equals("false")) { |
| 249 |
System.out.println("データなし"); |
| 250 |
} else if (ret[0].equals("error")) { |
| 251 |
System.out.println(ret[1]); |
| 252 |
} |
| 253 |
} |
| 254 |
} |
| 255 |
long end = new Date().getTime(); |
| 256 |
System.out.println((end - start) + "milli second"); |
| 257 |
|
| 258 |
okuyamaClient.close(); |
| 259 |
} else if (args[0].equals("2.1")) { |
| 260 |
|
| 261 |
int port = Integer.parseInt(args[2]); |
| 262 |
// OkuyamaClientを使用してデータを取得(Keyのみ) |
| 263 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 264 |
okuyamaClient.connect(args[1], port); |
| 265 |
String[] ret = null; |
| 266 |
|
| 267 |
long start = new Date().getTime(); |
| 268 |
if (args.length > 4) { |
| 269 |
ret = okuyamaClient.getValue(args[3], args[4]); |
| 270 |
} else { |
| 271 |
ret = okuyamaClient.getValue(args[3]); |
| 272 |
} |
| 273 |
long end = new Date().getTime(); |
| 274 |
if (ret[0].equals("true")) { |
| 275 |
// データ有り |
| 276 |
System.out.println("Value=[" + ret[1] + "]"); |
| 277 |
} else if (ret[0].equals("false")) { |
| 278 |
System.out.println("データなし"); |
| 279 |
} else if (ret[0].equals("error")) { |
| 280 |
System.out.println(ret[1]); |
| 281 |
} |
| 282 |
System.out.println((end - start) + "milli second"); |
| 283 |
|
| 284 |
okuyamaClient.close(); |
| 285 |
} else if (args[0].equals("2.11")) { |
| 286 |
|
| 287 |
int port = Integer.parseInt(args[2]); |
| 288 |
// OkuyamaClientを使用してデータを取得(Keyのみ) |
| 289 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 290 |
okuyamaClient.connect(args[1], port); |
| 291 |
String[] ret = null; |
| 292 |
|
| 293 |
long start = new Date().getTime(); |
| 294 |
if (args.length > 4) { |
| 295 |
for (int i = 0; i < Integer.parseInt(args[3]);i++) { |
| 296 |
ret = okuyamaClient.getValue("datasavekey_" + args[4] + "_" + new Integer(i).toString()); |
| 297 |
if (ret[0].equals("true")) { |
| 298 |
// データ有り |
| 299 |
//System.out.println(ret[1]); |
| 300 |
} else if (ret[0].equals("false")) { |
| 301 |
System.out.println("データなし"); |
| 302 |
} else if (ret[0].equals("error")) { |
| 303 |
System.out.println(ret[1]); |
| 304 |
} |
| 305 |
} |
| 306 |
} else{ |
| 307 |
for (int i = 0; i < Integer.parseInt(args[3]);i++) { |
| 308 |
ret = okuyamaClient.getValue("datasavekey_" + new Integer(i).toString()); |
| 309 |
if (ret[0].equals("true")) { |
| 310 |
// データ有り |
| 311 |
} else if (ret[0].equals("false")) { |
| 312 |
System.out.println("datasavekey_" + new Integer(i).toString() + " = データなし"); |
| 313 |
} else if (ret[0].equals("error")) { |
| 314 |
System.out.println(ret[1]); |
| 315 |
} |
| 316 |
} |
| 317 |
} |
| 318 |
long end = new Date().getTime(); |
| 319 |
System.out.println((end - start) + "milli second"); |
| 320 |
|
| 321 |
okuyamaClient.close(); |
| 322 |
} else if (args[0].equals("2.2")) { |
| 323 |
// AutoConnectionモード |
| 324 |
// OkuyamaClientを使用してデータを取得(Keyのみ) |
| 325 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 326 |
String[] infos = args[1].split(","); |
| 327 |
okuyamaClient.setConnectionInfos(infos); |
| 328 |
okuyamaClient.autoConnect(); |
| 329 |
|
| 330 |
String[] ret = null; |
| 331 |
|
| 332 |
long start = new Date().getTime(); |
| 333 |
for (int i = 0; i < Integer.parseInt(args[2]);i++) { |
| 334 |
ret = okuyamaClient.getValue("datasavekey_" + new Integer(i).toString()); |
| 335 |
if (ret[0].equals("true")) { |
| 336 |
// データ有り |
| 337 |
System.out.println(ret[1]); |
| 338 |
} else if (ret[0].equals("false")) { |
| 339 |
System.out.println("データなし"); |
| 340 |
} else if (ret[0].equals("error")) { |
| 341 |
System.out.println(ret[1]); |
| 342 |
} |
| 343 |
} |
| 344 |
long end = new Date().getTime(); |
| 345 |
System.out.println((end - start) + "milli second"); |
| 346 |
|
| 347 |
okuyamaClient.close(); |
| 348 |
} else if (args[0].equals("2.22")) { |
| 349 |
// AutoConnectionモード |
| 350 |
// OkuyamaClientを使用してデータを取得(Keyのみ) |
| 351 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 352 |
String[] infos = args[1].split(","); |
| 353 |
okuyamaClient.setConnectionInfos(infos); |
| 354 |
okuyamaClient.autoConnect(); |
| 355 |
|
| 356 |
String[] ret = null; |
| 357 |
|
| 358 |
long start = new Date().getTime(); |
| 359 |
ret = okuyamaClient.getValue(args[2]); |
| 360 |
if (ret[0].equals("true")) { |
| 361 |
// データ有り |
| 362 |
System.out.println(ret[1]); |
| 363 |
} else if (ret[0].equals("false")) { |
| 364 |
System.out.println("データなし"); |
| 365 |
} else if (ret[0].equals("error")) { |
| 366 |
System.out.println(ret[1]); |
| 367 |
} |
| 368 |
long end = new Date().getTime(); |
| 369 |
System.out.println((end - start) + "milli second"); |
| 370 |
|
| 371 |
okuyamaClient.close(); |
| 372 |
|
| 373 |
} else if (args[0].equals("2.3")) { |
| 374 |
|
| 375 |
int port = Integer.parseInt(args[2]); |
| 376 |
// OkuyamaClientを使用してデータを取得(Keyのみ) |
| 377 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 378 |
okuyamaClient.connect(args[1], port); |
| 379 |
String[] ret = null; |
| 380 |
|
| 381 |
long start = new Date().getTime(); |
| 382 |
ret = okuyamaClient.getValueScript(args[3], args[4]); |
| 383 |
if (ret[0].equals("true")) { |
| 384 |
// データ有り |
| 385 |
System.out.println(ret[1]); |
| 386 |
} else if (ret[0].equals("false")) { |
| 387 |
System.out.println("データなし"); |
| 388 |
} else if (ret[0].equals("error")) { |
| 389 |
System.out.println(ret[1]); |
| 390 |
} |
| 391 |
long end = new Date().getTime(); |
| 392 |
System.out.println((end - start) + "milli second"); |
| 393 |
|
| 394 |
okuyamaClient.close(); |
| 395 |
} else if (args[0].equals("2.33")) { |
| 396 |
|
| 397 |
int port = Integer.parseInt(args[2]); |
| 398 |
// OkuyamaClientを使用してデータを取得(Keyのみ) |
| 399 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 400 |
okuyamaClient.connect(args[1], port); |
| 401 |
String[] ret = null; |
| 402 |
|
| 403 |
long start = new Date().getTime(); |
| 404 |
for (int i = 0; i < Integer.parseInt(args[3]); i++) { |
| 405 |
ret = okuyamaClient.getValueScript("datasavekey_" + new Integer(i).toString(), "var dataValue; var retValue = ''; var execRet = '0'; if (dataValue.indexOf('99') != -1) { retValue = dataValue; execRet = '1';}"); |
| 406 |
//if (ret[0].equals("true")) System.out.println(ret[1]); |
| 407 |
} |
| 408 |
long end = new Date().getTime(); |
| 409 |
System.out.println((end - start) + "milli second"); |
| 410 |
|
| 411 |
okuyamaClient.close(); |
| 412 |
} else if (args[0].equals("2.4")) { |
| 413 |
|
| 414 |
int port = Integer.parseInt(args[2]); |
| 415 |
// OkuyamaClientを使用してデータを取得(Keyのみ) |
| 416 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 417 |
okuyamaClient.connect(args[1], port); |
| 418 |
String[] ret = null; |
| 419 |
|
| 420 |
long start = new Date().getTime(); |
| 421 |
ret = okuyamaClient.getValueScriptForUpdate(args[3], args[4]); |
| 422 |
if (ret[0].equals("true")) { |
| 423 |
// データ有り |
| 424 |
System.out.println(ret[1]); |
| 425 |
} else if (ret[0].equals("false")) { |
| 426 |
System.out.println("データなし"); |
| 427 |
} else if (ret[0].equals("error")) { |
| 428 |
System.out.println(ret[1]); |
| 429 |
} |
| 430 |
long end = new Date().getTime(); |
| 431 |
System.out.println((end - start) + "milli second"); |
| 432 |
|
| 433 |
okuyamaClient.close(); |
| 434 |
} else if (args[0].equals("3")) { |
| 435 |
|
| 436 |
int port = Integer.parseInt(args[2]); |
| 437 |
// OkuyamaClientを使用してデータを保存(Tagあり) |
| 438 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 439 |
okuyamaClient.connect(args[1], port); |
| 440 |
String[] tag1 = {"tag1"}; |
| 441 |
String[] tag2 = {"tag1","tag2"}; |
| 442 |
String[] tag3 = {"tag1","tag2","tag3"}; |
| 443 |
String[] tag4 = {"tag4"}; |
| 444 |
String[] setTag = null; |
| 445 |
int counter = 0; |
| 446 |
|
| 447 |
long start = new Date().getTime(); |
| 448 |
|
| 449 |
for (int i = 0; i < Integer.parseInt(args[3]);i++) { |
| 450 |
if (counter == 0) { |
| 451 |
setTag = tag1; |
| 452 |
counter++; |
| 453 |
} else if (counter == 1) { |
| 454 |
setTag = tag2; |
| 455 |
counter++; |
| 456 |
} else if (counter == 2) { |
| 457 |
setTag = tag3; |
| 458 |
counter++; |
| 459 |
} else if (counter == 3) { |
| 460 |
setTag = tag4; |
| 461 |
counter = 0; |
| 462 |
} |
| 463 |
|
| 464 |
if (!okuyamaClient.setValue("tagsampledatakey_" + new Integer(i).toString(), setTag, "tagsamplesavedata_" + new Integer(i).toString())) { |
| 465 |
System.out.println("OkuyamaClient - error"); |
| 466 |
} |
| 467 |
} |
| 468 |
long end = new Date().getTime(); |
| 469 |
System.out.println((end - start) + "milli second"); |
| 470 |
|
| 471 |
okuyamaClient.close(); |
| 472 |
|
| 473 |
} else if (args[0].equals("3.1")) { |
| 474 |
|
| 475 |
int port = Integer.parseInt(args[2]); |
| 476 |
// OkuyamaClientを使用してデータを保存(Tagあり) |
| 477 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 478 |
okuyamaClient.connect(args[1], port); |
| 479 |
String[] tag1 = {"tag1-d"}; |
| 480 |
String[] tag2 = {"tag1-d","tag2-d"}; |
| 481 |
String[] tag3 = {"tag1-d","tag2-d","tag3-d"}; |
| 482 |
String[] tag4 = {"tag4-d"}; |
| 483 |
|
| 484 |
String[] setTag = null; |
| 485 |
int counter = 0; |
| 486 |
|
| 487 |
long start = new Date().getTime(); |
| 488 |
|
| 489 |
Random rnd = new Random(); |
| 490 |
for (int i = 0; i < Integer.parseInt(args[3]);i++) { |
| 491 |
if (counter == 0) { |
| 492 |
setTag = tag1; |
| 493 |
counter++; |
| 494 |
} else if (counter == 1) { |
| 495 |
setTag = tag2; |
| 496 |
counter++; |
| 497 |
} else if (counter == 2) { |
| 498 |
setTag = tag3; |
| 499 |
counter++; |
| 500 |
} else if (counter == 3) { |
| 501 |
setTag = tag4; |
| 502 |
counter = 0; |
| 503 |
} |
| 504 |
|
| 505 |
int expireTime = rnd.nextInt(60); |
| 506 |
if (expireTime < 1) expireTime = 10; |
| 507 |
if (!okuyamaClient.setValue("tagsampledatakey_d_" + new Integer(i).toString(), setTag, "tagsamplesavedata_d_" + new Integer(i).toString(), expireTime)) { |
| 508 |
System.out.println("OkuyamaClient - error"); |
| 509 |
} |
| 510 |
} |
| 511 |
long end = new Date().getTime(); |
| 512 |
System.out.println((end - start) + "milli second"); |
| 513 |
|
| 514 |
okuyamaClient.close(); |
| 515 |
|
| 516 |
} else if (args[0].equals("3.9")) { |
| 517 |
|
| 518 |
int port = Integer.parseInt(args[2]); |
| 519 |
// OkuyamaClientを使用してデータを保存(Tagあり) |
| 520 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 521 |
okuyamaClient.connect(args[1], port); |
| 522 |
String[] tag1 = {"tag11"}; |
| 523 |
String[] setTag = null; |
| 524 |
int counter = 0; |
| 525 |
|
| 526 |
long start = new Date().getTime(); |
| 527 |
long end = 0L; |
| 528 |
for (int i = 0; i < Integer.parseInt(args[3]);i++) { |
| 529 |
setTag = tag1; |
| 530 |
|
| 531 |
if (!okuyamaClient.setValue("tagsampledatakey_" + new Integer(i).toString(), setTag, "tagsamplesavedata_" + new Integer(i).toString())) { |
| 532 |
System.out.println("OkuyamaClient - error"); |
| 533 |
} |
| 534 |
if ((i % 1000) == 0) { |
| 535 |
end = new Date().getTime(); |
| 536 |
System.out.println((end - start)); |
| 537 |
start = new Date().getTime(); |
| 538 |
} |
| 539 |
} |
| 540 |
end = new Date().getTime(); |
| 541 |
System.out.println((end - start) + "milli second"); |
| 542 |
|
| 543 |
okuyamaClient.close(); |
| 544 |
} else if (args[0].equals("3.2")) { |
| 545 |
int port = Integer.parseInt(args[2]); |
| 546 |
// OkuyamaClientを使用してデータを保存(Tagあり) |
| 547 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 548 |
okuyamaClient.connect(args[1], port); |
| 549 |
String[] setTag = args[3].split(" "); |
| 550 |
|
| 551 |
int counter = 0; |
| 552 |
String keyStr = null; |
| 553 |
|
| 554 |
long start = new Date().getTime(); |
| 555 |
for (int idx = 0; idx < Integer.parseInt(args[4]); idx++) { |
| 556 |
okuyamaClient.setValue(new Integer(idx).toString(), setTag, new Integer(idx).toString()); |
| 557 |
} |
| 558 |
long end = new Date().getTime(); |
| 559 |
System.out.println((end - start) + "milli second"); |
| 560 |
|
| 561 |
okuyamaClient.close(); |
| 562 |
} else if (args[0].equals("3.3")) { |
| 563 |
int port = Integer.parseInt(args[2]); |
| 564 |
// OkuyamaClientを使用してデータを保存(Tagあり) |
| 565 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 566 |
okuyamaClient.connect(args[1], port); |
| 567 |
String[] setTag = args[4].split(" "); |
| 568 |
|
| 569 |
int counter = 0; |
| 570 |
String keyStr = null; |
| 571 |
|
| 572 |
long start = new Date().getTime(); |
| 573 |
okuyamaClient.setValue(args[3], setTag, args[5]); |
| 574 |
long end = new Date().getTime(); |
| 575 |
System.out.println((end - start) + "milli second"); |
| 576 |
|
| 577 |
okuyamaClient.close(); |
| 578 |
} else if (args[0].equals("4")) { |
| 579 |
|
| 580 |
int port = Integer.parseInt(args[2]); |
| 581 |
// OkuyamaClientを使用してデータを取得(Tagでの取得) |
| 582 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 583 |
okuyamaClient.connect(args[1], port); |
| 584 |
|
| 585 |
String[] keys = null; |
| 586 |
boolean noExistsData = true; |
| 587 |
if (args.length > 5) noExistsData = new Boolean(args[5]).booleanValue(); |
| 588 |
|
| 589 |
long start = new Date().getTime(); |
| 590 |
for (int i = 0; i < Integer.parseInt(args[3]); i++) { |
| 591 |
|
| 592 |
Object[] ret = okuyamaClient.getTagKeys(args[4], noExistsData); |
| 593 |
long end = new Date().getTime(); |
| 594 |
System.out.println((end - start)); |
| 595 |
|
| 596 |
if (ret[0].equals("true")) { |
| 597 |
// データ有り |
| 598 |
keys = (String[])ret[1]; |
| 599 |
System.out.println("ResultCount=" + keys.length); |
| 600 |
/*for (int idx = 0; idx < keys.length; idx++) { |
| 601 |
System.out.println(keys[idx]); |
| 602 |
}*/ |
| 603 |
} else if (ret[0].equals("false")) { |
| 604 |
System.out.println("データなし"); |
| 605 |
} else if (ret[0].equals("error")) { |
| 606 |
System.out.println(ret[1]); |
| 607 |
} |
| 608 |
} |
| 609 |
|
| 610 |
if (keys != null) { |
| 611 |
for (int ii = 0; ii < keys.length; ii++) { |
| 612 |
System.out.println("Key=[" + keys[ii] + "]"); |
| 613 |
String[] ret = okuyamaClient.getValue(keys[ii]); |
| 614 |
System.out.println("Value=[" + ret[1] + "]"); |
| 615 |
} |
| 616 |
} |
| 617 |
okuyamaClient.close(); |
| 618 |
} else if (args[0].equals("4.1")) { |
| 619 |
|
| 620 |
int port = Integer.parseInt(args[2]); |
| 621 |
// OkuyamaClientを使用してデータを取得(Tagでの取得) |
| 622 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 623 |
okuyamaClient.connect(args[1], port); |
| 624 |
|
| 625 |
String[] keys = null; |
| 626 |
boolean noExistsData = true; |
| 627 |
if (args.length > 5) noExistsData = new Boolean(args[5]).booleanValue(); |
| 628 |
|
| 629 |
long start = new Date().getTime(); |
| 630 |
for (int i = 0; i < Integer.parseInt(args[3]); i++) { |
| 631 |
|
| 632 |
Object[] ret = okuyamaClient.getTagKeys(args[4], noExistsData, false); |
| 633 |
long end = new Date().getTime(); |
| 634 |
System.out.println((end - start)); |
| 635 |
|
| 636 |
if (ret[0].equals("true")) { |
| 637 |
// データ有り |
| 638 |
keys = (String[])ret[1]; |
| 639 |
System.out.println("ResultCount=" + keys.length); |
| 640 |
/*for (int idx = 0; idx < keys.length; idx++) { |
| 641 |
System.out.println(keys[idx]); |
| 642 |
}*/ |
| 643 |
} else if (ret[0].equals("false")) { |
| 644 |
System.out.println("データなし"); |
| 645 |
} else if (ret[0].equals("error")) { |
| 646 |
System.out.println(ret[1]); |
| 647 |
} |
| 648 |
} |
| 649 |
|
| 650 |
okuyamaClient.close(); |
| 651 |
} else if (args[0].equals("5")) { |
| 652 |
int port = Integer.parseInt(args[2]); |
| 653 |
// OkuyamaClientでファイルをキー値で保存する |
| 654 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 655 |
okuyamaClient.connect(args[1], port); |
| 656 |
String[] keys = null; |
| 657 |
long start = new Date().getTime(); |
| 658 |
// args[4]はファイル名、args[5]はキー値 |
| 659 |
for (int i = 0; i < Integer.parseInt(args[3]); i++) { |
| 660 |
// ファイルをバイナリで読み込み |
| 661 |
byte[] fileByte = null; |
| 662 |
File file = new File(args[4]); |
| 663 |
fileByte = new byte[new Long(file.length()).intValue()]; |
| 664 |
FileInputStream fis = new FileInputStream(file); |
| 665 |
fis.read(fileByte, 0, fileByte.length); |
| 666 |
//okuyamaClient.setCompressMode(true); |
| 667 |
if (!okuyamaClient.setByteValue(args[5], fileByte)) { |
| 668 |
System.out.println("OkuyamaClient - error"); |
| 669 |
} |
| 670 |
fis.close(); |
| 671 |
} |
| 672 |
long end = new Date().getTime(); |
| 673 |
System.out.println((end - start)); |
| 674 |
okuyamaClient.close(); |
| 675 |
} else if (args[0].equals("5.1")) { |
| 676 |
int port = Integer.parseInt(args[2]); |
| 677 |
// OkuyamaClientでファイルのバイナリデータをBase64にエンコードして文字列として保存 |
| 678 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 679 |
okuyamaClient.connect(args[1], port); |
| 680 |
String[] keys = null; |
| 681 |
long start = new Date().getTime(); |
| 682 |
// args[3]はファイル名、args[4]はキー値 |
| 683 |
|
| 684 |
// ファイルをバイナリで読み込み |
| 685 |
byte[] fileByte = null; |
| 686 |
File file = new File(args[3]); |
| 687 |
fileByte = new byte[new Long(file.length()).intValue()]; |
| 688 |
FileInputStream fis = new FileInputStream(file); |
| 689 |
fis.read(fileByte, 0, fileByte.length); |
| 690 |
//okuyamaClient.setCompressMode(true); |
| 691 |
if (!okuyamaClient.sendByteValue(args[4], fileByte)) { |
| 692 |
System.out.println("OkuyamaClient - error"); |
| 693 |
} |
| 694 |
fis.close(); |
| 695 |
|
| 696 |
long end = new Date().getTime(); |
| 697 |
System.out.println((end - start)); |
| 698 |
okuyamaClient.close(); |
| 699 |
|
| 700 |
} else if (args[0].equals("6")) { |
| 701 |
int port = Integer.parseInt(args[2]); |
| 702 |
// OkuyamaClientを使用してデータを取得(Keyのみ)(バイナリ) |
| 703 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 704 |
okuyamaClient.connect(args[1], port); |
| 705 |
Object[] ret = null; |
| 706 |
long start = new Date().getTime(); |
| 707 |
|
| 708 |
for (int i = 0; i < Integer.parseInt(args[3]);i++) { |
| 709 |
//okuyamaClient.setCompressMode(true); |
| 710 |
ret = okuyamaClient.getByteValue(args[5]); |
| 711 |
if (ret[0].equals("true")) { |
| 712 |
// データ有り |
| 713 |
byte[] fileByte = null; |
| 714 |
File file = new File(args[4]); |
| 715 |
FileOutputStream fos = new FileOutputStream(file); |
| 716 |
fileByte = (byte[])ret[1]; |
| 717 |
fos.write(fileByte, 0, fileByte.length); |
| 718 |
fos.close(); |
| 719 |
} else if (ret[0].equals("false")) { |
| 720 |
System.out.println("データなし"); |
| 721 |
} else if (ret[0].equals("error")) { |
| 722 |
System.out.println(ret[1]); |
| 723 |
} |
| 724 |
} |
| 725 |
long end = new Date().getTime(); |
| 726 |
System.out.println((end - start)); |
| 727 |
okuyamaClient.close(); |
| 728 |
} else if (args[0].equals("6.1")) { |
| 729 |
int port = Integer.parseInt(args[2]); |
| 730 |
// OkuyamaClientを使用してデータを取得(Keyのみ)(バイナリ) |
| 731 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 732 |
okuyamaClient.connect(args[1], port); |
| 733 |
Object[] ret = null; |
| 734 |
long start = new Date().getTime(); |
| 735 |
|
| 736 |
for (int i = 0; i < Integer.parseInt(args[3]);i++) { |
| 737 |
//okuyamaClient.setCompressMode(true); |
| 738 |
ret = okuyamaClient.getByteValueVer2(args[5]); |
| 739 |
if (ret[0].equals("true")) { |
| 740 |
// データ有り |
| 741 |
byte[] fileByte = null; |
| 742 |
File file = new File(args[4]); |
| 743 |
FileOutputStream fos = new FileOutputStream(file); |
| 744 |
fileByte = (byte[])ret[1]; |
| 745 |
fos.write(fileByte, 0, fileByte.length); |
| 746 |
fos.close(); |
| 747 |
} else if (ret[0].equals("false")) { |
| 748 |
System.out.println("データなし"); |
| 749 |
} else if (ret[0].equals("error")) { |
| 750 |
System.out.println(ret[1]); |
| 751 |
} |
| 752 |
} |
| 753 |
long end = new Date().getTime(); |
| 754 |
System.out.println((end - start)); |
| 755 |
okuyamaClient.close(); |
| 756 |
} else if (args[0].equals("6.2")) { |
| 757 |
int port = Integer.parseInt(args[2]); |
| 758 |
// OkuyamaClientを使用してデータを取得(Keyのみ)(バイナリ) |
| 759 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 760 |
okuyamaClient.connect(args[1], port); |
| 761 |
Object[] ret = null; |
| 762 |
long start = new Date().getTime(); |
| 763 |
|
| 764 |
for (int i = 0; i < Integer.parseInt(args[3]);i++) { |
| 765 |
//okuyamaClient.setCompressMode(true); |
| 766 |
ret = okuyamaClient.readByteValue(args[5]); |
| 767 |
if (ret[0].equals("true")) { |
| 768 |
// データ有り |
| 769 |
byte[] fileByte = null; |
| 770 |
File file = new File(args[4]); |
| 771 |
FileOutputStream fos = new FileOutputStream(file); |
| 772 |
fileByte = (byte[])ret[1]; |
| 773 |
fos.write(fileByte, 0, fileByte.length); |
| 774 |
fos.close(); |
| 775 |
} else if (ret[0].equals("false")) { |
| 776 |
System.out.println("データなし"); |
| 777 |
} else if (ret[0].equals("error")) { |
| 778 |
System.out.println(ret[1]); |
| 779 |
} |
| 780 |
} |
| 781 |
long end = new Date().getTime(); |
| 782 |
System.out.println((end - start)); |
| 783 |
okuyamaClient.close(); |
| 784 |
} else if (args[0].equals("7")) { |
| 785 |
int port = Integer.parseInt(args[2]); |
| 786 |
// OkuyamaClientを使用してデータを削除 |
| 787 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 788 |
okuyamaClient.connect(args[1], port); |
| 789 |
String[] ret = null; |
| 790 |
|
| 791 |
long start = new Date().getTime(); |
| 792 |
if (args.length > 4) { |
| 793 |
|
| 794 |
for (int i = 0; i < Integer.parseInt(args[3]);i++) { |
| 795 |
ret = okuyamaClient.removeValue("datasavekey_" + args[4] + "_" + new Integer(i).toString()); |
| 796 |
if (ret[0].equals("true")) { |
| 797 |
// データ有り |
| 798 |
System.out.println(ret[1]); |
| 799 |
} else if (ret[0].equals("false")) { |
| 800 |
System.out.println("データなし"); |
| 801 |
} else if (ret[0].equals("error")) { |
| 802 |
System.out.println(ret[1]); |
| 803 |
} |
| 804 |
} |
| 805 |
} else { |
| 806 |
|
| 807 |
for (int i = 0; i < Integer.parseInt(args[3]);i++) { |
| 808 |
ret = okuyamaClient.removeValue("datasavekey_" + new Integer(i).toString()); |
| 809 |
if (ret[0].equals("true")) { |
| 810 |
// データ有り |
| 811 |
System.out.println(ret[1]); |
| 812 |
} else if (ret[0].equals("false")) { |
| 813 |
System.out.println("データなし"); |
| 814 |
} else if (ret[0].equals("error")) { |
| 815 |
System.out.println(ret[1]); |
| 816 |
} |
| 817 |
} |
| 818 |
} |
| 819 |
long end = new Date().getTime(); |
| 820 |
System.out.println((end - start) + "milli second"); |
| 821 |
|
| 822 |
okuyamaClient.close(); |
| 823 |
} else if (args[0].equals("7.1")) { |
| 824 |
int port = Integer.parseInt(args[2]); |
| 825 |
// OkuyamaClientを使用してTag用のテストKey値データを削除 |
| 826 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 827 |
okuyamaClient.connect(args[1], port); |
| 828 |
String[] ret = null; |
| 829 |
|
| 830 |
long start = new Date().getTime(); |
| 831 |
for (int i = 0; i < Integer.parseInt(args[3]);i++) { |
| 832 |
ret = okuyamaClient.removeValue("tagsampledatakey_" + new Integer(i).toString()); |
| 833 |
if (ret[0].equals("true")) { |
| 834 |
// データ有り |
| 835 |
System.out.println(ret[1]); |
| 836 |
} else if (ret[0].equals("false")) { |
| 837 |
System.out.println("データなし"); |
| 838 |
} else if (ret[0].equals("error")) { |
| 839 |
System.out.println(ret[1]); |
| 840 |
} |
| 841 |
} |
| 842 |
long end = new Date().getTime(); |
| 843 |
System.out.println((end - start) + "milli second"); |
| 844 |
|
| 845 |
okuyamaClient.close(); |
| 846 |
} else if (args[0].equals("8")) { |
| 847 |
int port = Integer.parseInt(args[2]); |
| 848 |
// OkuyamaClientを使用してデータを削除 |
| 849 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 850 |
okuyamaClient.connect(args[1], port); |
| 851 |
String[] ret = null; |
| 852 |
|
| 853 |
long start = new Date().getTime(); |
| 854 |
|
| 855 |
ret = okuyamaClient.removeValue(args[3]); |
| 856 |
if (ret[0].equals("true")) { |
| 857 |
// データ有り |
| 858 |
System.out.println(ret[1]); |
| 859 |
} else if (ret[0].equals("false")) { |
| 860 |
System.out.println("データなし"); |
| 861 |
} else if (ret[0].equals("error")) { |
| 862 |
System.out.println(ret[1]); |
| 863 |
} |
| 864 |
long end = new Date().getTime(); |
| 865 |
System.out.println((end - start) + "milli second"); |
| 866 |
|
| 867 |
okuyamaClient.close(); |
| 868 |
} else if (args[0].equals("9")) { |
| 869 |
int port = Integer.parseInt(args[2]); |
| 870 |
// Transactionを開始してデータをLock後、データを更新、取得し、Lockを解除 |
| 871 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 872 |
okuyamaClient.connect(args[1], port); |
| 873 |
String[] ret = null; |
| 874 |
|
| 875 |
long start = new Date().getTime(); |
| 876 |
|
| 877 |
okuyamaClient.startTransaction(); |
| 878 |
okuyamaClient.lockData("datasavekey_3", 20, 5); |
| 879 |
okuyamaClient.lockData("datasavekey_2", 5, 5); |
| 880 |
if (!okuyamaClient.setValue("datasavekey_3", "locktestdata")) { |
| 881 |
|
| 882 |
System.out.println("OkuyamaClient - Lock Update Error"); |
| 883 |
} |
| 884 |
ret = okuyamaClient.getValue("datasavekey_3"); |
| 885 |
if (ret[0].equals("true")) { |
| 886 |
// データ有り |
| 887 |
System.out.println(ret[1]); |
| 888 |
} else if (ret[0].equals("false")) { |
| 889 |
System.out.println("データなし"); |
| 890 |
} else if (ret[0].equals("error")) { |
| 891 |
System.out.println(ret[1]); |
| 892 |
} |
| 893 |
|
| 894 |
|
| 895 |
//Thread.sleep(10000); |
| 896 |
//okuyamaClient.releaseLockData("datasavekey_3"); |
| 897 |
|
| 898 |
long end = new Date().getTime(); |
| 899 |
System.out.println((end - start) + "milli second"); |
| 900 |
|
| 901 |
okuyamaClient.close(); |
| 902 |
} else if (args[0].equals("10")) { |
| 903 |
int port = Integer.parseInt(args[2]); |
| 904 |
// Transactionを開始してデータをLock後、データを更新、取得し、Lockを解除 |
| 905 |
|
| 906 |
// 引数はLock対象のKey値, Lock維持時間(秒)(0は無制限), Lockが既に取得されている場合の取得リトライし続ける時間(秒)(0は1回取得を試みる) |
| 907 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 908 |
okuyamaClient.connect(args[1], port); |
| 909 |
String[] ret = null; |
| 910 |
|
| 911 |
// Lock準備 |
| 912 |
if(!okuyamaClient.startTransaction()) { |
| 913 |
throw new Exception("Transactionの開始に失敗"); |
| 914 |
} |
| 915 |
|
| 916 |
long start = new Date().getTime(); |
| 917 |
|
| 918 |
// Lock実行 |
| 919 |
ret = okuyamaClient.lockData(args[3], Integer.parseInt(args[4]), Integer.parseInt(args[5])); |
| 920 |
if (ret[0].equals("true")) { |
| 921 |
System.out.println("Lock成功"); |
| 922 |
} else if (ret[0].equals("false")) { |
| 923 |
System.out.println("Lock失敗"); |
| 924 |
} |
| 925 |
|
| 926 |
|
| 927 |
// 以下のコメントアウトをはずして、コンパイルし、 |
| 928 |
// 別のクライアントから更新を実行すると、更新できないのが、わかる |
| 929 |
Thread.sleep(5000); |
| 930 |
|
| 931 |
// 自身でロックしているので更新可能 |
| 932 |
if (!okuyamaClient.setValue(args[3], "LockDataValue")) { |
| 933 |
System.out.println("登録失敗"); |
| 934 |
} |
| 935 |
|
| 936 |
ret = okuyamaClient.getValue(args[3]); |
| 937 |
if (ret[0].equals("true")) { |
| 938 |
// データ有り |
| 939 |
System.out.println("Lock中に登録したデータ[" + ret[1] + "]"); |
| 940 |
} else if (ret[0].equals("false")) { |
| 941 |
System.out.println("データなし"); |
| 942 |
} else if (ret[0].equals("error")) { |
| 943 |
System.out.println(ret[1]); |
| 944 |
} |
| 945 |
|
| 946 |
// 自身でロックしているので削除可能 |
| 947 |
ret = okuyamaClient.removeValue(args[3]); |
| 948 |
|
| 949 |
if (ret[0].equals("true")) { |
| 950 |
// データ有り |
| 951 |
System.out.println("Lock中に削除したデータ[" + ret[1] + "]"); |
| 952 |
} else if (ret[0].equals("false")) { |
| 953 |
System.out.println("データなし"); |
| 954 |
} else if (ret[0].equals("error")) { |
| 955 |
System.out.println(ret[1]); |
| 956 |
} |
| 957 |
|
| 958 |
// Lock開放 |
| 959 |
ret = okuyamaClient.releaseLockData(args[3]); |
| 960 |
if (ret[0].equals("true")) { |
| 961 |
System.out.println("Lock開放成功"); |
| 962 |
} else if (ret[0].equals("false")) { |
| 963 |
System.out.println("Lock開放失敗"); |
| 964 |
} |
| 965 |
|
| 966 |
long end = new Date().getTime(); |
| 967 |
System.out.println((end - start) + "milli second"); |
| 968 |
|
| 969 |
// トランザクション開放 |
| 970 |
okuyamaClient.endTransaction(); |
| 971 |
okuyamaClient.close(); |
| 972 |
} else if (args[0].equals("11")) { |
| 973 |
|
| 974 |
int port = Integer.parseInt(args[2]); |
| 975 |
// OkuyamaClientを使用してデータを保存一度登録した値はエラー |
| 976 |
|
| 977 |
// クライアントインスタンスを作成 |
| 978 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 979 |
|
| 980 |
// マスタサーバに接続 |
| 981 |
okuyamaClient.connect(args[1], port); |
| 982 |
|
| 983 |
String[] retParam = null; |
| 984 |
long start = new Date().getTime(); |
| 985 |
|
| 986 |
if (args.length == 6) { |
| 987 |
retParam = okuyamaClient.setNewValue(args[3], args[4], new Integer(args[5])); |
| 988 |
|
| 989 |
} else if (args.length == 7) { |
| 990 |
retParam = okuyamaClient.setNewValue(args[3], args[4], args[5], new Integer(args[6])); |
| 991 |
} else { |
| 992 |
retParam = okuyamaClient.setNewValue(args[3], args[4]); |
| 993 |
} |
| 994 |
|
| 995 |
if(retParam[0].equals("false")) { |
| 996 |
|
| 997 |
System.out.println(retParam[1]); |
| 998 |
} else { |
| 999 |
|
| 1000 |
System.out.println("処理成功"); |
| 1001 |
} |
| 1002 |
long end = new Date().getTime(); |
| 1003 |
System.out.println((end - start) + "milli second"); |
| 1004 |
|
| 1005 |
okuyamaClient.close(); |
| 1006 |
} else if (args[0].equals("12")) { |
| 1007 |
|
| 1008 |
int port = Integer.parseInt(args[2]); |
| 1009 |
// OkuyamaClientを使用してデータを保存一度登録した値はエラー |
| 1010 |
// Tag有り |
| 1011 |
|
| 1012 |
// クライアントインスタンスを作成 |
| 1013 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1014 |
|
| 1015 |
// マスタサーバに接続 |
| 1016 |
okuyamaClient.connect(args[1], port); |
| 1017 |
|
| 1018 |
|
| 1019 |
long start = new Date().getTime(); |
| 1020 |
String[] tags = args[4].split(","); |
| 1021 |
String[] retParam = okuyamaClient.setNewValue(args[3], tags, args[5]); |
| 1022 |
if(retParam[0].equals("false")) { |
| 1023 |
|
| 1024 |
System.out.println(retParam[1]); |
| 1025 |
} else { |
| 1026 |
|
| 1027 |
System.out.println("処理成功"); |
| 1028 |
} |
| 1029 |
long end = new Date().getTime(); |
| 1030 |
System.out.println((end - start) + "milli second"); |
| 1031 |
|
| 1032 |
okuyamaClient.close(); |
| 1033 |
} else if (args[0].equals("13")) { |
| 1034 |
|
| 1035 |
int port = Integer.parseInt(args[2]); |
| 1036 |
// OkuyamaClientを使用してデータを取得(getValueVersionCheck) |
| 1037 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1038 |
okuyamaClient.connect(args[1], port); |
| 1039 |
String[] ret = null; |
| 1040 |
|
| 1041 |
long start = new Date().getTime(); |
| 1042 |
if (args.length > 4) { |
| 1043 |
for (int i = 0; i < Integer.parseInt(args[3]);i++) { |
| 1044 |
ret = okuyamaClient.getValueVersionCheck("datasavekey_" + args[4] + "_" + new Integer(i).toString()); |
| 1045 |
if (ret[0].equals("true")) { |
| 1046 |
// データ有り |
| 1047 |
System.out.println("Value=[" + ret[1] + "]"); |
| 1048 |
System.out.println("VersionNo=[" + ret[2] + "]"); |
| 1049 |
} else if (ret[0].equals("false")) { |
| 1050 |
System.out.println("データなし"); |
| 1051 |
} else if (ret[0].equals("error")) { |
| 1052 |
System.out.println(ret[1]); |
| 1053 |
System.out.println(ret[2]); |
| 1054 |
} |
| 1055 |
} |
| 1056 |
} else { |
| 1057 |
for (int i = 0; i < Integer.parseInt(args[3]);i++) { |
| 1058 |
ret = okuyamaClient.getValueVersionCheck("datasavekey_" + new Integer(i).toString()); |
| 1059 |
if (ret[0].equals("true")) { |
| 1060 |
// データ有り |
| 1061 |
System.out.println(ret[1]); |
| 1062 |
System.out.println("VersionNo=[" + ret[2] + "]"); |
| 1063 |
} else if (ret[0].equals("false")) { |
| 1064 |
System.out.println("データなし"); |
| 1065 |
} else if (ret[0].equals("error")) { |
| 1066 |
System.out.println(ret[1]); |
| 1067 |
System.out.println(ret[2]); |
| 1068 |
} |
| 1069 |
} |
| 1070 |
} |
| 1071 |
long end = new Date().getTime(); |
| 1072 |
System.out.println((end - start) + "milli second"); |
| 1073 |
|
| 1074 |
okuyamaClient.close(); |
| 1075 |
} else if (args[0].equals("13.1")) { |
| 1076 |
|
| 1077 |
int port = Integer.parseInt(args[2]); |
| 1078 |
// OkuyamaClientを使用してデータを取得(Keyのみ) |
| 1079 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1080 |
okuyamaClient.connect(args[1], port); |
| 1081 |
String[] ret = null; |
| 1082 |
|
| 1083 |
long start = new Date().getTime(); |
| 1084 |
ret = okuyamaClient.getValueVersionCheck(args[3]); |
| 1085 |
if (ret[0].equals("true")) { |
| 1086 |
|
| 1087 |
// データ有り |
| 1088 |
System.out.println("Value=[" + ret[1] + "]"); |
| 1089 |
System.out.println("VersionNo=[" + ret[2] + "]"); |
| 1090 |
} else if (ret[0].equals("false")) { |
| 1091 |
System.out.println("データなし"); |
| 1092 |
} else if (ret[0].equals("error")) { |
| 1093 |
System.out.println(ret[1]); |
| 1094 |
System.out.println(ret[2]); |
| 1095 |
} |
| 1096 |
long end = new Date().getTime(); |
| 1097 |
System.out.println((end - start) + "milli second"); |
| 1098 |
|
| 1099 |
okuyamaClient.close(); |
| 1100 |
} else if (args[0].equals("14")) { |
| 1101 |
|
| 1102 |
int port = Integer.parseInt(args[2]); |
| 1103 |
// OkuyamaClientを使用してデータを保存 |
| 1104 |
// バージョンチェック有り |
| 1105 |
|
| 1106 |
// クライアントインスタンスを作成 |
| 1107 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1108 |
|
| 1109 |
// マスタサーバに接続 |
| 1110 |
okuyamaClient.connect(args[1], port); |
| 1111 |
|
| 1112 |
|
| 1113 |
long start = new Date().getTime(); |
| 1114 |
String[] retParam = okuyamaClient.setValueVersionCheck(args[3], args[4], args[5]); |
| 1115 |
if(retParam[0].equals("false")) { |
| 1116 |
|
| 1117 |
System.out.println(retParam[1]); |
| 1118 |
} else { |
| 1119 |
|
| 1120 |
System.out.println("処理成功"); |
| 1121 |
} |
| 1122 |
long end = new Date().getTime(); |
| 1123 |
System.out.println((end - start) + "milli second"); |
| 1124 |
|
| 1125 |
okuyamaClient.close(); |
| 1126 |
} else if (args[0].equals("15")) { |
| 1127 |
|
| 1128 |
int port = Integer.parseInt(args[2]); |
| 1129 |
// OkuyamaClientを使用してデータを保存 |
| 1130 |
// バージョンチェック有り |
| 1131 |
// Tag有り |
| 1132 |
|
| 1133 |
// クライアントインスタンスを作成 |
| 1134 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1135 |
|
| 1136 |
// マスタサーバに接続 |
| 1137 |
okuyamaClient.connect(args[1], port); |
| 1138 |
|
| 1139 |
|
| 1140 |
long start = new Date().getTime(); |
| 1141 |
String[] tags = args[4].split(","); |
| 1142 |
String[] retParam = okuyamaClient.setValueVersionCheck(args[3], tags, args[5], args[6]); |
| 1143 |
if(retParam[0].equals("false")) { |
| 1144 |
|
| 1145 |
System.out.println(retParam[1]); |
| 1146 |
} else { |
| 1147 |
|
| 1148 |
System.out.println("処理成功"); |
| 1149 |
} |
| 1150 |
long end = new Date().getTime(); |
| 1151 |
System.out.println((end - start) + "milli second"); |
| 1152 |
|
| 1153 |
okuyamaClient.close(); |
| 1154 |
} else if (args[0].equals("22")) { |
| 1155 |
|
| 1156 |
int port = Integer.parseInt(args[2]); |
| 1157 |
// OkuyamaClientを使用してデータを取得(Keyのみ) |
| 1158 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1159 |
okuyamaClient.connect(args[1], port); |
| 1160 |
String[] ret = null; |
| 1161 |
String[] multiKeys = null; |
| 1162 |
|
| 1163 |
if (args.length > 4) { |
| 1164 |
multiKeys = new String[Integer.parseInt(args[3])]; |
| 1165 |
for (int i = 0; i < Integer.parseInt(args[3]);i++) { |
| 1166 |
multiKeys[i] = "datasavekey_" + args[4] + "_" + new Integer(i).toString(); |
| 1167 |
} |
| 1168 |
} else { |
| 1169 |
multiKeys = new String[Integer.parseInt(args[3])]; |
| 1170 |
for (int i = 0; i < Integer.parseInt(args[3]);i++) { |
| 1171 |
multiKeys[i] = "datasavekey_" + new Integer(i).toString(); |
| 1172 |
} |
| 1173 |
} |
| 1174 |
|
| 1175 |
long start = new Date().getTime(); |
| 1176 |
Map retMap = okuyamaClient.getMultiValue(multiKeys); |
| 1177 |
long end = new Date().getTime(); |
| 1178 |
if (retMap == null) { |
| 1179 |
System.out.println(retMap); |
| 1180 |
} else { |
| 1181 |
|
| 1182 |
if (args.length > 4) { |
| 1183 |
for (int i = 0; i < Integer.parseInt(args[3]);i++) { |
| 1184 |
String val = (String)retMap.get("datasavekey_" + args[4] + "_" + new Integer(i).toString()); |
| 1185 |
if(val == null || !val.equals("savedatavaluestr0987654321qazxswedcvfrtgbnhyujm,kiol<MKIUJNBGTRFBVFREDCXSWQAZXSWEDCVFRTGBNHY678745_savedatavaluestr0987654321qazxswedcvfrtgbnhyujm,kiol<MKIUJNBGTRFBVFREDCXSWQAZXSWEDCVFRTGBNHY678745savedatavaluestr0987654321qazxswedcvfrtgbnhyujm,kiol" + args[4] + "_" + new Integer(i).toString())) { |
| 1186 |
System.out.println("Error - Key=[" + "datasavekey_" + args[4] + "_" + new Integer(i).toString() + " Value=[" + val + "]"); |
| 1187 |
} |
| 1188 |
} |
| 1189 |
} else { |
| 1190 |
for (int i = 0; i < Integer.parseInt(args[3]);i++) { |
| 1191 |
String val = (String)retMap.get("datasavekey_" + new Integer(i).toString()); |
| 1192 |
if(val == null || !val.equals("savedatavaluestr_" + new Integer(i).toString())) { |
| 1193 |
System.out.println("Error - Key=[" + "datasavekey_" + new Integer(i).toString() + " Value=[" + val + "]"); |
| 1194 |
} |
| 1195 |
} |
| 1196 |
} |
| 1197 |
System.out.println(retMap); |
| 1198 |
System.out.println("ResultSize = [" + retMap.size() + "]"); |
| 1199 |
} |
| 1200 |
System.out.println((end - start) + "milli second"); |
| 1201 |
|
| 1202 |
okuyamaClient.close(); |
| 1203 |
} else if (args[0].equals("22.1")) { |
| 1204 |
|
| 1205 |
int port = Integer.parseInt(args[2]); |
| 1206 |
// OkuyamaClientを使用してデータを取得(Keyのみ) |
| 1207 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1208 |
okuyamaClient.connect(args[1], port); |
| 1209 |
String[] ret = null; |
| 1210 |
String[] multiKeys = null; |
| 1211 |
|
| 1212 |
String targetKeysStr = args[3]; |
| 1213 |
// Key配列作成 |
| 1214 |
multiKeys = targetKeysStr.split(" "); |
| 1215 |
|
| 1216 |
long start = new Date().getTime(); |
| 1217 |
Map retMap = okuyamaClient.getMultiValue(multiKeys); |
| 1218 |
long end = new Date().getTime(); |
| 1219 |
if (retMap == null) { |
| 1220 |
System.out.println(retMap); |
| 1221 |
} else { |
| 1222 |
System.out.println(retMap); |
| 1223 |
System.out.println("ResultSize = [" + retMap.size() + "]"); |
| 1224 |
} |
| 1225 |
System.out.println((end - start) + "milli second"); |
| 1226 |
|
| 1227 |
okuyamaClient.close(); |
| 1228 |
} else if (args[0].equals("23")) { |
| 1229 |
|
| 1230 |
int port = Integer.parseInt(args[2]); |
| 1231 |
// OkuyamaClientを使用してデータを取得(Keyのみ) |
| 1232 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1233 |
okuyamaClient.connect(args[1], port); |
| 1234 |
|
| 1235 |
long start = new Date().getTime(); |
| 1236 |
Map retMap = okuyamaClient.getTagValues(args[3]); |
| 1237 |
long end = new Date().getTime(); |
| 1238 |
if (retMap == null) { |
| 1239 |
System.out.println(retMap); |
| 1240 |
} else { |
| 1241 |
System.out.println(retMap); |
| 1242 |
System.out.println("ResultSize = [" + retMap.size() + "]"); |
| 1243 |
} |
| 1244 |
System.out.println((end - start) + "milli second"); |
| 1245 |
|
| 1246 |
okuyamaClient.close(); |
| 1247 |
} else if (args[0].equals("24")) { |
| 1248 |
|
| 1249 |
// OkuyamaClientを使用してデータの加算を行う |
| 1250 |
int port = Integer.parseInt(args[2]); |
| 1251 |
|
| 1252 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1253 |
okuyamaClient.connect(args[1], port); |
| 1254 |
|
| 1255 |
long start = new Date().getTime(); |
| 1256 |
Object[] ret = okuyamaClient.incrValue(args[3], 1); |
| 1257 |
long end = new Date().getTime(); |
| 1258 |
if (ret[0].equals("true")) { |
| 1259 |
System.out.println(ret[1]); |
| 1260 |
} else { |
| 1261 |
System.out.println(ret[0]); |
| 1262 |
System.out.println(ret[1]); |
| 1263 |
} |
| 1264 |
System.out.println((end - start) + "milli second"); |
| 1265 |
|
| 1266 |
okuyamaClient.close(); |
| 1267 |
} else if (args[0].equals("24.1")) { |
| 1268 |
|
| 1269 |
// OkuyamaClientを使用してデータの加算を行う |
| 1270 |
int port = Integer.parseInt(args[2]); |
| 1271 |
|
| 1272 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1273 |
okuyamaClient.connect(args[1], port); |
| 1274 |
|
| 1275 |
long start = new Date().getTime(); |
| 1276 |
Object[] ret = null; |
| 1277 |
for (int i = 0; i < Integer.parseInt(args[3]); i++) { |
| 1278 |
ret = okuyamaClient.incrValue(args[4], 1); |
| 1279 |
} |
| 1280 |
long end = new Date().getTime(); |
| 1281 |
if (ret[0].equals("true")) { |
| 1282 |
System.out.println(ret[1]); |
| 1283 |
} else { |
| 1284 |
System.out.println(ret[0]); |
| 1285 |
System.out.println(ret[1]); |
| 1286 |
} |
| 1287 |
System.out.println((end - start) + "milli second"); |
| 1288 |
|
| 1289 |
okuyamaClient.close(); |
| 1290 |
} else if (args[0].equals("24.2")) { |
| 1291 |
|
| 1292 |
// OkuyamaClientを使用してデータの加算を行う |
| 1293 |
int port = Integer.parseInt(args[2]); |
| 1294 |
|
| 1295 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1296 |
okuyamaClient.connect(args[1], port); |
| 1297 |
|
| 1298 |
long start = new Date().getTime(); |
| 1299 |
Object[] ret = okuyamaClient.incrValue(args[3], Integer.parseInt(args[4])); |
| 1300 |
long end = new Date().getTime(); |
| 1301 |
if (ret[0].equals("true")) { |
| 1302 |
System.out.println(ret[1]); |
| 1303 |
} else { |
| 1304 |
System.out.println(ret[0]); |
| 1305 |
System.out.println(ret[1]); |
| 1306 |
} |
| 1307 |
System.out.println((end - start) + "milli second"); |
| 1308 |
|
| 1309 |
okuyamaClient.close(); |
| 1310 |
} else if (args[0].equals("25")) { |
| 1311 |
|
| 1312 |
// OkuyamaClientを使用してデータの減算を行う |
| 1313 |
int port = Integer.parseInt(args[2]); |
| 1314 |
|
| 1315 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1316 |
okuyamaClient.connect(args[1], port); |
| 1317 |
|
| 1318 |
long start = new Date().getTime(); |
| 1319 |
Object[] ret = okuyamaClient.decrValue(args[3], 1); |
| 1320 |
long end = new Date().getTime(); |
| 1321 |
if (ret[0].equals("true")) { |
| 1322 |
System.out.println(ret[1]); |
| 1323 |
} else { |
| 1324 |
System.out.println(ret[0]); |
| 1325 |
System.out.println(ret[1]); |
| 1326 |
} |
| 1327 |
System.out.println((end - start) + "milli second"); |
| 1328 |
|
| 1329 |
okuyamaClient.close(); |
| 1330 |
} else if (args[0].equals("25.1")) { |
| 1331 |
|
| 1332 |
// OkuyamaClientを使用してデータの加算を行う |
| 1333 |
int port = Integer.parseInt(args[2]); |
| 1334 |
|
| 1335 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1336 |
okuyamaClient.connect(args[1], port); |
| 1337 |
|
| 1338 |
long start = new Date().getTime(); |
| 1339 |
Object[] ret = null; |
| 1340 |
for (int i = 0; i < Integer.parseInt(args[3]); i++) { |
| 1341 |
ret = okuyamaClient.decrValue(args[4], 1); |
| 1342 |
} |
| 1343 |
long end = new Date().getTime(); |
| 1344 |
if (ret[0].equals("true")) { |
| 1345 |
System.out.println(ret[1]); |
| 1346 |
} else { |
| 1347 |
System.out.println(ret[0]); |
| 1348 |
System.out.println(ret[1]); |
| 1349 |
} |
| 1350 |
System.out.println((end - start) + "milli second"); |
| 1351 |
|
| 1352 |
okuyamaClient.close(); |
| 1353 |
} else if (args[0].equals("26")) { |
| 1354 |
|
| 1355 |
// OkuyamaClientを使用してKeyとTagを指定してKeyからTagを外す |
| 1356 |
int port = Integer.parseInt(args[2]); |
| 1357 |
|
| 1358 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1359 |
okuyamaClient.connect(args[1], port); |
| 1360 |
String[] tag1 = {"tag1"}; |
| 1361 |
String[] tag2 = {"tag1","tag2"}; |
| 1362 |
String[] tag3 = {"tag1","tag2","tag3"}; |
| 1363 |
String[] tag4 = {"tag4"}; |
| 1364 |
String[] setTag = null; |
| 1365 |
int counter = 0; |
| 1366 |
|
| 1367 |
long start = new Date().getTime(); |
| 1368 |
|
| 1369 |
for (int i = 0; i < Integer.parseInt(args[3]);i++) { |
| 1370 |
if (counter == 0) { |
| 1371 |
setTag = tag1; |
| 1372 |
counter++; |
| 1373 |
} else if (counter == 1) { |
| 1374 |
setTag = tag2; |
| 1375 |
counter++; |
| 1376 |
} else if (counter == 2) { |
| 1377 |
setTag = tag3; |
| 1378 |
counter++; |
| 1379 |
} else if (counter == 3) { |
| 1380 |
setTag = tag4; |
| 1381 |
counter = 0; |
| 1382 |
} |
| 1383 |
|
| 1384 |
for (int ii = 0; ii < setTag.length; ii++) { |
| 1385 |
if (!okuyamaClient.removeTagFromKey("tagsampledatakey_" + new Integer(i).toString(), setTag[ii])) { |
| 1386 |
System.out.println("OkuyamaClient - error Key=[" + "tagsampledatakey_" + new Integer(i) + "] Tag[" + setTag[ii] +"]"); |
| 1387 |
} |
| 1388 |
} |
| 1389 |
} |
| 1390 |
long end = new Date().getTime(); |
| 1391 |
System.out.println((end - start) + "milli second"); |
| 1392 |
|
| 1393 |
okuyamaClient.close(); |
| 1394 |
} else if (args[0].equals("26.1")) { |
| 1395 |
|
| 1396 |
// OkuyamaClientを使用してKeyとTagを指定してKeyからTagを外す |
| 1397 |
int port = Integer.parseInt(args[2]); |
| 1398 |
|
| 1399 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1400 |
okuyamaClient.connect(args[1], port); |
| 1401 |
String[] tag1 = {args[3]}; |
| 1402 |
String key = args[4]; |
| 1403 |
|
| 1404 |
|
| 1405 |
long start = new Date().getTime(); |
| 1406 |
if (!okuyamaClient.removeTagFromKey(key, tag1[0])) { |
| 1407 |
System.out.println("OkuyamaClient - error Key=[" + key + "] Tag[" + args[3] +"]"); |
| 1408 |
} |
| 1409 |
long end = new Date().getTime(); |
| 1410 |
System.out.println((end - start) + "milli second"); |
| 1411 |
|
| 1412 |
okuyamaClient.close(); |
| 1413 |
} else if (args[0].equals("27")) { |
| 1414 |
|
| 1415 |
int port = Integer.parseInt(args[2]); |
| 1416 |
// OkuyamaClientを使用してデータを保存(Tagなし) |
| 1417 |
|
| 1418 |
// クライアントインスタンスを作成 |
| 1419 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1420 |
|
| 1421 |
// マスタサーバに接続 |
| 1422 |
okuyamaClient.connect(args[1], port); |
| 1423 |
|
| 1424 |
Random rnd = new Random(); |
| 1425 |
StringBuilder strBuf =null; |
| 1426 |
if (args.length > 4) { |
| 1427 |
strBuf = new StringBuilder(6000*10); |
| 1428 |
for (int i = 0; i < 3000; i++) { |
| 1429 |
strBuf.append(rnd.nextInt(1999999999)); |
| 1430 |
} |
| 1431 |
} |
| 1432 |
|
| 1433 |
long start = new Date().getTime(); |
| 1434 |
for (int i = 0; i < Integer.parseInt(args[3]);i++) { |
| 1435 |
// データ登録 |
| 1436 |
|
| 1437 |
//if (!okuyamaClient.setValue("datasavekey_" + args[4] + "_" + new Integer(i).toString(), "savedatavaluestr_" + args[4] + "_" + new Integer(i).toString())) { |
| 1438 |
if (!okuyamaClient.setValueAndCreateIndex("datasavekey_" + args[4] + "_" + new Integer(i).toString(), "sav"+ i +"edatavaluestr_swedcvfrtgbnhyujm_09876543" + args[4] + "_" + new Integer(i).toString(), "aa", 6, 3)) { |
| 1439 |
//if (!okuyamaClient.setValue("datasavekey_" + args[4] + "_" + new Integer(i).toString(), "savedatavaluestr0987654321" + strBuf.toString() + "_" + args[4] + "_" + new Integer(i).toString())) { |
| 1440 |
System.out.println("OkuyamaClient - error"); |
| 1441 |
} else { |
| 1442 |
//System.out.println("Store[" + "datasavekey_" + args[4] + "_" + new Integer(i).toString() + "]"); |
| 1443 |
} |
| 1444 |
if ((i % 100) == 0) System.out.println(i); |
| 1445 |
} |
| 1446 |
long end = new Date().getTime(); |
| 1447 |
System.out.println((end - start) + "milli second"); |
| 1448 |
|
| 1449 |
okuyamaClient.close(); |
| 1450 |
|
| 1451 |
} if (args[0].equals("27.2")) { |
| 1452 |
|
| 1453 |
int port = Integer.parseInt(args[2]); |
| 1454 |
// OkuyamaClientを使用してデータをIndexを作りながら保存 |
| 1455 |
|
| 1456 |
// クライアントインスタンスを作成 |
| 1457 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1458 |
|
| 1459 |
// マスタサーバに接続 |
| 1460 |
okuyamaClient.connect(args[1], port); |
| 1461 |
|
| 1462 |
|
| 1463 |
long start = new Date().getTime(); |
| 1464 |
// Key, Value, Prefix |
| 1465 |
if (!okuyamaClient.setValueAndCreateIndex(args[3], args[4], args[5])) { |
| 1466 |
//if (!okuyamaClient.setValue("datasavekey_" + new Integer(i).toString(), "savedatavaluestr_" + new Integer(i).toString())) { |
| 1467 |
System.out.println("OkuyamaClient - error"); |
| 1468 |
} |
| 1469 |
long end = new Date().getTime(); |
| 1470 |
System.out.println((end - start) + "milli second"); |
| 1471 |
|
| 1472 |
okuyamaClient.close(); |
| 1473 |
} if (args[0].equals("27.3")) { |
| 1474 |
|
| 1475 |
int port = Integer.parseInt(args[2]); |
| 1476 |
// OkuyamaClientを使用してデータをIndexを作りながら保存(Prefixあり) |
| 1477 |
|
| 1478 |
// クライアントインスタンスを作成 |
| 1479 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1480 |
|
| 1481 |
// マスタサーバに接続 |
| 1482 |
okuyamaClient.connect(args[1], port); |
| 1483 |
|
| 1484 |
|
| 1485 |
long start = new Date().getTime(); |
| 1486 |
// Key, Tag, Value, Prefix |
| 1487 |
String[] tags = {args[4]}; |
| 1488 |
if (!okuyamaClient.setValueAndCreateIndex(args[3], tags, args[5], args[6])) { |
| 1489 |
//if (!okuyamaClient.setValue("datasavekey_" + new Integer(i).toString(), "savedatavaluestr_" + new Integer(i).toString())) { |
| 1490 |
System.out.println("OkuyamaClient - error"); |
| 1491 |
} |
| 1492 |
long end = new Date().getTime(); |
| 1493 |
System.out.println((end - start) + "milli second"); |
| 1494 |
|
| 1495 |
okuyamaClient.close(); |
| 1496 |
} else if (args[0].equals("27.4")) { |
| 1497 |
|
| 1498 |
int port = Integer.parseInt(args[2]); |
| 1499 |
// OkuyamaClientを使用してデータを保存(Tagなし) |
| 1500 |
|
| 1501 |
// クライアントインスタンスを作成 |
| 1502 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1503 |
|
| 1504 |
// マスタサーバに接続 |
| 1505 |
okuyamaClient.connect(args[1], port); |
| 1506 |
|
| 1507 |
Random rnd = new Random(); |
| 1508 |
|
| 1509 |
|
| 1510 |
long start = new Date().getTime(); |
| 1511 |
|
| 1512 |
int idx = 0; |
| 1513 |
|
| 1514 |
FileInputStream workKeyFilefis = null; |
| 1515 |
InputStreamReader isr = null; |
| 1516 |
|
| 1517 |
FileReader fr = null; |
| 1518 |
BufferedReader br = null; |
| 1519 |
|
| 1520 |
File dataFile = new File(args[3]); |
| 1521 |
workKeyFilefis = new FileInputStream(dataFile); |
| 1522 |
isr = new InputStreamReader(workKeyFilefis , "UTF-8"); |
| 1523 |
br = new BufferedReader(isr); |
| 1524 |
|
| 1525 |
String line = null; |
| 1526 |
|
| 1527 |
|
| 1528 |
while ((line = br.readLine()) != null) { |
| 1529 |
idx++; |
| 1530 |
// データ登録 |
| 1531 |
if (!okuyamaClient.setValueAndCreateIndex("key_" + idx, line)) { |
| 1532 |
System.out.println("OkuyamaClient - error"); |
| 1533 |
} else { |
| 1534 |
//System.out.println("Store[key_" + idx + "]"); |
| 1535 |
} |
| 1536 |
if ((idx % 1000) == 0) System.out.println(idx); |
| 1537 |
} |
| 1538 |
|
| 1539 |
long end = new Date().getTime(); |
| 1540 |
System.out.println((end - start) + "milli second"); |
| 1541 |
|
| 1542 |
okuyamaClient.close(); |
| 1543 |
} if (args[0].equals("27.5")) { |
| 1544 |
|
| 1545 |
int port = Integer.parseInt(args[2]); |
| 1546 |
// OkuyamaClientを使用してデータをIndexを作りながら保存(Prefixあり) |
| 1547 |
|
| 1548 |
// クライアントインスタンスを作成 |
| 1549 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1550 |
|
| 1551 |
// マスタサーバに接続 |
| 1552 |
okuyamaClient.connect(args[1], port); |
| 1553 |
|
| 1554 |
|
| 1555 |
long start = new Date().getTime(); |
| 1556 |
// Key, Tag, Value, Prefix |
| 1557 |
String[] tags = {args[4]}; |
| 1558 |
if (!okuyamaClient.setValueAndCreateIndex(args[3], tags, args[5], args[6], 2)) { |
| 1559 |
//if (!okuyamaClient.setValue("datasavekey_" + new Integer(i).toString(), "savedatavaluestr_" + new Integer(i).toString())) { |
| 1560 |
System.out.println("OkuyamaClient - error"); |
| 1561 |
} |
| 1562 |
long end = new Date().getTime(); |
| 1563 |
System.out.println((end - start) + "milli second"); |
| 1564 |
|
| 1565 |
okuyamaClient.close(); |
| 1566 |
|
| 1567 |
} else if (args[0].equals("28")) { |
| 1568 |
|
| 1569 |
int port = Integer.parseInt(args[2]); |
| 1570 |
// OkuyamaClientを使用してValueを検索 |
| 1571 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1572 |
okuyamaClient.connect(args[1], port); |
| 1573 |
String[] keys = null; |
| 1574 |
String[] searchCharList = args[3].split(":"); |
| 1575 |
long start = new Date().getTime(); |
| 1576 |
|
| 1577 |
Object[] ret = okuyamaClient.searchValue(searchCharList, args[4], 2); |
| 1578 |
long end = new Date().getTime(); |
| 1579 |
|
| 1580 |
if (ret[0].equals("true")) { |
| 1581 |
// データ有り |
| 1582 |
System.out.println((end - start) + " mille"); |
| 1583 |
keys = (String[])ret[1]; |
| 1584 |
System.out.println("Result Count[" + keys.length + "]"); |
| 1585 |
for (int idx = 0; idx < keys.length; idx++) { |
| 1586 |
System.out.println(keys[idx]); |
| 1587 |
} |
| 1588 |
} else if (ret[0].equals("false")) { |
| 1589 |
System.out.println("データなし"); |
| 1590 |
} else if (ret[0].equals("error")) { |
| 1591 |
System.out.println(ret[1]); |
| 1592 |
} |
| 1593 |
|
| 1594 |
/* |
| 1595 |
if (keys != null) { |
| 1596 |
for (int ii = 0; ii < keys.length; ii++) { |
| 1597 |
System.out.println("Key=[" + keys[ii] + "]"); |
| 1598 |
ret = okuyamaClient.getValue(keys[ii]); |
| 1599 |
System.out.println("Value=[" + ret[1] + "]"); |
| 1600 |
} |
| 1601 |
} |
| 1602 |
*/ |
| 1603 |
end = new Date().getTime(); |
| 1604 |
System.out.println((end - start)); |
| 1605 |
okuyamaClient.close(); |
| 1606 |
} else if (args[0].equals("28.2")) { |
| 1607 |
|
| 1608 |
int port = Integer.parseInt(args[2]); |
| 1609 |
// OkuyamaClientを使用してValueを検索 |
| 1610 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1611 |
okuyamaClient.connect(args[1], port); |
| 1612 |
String[] keys = null; |
| 1613 |
String[] searchCharList = args[3].split(":"); |
| 1614 |
long start = new Date().getTime(); |
| 1615 |
|
| 1616 |
Object[] ret = okuyamaClient.searchValue(searchCharList, args[4], args[5]); |
| 1617 |
long end = new Date().getTime(); |
| 1618 |
|
| 1619 |
if (ret[0].equals("true")) { |
| 1620 |
// データ有り |
| 1621 |
System.out.println((end - start) + " mille"); |
| 1622 |
keys = (String[])ret[1]; |
| 1623 |
System.out.println("Result Count[" + keys.length + "]"); |
| 1624 |
for (int idx = 0; idx < keys.length; idx++) { |
| 1625 |
// System.out.println(keys[idx]); |
| 1626 |
} |
| 1627 |
} else if (ret[0].equals("false")) { |
| 1628 |
System.out.println("データなし"); |
| 1629 |
} else if (ret[0].equals("error")) { |
| 1630 |
System.out.println(ret[1]); |
| 1631 |
} |
| 1632 |
|
| 1633 |
/* |
| 1634 |
if (keys != null) { |
| 1635 |
for (int ii = 0; ii < keys.length; ii++) { |
| 1636 |
System.out.println("Key=[" + keys[ii] + "]"); |
| 1637 |
ret = okuyamaClient.getValue(keys[ii]); |
| 1638 |
System.out.println("Value=[" + ret[1] + "]"); |
| 1639 |
} |
| 1640 |
} |
| 1641 |
*/ |
| 1642 |
end = new Date().getTime(); |
| 1643 |
System.out.println((end - start)); |
| 1644 |
okuyamaClient.close(); |
| 1645 |
} else if (args[0].equals("28.3")) { |
| 1646 |
|
| 1647 |
int port = Integer.parseInt(args[2]); |
| 1648 |
// OkuyamaClientを使用してValueを検索 |
| 1649 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1650 |
okuyamaClient.connect(args[1], port); |
| 1651 |
String[] keys = null; |
| 1652 |
String[] searchCharList = args[3].split(":"); |
| 1653 |
long start = new Date().getTime(); |
| 1654 |
|
| 1655 |
Object[] ret = okuyamaClient.searchValue(searchCharList, args[4], args[5], Integer.parseInt(args[6])); |
| 1656 |
long end = new Date().getTime(); |
| 1657 |
|
| 1658 |
if (ret[0].equals("true")) { |
| 1659 |
// データ有り |
| 1660 |
System.out.println((end - start) + " mille"); |
| 1661 |
keys = (String[])ret[1]; |
| 1662 |
System.out.println("Result Count[" + keys.length + "]"); |
| 1663 |
for (int idx = 0; idx < keys.length; idx++) { |
| 1664 |
// System.out.println(keys[idx]); |
| 1665 |
} |
| 1666 |
} else if (ret[0].equals("false")) { |
| 1667 |
System.out.println("データなし"); |
| 1668 |
} else if (ret[0].equals("error")) { |
| 1669 |
System.out.println(ret[1]); |
| 1670 |
} |
| 1671 |
|
| 1672 |
/* |
| 1673 |
if (keys != null) { |
| 1674 |
for (int ii = 0; ii < keys.length; ii++) { |
| 1675 |
System.out.println("Key=[" + keys[ii] + "]"); |
| 1676 |
ret = okuyamaClient.getValue(keys[ii]); |
| 1677 |
System.out.println("Value=[" + ret[1] + "]"); |
| 1678 |
} |
| 1679 |
} |
| 1680 |
*/ |
| 1681 |
end = new Date().getTime(); |
| 1682 |
System.out.println((end - start)); |
| 1683 |
okuyamaClient.close(); |
| 1684 |
} else if (args[0].equals("29")) { |
| 1685 |
|
| 1686 |
int port = Integer.parseInt(args[2]); |
| 1687 |
// OkuyamaClientを使用してデータを取得して有効期限を更新 |
| 1688 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1689 |
okuyamaClient.connect(args[1], port); |
| 1690 |
String[] ret = null; |
| 1691 |
|
| 1692 |
long start = new Date().getTime(); |
| 1693 |
if (args.length > 4) { |
| 1694 |
for (int i = 0; i < Integer.parseInt(args[3]);i++) { |
| 1695 |
ret = okuyamaClient.getValueAndUpdateExpireTime("datasavekey_" + args[4] + "_" + new Integer(i).toString()); |
| 1696 |
if (ret[0].equals("true")) { |
| 1697 |
// データ有り |
| 1698 |
System.out.println(ret[1]); |
| 1699 |
} else if (ret[0].equals("false")) { |
| 1700 |
System.out.println("データなし"); |
| 1701 |
} else if (ret[0].equals("error")) { |
| 1702 |
System.out.println(ret[1]); |
| 1703 |
} |
| 1704 |
} |
| 1705 |
} else { |
| 1706 |
for (int i = 0; i < Integer.parseInt(args[3]);i++) { |
| 1707 |
ret = okuyamaClient.getValueAndUpdateExpireTime("datasavekey_" + new Integer(i).toString()); |
| 1708 |
if (ret[0].equals("true")) { |
| 1709 |
// データ有り |
| 1710 |
System.out.println(ret[1]); |
| 1711 |
} else if (ret[0].equals("false")) { |
| 1712 |
System.out.println("データなし"); |
| 1713 |
} else if (ret[0].equals("error")) { |
| 1714 |
System.out.println(ret[1]); |
| 1715 |
} |
| 1716 |
} |
| 1717 |
} |
| 1718 |
long end = new Date().getTime(); |
| 1719 |
System.out.println((end - start) + "milli second"); |
| 1720 |
|
| 1721 |
okuyamaClient.close(); |
| 1722 |
} else if (args[0].equals("30")) { |
| 1723 |
|
| 1724 |
int port = Integer.parseInt(args[2]); |
| 1725 |
// OkuyamaClientを使用して複数Tag指定でKeyとValueのMapを取得 |
| 1726 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1727 |
okuyamaClient.connect(args[1], port); |
| 1728 |
|
| 1729 |
long start = new Date().getTime(); |
| 1730 |
Map retMap = okuyamaClient.getMultiTagValues(args[3].split(","), new Boolean(args[4]).booleanValue()); |
| 1731 |
long end = new Date().getTime(); |
| 1732 |
if (retMap == null) { |
| 1733 |
System.out.println(retMap); |
| 1734 |
} else { |
| 1735 |
//System.out.println(retMap); |
| 1736 |
System.out.println("ResultSize = [" + retMap.size() + "]"); |
| 1737 |
} |
| 1738 |
System.out.println((end - start) + "milli second"); |
| 1739 |
|
| 1740 |
okuyamaClient.close(); |
| 1741 |
} if (args[0].equals("31")) { |
| 1742 |
|
| 1743 |
int port = Integer.parseInt(args[2]); |
| 1744 |
// OkuyamaClientを使用してデータを保存(Tagなし) |
| 1745 |
|
| 1746 |
// クライアントインスタンスを作成 |
| 1747 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1748 |
|
| 1749 |
// マスタサーバに接続 |
| 1750 |
okuyamaClient.connect(args[1], port); |
| 1751 |
|
| 1752 |
|
| 1753 |
long start = new Date().getTime(); |
| 1754 |
for (int idx = 0; idx < Integer.parseInt(args[3]); idx++) { |
| 1755 |
Map objData = new HashMap(); |
| 1756 |
objData.put("key" + idx, "value" + idx); |
| 1757 |
objData.put("key_x_" + idx, "value_x_" + idx); |
| 1758 |
if (!okuyamaClient.setObjectValue("ObjectSetKey_" + idx, objData)) { |
| 1759 |
System.out.println("OkuyamaClient - error"); |
| 1760 |
} |
| 1761 |
} |
| 1762 |
long end = new Date().getTime(); |
| 1763 |
System.out.println((end - start) + "milli second"); |
| 1764 |
|
| 1765 |
okuyamaClient.close(); |
| 1766 |
|
| 1767 |
} if (args[0].equals("31.1")) { |
| 1768 |
|
| 1769 |
int port = Integer.parseInt(args[2]); |
| 1770 |
// OkuyamaClientを使用してデータを保存(Tagあり) |
| 1771 |
|
| 1772 |
// クライアントインスタンスを作成 |
| 1773 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1774 |
|
| 1775 |
// マスタサーバに接続 |
| 1776 |
okuyamaClient.connect(args[1], port); |
| 1777 |
|
| 1778 |
|
| 1779 |
long start = new Date().getTime(); |
| 1780 |
for (int idx = 0; idx < Integer.parseInt(args[3]); idx++) { |
| 1781 |
Map objData = new HashMap(); |
| 1782 |
objData.put("key" + idx, "value" + idx); |
| 1783 |
objData.put("key_x_" + idx, "value_x_" + idx); |
| 1784 |
if ((idx % 2) == 0) { |
| 1785 |
String[] tag = {"Tag1","Tag3"}; |
| 1786 |
if (!okuyamaClient.setObjectValue("ObjectSetKey_" + idx, tag, objData)) { |
| 1787 |
System.out.println("OkuyamaClient - error"); |
| 1788 |
} |
| 1789 |
} else { |
| 1790 |
String[] tag = {"Tag2"}; |
| 1791 |
if (!okuyamaClient.setObjectValue("ObjectSetKey_" + idx, tag, objData)) { |
| 1792 |
System.out.println("OkuyamaClient - error"); |
| 1793 |
} |
| 1794 |
} |
| 1795 |
} |
| 1796 |
long end = new Date().getTime(); |
| 1797 |
System.out.println((end - start) + "milli second"); |
| 1798 |
|
| 1799 |
okuyamaClient.close(); |
| 1800 |
} if (args[0].equals("32")) { |
| 1801 |
|
| 1802 |
int port = Integer.parseInt(args[2]); |
| 1803 |
// OkuyamaClientを使用してデータ取得 |
| 1804 |
|
| 1805 |
// クライアントインスタンスを作成 |
| 1806 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1807 |
|
| 1808 |
// マスタサーバに接続 |
| 1809 |
okuyamaClient.connect(args[1], port); |
| 1810 |
|
| 1811 |
|
| 1812 |
long start = new Date().getTime(); |
| 1813 |
for (int idx = 0; idx < Integer.parseInt(args[3]); idx++) { |
| 1814 |
Object[] retData = okuyamaClient.getObjectValue("ObjectSetKey_" + idx); |
| 1815 |
if (retData[0].equals("true")) { |
| 1816 |
Map objData = (Map)retData[1]; |
| 1817 |
System.out.println(objData); |
| 1818 |
} else if (retData[0].equals("false")) { |
| 1819 |
System.out.println("ObjectSetKey_" + idx + " Not Found"); |
| 1820 |
} else if (retData[0].equals("error")) { |
| 1821 |
System.out.println("ObjectSetKey_" + idx + " Error Message[" + retData[1] + "]"); |
| 1822 |
} |
| 1823 |
} |
| 1824 |
long end = new Date().getTime(); |
| 1825 |
System.out.println((end - start) + "milli second"); |
| 1826 |
|
| 1827 |
okuyamaClient.close(); |
| 1828 |
} if (args[0].equals("32.11")) { |
| 1829 |
|
| 1830 |
int port = Integer.parseInt(args[2]); |
| 1831 |
// OkuyamaClientを使用してデータ取得 |
| 1832 |
|
| 1833 |
// クライアントインスタンスを作成 |
| 1834 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1835 |
|
| 1836 |
// マスタサーバに接続 |
| 1837 |
okuyamaClient.connect(args[1], port); |
| 1838 |
|
| 1839 |
|
| 1840 |
long start = new Date().getTime(); |
| 1841 |
for (int idx = 0; idx < Integer.parseInt(args[3]); idx++) { |
| 1842 |
Object[] retData = okuyamaClient.getObjectValue("ObjectSetKey_" + idx); |
| 1843 |
if (retData[0].equals("true")) { |
| 1844 |
Map objData = (Map)retData[1]; |
| 1845 |
} else if (retData[0].equals("false")) { |
| 1846 |
System.out.println("ObjectSetKey_" + idx + " Not Found"); |
| 1847 |
} else if (retData[0].equals("error")) { |
| 1848 |
System.out.println("ObjectSetKey_" + idx + " Error Message[" + retData[1] + "]"); |
| 1849 |
} |
| 1850 |
} |
| 1851 |
long end = new Date().getTime(); |
| 1852 |
System.out.println((end - start) + "milli second"); |
| 1853 |
|
| 1854 |
okuyamaClient.close(); |
| 1855 |
} else if (args[0].equals("33")) { |
| 1856 |
|
| 1857 |
int port = Integer.parseInt(args[2]); |
| 1858 |
// OkuyamaClientを使用して複数Tag指定でKeyとValueのMapを取得 |
| 1859 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1860 |
okuyamaClient.connect(args[1], port); |
| 1861 |
|
| 1862 |
long start = new Date().getTime(); |
| 1863 |
String[] retKeys = okuyamaClient.getMultiTagKeys(args[3].split(","), new Boolean(args[4]).booleanValue()); |
| 1864 |
long end = new Date().getTime(); |
| 1865 |
if (retKeys == null) { |
| 1866 |
System.out.println(retKeys); |
| 1867 |
} else { |
| 1868 |
/*for (int idx = 0; idx < retKeys.length; idx++) { |
| 1869 |
System.out.println(retKeys[idx]); |
| 1870 |
}*/ |
| 1871 |
System.out.println("ResultSize = [" + retKeys.length + "]"); |
| 1872 |
} |
| 1873 |
System.out.println((end - start) + "milli second"); |
| 1874 |
|
| 1875 |
okuyamaClient.close(); |
| 1876 |
} else if (args[0].equals("34")) { |
| 1877 |
|
| 1878 |
int port = Integer.parseInt(args[2]); |
| 1879 |
// OkuyamaClientを使用して複数Tag指定でKeyとValueのMapを取得 |
| 1880 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1881 |
okuyamaClient.connect(args[1], port); |
| 1882 |
|
| 1883 |
long start = new Date().getTime(); |
| 1884 |
OkuyamaResultSet okuyamaResultSet = okuyamaClient.getTagKeysResult(args[3]); |
| 1885 |
long end = new Date().getTime(); |
| 1886 |
if (okuyamaResultSet == null) { |
| 1887 |
System.out.println(okuyamaResultSet); |
| 1888 |
} else { |
| 1889 |
int counter = 0; |
| 1890 |
while(okuyamaResultSet.next()) { |
| 1891 |
counter++; |
| 1892 |
System.out.println("Key=" + (String)okuyamaResultSet.getKey()); |
| 1893 |
System.out.println("Value=" + (String)okuyamaResultSet.getValue()); |
| 1894 |
} |
| 1895 |
okuyamaResultSet.close(); |
| 1896 |
|
| 1897 |
System.out.println("ResultSize = [" + counter + "]"); |
| 1898 |
} |
| 1899 |
System.out.println((end - start) + "milli second"); |
| 1900 |
|
| 1901 |
okuyamaClient.close(); |
| 1902 |
} else if (args[0].equals("34.1")) { |
| 1903 |
|
| 1904 |
int port = Integer.parseInt(args[2]); |
| 1905 |
// OkuyamaClientを使用して複数Tag指定でKeyとValueのMapを取得 |
| 1906 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1907 |
okuyamaClient.connect(args[1], port); |
| 1908 |
|
| 1909 |
long start = new Date().getTime(); |
| 1910 |
OkuyamaResultSet okuyamaResultSet = okuyamaClient.getTagKeysResult(args[3]); |
| 1911 |
|
| 1912 |
if (okuyamaResultSet == null) { |
| 1913 |
System.out.println(okuyamaResultSet); |
| 1914 |
} else { |
| 1915 |
int counter = 0; |
| 1916 |
while(okuyamaResultSet.next()) { |
| 1917 |
counter++; |
| 1918 |
//System.out.println("Key=" + (String)okuyamaResultSet.getKey()); |
| 1919 |
//System.out.println("Value=" + (String)okuyamaResultSet.getValue()); |
| 1920 |
} |
| 1921 |
okuyamaResultSet.close(); |
| 1922 |
|
| 1923 |
System.out.println("ResultSize = [" + counter + "]"); |
| 1924 |
} |
| 1925 |
long end = new Date().getTime(); |
| 1926 |
System.out.println((end - start) + "milli second"); |
| 1927 |
|
| 1928 |
okuyamaClient.close(); |
| 1929 |
} else if (args[0].equals("34.2")) { |
| 1930 |
|
| 1931 |
int port = Integer.parseInt(args[2]); |
| 1932 |
// OkuyamaClientを使用して複数Tag指定でKeyとValueのMapを取得 |
| 1933 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1934 |
okuyamaClient.connect(args[1], port); |
| 1935 |
|
| 1936 |
long start = new Date().getTime(); |
| 1937 |
double[] rangeSet = {Double.parseDouble(args[4]), Double.parseDouble(args[5])}; |
| 1938 |
OkuyamaResultSet okuyamaResultSet = okuyamaClient.getTagKeysResult(args[3], rangeSet, Integer.parseInt(args[6])); |
| 1939 |
|
| 1940 |
if (okuyamaResultSet == null) { |
| 1941 |
System.out.println(okuyamaResultSet); |
| 1942 |
} else { |
| 1943 |
int counter = 0; |
| 1944 |
while(okuyamaResultSet.next()) { |
| 1945 |
counter++; |
| 1946 |
//System.out.println("Key=" + (String)okuyamaResultSet.getKey()); |
| 1947 |
//System.out.println("Value=" + (String)okuyamaResultSet.getValue()); |
| 1948 |
} |
| 1949 |
okuyamaResultSet.close(); |
| 1950 |
|
| 1951 |
System.out.println("ResultSize = [" + counter + "]"); |
| 1952 |
} |
| 1953 |
long end = new Date().getTime(); |
| 1954 |
System.out.println((end - start) + "milli second"); |
| 1955 |
|
| 1956 |
okuyamaClient.close(); |
| 1957 |
|
| 1958 |
} else if (args[0].equals("35")) { |
| 1959 |
|
| 1960 |
int port = Integer.parseInt(args[2]); |
| 1961 |
// OkuyamaClientを使用して複数Tag指定でKeyとValueのMapを取得 |
| 1962 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1963 |
okuyamaClient.connect(args[1], port); |
| 1964 |
|
| 1965 |
long start = new Date().getTime(); |
| 1966 |
OkuyamaResultSet okuyamaResultSet = okuyamaClient.getMultiTagKeysResult(args[3].split(","), new Boolean(args[4]).booleanValue()); |
| 1967 |
long end = new Date().getTime(); |
| 1968 |
if (okuyamaResultSet == null) { |
| 1969 |
System.out.println(okuyamaResultSet); |
| 1970 |
} else { |
| 1971 |
int counter = 0; |
| 1972 |
while(okuyamaResultSet.next()) { |
| 1973 |
counter++; |
| 1974 |
System.out.println("Key=" + (String)okuyamaResultSet.getKey()); |
| 1975 |
System.out.println("Value=" + (String)okuyamaResultSet.getValue()); |
| 1976 |
} |
| 1977 |
okuyamaResultSet.close(); |
| 1978 |
|
| 1979 |
System.out.println("ResultSize = [" + counter + "]"); |
| 1980 |
} |
| 1981 |
System.out.println((end - start) + "milli second"); |
| 1982 |
|
| 1983 |
okuyamaClient.close(); |
| 1984 |
} else if (args[0].equals("35.1")) { |
| 1985 |
|
| 1986 |
int port = Integer.parseInt(args[2]); |
| 1987 |
// OkuyamaClientを使用して複数Tag指定でKeyとValueのMapを取得 |
| 1988 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 1989 |
okuyamaClient.connect(args[1], port); |
| 1990 |
|
| 1991 |
long start = new Date().getTime(); |
| 1992 |
OkuyamaResultSet okuyamaResultSet = okuyamaClient.getMultiTagKeysResult(args[3].split(","), new Boolean(args[4]).booleanValue()); |
| 1993 |
|
| 1994 |
if (okuyamaResultSet == null) { |
| 1995 |
System.out.println(okuyamaResultSet); |
| 1996 |
} else { |
| 1997 |
int counter = 0; |
| 1998 |
while(okuyamaResultSet.next()) { |
| 1999 |
counter++; |
| 2000 |
//System.out.println("Key=" + (String)okuyamaResultSet.getKey()); |
| 2001 |
//System.out.println("Value=" + (String)okuyamaResultSet.getValue()); |
| 2002 |
} |
| 2003 |
okuyamaResultSet.close(); |
| 2004 |
|
| 2005 |
System.out.println("ResultSize = [" + counter + "]"); |
| 2006 |
} |
| 2007 |
long end = new Date().getTime(); |
| 2008 |
System.out.println((end - start) + "milli second"); |
| 2009 |
|
| 2010 |
okuyamaClient.close(); |
| 2011 |
} else if (args[0].equals("36")) { |
| 2012 |
|
| 2013 |
int port = Integer.parseInt(args[2]); |
| 2014 |
// OkuyamaClientを使用してデータを取得(ObjectのTag版のみ) |
| 2015 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 2016 |
okuyamaClient.connect(args[1], port); |
| 2017 |
|
| 2018 |
long start = new Date().getTime(); |
| 2019 |
Map retMap = okuyamaClient.getTagObjectValues(args[3]); |
| 2020 |
long end = new Date().getTime(); |
| 2021 |
if (retMap == null) { |
| 2022 |
System.out.println(retMap); |
| 2023 |
} else { |
| 2024 |
System.out.println(retMap); |
| 2025 |
System.out.println("ResultSize = [" + retMap.size() + "]"); |
| 2026 |
} |
| 2027 |
System.out.println((end - start) + "milli second"); |
| 2028 |
|
| 2029 |
okuyamaClient.close(); |
| 2030 |
} else if (args[0].equals("41")) { |
| 2031 |
|
| 2032 |
int port = Integer.parseInt(args[2]); |
| 2033 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 2034 |
okuyamaClient.connect(args[1], port); |
| 2035 |
|
| 2036 |
long start = new Date().getTime(); |
| 2037 |
String[] ret = okuyamaClient.createListStruct(args[3]); |
| 2038 |
long end = new Date().getTime(); |
| 2039 |
if (ret[0].equals("true")) { |
| 2040 |
System.out.println("success"); |
| 2041 |
} else { |
| 2042 |
System.out.println(ret[0]); |
| 2043 |
System.out.println(ret[1]); |
| 2044 |
} |
| 2045 |
System.out.println((end - start) + "milli second"); |
| 2046 |
|
| 2047 |
okuyamaClient.close(); |
| 2048 |
} else if (args[0].equals("42")) { |
| 2049 |
|
| 2050 |
int port = Integer.parseInt(args[2]); |
| 2051 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 2052 |
okuyamaClient.connect(args[1], port); |
| 2053 |
|
| 2054 |
long start = new Date().getTime(); |
| 2055 |
for (int idx = 0; idx < Integer.parseInt(args[4]); idx++) { |
| 2056 |
String[] ret = okuyamaClient.listLPush(args[3], "listLPush."+idx); |
| 2057 |
|
| 2058 |
if (!ret[0].equals("true")) { |
| 2059 |
|
| 2060 |
System.out.println(ret[0]); |
| 2061 |
System.out.println(ret[1]); |
| 2062 |
} |
| 2063 |
} |
| 2064 |
long end = new Date().getTime(); |
| 2065 |
|
| 2066 |
System.out.println((end - start) + "milli second"); |
| 2067 |
|
| 2068 |
okuyamaClient.close(); |
| 2069 |
} else if (args[0].equals("42.1")) { |
| 2070 |
|
| 2071 |
int port = Integer.parseInt(args[2]); |
| 2072 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 2073 |
okuyamaClient.connect(args[1], port); |
| 2074 |
|
| 2075 |
long start = new Date().getTime(); |
| 2076 |
String[] ret = okuyamaClient.listLPush(args[3], args[4]); |
| 2077 |
long end = new Date().getTime(); |
| 2078 |
if (ret[0].equals("true")) { |
| 2079 |
System.out.println("success"); |
| 2080 |
} else { |
| 2081 |
System.out.println(ret[0]); |
| 2082 |
System.out.println(ret[1]); |
| 2083 |
} |
| 2084 |
System.out.println((end - start) + "milli second"); |
| 2085 |
|
| 2086 |
okuyamaClient.close(); |
| 2087 |
|
| 2088 |
} else if (args[0].equals("43")) { |
| 2089 |
|
| 2090 |
int port = Integer.parseInt(args[2]); |
| 2091 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 2092 |
okuyamaClient.connect(args[1], port); |
| 2093 |
|
| 2094 |
long start = new Date().getTime(); |
| 2095 |
for (int idx = 0; idx < Integer.parseInt(args[4]); idx++) { |
| 2096 |
|
| 2097 |
String[] ret = okuyamaClient.listRPush(args[3], "listRPush."+idx); |
| 2098 |
if (!ret[0].equals("true")) { |
| 2099 |
System.out.println(ret[0]); |
| 2100 |
System.out.println(ret[1]); |
| 2101 |
} |
| 2102 |
} |
| 2103 |
long end = new Date().getTime(); |
| 2104 |
|
| 2105 |
System.out.println((end - start) + "milli second"); |
| 2106 |
|
| 2107 |
okuyamaClient.close(); |
| 2108 |
} else if (args[0].equals("43.1")) { |
| 2109 |
|
| 2110 |
int port = Integer.parseInt(args[2]); |
| 2111 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 2112 |
okuyamaClient.connect(args[1], port); |
| 2113 |
|
| 2114 |
long start = new Date().getTime(); |
| 2115 |
String[] ret = okuyamaClient.listRPush(args[3], args[4]); |
| 2116 |
long end = new Date().getTime(); |
| 2117 |
if (ret[0].equals("true")) { |
| 2118 |
System.out.println("success"); |
| 2119 |
} else { |
| 2120 |
System.out.println(ret[0]); |
| 2121 |
System.out.println(ret[1]); |
| 2122 |
} |
| 2123 |
System.out.println((end - start) + "milli second"); |
| 2124 |
|
| 2125 |
okuyamaClient.close(); |
| 2126 |
} else if (args[0].equals("44")) { |
| 2127 |
|
| 2128 |
int port = Integer.parseInt(args[2]); |
| 2129 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 2130 |
okuyamaClient.connect(args[1], port); |
| 2131 |
|
| 2132 |
long start = new Date().getTime(); |
| 2133 |
for (long idx = 0; idx < Long.parseLong(args[4]); idx++) { |
| 2134 |
|
| 2135 |
String[] ret = okuyamaClient.listIndex(args[3], idx); |
| 2136 |
if (!ret[0].equals("true")) { |
| 2137 |
System.out.println(ret[0]); |
| 2138 |
System.out.println(ret[1]); |
| 2139 |
} |
| 2140 |
if ((idx % 1000) == 0L) { |
| 2141 |
System.out.println(idx); |
| 2142 |
} |
| 2143 |
} |
| 2144 |
long end = new Date().getTime(); |
| 2145 |
|
| 2146 |
System.out.println((end - start) + "milli second"); |
| 2147 |
|
| 2148 |
okuyamaClient.close(); |
| 2149 |
} else if (args[0].equals("44.1")) { |
| 2150 |
|
| 2151 |
int port = Integer.parseInt(args[2]); |
| 2152 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 2153 |
okuyamaClient.connect(args[1], port); |
| 2154 |
|
| 2155 |
long start = new Date().getTime(); |
| 2156 |
String[] ret = okuyamaClient.listIndex(args[3], new Long(args[4]).longValue()); |
| 2157 |
long end = new Date().getTime(); |
| 2158 |
if (ret[0].equals("true")) { |
| 2159 |
System.out.println("List["+args[4]+"]=" + ret[1]); |
| 2160 |
} else { |
| 2161 |
System.out.println(ret[0]); |
| 2162 |
System.out.println(ret[1]); |
| 2163 |
} |
| 2164 |
System.out.println((end - start) + "milli second"); |
| 2165 |
|
| 2166 |
okuyamaClient.close(); |
| 2167 |
} else if (args[0].equals("45")) { |
| 2168 |
|
| 2169 |
int port = Integer.parseInt(args[2]); |
| 2170 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 2171 |
okuyamaClient.connect(args[1], port); |
| 2172 |
|
| 2173 |
long start = new Date().getTime(); |
| 2174 |
for (long idx = 0; idx < Long.parseLong(args[4]); idx++) { |
| 2175 |
|
| 2176 |
String[] ret = okuyamaClient.listLPop(args[3]); |
| 2177 |
if (!ret[0].equals("true")) { |
| 2178 |
System.out.println(ret[0]); |
| 2179 |
System.out.println(ret[1]); |
| 2180 |
} |
| 2181 |
} |
| 2182 |
long end = new Date().getTime(); |
| 2183 |
System.out.println((end - start) + "milli second"); |
| 2184 |
|
| 2185 |
okuyamaClient.close(); |
| 2186 |
|
| 2187 |
} else if (args[0].equals("45.1")) { |
| 2188 |
|
| 2189 |
int port = Integer.parseInt(args[2]); |
| 2190 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 2191 |
okuyamaClient.connect(args[1], port); |
| 2192 |
|
| 2193 |
long start = new Date().getTime(); |
| 2194 |
String[] ret = okuyamaClient.listLPop(args[3]); |
| 2195 |
long end = new Date().getTime(); |
| 2196 |
if (ret[0].equals("true")) { |
| 2197 |
System.out.println(ret[1]); |
| 2198 |
} else { |
| 2199 |
System.out.println(ret[0]); |
| 2200 |
System.out.println(ret[1]); |
| 2201 |
} |
| 2202 |
System.out.println((end - start) + "milli second"); |
| 2203 |
|
| 2204 |
okuyamaClient.close(); |
| 2205 |
} else if (args[0].equals("46")) { |
| 2206 |
|
| 2207 |
int port = Integer.parseInt(args[2]); |
| 2208 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 2209 |
okuyamaClient.connect(args[1], port); |
| 2210 |
|
| 2211 |
long start = new Date().getTime(); |
| 2212 |
for (long idx = 0; idx < Long.parseLong(args[4]); idx++) { |
| 2213 |
|
| 2214 |
String[] ret = okuyamaClient.listRPop(args[3]); |
| 2215 |
if (!ret[0].equals("true")) { |
| 2216 |
System.out.println(ret[0]); |
| 2217 |
System.out.println(ret[1]); |
| 2218 |
} |
| 2219 |
} |
| 2220 |
long end = new Date().getTime(); |
| 2221 |
System.out.println((end - start) + "milli second"); |
| 2222 |
|
| 2223 |
okuyamaClient.close(); |
| 2224 |
|
| 2225 |
} else if (args[0].equals("46.1")) { |
| 2226 |
|
| 2227 |
int port = Integer.parseInt(args[2]); |
| 2228 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 2229 |
okuyamaClient.connect(args[1], port); |
| 2230 |
|
| 2231 |
long start = new Date().getTime(); |
| 2232 |
String[] ret = okuyamaClient.listRPop(args[3]); |
| 2233 |
long end = new Date().getTime(); |
| 2234 |
if (ret[0].equals("true")) { |
| 2235 |
System.out.println(ret[1]); |
| 2236 |
} else { |
| 2237 |
System.out.println(ret[0]); |
| 2238 |
System.out.println(ret[1]); |
| 2239 |
} |
| 2240 |
System.out.println((end - start) + "milli second"); |
| 2241 |
|
| 2242 |
okuyamaClient.close(); |
| 2243 |
|
| 2244 |
|
| 2245 |
} else if (args[0].equals("47")) { |
| 2246 |
|
| 2247 |
int port = Integer.parseInt(args[2]); |
| 2248 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 2249 |
okuyamaClient.connect(args[1], port); |
| 2250 |
|
| 2251 |
long start = new Date().getTime(); |
| 2252 |
Object[] ret = okuyamaClient.listLen(args[3]); |
| 2253 |
long end = new Date().getTime(); |
| 2254 |
if (ret[0].equals("true")) { |
| 2255 |
System.out.println("List length=" + ret[1]); |
| 2256 |
} else { |
| 2257 |
System.out.println(ret[0]); |
| 2258 |
System.out.println(ret[1]); |
| 2259 |
} |
| 2260 |
System.out.println((end - start) + "milli second"); |
| 2261 |
|
| 2262 |
okuyamaClient.close(); |
| 2263 |
} else if (args[0].equals("999")) { |
| 2264 |
|
| 2265 |
int port = Integer.parseInt(args[2]); |
| 2266 |
// OkuyamaClientを使用してokuyamaのバージョンを取得 |
| 2267 |
OkuyamaClient okuyamaClient = new OkuyamaClient(); |
| 2268 |
okuyamaClient.connect(args[1], port); |
| 2269 |
|
| 2270 |
long start = new Date().getTime(); |
| 2271 |
String[] ret = okuyamaClient.getOkuyamaVersion(); |
| 2272 |
long end = new Date().getTime(); |
| 2273 |
if (ret[0].equals("true")) { |
| 2274 |
System.out.println(ret[1]); |
| 2275 |
} else { |
| 2276 |
System.out.println(ret[0]); |
| 2277 |
} |
| 2278 |
System.out.println((end - start) + "milli second"); |
| 2279 |
|
| 2280 |
okuyamaClient.close(); |
| 2281 |
} |
| 2282 |
|
| 2283 |
} catch (Exception e) { |
| 2284 |
e.printStackTrace(); |
| 2285 |
} |
| 2286 |
} |
| 2287 |
} |
| 2288 |
|