repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
iluu/algs-progfun | src/test/java/com/hackerrank/BiggerIsGreaterTest.java | // Path: src/main/java/com/hackerrank/BiggerIsGreater.java
// static String nextPermutation(String s) {
// int p = s.length() - 2;
// while (p >= 0 && s.charAt(p) >= s.charAt(p + 1)) {
// p--;
// }
// if (p < 0 || s.charAt(p) >= s.charAt(p + 1)) {
// return "no answer";
// }
//
// int q = s.length() - 1;
// while (s.charAt(q) <= s.charAt(p)) {
// q--;
// }
//
// char[] a = s.toCharArray();
// char temp = a[p];
// a[p] = a[q];
// a[q] = temp;
//
// String result = new String(a);
// StringBuilder reversed = new StringBuilder(result.substring(p + 1, result.length()));
//
// return result.substring(0, p + 1) + reversed.reverse().toString();
// }
| import org.junit.Test;
import static com.hackerrank.BiggerIsGreater.nextPermutation;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; | package com.hackerrank;
public class BiggerIsGreaterTest {
@Test
public void simpleRearrange() { | // Path: src/main/java/com/hackerrank/BiggerIsGreater.java
// static String nextPermutation(String s) {
// int p = s.length() - 2;
// while (p >= 0 && s.charAt(p) >= s.charAt(p + 1)) {
// p--;
// }
// if (p < 0 || s.charAt(p) >= s.charAt(p + 1)) {
// return "no answer";
// }
//
// int q = s.length() - 1;
// while (s.charAt(q) <= s.charAt(p)) {
// q--;
// }
//
// char[] a = s.toCharArray();
// char temp = a[p];
// a[p] = a[q];
// a[q] = temp;
//
// String result = new String(a);
// StringBuilder reversed = new StringBuilder(result.substring(p + 1, result.length()));
//
// return result.substring(0, p + 1) + reversed.reverse().toString();
// }
// Path: src/test/java/com/hackerrank/BiggerIsGreaterTest.java
import org.junit.Test;
import static com.hackerrank.BiggerIsGreater.nextPermutation;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
package com.hackerrank;
public class BiggerIsGreaterTest {
@Test
public void simpleRearrange() { | assertThat(nextPermutation("ab")).isEqualTo("ba"); |
iluu/algs-progfun | src/test/java/com/other/FirstDuplicateTest.java | // Path: src/main/java/com/other/FirstDuplicate.java
// static int firstDuplicate(int[] a) {
// boolean[] duplicates = new boolean[(int) (Math.pow(10, 5)+1)];
// int i = 0;
// while(i < a.length && !duplicates[a[i]]){
// duplicates[a[i++]] = true;
// }
// return i < a.length && duplicates[a[i]] ? a[i] : -1;
// }
| import org.junit.Test;
import static com.other.FirstDuplicate.firstDuplicate;
import static org.assertj.core.api.Assertions.assertThat; | package com.other;
public class FirstDuplicateTest {
@Test
public void failingCase13() {
int[] a = new int[]{28, 19, 13, 6, 34, 48, 50, 3, 47, 18, 15, 34, 16, 11, 13, 3, 2, 4, 46, 6, 7, 3, 18, 9, 32, 21, 3, 21, 50, 10, 45, 13, 22, 1, 27, 18, 3, 27, 30, 44, 12, 30, 40, 1, 1, 31, 6, 18, 33, 5}; | // Path: src/main/java/com/other/FirstDuplicate.java
// static int firstDuplicate(int[] a) {
// boolean[] duplicates = new boolean[(int) (Math.pow(10, 5)+1)];
// int i = 0;
// while(i < a.length && !duplicates[a[i]]){
// duplicates[a[i++]] = true;
// }
// return i < a.length && duplicates[a[i]] ? a[i] : -1;
// }
// Path: src/test/java/com/other/FirstDuplicateTest.java
import org.junit.Test;
import static com.other.FirstDuplicate.firstDuplicate;
import static org.assertj.core.api.Assertions.assertThat;
package com.other;
public class FirstDuplicateTest {
@Test
public void failingCase13() {
int[] a = new int[]{28, 19, 13, 6, 34, 48, 50, 3, 47, 18, 15, 34, 16, 11, 13, 3, 2, 4, 46, 6, 7, 3, 18, 9, 32, 21, 3, 21, 50, 10, 45, 13, 22, 1, 27, 18, 3, 27, 30, 44, 12, 30, 40, 1, 1, 31, 6, 18, 33, 5}; | assertThat(firstDuplicate(a)).isEqualTo(34); |
iluu/algs-progfun | src/test/java/com/hackerrank/BeautifulDaysAtTheMoviesTest.java | // Path: src/main/java/com/hackerrank/BeautifulDaysAtTheMovies.java
// static int countBeautiful(int i, int j, int k) {
// int result = 0;
// for (int l = i; l <= j; l++) {
// if (isBeautiful(l, k)) {
// result++;
// }
// }
// return result;
// }
//
// Path: src/main/java/com/hackerrank/BeautifulDaysAtTheMovies.java
// static boolean isBeautiful(int i, int k) {
// return Math.abs(i - reversed(i)) % k == 0;
// }
//
// Path: src/main/java/com/hackerrank/BeautifulDaysAtTheMovies.java
// static int reversed(int i) {
// String s = String.valueOf(i);
// StringBuilder result = new StringBuilder();
// for (int j = s.length() - 1; j >= 0; j--) {
// if (j != s.length() || s.charAt(j) != '0') {
// result.append(s.charAt(j));
// }
// }
// return Integer.valueOf(result.toString());
// }
| import org.junit.Test;
import static com.hackerrank.BeautifulDaysAtTheMovies.countBeautiful;
import static com.hackerrank.BeautifulDaysAtTheMovies.isBeautiful;
import static com.hackerrank.BeautifulDaysAtTheMovies.reversed;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; | package com.hackerrank;
public class BeautifulDaysAtTheMoviesTest {
@Test
public void shouldReverse() { | // Path: src/main/java/com/hackerrank/BeautifulDaysAtTheMovies.java
// static int countBeautiful(int i, int j, int k) {
// int result = 0;
// for (int l = i; l <= j; l++) {
// if (isBeautiful(l, k)) {
// result++;
// }
// }
// return result;
// }
//
// Path: src/main/java/com/hackerrank/BeautifulDaysAtTheMovies.java
// static boolean isBeautiful(int i, int k) {
// return Math.abs(i - reversed(i)) % k == 0;
// }
//
// Path: src/main/java/com/hackerrank/BeautifulDaysAtTheMovies.java
// static int reversed(int i) {
// String s = String.valueOf(i);
// StringBuilder result = new StringBuilder();
// for (int j = s.length() - 1; j >= 0; j--) {
// if (j != s.length() || s.charAt(j) != '0') {
// result.append(s.charAt(j));
// }
// }
// return Integer.valueOf(result.toString());
// }
// Path: src/test/java/com/hackerrank/BeautifulDaysAtTheMoviesTest.java
import org.junit.Test;
import static com.hackerrank.BeautifulDaysAtTheMovies.countBeautiful;
import static com.hackerrank.BeautifulDaysAtTheMovies.isBeautiful;
import static com.hackerrank.BeautifulDaysAtTheMovies.reversed;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
package com.hackerrank;
public class BeautifulDaysAtTheMoviesTest {
@Test
public void shouldReverse() { | assertThat(reversed(123)).isEqualTo(321); |
iluu/algs-progfun | src/test/java/com/hackerrank/BeautifulDaysAtTheMoviesTest.java | // Path: src/main/java/com/hackerrank/BeautifulDaysAtTheMovies.java
// static int countBeautiful(int i, int j, int k) {
// int result = 0;
// for (int l = i; l <= j; l++) {
// if (isBeautiful(l, k)) {
// result++;
// }
// }
// return result;
// }
//
// Path: src/main/java/com/hackerrank/BeautifulDaysAtTheMovies.java
// static boolean isBeautiful(int i, int k) {
// return Math.abs(i - reversed(i)) % k == 0;
// }
//
// Path: src/main/java/com/hackerrank/BeautifulDaysAtTheMovies.java
// static int reversed(int i) {
// String s = String.valueOf(i);
// StringBuilder result = new StringBuilder();
// for (int j = s.length() - 1; j >= 0; j--) {
// if (j != s.length() || s.charAt(j) != '0') {
// result.append(s.charAt(j));
// }
// }
// return Integer.valueOf(result.toString());
// }
| import org.junit.Test;
import static com.hackerrank.BeautifulDaysAtTheMovies.countBeautiful;
import static com.hackerrank.BeautifulDaysAtTheMovies.isBeautiful;
import static com.hackerrank.BeautifulDaysAtTheMovies.reversed;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; | package com.hackerrank;
public class BeautifulDaysAtTheMoviesTest {
@Test
public void shouldReverse() {
assertThat(reversed(123)).isEqualTo(321);
assertThat(reversed(120)).isEqualTo(21);
}
@Test
public void shouldBeBeautiful() { | // Path: src/main/java/com/hackerrank/BeautifulDaysAtTheMovies.java
// static int countBeautiful(int i, int j, int k) {
// int result = 0;
// for (int l = i; l <= j; l++) {
// if (isBeautiful(l, k)) {
// result++;
// }
// }
// return result;
// }
//
// Path: src/main/java/com/hackerrank/BeautifulDaysAtTheMovies.java
// static boolean isBeautiful(int i, int k) {
// return Math.abs(i - reversed(i)) % k == 0;
// }
//
// Path: src/main/java/com/hackerrank/BeautifulDaysAtTheMovies.java
// static int reversed(int i) {
// String s = String.valueOf(i);
// StringBuilder result = new StringBuilder();
// for (int j = s.length() - 1; j >= 0; j--) {
// if (j != s.length() || s.charAt(j) != '0') {
// result.append(s.charAt(j));
// }
// }
// return Integer.valueOf(result.toString());
// }
// Path: src/test/java/com/hackerrank/BeautifulDaysAtTheMoviesTest.java
import org.junit.Test;
import static com.hackerrank.BeautifulDaysAtTheMovies.countBeautiful;
import static com.hackerrank.BeautifulDaysAtTheMovies.isBeautiful;
import static com.hackerrank.BeautifulDaysAtTheMovies.reversed;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
package com.hackerrank;
public class BeautifulDaysAtTheMoviesTest {
@Test
public void shouldReverse() {
assertThat(reversed(123)).isEqualTo(321);
assertThat(reversed(120)).isEqualTo(21);
}
@Test
public void shouldBeBeautiful() { | assertThat(isBeautiful(20, 6)).isTrue(); |
iluu/algs-progfun | src/test/java/com/hackerrank/BeautifulDaysAtTheMoviesTest.java | // Path: src/main/java/com/hackerrank/BeautifulDaysAtTheMovies.java
// static int countBeautiful(int i, int j, int k) {
// int result = 0;
// for (int l = i; l <= j; l++) {
// if (isBeautiful(l, k)) {
// result++;
// }
// }
// return result;
// }
//
// Path: src/main/java/com/hackerrank/BeautifulDaysAtTheMovies.java
// static boolean isBeautiful(int i, int k) {
// return Math.abs(i - reversed(i)) % k == 0;
// }
//
// Path: src/main/java/com/hackerrank/BeautifulDaysAtTheMovies.java
// static int reversed(int i) {
// String s = String.valueOf(i);
// StringBuilder result = new StringBuilder();
// for (int j = s.length() - 1; j >= 0; j--) {
// if (j != s.length() || s.charAt(j) != '0') {
// result.append(s.charAt(j));
// }
// }
// return Integer.valueOf(result.toString());
// }
| import org.junit.Test;
import static com.hackerrank.BeautifulDaysAtTheMovies.countBeautiful;
import static com.hackerrank.BeautifulDaysAtTheMovies.isBeautiful;
import static com.hackerrank.BeautifulDaysAtTheMovies.reversed;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; | package com.hackerrank;
public class BeautifulDaysAtTheMoviesTest {
@Test
public void shouldReverse() {
assertThat(reversed(123)).isEqualTo(321);
assertThat(reversed(120)).isEqualTo(21);
}
@Test
public void shouldBeBeautiful() {
assertThat(isBeautiful(20, 6)).isTrue();
assertThat(isBeautiful(22, 6)).isTrue();
}
@Test
public void shouldNotBeBeautiful() {
assertThat(isBeautiful(21, 6)).isFalse();
assertThat(isBeautiful(23, 6)).isFalse();
}
@Test
public void shouldCountBeautiful() { | // Path: src/main/java/com/hackerrank/BeautifulDaysAtTheMovies.java
// static int countBeautiful(int i, int j, int k) {
// int result = 0;
// for (int l = i; l <= j; l++) {
// if (isBeautiful(l, k)) {
// result++;
// }
// }
// return result;
// }
//
// Path: src/main/java/com/hackerrank/BeautifulDaysAtTheMovies.java
// static boolean isBeautiful(int i, int k) {
// return Math.abs(i - reversed(i)) % k == 0;
// }
//
// Path: src/main/java/com/hackerrank/BeautifulDaysAtTheMovies.java
// static int reversed(int i) {
// String s = String.valueOf(i);
// StringBuilder result = new StringBuilder();
// for (int j = s.length() - 1; j >= 0; j--) {
// if (j != s.length() || s.charAt(j) != '0') {
// result.append(s.charAt(j));
// }
// }
// return Integer.valueOf(result.toString());
// }
// Path: src/test/java/com/hackerrank/BeautifulDaysAtTheMoviesTest.java
import org.junit.Test;
import static com.hackerrank.BeautifulDaysAtTheMovies.countBeautiful;
import static com.hackerrank.BeautifulDaysAtTheMovies.isBeautiful;
import static com.hackerrank.BeautifulDaysAtTheMovies.reversed;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
package com.hackerrank;
public class BeautifulDaysAtTheMoviesTest {
@Test
public void shouldReverse() {
assertThat(reversed(123)).isEqualTo(321);
assertThat(reversed(120)).isEqualTo(21);
}
@Test
public void shouldBeBeautiful() {
assertThat(isBeautiful(20, 6)).isTrue();
assertThat(isBeautiful(22, 6)).isTrue();
}
@Test
public void shouldNotBeBeautiful() {
assertThat(isBeautiful(21, 6)).isFalse();
assertThat(isBeautiful(23, 6)).isFalse();
}
@Test
public void shouldCountBeautiful() { | assertThat(countBeautiful(20, 23, 6)).isEqualTo(2); |
iluu/algs-progfun | src/test/java/com/hackerrank/SherlockAndTheValidStringTest.java | // Path: src/main/java/com/hackerrank/SherlockAndTheValidString.java
// static String isValid(String s) {
// Map<Character, Integer> dict = new HashMap<>();
// for (Character c : s.toCharArray()) {
// if (!dict.containsKey(c)) {
// dict.put(c, 0);
// }
// dict.put(c, dict.get(c) + 1);
// }
//
// int err = 0;
// int val = dict.get(s.charAt(0));
// for (Integer v : dict.values()) {
// int abs = Math.abs(v - val);
// if (abs == 1 || v == 1) {
// err++;
// }
// if (err > 1 || abs > 1 && v > 1) {
// return "NO";
// }
//
// }
// return "YES";
// }
| import org.junit.Test;
import static com.hackerrank.SherlockAndTheValidString.isValid;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; | package com.hackerrank;
public class SherlockAndTheValidStringTest {
@Test
public void shouldBeValid() { | // Path: src/main/java/com/hackerrank/SherlockAndTheValidString.java
// static String isValid(String s) {
// Map<Character, Integer> dict = new HashMap<>();
// for (Character c : s.toCharArray()) {
// if (!dict.containsKey(c)) {
// dict.put(c, 0);
// }
// dict.put(c, dict.get(c) + 1);
// }
//
// int err = 0;
// int val = dict.get(s.charAt(0));
// for (Integer v : dict.values()) {
// int abs = Math.abs(v - val);
// if (abs == 1 || v == 1) {
// err++;
// }
// if (err > 1 || abs > 1 && v > 1) {
// return "NO";
// }
//
// }
// return "YES";
// }
// Path: src/test/java/com/hackerrank/SherlockAndTheValidStringTest.java
import org.junit.Test;
import static com.hackerrank.SherlockAndTheValidString.isValid;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
package com.hackerrank;
public class SherlockAndTheValidStringTest {
@Test
public void shouldBeValid() { | assertThat(isValid("aabbcc")).isEqualTo("YES"); |
iluu/algs-progfun | src/test/java/com/hackerrank/ManasaAndStonesTest.java | // Path: src/main/java/com/hackerrank/ManasaAndStones.java
// static Set<Integer> calculateLastStone(int n, int a, int b) {
// Set<Integer> result = new TreeSet<>();
// for (int i = 0; i < n; i++) {
// result.add(i * a + (n - i - 1) * b);
// }
// return result;
// }
| import org.junit.Test;
import java.util.Arrays;
import java.util.HashSet;
import static com.hackerrank.ManasaAndStones.calculateLastStone;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat; | package com.hackerrank;
public class ManasaAndStonesTest {
@Test
public void sampleTest1() { | // Path: src/main/java/com/hackerrank/ManasaAndStones.java
// static Set<Integer> calculateLastStone(int n, int a, int b) {
// Set<Integer> result = new TreeSet<>();
// for (int i = 0; i < n; i++) {
// result.add(i * a + (n - i - 1) * b);
// }
// return result;
// }
// Path: src/test/java/com/hackerrank/ManasaAndStonesTest.java
import org.junit.Test;
import java.util.Arrays;
import java.util.HashSet;
import static com.hackerrank.ManasaAndStones.calculateLastStone;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
package com.hackerrank;
public class ManasaAndStonesTest {
@Test
public void sampleTest1() { | assertThat(calculateLastStone(3, 1, 2), |
iluu/algs-progfun | src/test/java/com/hackerrank/SuperReducedStringTest.java | // Path: src/main/java/com/hackerrank/SuperReducedString.java
// static String superReducedString(String input) {
// Pattern pattern = Pattern.compile("([a-z])\\1");
// Matcher matcher = pattern.matcher(input);
// while (matcher.find()) {
// input = matcher.replaceAll("");
// matcher.reset(input);
// }
// return input.equals("") ? "Empty String" : input;
// }
| import org.junit.Test;
import static com.hackerrank.SuperReducedString.superReducedString;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; | package com.hackerrank;
public class SuperReducedStringTest {
@Test
public void simpleTestCase() { | // Path: src/main/java/com/hackerrank/SuperReducedString.java
// static String superReducedString(String input) {
// Pattern pattern = Pattern.compile("([a-z])\\1");
// Matcher matcher = pattern.matcher(input);
// while (matcher.find()) {
// input = matcher.replaceAll("");
// matcher.reset(input);
// }
// return input.equals("") ? "Empty String" : input;
// }
// Path: src/test/java/com/hackerrank/SuperReducedStringTest.java
import org.junit.Test;
import static com.hackerrank.SuperReducedString.superReducedString;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
package com.hackerrank;
public class SuperReducedStringTest {
@Test
public void simpleTestCase() { | assertThat(superReducedString("aaabccddd")).isEqualTo("abd"); |
iluu/algs-progfun | src/test/java/com/hackerrank/ElectronicsShopTest.java | // Path: src/main/java/com/hackerrank/ElectronicsShop.java
// static int getMoneySpent(int[] keyboards, int[] drives, int s) {
// int max = -1;
// for (int keyboard : keyboards) {
// for (int drive : drives) {
// int current = keyboard + drive;
// if (current <= s && current > max) {
// max = current;
// }
// }
// }
// return max;
// }
| import org.junit.Test;
import static com.hackerrank.ElectronicsShop.getMoneySpent;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; | package com.hackerrank;
public class ElectronicsShopTest {
@Test
public void firstTestCase() { | // Path: src/main/java/com/hackerrank/ElectronicsShop.java
// static int getMoneySpent(int[] keyboards, int[] drives, int s) {
// int max = -1;
// for (int keyboard : keyboards) {
// for (int drive : drives) {
// int current = keyboard + drive;
// if (current <= s && current > max) {
// max = current;
// }
// }
// }
// return max;
// }
// Path: src/test/java/com/hackerrank/ElectronicsShopTest.java
import org.junit.Test;
import static com.hackerrank.ElectronicsShop.getMoneySpent;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
package com.hackerrank;
public class ElectronicsShopTest {
@Test
public void firstTestCase() { | assertThat(getMoneySpent(new int[]{3, 1}, new int[]{5, 2, 8}, 10)).isEqualTo(9); |
GitLqr/LQRBiliBlili | app/src/main/java/com/lqr/biliblili/mvp/ui/activity/SplashActivity.java | // Path: app/src/main/java/com/lqr/biliblili/app/utils/SystemUiVisibilityUtil.java
// public class SystemUiVisibilityUtil {
// public static void addFlags(View view, int flags) {
// view.setSystemUiVisibility(view.getSystemUiVisibility() | flags);
// }
//
// public static void clearFlags(View view, int flags) {
// view.setSystemUiVisibility(view.getSystemUiVisibility() & ~flags);
// }
//
// public static boolean hasFlags(View view, int flags) {
// return (view.getSystemUiVisibility() & flags) == flags;
// }
//
// /**
// * * 显示或隐藏StatusBar
// *
// * @param enable false 显示,true 隐藏
// */
// public static void hideStatusBar(Window window, boolean enable) {
// WindowManager.LayoutParams p = window.getAttributes();
// if (enable)
// //|=:或等于,取其一
// {
// p.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
// } else
// //&=:与等于,取其二同时满足, ~ : 取反
// {
// p.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
// }
//
// window.setAttributes(p);
// window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
// }
// }
| import android.os.Bundle;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.RxLifecycleUtils;
import com.lqr.biliblili.R;
import com.lqr.biliblili.app.utils.SystemUiVisibilityUtil;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers; | package com.lqr.biliblili.mvp.ui.activity;
/**
* @创建者 CSDN_LQR
* @描述 启动页面
*/
@Route(path = "/app/splash")
public class SplashActivity extends BaseActivity {
@Override
public void setupActivityComponent(AppComponent appComponent) {
}
@Override
public int initView(Bundle savedInstanceState) { | // Path: app/src/main/java/com/lqr/biliblili/app/utils/SystemUiVisibilityUtil.java
// public class SystemUiVisibilityUtil {
// public static void addFlags(View view, int flags) {
// view.setSystemUiVisibility(view.getSystemUiVisibility() | flags);
// }
//
// public static void clearFlags(View view, int flags) {
// view.setSystemUiVisibility(view.getSystemUiVisibility() & ~flags);
// }
//
// public static boolean hasFlags(View view, int flags) {
// return (view.getSystemUiVisibility() & flags) == flags;
// }
//
// /**
// * * 显示或隐藏StatusBar
// *
// * @param enable false 显示,true 隐藏
// */
// public static void hideStatusBar(Window window, boolean enable) {
// WindowManager.LayoutParams p = window.getAttributes();
// if (enable)
// //|=:或等于,取其一
// {
// p.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
// } else
// //&=:与等于,取其二同时满足, ~ : 取反
// {
// p.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
// }
//
// window.setAttributes(p);
// window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
// }
// }
// Path: app/src/main/java/com/lqr/biliblili/mvp/ui/activity/SplashActivity.java
import android.os.Bundle;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.RxLifecycleUtils;
import com.lqr.biliblili.R;
import com.lqr.biliblili.app.utils.SystemUiVisibilityUtil;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
package com.lqr.biliblili.mvp.ui.activity;
/**
* @创建者 CSDN_LQR
* @描述 启动页面
*/
@Route(path = "/app/splash")
public class SplashActivity extends BaseActivity {
@Override
public void setupActivityComponent(AppComponent appComponent) {
}
@Override
public int initView(Bundle savedInstanceState) { | SystemUiVisibilityUtil.hideStatusBar(getWindow(), true); |
GitLqr/LQRBiliBlili | app/src/main/java/com/lqr/biliblili/di/module/MainModule.java | // Path: app/src/main/java/com/lqr/biliblili/mvp/contract/MainContract.java
// public interface MainContract {
// //对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
// interface View extends IView {
//
// }
//
// //Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
// interface Model extends IModel {
//
// }
// }
//
// Path: app/src/main/java/com/lqr/biliblili/mvp/model/MainModel.java
// @ActivityScope
// public class MainModel extends BaseModel implements MainContract.Model {
// private Gson mGson;
// private Application mApplication;
//
// @Inject
// public MainModel(IRepositoryManager repositoryManager, Gson gson, Application application) {
// super(repositoryManager);
// this.mGson = gson;
// this.mApplication = application;
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// this.mGson = null;
// this.mApplication = null;
// }
//
// }
| import com.jess.arms.di.scope.ActivityScope;
import com.lqr.biliblili.mvp.contract.MainContract;
import com.lqr.biliblili.mvp.model.MainModel;
import dagger.Module;
import dagger.Provides; | package com.lqr.biliblili.di.module;
@Module
public class MainModule { | // Path: app/src/main/java/com/lqr/biliblili/mvp/contract/MainContract.java
// public interface MainContract {
// //对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
// interface View extends IView {
//
// }
//
// //Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
// interface Model extends IModel {
//
// }
// }
//
// Path: app/src/main/java/com/lqr/biliblili/mvp/model/MainModel.java
// @ActivityScope
// public class MainModel extends BaseModel implements MainContract.Model {
// private Gson mGson;
// private Application mApplication;
//
// @Inject
// public MainModel(IRepositoryManager repositoryManager, Gson gson, Application application) {
// super(repositoryManager);
// this.mGson = gson;
// this.mApplication = application;
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// this.mGson = null;
// this.mApplication = null;
// }
//
// }
// Path: app/src/main/java/com/lqr/biliblili/di/module/MainModule.java
import com.jess.arms.di.scope.ActivityScope;
import com.lqr.biliblili.mvp.contract.MainContract;
import com.lqr.biliblili.mvp.model.MainModel;
import dagger.Module;
import dagger.Provides;
package com.lqr.biliblili.di.module;
@Module
public class MainModule { | private MainContract.View view; |
GitLqr/LQRBiliBlili | app/src/main/java/com/lqr/biliblili/di/module/MainModule.java | // Path: app/src/main/java/com/lqr/biliblili/mvp/contract/MainContract.java
// public interface MainContract {
// //对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
// interface View extends IView {
//
// }
//
// //Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
// interface Model extends IModel {
//
// }
// }
//
// Path: app/src/main/java/com/lqr/biliblili/mvp/model/MainModel.java
// @ActivityScope
// public class MainModel extends BaseModel implements MainContract.Model {
// private Gson mGson;
// private Application mApplication;
//
// @Inject
// public MainModel(IRepositoryManager repositoryManager, Gson gson, Application application) {
// super(repositoryManager);
// this.mGson = gson;
// this.mApplication = application;
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// this.mGson = null;
// this.mApplication = null;
// }
//
// }
| import com.jess.arms.di.scope.ActivityScope;
import com.lqr.biliblili.mvp.contract.MainContract;
import com.lqr.biliblili.mvp.model.MainModel;
import dagger.Module;
import dagger.Provides; | package com.lqr.biliblili.di.module;
@Module
public class MainModule {
private MainContract.View view;
/**
* 构建MainModule时,将View的实现类传进来,这样就可以提供View的实现类给presenter
*
* @param view
*/
public MainModule(MainContract.View view) {
this.view = view;
}
@ActivityScope
@Provides
MainContract.View provideMainView() {
return this.view;
}
@ActivityScope
@Provides | // Path: app/src/main/java/com/lqr/biliblili/mvp/contract/MainContract.java
// public interface MainContract {
// //对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
// interface View extends IView {
//
// }
//
// //Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
// interface Model extends IModel {
//
// }
// }
//
// Path: app/src/main/java/com/lqr/biliblili/mvp/model/MainModel.java
// @ActivityScope
// public class MainModel extends BaseModel implements MainContract.Model {
// private Gson mGson;
// private Application mApplication;
//
// @Inject
// public MainModel(IRepositoryManager repositoryManager, Gson gson, Application application) {
// super(repositoryManager);
// this.mGson = gson;
// this.mApplication = application;
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// this.mGson = null;
// this.mApplication = null;
// }
//
// }
// Path: app/src/main/java/com/lqr/biliblili/di/module/MainModule.java
import com.jess.arms.di.scope.ActivityScope;
import com.lqr.biliblili.mvp.contract.MainContract;
import com.lqr.biliblili.mvp.model.MainModel;
import dagger.Module;
import dagger.Provides;
package com.lqr.biliblili.di.module;
@Module
public class MainModule {
private MainContract.View view;
/**
* 构建MainModule时,将View的实现类传进来,这样就可以提供View的实现类给presenter
*
* @param view
*/
public MainModule(MainContract.View view) {
this.view = view;
}
@ActivityScope
@Provides
MainContract.View provideMainView() {
return this.view;
}
@ActivityScope
@Provides | MainContract.Model provideMainModel(MainModel model) { |
GitLqr/LQRBiliBlili | app/src/main/java/com/lqr/biliblili/di/module/MainCategoryModule.java | // Path: app/src/main/java/com/lqr/biliblili/mvp/contract/MainCategoryContract.java
// public interface MainCategoryContract {
// //对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
// interface View extends IView {
//
// }
//
// //Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
// interface Model extends IModel {
//
// }
// }
//
// Path: app/src/main/java/com/lqr/biliblili/mvp/model/MainCategoryModel.java
// @FragmentScope
// public class MainCategoryModel extends BaseModel implements MainCategoryContract.Model {
//
// private Gson mGson;
// private Application mApplication;
//
// @Inject
// public MainCategoryModel(IRepositoryManager repositoryManager, Gson gson, Application application) {
// super(repositoryManager);
// mGson = gson;
// mApplication = application;
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// this.mGson = null;
// this.mApplication = null;
// }
// }
| import com.jess.arms.di.scope.FragmentScope;
import com.lqr.biliblili.mvp.contract.MainCategoryContract;
import com.lqr.biliblili.mvp.model.MainCategoryModel;
import dagger.Module;
import dagger.Provides; | package com.lqr.biliblili.di.module;
@Module
public class MainCategoryModule { | // Path: app/src/main/java/com/lqr/biliblili/mvp/contract/MainCategoryContract.java
// public interface MainCategoryContract {
// //对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
// interface View extends IView {
//
// }
//
// //Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
// interface Model extends IModel {
//
// }
// }
//
// Path: app/src/main/java/com/lqr/biliblili/mvp/model/MainCategoryModel.java
// @FragmentScope
// public class MainCategoryModel extends BaseModel implements MainCategoryContract.Model {
//
// private Gson mGson;
// private Application mApplication;
//
// @Inject
// public MainCategoryModel(IRepositoryManager repositoryManager, Gson gson, Application application) {
// super(repositoryManager);
// mGson = gson;
// mApplication = application;
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// this.mGson = null;
// this.mApplication = null;
// }
// }
// Path: app/src/main/java/com/lqr/biliblili/di/module/MainCategoryModule.java
import com.jess.arms.di.scope.FragmentScope;
import com.lqr.biliblili.mvp.contract.MainCategoryContract;
import com.lqr.biliblili.mvp.model.MainCategoryModel;
import dagger.Module;
import dagger.Provides;
package com.lqr.biliblili.di.module;
@Module
public class MainCategoryModule { | private MainCategoryContract.View view; |
GitLqr/LQRBiliBlili | app/src/main/java/com/lqr/biliblili/di/module/MainCategoryModule.java | // Path: app/src/main/java/com/lqr/biliblili/mvp/contract/MainCategoryContract.java
// public interface MainCategoryContract {
// //对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
// interface View extends IView {
//
// }
//
// //Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
// interface Model extends IModel {
//
// }
// }
//
// Path: app/src/main/java/com/lqr/biliblili/mvp/model/MainCategoryModel.java
// @FragmentScope
// public class MainCategoryModel extends BaseModel implements MainCategoryContract.Model {
//
// private Gson mGson;
// private Application mApplication;
//
// @Inject
// public MainCategoryModel(IRepositoryManager repositoryManager, Gson gson, Application application) {
// super(repositoryManager);
// mGson = gson;
// mApplication = application;
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// this.mGson = null;
// this.mApplication = null;
// }
// }
| import com.jess.arms.di.scope.FragmentScope;
import com.lqr.biliblili.mvp.contract.MainCategoryContract;
import com.lqr.biliblili.mvp.model.MainCategoryModel;
import dagger.Module;
import dagger.Provides; | package com.lqr.biliblili.di.module;
@Module
public class MainCategoryModule {
private MainCategoryContract.View view;
public MainCategoryModule(MainCategoryContract.View view) {
this.view = view;
}
@FragmentScope
@Provides
MainCategoryContract.View provideMainCategoryView() {
return this.view;
}
@FragmentScope
@Provides | // Path: app/src/main/java/com/lqr/biliblili/mvp/contract/MainCategoryContract.java
// public interface MainCategoryContract {
// //对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
// interface View extends IView {
//
// }
//
// //Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
// interface Model extends IModel {
//
// }
// }
//
// Path: app/src/main/java/com/lqr/biliblili/mvp/model/MainCategoryModel.java
// @FragmentScope
// public class MainCategoryModel extends BaseModel implements MainCategoryContract.Model {
//
// private Gson mGson;
// private Application mApplication;
//
// @Inject
// public MainCategoryModel(IRepositoryManager repositoryManager, Gson gson, Application application) {
// super(repositoryManager);
// mGson = gson;
// mApplication = application;
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// this.mGson = null;
// this.mApplication = null;
// }
// }
// Path: app/src/main/java/com/lqr/biliblili/di/module/MainCategoryModule.java
import com.jess.arms.di.scope.FragmentScope;
import com.lqr.biliblili.mvp.contract.MainCategoryContract;
import com.lqr.biliblili.mvp.model.MainCategoryModel;
import dagger.Module;
import dagger.Provides;
package com.lqr.biliblili.di.module;
@Module
public class MainCategoryModule {
private MainCategoryContract.View view;
public MainCategoryModule(MainCategoryContract.View view) {
this.view = view;
}
@FragmentScope
@Provides
MainCategoryContract.View provideMainCategoryView() {
return this.view;
}
@FragmentScope
@Provides | MainCategoryContract.Model provideMainCategoryModel(MainCategoryModel model) { |
GitLqr/LQRBiliBlili | app/src/main/java/com/lqr/biliblili/di/component/RecommendComponent.java | // Path: app/src/main/java/com/lqr/biliblili/di/module/RecommendModule.java
// @Module
// public class RecommendModule {
//
// private RecommendContract.View view;
//
// public RecommendModule(RecommendContract.View view) {
// this.view = view;
// }
//
// @FragmentScope
// @Provides
// public RecommendContract.View provideView() {
// return view;
// }
//
// @FragmentScope
// @Provides
// public RecommendContract.Model provideModel(RecommendModel model) {
// return model;
// }
// }
//
// Path: app/src/main/java/com/lqr/biliblili/mvp/ui/fragment/main/home/RecommendFragment.java
// public class RecommendFragment extends MySupportFragment<RecommendPresenter> implements RecommendContract.View {
//
// private View mRootView;
//
// @BindView(R.id.refresh_layout)
// SwipeRefreshLayout mRefreshLayout;
// @BindView(R.id.recyclerview)
// RecyclerView mRecyclerView;
//
// public static RecommendFragment newInstance() {
// return new RecommendFragment();
// }
//
// @Override
// public void setupFragmentComponent(AppComponent appComponent) {
// DaggerRecommendComponent
// .builder()
// .recommendModule(new RecommendModule(this))
// .appComponent(appComponent)
// .build()
// .inject(this);
// }
//
// @Override
// public View initView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// if (mRootView == null)
// mRootView = inflater.inflate(R.layout.fragment_recommend_main_home, container, false);
// return mRootView;
// }
//
// @Override
// public void initData(Bundle savedInstanceState) {
// initRefreshLayout();
// }
//
// @Override
// public void setData(Object data) {
//
// }
//
// @Override
// public void onLazyInitView(@Nullable Bundle savedInstanceState) {
// super.onLazyInitView(savedInstanceState);
// mPresenter.loadData(0, false, true);
// }
//
// @Override
// public void showLoading() {
// mRefreshLayout.setRefreshing(true);
// }
//
// @Override
// public void hideLoading() {
// mRefreshLayout.setRefreshing(false);
// }
//
// @Override
// public void showMessage(String message) {
//
// }
//
// @Override
// public void launchActivity(Intent intent) {
//
// }
//
// @Override
// public void killMyself() {
//
// }
//
// private void initRefreshLayout() {
// mRefreshLayout.setColorSchemeColors(ArmsUtils.getColor(_mActivity, R.color.colorPrimary));
// mRefreshLayout.setOnRefreshListener(() -> mPresenter.loadData(mPresenter.getIdx(true), true, false));
// }
//
// @Override
// public void setRecyclerAdapter(RecommendMultiItemAdapter adapter) {
// GridLayoutManager gridLayoutManager = new GridLayoutManager(_mActivity, 2);
// mRecyclerView.setLayoutManager(gridLayoutManager);
// mRecyclerView.setAdapter(adapter);
// gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
// @Override
// public int getSpanSize(int position) {
// // 上拉加载更多视图
// if (position == adapter.getData().size()) {
// return 2;
// }
// return adapter.getData().get(position).getSpanSize();
// }
// });
// }
//
// @Override
// public void recyclerScrollToPosition(int position) {
// mRecyclerView.scrollToPosition(position);
// }
// }
| import com.jess.arms.di.component.AppComponent;
import com.jess.arms.di.scope.FragmentScope;
import com.lqr.biliblili.di.module.RecommendModule;
import com.lqr.biliblili.mvp.ui.fragment.main.home.RecommendFragment;
import dagger.Component; | package com.lqr.biliblili.di.component;
@FragmentScope
@Component(modules = RecommendModule.class, dependencies = AppComponent.class)
public interface RecommendComponent { | // Path: app/src/main/java/com/lqr/biliblili/di/module/RecommendModule.java
// @Module
// public class RecommendModule {
//
// private RecommendContract.View view;
//
// public RecommendModule(RecommendContract.View view) {
// this.view = view;
// }
//
// @FragmentScope
// @Provides
// public RecommendContract.View provideView() {
// return view;
// }
//
// @FragmentScope
// @Provides
// public RecommendContract.Model provideModel(RecommendModel model) {
// return model;
// }
// }
//
// Path: app/src/main/java/com/lqr/biliblili/mvp/ui/fragment/main/home/RecommendFragment.java
// public class RecommendFragment extends MySupportFragment<RecommendPresenter> implements RecommendContract.View {
//
// private View mRootView;
//
// @BindView(R.id.refresh_layout)
// SwipeRefreshLayout mRefreshLayout;
// @BindView(R.id.recyclerview)
// RecyclerView mRecyclerView;
//
// public static RecommendFragment newInstance() {
// return new RecommendFragment();
// }
//
// @Override
// public void setupFragmentComponent(AppComponent appComponent) {
// DaggerRecommendComponent
// .builder()
// .recommendModule(new RecommendModule(this))
// .appComponent(appComponent)
// .build()
// .inject(this);
// }
//
// @Override
// public View initView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// if (mRootView == null)
// mRootView = inflater.inflate(R.layout.fragment_recommend_main_home, container, false);
// return mRootView;
// }
//
// @Override
// public void initData(Bundle savedInstanceState) {
// initRefreshLayout();
// }
//
// @Override
// public void setData(Object data) {
//
// }
//
// @Override
// public void onLazyInitView(@Nullable Bundle savedInstanceState) {
// super.onLazyInitView(savedInstanceState);
// mPresenter.loadData(0, false, true);
// }
//
// @Override
// public void showLoading() {
// mRefreshLayout.setRefreshing(true);
// }
//
// @Override
// public void hideLoading() {
// mRefreshLayout.setRefreshing(false);
// }
//
// @Override
// public void showMessage(String message) {
//
// }
//
// @Override
// public void launchActivity(Intent intent) {
//
// }
//
// @Override
// public void killMyself() {
//
// }
//
// private void initRefreshLayout() {
// mRefreshLayout.setColorSchemeColors(ArmsUtils.getColor(_mActivity, R.color.colorPrimary));
// mRefreshLayout.setOnRefreshListener(() -> mPresenter.loadData(mPresenter.getIdx(true), true, false));
// }
//
// @Override
// public void setRecyclerAdapter(RecommendMultiItemAdapter adapter) {
// GridLayoutManager gridLayoutManager = new GridLayoutManager(_mActivity, 2);
// mRecyclerView.setLayoutManager(gridLayoutManager);
// mRecyclerView.setAdapter(adapter);
// gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
// @Override
// public int getSpanSize(int position) {
// // 上拉加载更多视图
// if (position == adapter.getData().size()) {
// return 2;
// }
// return adapter.getData().get(position).getSpanSize();
// }
// });
// }
//
// @Override
// public void recyclerScrollToPosition(int position) {
// mRecyclerView.scrollToPosition(position);
// }
// }
// Path: app/src/main/java/com/lqr/biliblili/di/component/RecommendComponent.java
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.di.scope.FragmentScope;
import com.lqr.biliblili.di.module.RecommendModule;
import com.lqr.biliblili.mvp.ui.fragment.main.home.RecommendFragment;
import dagger.Component;
package com.lqr.biliblili.di.component;
@FragmentScope
@Component(modules = RecommendModule.class, dependencies = AppComponent.class)
public interface RecommendComponent { | void inject(RecommendFragment fragment); |
GitLqr/LQRBiliBlili | app/src/main/java/com/lqr/biliblili/di/module/VideoDetailModule.java | // Path: app/src/main/java/com/lqr/biliblili/mvp/contract/VideoDetailContract.java
// public interface VideoDetailContract {
// //对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
// interface View extends IView {
// void setTvAvStr(String av);
//
// ImageView getIvCover();
//
// void initViewPager(VideoDetail videoDetail);
//
// void setTvVideoStartInfoStr(String tip);
//
// void playVideo(PlayUrl playUrl);
//
// }
//
// //Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
// interface Model extends IModel {
// Observable<Summary> getSummaryData(String aid);
//
// Observable<Reply> getReplyData(String aid, int pn, int ps);
//
// Observable<PlayUrl> getPlayurl(String aid);
// }
// }
//
// Path: app/src/main/java/com/lqr/biliblili/mvp/model/VideoDetailModel.java
// @ActivityScope
// public class VideoDetailModel extends BaseModel implements VideoDetailContract.Model {
// private Gson mGson;
// private Application mApplication;
//
// @Inject
// public VideoDetailModel(IRepositoryManager repositoryManager, Gson gson, Application application) {
// super(repositoryManager);
// this.mGson = gson;
// this.mApplication = application;
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// this.mGson = null;
// this.mApplication = null;
// }
//
// @Override
// public Observable<Summary> getSummaryData(String aid) {
// return mRepositoryManager.obtainRetrofitService(VideoDetailService.class).getSummaryData(aid);
// }
//
// @Override
// public Observable<Reply> getReplyData(String oid, int pn, int ps) {
// return mRepositoryManager.obtainRetrofitService(VideoDetailService.class).getReplyData(oid, pn, ps);
// }
//
// @Override
// public Observable<PlayUrl> getPlayurl(String aid) {
// return mRepositoryManager.obtainRetrofitService(VideoDetailService.class).getPlayurl(aid);
// }
// }
| import com.jess.arms.di.scope.ActivityScope;
import dagger.Module;
import dagger.Provides;
import com.lqr.biliblili.mvp.contract.VideoDetailContract;
import com.lqr.biliblili.mvp.model.VideoDetailModel; | package com.lqr.biliblili.di.module;
@Module
public class VideoDetailModule { | // Path: app/src/main/java/com/lqr/biliblili/mvp/contract/VideoDetailContract.java
// public interface VideoDetailContract {
// //对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
// interface View extends IView {
// void setTvAvStr(String av);
//
// ImageView getIvCover();
//
// void initViewPager(VideoDetail videoDetail);
//
// void setTvVideoStartInfoStr(String tip);
//
// void playVideo(PlayUrl playUrl);
//
// }
//
// //Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
// interface Model extends IModel {
// Observable<Summary> getSummaryData(String aid);
//
// Observable<Reply> getReplyData(String aid, int pn, int ps);
//
// Observable<PlayUrl> getPlayurl(String aid);
// }
// }
//
// Path: app/src/main/java/com/lqr/biliblili/mvp/model/VideoDetailModel.java
// @ActivityScope
// public class VideoDetailModel extends BaseModel implements VideoDetailContract.Model {
// private Gson mGson;
// private Application mApplication;
//
// @Inject
// public VideoDetailModel(IRepositoryManager repositoryManager, Gson gson, Application application) {
// super(repositoryManager);
// this.mGson = gson;
// this.mApplication = application;
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// this.mGson = null;
// this.mApplication = null;
// }
//
// @Override
// public Observable<Summary> getSummaryData(String aid) {
// return mRepositoryManager.obtainRetrofitService(VideoDetailService.class).getSummaryData(aid);
// }
//
// @Override
// public Observable<Reply> getReplyData(String oid, int pn, int ps) {
// return mRepositoryManager.obtainRetrofitService(VideoDetailService.class).getReplyData(oid, pn, ps);
// }
//
// @Override
// public Observable<PlayUrl> getPlayurl(String aid) {
// return mRepositoryManager.obtainRetrofitService(VideoDetailService.class).getPlayurl(aid);
// }
// }
// Path: app/src/main/java/com/lqr/biliblili/di/module/VideoDetailModule.java
import com.jess.arms.di.scope.ActivityScope;
import dagger.Module;
import dagger.Provides;
import com.lqr.biliblili.mvp.contract.VideoDetailContract;
import com.lqr.biliblili.mvp.model.VideoDetailModel;
package com.lqr.biliblili.di.module;
@Module
public class VideoDetailModule { | private VideoDetailContract.View view; |
GitLqr/LQRBiliBlili | app/src/main/java/com/lqr/biliblili/di/module/VideoDetailModule.java | // Path: app/src/main/java/com/lqr/biliblili/mvp/contract/VideoDetailContract.java
// public interface VideoDetailContract {
// //对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
// interface View extends IView {
// void setTvAvStr(String av);
//
// ImageView getIvCover();
//
// void initViewPager(VideoDetail videoDetail);
//
// void setTvVideoStartInfoStr(String tip);
//
// void playVideo(PlayUrl playUrl);
//
// }
//
// //Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
// interface Model extends IModel {
// Observable<Summary> getSummaryData(String aid);
//
// Observable<Reply> getReplyData(String aid, int pn, int ps);
//
// Observable<PlayUrl> getPlayurl(String aid);
// }
// }
//
// Path: app/src/main/java/com/lqr/biliblili/mvp/model/VideoDetailModel.java
// @ActivityScope
// public class VideoDetailModel extends BaseModel implements VideoDetailContract.Model {
// private Gson mGson;
// private Application mApplication;
//
// @Inject
// public VideoDetailModel(IRepositoryManager repositoryManager, Gson gson, Application application) {
// super(repositoryManager);
// this.mGson = gson;
// this.mApplication = application;
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// this.mGson = null;
// this.mApplication = null;
// }
//
// @Override
// public Observable<Summary> getSummaryData(String aid) {
// return mRepositoryManager.obtainRetrofitService(VideoDetailService.class).getSummaryData(aid);
// }
//
// @Override
// public Observable<Reply> getReplyData(String oid, int pn, int ps) {
// return mRepositoryManager.obtainRetrofitService(VideoDetailService.class).getReplyData(oid, pn, ps);
// }
//
// @Override
// public Observable<PlayUrl> getPlayurl(String aid) {
// return mRepositoryManager.obtainRetrofitService(VideoDetailService.class).getPlayurl(aid);
// }
// }
| import com.jess.arms.di.scope.ActivityScope;
import dagger.Module;
import dagger.Provides;
import com.lqr.biliblili.mvp.contract.VideoDetailContract;
import com.lqr.biliblili.mvp.model.VideoDetailModel; | package com.lqr.biliblili.di.module;
@Module
public class VideoDetailModule {
private VideoDetailContract.View view;
/**
* 构建VideoDetailModule时,将View的实现类传进来,这样就可以提供View的实现类给presenter
*
* @param view
*/
public VideoDetailModule(VideoDetailContract.View view) {
this.view = view;
}
@ActivityScope
@Provides
VideoDetailContract.View provideVideoDetailView() {
return this.view;
}
@ActivityScope
@Provides | // Path: app/src/main/java/com/lqr/biliblili/mvp/contract/VideoDetailContract.java
// public interface VideoDetailContract {
// //对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
// interface View extends IView {
// void setTvAvStr(String av);
//
// ImageView getIvCover();
//
// void initViewPager(VideoDetail videoDetail);
//
// void setTvVideoStartInfoStr(String tip);
//
// void playVideo(PlayUrl playUrl);
//
// }
//
// //Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
// interface Model extends IModel {
// Observable<Summary> getSummaryData(String aid);
//
// Observable<Reply> getReplyData(String aid, int pn, int ps);
//
// Observable<PlayUrl> getPlayurl(String aid);
// }
// }
//
// Path: app/src/main/java/com/lqr/biliblili/mvp/model/VideoDetailModel.java
// @ActivityScope
// public class VideoDetailModel extends BaseModel implements VideoDetailContract.Model {
// private Gson mGson;
// private Application mApplication;
//
// @Inject
// public VideoDetailModel(IRepositoryManager repositoryManager, Gson gson, Application application) {
// super(repositoryManager);
// this.mGson = gson;
// this.mApplication = application;
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// this.mGson = null;
// this.mApplication = null;
// }
//
// @Override
// public Observable<Summary> getSummaryData(String aid) {
// return mRepositoryManager.obtainRetrofitService(VideoDetailService.class).getSummaryData(aid);
// }
//
// @Override
// public Observable<Reply> getReplyData(String oid, int pn, int ps) {
// return mRepositoryManager.obtainRetrofitService(VideoDetailService.class).getReplyData(oid, pn, ps);
// }
//
// @Override
// public Observable<PlayUrl> getPlayurl(String aid) {
// return mRepositoryManager.obtainRetrofitService(VideoDetailService.class).getPlayurl(aid);
// }
// }
// Path: app/src/main/java/com/lqr/biliblili/di/module/VideoDetailModule.java
import com.jess.arms.di.scope.ActivityScope;
import dagger.Module;
import dagger.Provides;
import com.lqr.biliblili.mvp.contract.VideoDetailContract;
import com.lqr.biliblili.mvp.model.VideoDetailModel;
package com.lqr.biliblili.di.module;
@Module
public class VideoDetailModule {
private VideoDetailContract.View view;
/**
* 构建VideoDetailModule时,将View的实现类传进来,这样就可以提供View的实现类给presenter
*
* @param view
*/
public VideoDetailModule(VideoDetailContract.View view) {
this.view = view;
}
@ActivityScope
@Provides
VideoDetailContract.View provideVideoDetailView() {
return this.view;
}
@ActivityScope
@Provides | VideoDetailContract.Model provideVideoDetailModel(VideoDetailModel model) { |
GitLqr/LQRBiliBlili | app/src/main/java/com/lqr/biliblili/di/module/RecommendModule.java | // Path: app/src/main/java/com/lqr/biliblili/mvp/contract/RecommendContract.java
// public interface RecommendContract {
//
// interface View extends IView {
//
// void setRecyclerAdapter(RecommendMultiItemAdapter adapter);
//
// void recyclerScrollToPosition(int position);
// }
//
// interface Model extends IModel {
// /**
// * @param idx 下拉刷新时取第一个数据的idx,上拉加载更多时取最后一个数据的idx
// * @param refresh 下拉刷新时取"true",上拉加载更多时取"false"
// * @param clearCache 第一次加载数据时为true,其他时候为false(对应的true时,login_event的值为1[获取banner],为false时,login_event的值为0)
// * @return
// */
// Observable<IndexData> getRecommendIndexData(int idx, boolean refresh, boolean clearCache);
//
// List<RecommendMultiItem> parseIndexData(IndexData indexData);
//
// }
// }
//
// Path: app/src/main/java/com/lqr/biliblili/mvp/model/RecommendModel.java
// @FragmentScope
// public class RecommendModel extends BaseModel implements RecommendContract.Model {
//
// private boolean isOdd = true;
// private Gson mGson;
// private Application mApplication;
//
// @Inject
// public RecommendModel(IRepositoryManager repositoryManager, Gson gson, Application application) {
// super(repositoryManager);
// mGson = gson;
// mApplication = application;
// RetrofitUrlManager.getInstance().putDomain("recommend", Api.RECOMMEND_BASE_URL);
// }
//
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// this.mGson = null;
// this.mApplication = null;
// }
//
// @Override
// public Observable<IndexData> getRecommendIndexData(int idx, boolean refresh, boolean clearCache) {
// return Observable.just(mRepositoryManager
// .obtainRetrofitService(RecommendService.class)
// .getRecommendIndexData(idx, refresh ? "true" : "false", clearCache ? 1 : 0))
// .flatMap(new Function<Observable<IndexData>, ObservableSource<IndexData>>() {
// @Override
// public ObservableSource<IndexData> apply(@NonNull Observable<IndexData> indexDataObservable) throws Exception {
// return mRepositoryManager
// .obtainCacheService(RecommendCache.class)
// .getRecommendIndexData(indexDataObservable, new DynamicKey(idx), new EvictProvider(clearCache))
// .map(indexDataReply -> indexDataReply.getData());
// }
// });
// }
//
//
// @Override
// public List<RecommendMultiItem> parseIndexData(IndexData indexData) {
// List<RecommendMultiItem> list = new ArrayList<>();
// List<IndexData.DataBean> data = indexData.getData();
// if (data != null) {
// for (int i = 0; i < data.size(); i++) {
// IndexData.DataBean dataBean = data.get(i);
// if (dataBean != null) {
// String gotoX = dataBean.getGotoX();
// if (RecommendMultiItem.isWeNeed(gotoX)) {
// RecommendMultiItem item = new RecommendMultiItem();
// item.setItemTypeWithGoto(gotoX, dataBean.getRcmd_reason() == null);
// item.setIndexDataBean(dataBean);
// if (RecommendMultiItem.isItemData(gotoX)) {
// item.setOdd(isOdd);
// isOdd = !isOdd;
// } else {
// isOdd = true;
// }
// list.add(item);
// }
// }
// }
// }
// return list;
// }
// }
| import com.jess.arms.di.scope.FragmentScope;
import com.lqr.biliblili.mvp.contract.RecommendContract;
import com.lqr.biliblili.mvp.model.RecommendModel;
import dagger.Module;
import dagger.Provides; | package com.lqr.biliblili.di.module;
@Module
public class RecommendModule {
| // Path: app/src/main/java/com/lqr/biliblili/mvp/contract/RecommendContract.java
// public interface RecommendContract {
//
// interface View extends IView {
//
// void setRecyclerAdapter(RecommendMultiItemAdapter adapter);
//
// void recyclerScrollToPosition(int position);
// }
//
// interface Model extends IModel {
// /**
// * @param idx 下拉刷新时取第一个数据的idx,上拉加载更多时取最后一个数据的idx
// * @param refresh 下拉刷新时取"true",上拉加载更多时取"false"
// * @param clearCache 第一次加载数据时为true,其他时候为false(对应的true时,login_event的值为1[获取banner],为false时,login_event的值为0)
// * @return
// */
// Observable<IndexData> getRecommendIndexData(int idx, boolean refresh, boolean clearCache);
//
// List<RecommendMultiItem> parseIndexData(IndexData indexData);
//
// }
// }
//
// Path: app/src/main/java/com/lqr/biliblili/mvp/model/RecommendModel.java
// @FragmentScope
// public class RecommendModel extends BaseModel implements RecommendContract.Model {
//
// private boolean isOdd = true;
// private Gson mGson;
// private Application mApplication;
//
// @Inject
// public RecommendModel(IRepositoryManager repositoryManager, Gson gson, Application application) {
// super(repositoryManager);
// mGson = gson;
// mApplication = application;
// RetrofitUrlManager.getInstance().putDomain("recommend", Api.RECOMMEND_BASE_URL);
// }
//
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// this.mGson = null;
// this.mApplication = null;
// }
//
// @Override
// public Observable<IndexData> getRecommendIndexData(int idx, boolean refresh, boolean clearCache) {
// return Observable.just(mRepositoryManager
// .obtainRetrofitService(RecommendService.class)
// .getRecommendIndexData(idx, refresh ? "true" : "false", clearCache ? 1 : 0))
// .flatMap(new Function<Observable<IndexData>, ObservableSource<IndexData>>() {
// @Override
// public ObservableSource<IndexData> apply(@NonNull Observable<IndexData> indexDataObservable) throws Exception {
// return mRepositoryManager
// .obtainCacheService(RecommendCache.class)
// .getRecommendIndexData(indexDataObservable, new DynamicKey(idx), new EvictProvider(clearCache))
// .map(indexDataReply -> indexDataReply.getData());
// }
// });
// }
//
//
// @Override
// public List<RecommendMultiItem> parseIndexData(IndexData indexData) {
// List<RecommendMultiItem> list = new ArrayList<>();
// List<IndexData.DataBean> data = indexData.getData();
// if (data != null) {
// for (int i = 0; i < data.size(); i++) {
// IndexData.DataBean dataBean = data.get(i);
// if (dataBean != null) {
// String gotoX = dataBean.getGotoX();
// if (RecommendMultiItem.isWeNeed(gotoX)) {
// RecommendMultiItem item = new RecommendMultiItem();
// item.setItemTypeWithGoto(gotoX, dataBean.getRcmd_reason() == null);
// item.setIndexDataBean(dataBean);
// if (RecommendMultiItem.isItemData(gotoX)) {
// item.setOdd(isOdd);
// isOdd = !isOdd;
// } else {
// isOdd = true;
// }
// list.add(item);
// }
// }
// }
// }
// return list;
// }
// }
// Path: app/src/main/java/com/lqr/biliblili/di/module/RecommendModule.java
import com.jess.arms.di.scope.FragmentScope;
import com.lqr.biliblili.mvp.contract.RecommendContract;
import com.lqr.biliblili.mvp.model.RecommendModel;
import dagger.Module;
import dagger.Provides;
package com.lqr.biliblili.di.module;
@Module
public class RecommendModule {
| private RecommendContract.View view; |
GitLqr/LQRBiliBlili | app/src/main/java/com/lqr/biliblili/di/module/RecommendModule.java | // Path: app/src/main/java/com/lqr/biliblili/mvp/contract/RecommendContract.java
// public interface RecommendContract {
//
// interface View extends IView {
//
// void setRecyclerAdapter(RecommendMultiItemAdapter adapter);
//
// void recyclerScrollToPosition(int position);
// }
//
// interface Model extends IModel {
// /**
// * @param idx 下拉刷新时取第一个数据的idx,上拉加载更多时取最后一个数据的idx
// * @param refresh 下拉刷新时取"true",上拉加载更多时取"false"
// * @param clearCache 第一次加载数据时为true,其他时候为false(对应的true时,login_event的值为1[获取banner],为false时,login_event的值为0)
// * @return
// */
// Observable<IndexData> getRecommendIndexData(int idx, boolean refresh, boolean clearCache);
//
// List<RecommendMultiItem> parseIndexData(IndexData indexData);
//
// }
// }
//
// Path: app/src/main/java/com/lqr/biliblili/mvp/model/RecommendModel.java
// @FragmentScope
// public class RecommendModel extends BaseModel implements RecommendContract.Model {
//
// private boolean isOdd = true;
// private Gson mGson;
// private Application mApplication;
//
// @Inject
// public RecommendModel(IRepositoryManager repositoryManager, Gson gson, Application application) {
// super(repositoryManager);
// mGson = gson;
// mApplication = application;
// RetrofitUrlManager.getInstance().putDomain("recommend", Api.RECOMMEND_BASE_URL);
// }
//
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// this.mGson = null;
// this.mApplication = null;
// }
//
// @Override
// public Observable<IndexData> getRecommendIndexData(int idx, boolean refresh, boolean clearCache) {
// return Observable.just(mRepositoryManager
// .obtainRetrofitService(RecommendService.class)
// .getRecommendIndexData(idx, refresh ? "true" : "false", clearCache ? 1 : 0))
// .flatMap(new Function<Observable<IndexData>, ObservableSource<IndexData>>() {
// @Override
// public ObservableSource<IndexData> apply(@NonNull Observable<IndexData> indexDataObservable) throws Exception {
// return mRepositoryManager
// .obtainCacheService(RecommendCache.class)
// .getRecommendIndexData(indexDataObservable, new DynamicKey(idx), new EvictProvider(clearCache))
// .map(indexDataReply -> indexDataReply.getData());
// }
// });
// }
//
//
// @Override
// public List<RecommendMultiItem> parseIndexData(IndexData indexData) {
// List<RecommendMultiItem> list = new ArrayList<>();
// List<IndexData.DataBean> data = indexData.getData();
// if (data != null) {
// for (int i = 0; i < data.size(); i++) {
// IndexData.DataBean dataBean = data.get(i);
// if (dataBean != null) {
// String gotoX = dataBean.getGotoX();
// if (RecommendMultiItem.isWeNeed(gotoX)) {
// RecommendMultiItem item = new RecommendMultiItem();
// item.setItemTypeWithGoto(gotoX, dataBean.getRcmd_reason() == null);
// item.setIndexDataBean(dataBean);
// if (RecommendMultiItem.isItemData(gotoX)) {
// item.setOdd(isOdd);
// isOdd = !isOdd;
// } else {
// isOdd = true;
// }
// list.add(item);
// }
// }
// }
// }
// return list;
// }
// }
| import com.jess.arms.di.scope.FragmentScope;
import com.lqr.biliblili.mvp.contract.RecommendContract;
import com.lqr.biliblili.mvp.model.RecommendModel;
import dagger.Module;
import dagger.Provides; | package com.lqr.biliblili.di.module;
@Module
public class RecommendModule {
private RecommendContract.View view;
public RecommendModule(RecommendContract.View view) {
this.view = view;
}
@FragmentScope
@Provides
public RecommendContract.View provideView() {
return view;
}
@FragmentScope
@Provides | // Path: app/src/main/java/com/lqr/biliblili/mvp/contract/RecommendContract.java
// public interface RecommendContract {
//
// interface View extends IView {
//
// void setRecyclerAdapter(RecommendMultiItemAdapter adapter);
//
// void recyclerScrollToPosition(int position);
// }
//
// interface Model extends IModel {
// /**
// * @param idx 下拉刷新时取第一个数据的idx,上拉加载更多时取最后一个数据的idx
// * @param refresh 下拉刷新时取"true",上拉加载更多时取"false"
// * @param clearCache 第一次加载数据时为true,其他时候为false(对应的true时,login_event的值为1[获取banner],为false时,login_event的值为0)
// * @return
// */
// Observable<IndexData> getRecommendIndexData(int idx, boolean refresh, boolean clearCache);
//
// List<RecommendMultiItem> parseIndexData(IndexData indexData);
//
// }
// }
//
// Path: app/src/main/java/com/lqr/biliblili/mvp/model/RecommendModel.java
// @FragmentScope
// public class RecommendModel extends BaseModel implements RecommendContract.Model {
//
// private boolean isOdd = true;
// private Gson mGson;
// private Application mApplication;
//
// @Inject
// public RecommendModel(IRepositoryManager repositoryManager, Gson gson, Application application) {
// super(repositoryManager);
// mGson = gson;
// mApplication = application;
// RetrofitUrlManager.getInstance().putDomain("recommend", Api.RECOMMEND_BASE_URL);
// }
//
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// this.mGson = null;
// this.mApplication = null;
// }
//
// @Override
// public Observable<IndexData> getRecommendIndexData(int idx, boolean refresh, boolean clearCache) {
// return Observable.just(mRepositoryManager
// .obtainRetrofitService(RecommendService.class)
// .getRecommendIndexData(idx, refresh ? "true" : "false", clearCache ? 1 : 0))
// .flatMap(new Function<Observable<IndexData>, ObservableSource<IndexData>>() {
// @Override
// public ObservableSource<IndexData> apply(@NonNull Observable<IndexData> indexDataObservable) throws Exception {
// return mRepositoryManager
// .obtainCacheService(RecommendCache.class)
// .getRecommendIndexData(indexDataObservable, new DynamicKey(idx), new EvictProvider(clearCache))
// .map(indexDataReply -> indexDataReply.getData());
// }
// });
// }
//
//
// @Override
// public List<RecommendMultiItem> parseIndexData(IndexData indexData) {
// List<RecommendMultiItem> list = new ArrayList<>();
// List<IndexData.DataBean> data = indexData.getData();
// if (data != null) {
// for (int i = 0; i < data.size(); i++) {
// IndexData.DataBean dataBean = data.get(i);
// if (dataBean != null) {
// String gotoX = dataBean.getGotoX();
// if (RecommendMultiItem.isWeNeed(gotoX)) {
// RecommendMultiItem item = new RecommendMultiItem();
// item.setItemTypeWithGoto(gotoX, dataBean.getRcmd_reason() == null);
// item.setIndexDataBean(dataBean);
// if (RecommendMultiItem.isItemData(gotoX)) {
// item.setOdd(isOdd);
// isOdd = !isOdd;
// } else {
// isOdd = true;
// }
// list.add(item);
// }
// }
// }
// }
// return list;
// }
// }
// Path: app/src/main/java/com/lqr/biliblili/di/module/RecommendModule.java
import com.jess.arms.di.scope.FragmentScope;
import com.lqr.biliblili.mvp.contract.RecommendContract;
import com.lqr.biliblili.mvp.model.RecommendModel;
import dagger.Module;
import dagger.Provides;
package com.lqr.biliblili.di.module;
@Module
public class RecommendModule {
private RecommendContract.View view;
public RecommendModule(RecommendContract.View view) {
this.view = view;
}
@FragmentScope
@Provides
public RecommendContract.View provideView() {
return view;
}
@FragmentScope
@Provides | public RecommendContract.Model provideModel(RecommendModel model) { |
GitLqr/LQRBiliBlili | app/src/main/java/com/lqr/biliblili/app/config/applyOptions/MyRetrofitConfiguration.java | // Path: app/src/main/java/com/lqr/biliblili/app/config/applyOptions/intercept/LoggingInterceptor.java
// public class LoggingInterceptor implements Interceptor {
// @Override
// public Response intercept(Chain chain) throws IOException {
// //这个chain里面包含了request和response,所以你要什么都可以从这里拿
// Request request = chain.request();
// long t1 = System.nanoTime();//请求发起的时间
//
// String method = request.method();
// if ("POST".equals(method)) {
// StringBuilder sb = new StringBuilder();
// if (request.body() instanceof FormBody) {
// FormBody body = (FormBody) request.body();
// for (int i = 0; i < body.size(); i++) {
// sb.append(body.encodedName(i) + "=" + body.encodedValue(i) + ",");
// }
// sb.delete(sb.length() - 1, sb.length());
// Log.d("CSDN_LQR", String.format("发送请求 %s on %s %n%s %nRequestParams:{%s}",
// request.url(), chain.connection(), request.headers(), sb.toString()));
// }
// } else {
// Log.d("CSDN_LQR", String.format("发送请求 %s on %s%n%s",
// request.url(), chain.connection(), request.headers()));
// }
// Response response = chain.proceed(request);
// long t2 = System.nanoTime();//收到响应的时间
// //这里不能直接使用response.body().string()的方式输出日志
// //因为response.body().string()之后,response中的流会被关闭,程序会报错,我们需要创建出一
// //个新的response给应用层处理
// ResponseBody responseBody = response.peekBody(1024 * 1024);
// Log.d("CSDN_LQR",
// String.format("接收响应: [%s] %n返回json:【%s】 %.1fms %n%s",
// response.request().url(),
// responseBody.string(),
// (t2 - t1) / 1e6d,
// response.headers()
// ));
// return response;
// }
// }
//
// Path: app/src/main/java/com/lqr/biliblili/app/config/applyOptions/intercept/UserAgentInterceptor.java
// public class UserAgentInterceptor implements Interceptor {
// @Override
// public Response intercept(Chain chain) throws IOException {
// Request originalRequest = chain.request();
// Request requestWithUserAgent = originalRequest.newBuilder()
// .removeHeader("User-Agent")
// .addHeader("User-Agent", Api.COMMON_UA_STR)
// .build();
// return chain.proceed(requestWithUserAgent);
// }
// }
| import android.content.Context;
import com.jess.arms.di.module.ClientModule;
import com.lqr.biliblili.BuildConfig;
import com.lqr.biliblili.app.config.applyOptions.intercept.LoggingInterceptor;
import com.lqr.biliblili.app.config.applyOptions.intercept.UserAgentInterceptor;
import me.jessyan.retrofiturlmanager.RetrofitUrlManager;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit; | package com.lqr.biliblili.app.config.applyOptions;
public class MyRetrofitConfiguration implements ClientModule.RetrofitConfiguration {
@Override
public void configRetrofit(Context context, Retrofit.Builder builder) {
// 配置多BaseUrl支持
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
if (BuildConfig.DEBUG) { | // Path: app/src/main/java/com/lqr/biliblili/app/config/applyOptions/intercept/LoggingInterceptor.java
// public class LoggingInterceptor implements Interceptor {
// @Override
// public Response intercept(Chain chain) throws IOException {
// //这个chain里面包含了request和response,所以你要什么都可以从这里拿
// Request request = chain.request();
// long t1 = System.nanoTime();//请求发起的时间
//
// String method = request.method();
// if ("POST".equals(method)) {
// StringBuilder sb = new StringBuilder();
// if (request.body() instanceof FormBody) {
// FormBody body = (FormBody) request.body();
// for (int i = 0; i < body.size(); i++) {
// sb.append(body.encodedName(i) + "=" + body.encodedValue(i) + ",");
// }
// sb.delete(sb.length() - 1, sb.length());
// Log.d("CSDN_LQR", String.format("发送请求 %s on %s %n%s %nRequestParams:{%s}",
// request.url(), chain.connection(), request.headers(), sb.toString()));
// }
// } else {
// Log.d("CSDN_LQR", String.format("发送请求 %s on %s%n%s",
// request.url(), chain.connection(), request.headers()));
// }
// Response response = chain.proceed(request);
// long t2 = System.nanoTime();//收到响应的时间
// //这里不能直接使用response.body().string()的方式输出日志
// //因为response.body().string()之后,response中的流会被关闭,程序会报错,我们需要创建出一
// //个新的response给应用层处理
// ResponseBody responseBody = response.peekBody(1024 * 1024);
// Log.d("CSDN_LQR",
// String.format("接收响应: [%s] %n返回json:【%s】 %.1fms %n%s",
// response.request().url(),
// responseBody.string(),
// (t2 - t1) / 1e6d,
// response.headers()
// ));
// return response;
// }
// }
//
// Path: app/src/main/java/com/lqr/biliblili/app/config/applyOptions/intercept/UserAgentInterceptor.java
// public class UserAgentInterceptor implements Interceptor {
// @Override
// public Response intercept(Chain chain) throws IOException {
// Request originalRequest = chain.request();
// Request requestWithUserAgent = originalRequest.newBuilder()
// .removeHeader("User-Agent")
// .addHeader("User-Agent", Api.COMMON_UA_STR)
// .build();
// return chain.proceed(requestWithUserAgent);
// }
// }
// Path: app/src/main/java/com/lqr/biliblili/app/config/applyOptions/MyRetrofitConfiguration.java
import android.content.Context;
import com.jess.arms.di.module.ClientModule;
import com.lqr.biliblili.BuildConfig;
import com.lqr.biliblili.app.config.applyOptions.intercept.LoggingInterceptor;
import com.lqr.biliblili.app.config.applyOptions.intercept.UserAgentInterceptor;
import me.jessyan.retrofiturlmanager.RetrofitUrlManager;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
package com.lqr.biliblili.app.config.applyOptions;
public class MyRetrofitConfiguration implements ClientModule.RetrofitConfiguration {
@Override
public void configRetrofit(Context context, Retrofit.Builder builder) {
// 配置多BaseUrl支持
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
if (BuildConfig.DEBUG) { | clientBuilder.addInterceptor(new LoggingInterceptor());//使用自定义的Log拦截器 |
GitLqr/LQRBiliBlili | app/src/main/java/com/lqr/biliblili/app/config/applyOptions/MyRetrofitConfiguration.java | // Path: app/src/main/java/com/lqr/biliblili/app/config/applyOptions/intercept/LoggingInterceptor.java
// public class LoggingInterceptor implements Interceptor {
// @Override
// public Response intercept(Chain chain) throws IOException {
// //这个chain里面包含了request和response,所以你要什么都可以从这里拿
// Request request = chain.request();
// long t1 = System.nanoTime();//请求发起的时间
//
// String method = request.method();
// if ("POST".equals(method)) {
// StringBuilder sb = new StringBuilder();
// if (request.body() instanceof FormBody) {
// FormBody body = (FormBody) request.body();
// for (int i = 0; i < body.size(); i++) {
// sb.append(body.encodedName(i) + "=" + body.encodedValue(i) + ",");
// }
// sb.delete(sb.length() - 1, sb.length());
// Log.d("CSDN_LQR", String.format("发送请求 %s on %s %n%s %nRequestParams:{%s}",
// request.url(), chain.connection(), request.headers(), sb.toString()));
// }
// } else {
// Log.d("CSDN_LQR", String.format("发送请求 %s on %s%n%s",
// request.url(), chain.connection(), request.headers()));
// }
// Response response = chain.proceed(request);
// long t2 = System.nanoTime();//收到响应的时间
// //这里不能直接使用response.body().string()的方式输出日志
// //因为response.body().string()之后,response中的流会被关闭,程序会报错,我们需要创建出一
// //个新的response给应用层处理
// ResponseBody responseBody = response.peekBody(1024 * 1024);
// Log.d("CSDN_LQR",
// String.format("接收响应: [%s] %n返回json:【%s】 %.1fms %n%s",
// response.request().url(),
// responseBody.string(),
// (t2 - t1) / 1e6d,
// response.headers()
// ));
// return response;
// }
// }
//
// Path: app/src/main/java/com/lqr/biliblili/app/config/applyOptions/intercept/UserAgentInterceptor.java
// public class UserAgentInterceptor implements Interceptor {
// @Override
// public Response intercept(Chain chain) throws IOException {
// Request originalRequest = chain.request();
// Request requestWithUserAgent = originalRequest.newBuilder()
// .removeHeader("User-Agent")
// .addHeader("User-Agent", Api.COMMON_UA_STR)
// .build();
// return chain.proceed(requestWithUserAgent);
// }
// }
| import android.content.Context;
import com.jess.arms.di.module.ClientModule;
import com.lqr.biliblili.BuildConfig;
import com.lqr.biliblili.app.config.applyOptions.intercept.LoggingInterceptor;
import com.lqr.biliblili.app.config.applyOptions.intercept.UserAgentInterceptor;
import me.jessyan.retrofiturlmanager.RetrofitUrlManager;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit; | package com.lqr.biliblili.app.config.applyOptions;
public class MyRetrofitConfiguration implements ClientModule.RetrofitConfiguration {
@Override
public void configRetrofit(Context context, Retrofit.Builder builder) {
// 配置多BaseUrl支持
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
if (BuildConfig.DEBUG) {
clientBuilder.addInterceptor(new LoggingInterceptor());//使用自定义的Log拦截器
} | // Path: app/src/main/java/com/lqr/biliblili/app/config/applyOptions/intercept/LoggingInterceptor.java
// public class LoggingInterceptor implements Interceptor {
// @Override
// public Response intercept(Chain chain) throws IOException {
// //这个chain里面包含了request和response,所以你要什么都可以从这里拿
// Request request = chain.request();
// long t1 = System.nanoTime();//请求发起的时间
//
// String method = request.method();
// if ("POST".equals(method)) {
// StringBuilder sb = new StringBuilder();
// if (request.body() instanceof FormBody) {
// FormBody body = (FormBody) request.body();
// for (int i = 0; i < body.size(); i++) {
// sb.append(body.encodedName(i) + "=" + body.encodedValue(i) + ",");
// }
// sb.delete(sb.length() - 1, sb.length());
// Log.d("CSDN_LQR", String.format("发送请求 %s on %s %n%s %nRequestParams:{%s}",
// request.url(), chain.connection(), request.headers(), sb.toString()));
// }
// } else {
// Log.d("CSDN_LQR", String.format("发送请求 %s on %s%n%s",
// request.url(), chain.connection(), request.headers()));
// }
// Response response = chain.proceed(request);
// long t2 = System.nanoTime();//收到响应的时间
// //这里不能直接使用response.body().string()的方式输出日志
// //因为response.body().string()之后,response中的流会被关闭,程序会报错,我们需要创建出一
// //个新的response给应用层处理
// ResponseBody responseBody = response.peekBody(1024 * 1024);
// Log.d("CSDN_LQR",
// String.format("接收响应: [%s] %n返回json:【%s】 %.1fms %n%s",
// response.request().url(),
// responseBody.string(),
// (t2 - t1) / 1e6d,
// response.headers()
// ));
// return response;
// }
// }
//
// Path: app/src/main/java/com/lqr/biliblili/app/config/applyOptions/intercept/UserAgentInterceptor.java
// public class UserAgentInterceptor implements Interceptor {
// @Override
// public Response intercept(Chain chain) throws IOException {
// Request originalRequest = chain.request();
// Request requestWithUserAgent = originalRequest.newBuilder()
// .removeHeader("User-Agent")
// .addHeader("User-Agent", Api.COMMON_UA_STR)
// .build();
// return chain.proceed(requestWithUserAgent);
// }
// }
// Path: app/src/main/java/com/lqr/biliblili/app/config/applyOptions/MyRetrofitConfiguration.java
import android.content.Context;
import com.jess.arms.di.module.ClientModule;
import com.lqr.biliblili.BuildConfig;
import com.lqr.biliblili.app.config.applyOptions.intercept.LoggingInterceptor;
import com.lqr.biliblili.app.config.applyOptions.intercept.UserAgentInterceptor;
import me.jessyan.retrofiturlmanager.RetrofitUrlManager;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
package com.lqr.biliblili.app.config.applyOptions;
public class MyRetrofitConfiguration implements ClientModule.RetrofitConfiguration {
@Override
public void configRetrofit(Context context, Retrofit.Builder builder) {
// 配置多BaseUrl支持
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
if (BuildConfig.DEBUG) {
clientBuilder.addInterceptor(new LoggingInterceptor());//使用自定义的Log拦截器
} | clientBuilder.addInterceptor(new UserAgentInterceptor());//使用自定义User-Agent |
GitLqr/LQRBiliBlili | app/src/main/java/com/lqr/biliblili/di/component/MainCategoryComponent.java | // Path: app/src/main/java/com/lqr/biliblili/di/module/MainCategoryModule.java
// @Module
// public class MainCategoryModule {
// private MainCategoryContract.View view;
//
// public MainCategoryModule(MainCategoryContract.View view) {
// this.view = view;
// }
//
// @FragmentScope
// @Provides
// MainCategoryContract.View provideMainCategoryView() {
// return this.view;
// }
//
// @FragmentScope
// @Provides
// MainCategoryContract.Model provideMainCategoryModel(MainCategoryModel model) {
// return model;
// }
// }
//
// Path: app/src/main/java/com/lqr/biliblili/mvp/ui/fragment/main/MainCategoryFragment.java
// public class MainCategoryFragment extends MySupportFragment<MainCategoryPresenter> implements MainCategoryContract.View {
//
// @BindView(R.id.toolbar)
// Toolbar mToolbar;
// @BindView(R.id.recyclerview)
// RecyclerView mRecyclerView;
//
// @OnClick(R.id.ll_toolbar)
// void openDrawer() {
// EventBus.getDefault().post(new MainTag(), "openDrawer");
// }
//
// public static MainCategoryFragment newInstance() {
// return new MainCategoryFragment();
// }
//
// @Override
// public void setupFragmentComponent(AppComponent appComponent) {
// DaggerMainCategoryComponent.builder()
// .appComponent(appComponent)
// .mainCategoryModule(new MainCategoryModule(this))
// .build()
// .inject(this);
// }
//
// @Override
// public View initView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// // 要让Fragment中的onCreateOptionsMenu()被回调,必须调用setHasOptionsMenu(true);
// setHasOptionsMenu(true);
// View view = inflater.inflate(R.layout.fragment_category_main, container, false);
// return view;
// }
//
// @Override
// public void initData(Bundle savedInstanceState) {
// }
//
// @Override
// public void setData(Object data) {
// }
//
// @Override
// public void onSupportVisible() {
// super.onSupportVisible();
// // 必须让Fragment中的Toolbar成为Activity的ActionBar,否则setHasOptionsMenu(true)就没有意义了。
// ((AppCompatActivity) _mActivity).setSupportActionBar(mToolbar);
// ((AppCompatActivity) _mActivity).getSupportActionBar().setDisplayShowTitleEnabled(false);
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// // 必须调用menu.clear();清空菜单栏,否则可能会出现Activity中的menu与Fragment中的menu重叠。
// menu.clear();
// inflater.inflate(R.menu.main_category_menu, menu);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// switch (item.getItemId()) {
// case R.id.main_download:
// break;
// case R.id.main_search:
// break;
// }
// return super.onOptionsItemSelected(item);
// }
//
// @Override
// public void showLoading() {
//
// }
//
// @Override
// public void hideLoading() {
//
// }
//
// @Override
// public void showMessage(String message) {
//
// }
//
// @Override
// public void launchActivity(Intent intent) {
//
// }
//
// @Override
// public void killMyself() {
//
// }
// }
| import com.jess.arms.di.component.AppComponent;
import com.jess.arms.di.scope.FragmentScope;
import com.lqr.biliblili.di.module.MainCategoryModule;
import com.lqr.biliblili.mvp.ui.fragment.main.MainCategoryFragment;
import dagger.Component; | package com.lqr.biliblili.di.component;
@FragmentScope
@Component(modules = MainCategoryModule.class, dependencies = AppComponent.class)
public interface MainCategoryComponent { | // Path: app/src/main/java/com/lqr/biliblili/di/module/MainCategoryModule.java
// @Module
// public class MainCategoryModule {
// private MainCategoryContract.View view;
//
// public MainCategoryModule(MainCategoryContract.View view) {
// this.view = view;
// }
//
// @FragmentScope
// @Provides
// MainCategoryContract.View provideMainCategoryView() {
// return this.view;
// }
//
// @FragmentScope
// @Provides
// MainCategoryContract.Model provideMainCategoryModel(MainCategoryModel model) {
// return model;
// }
// }
//
// Path: app/src/main/java/com/lqr/biliblili/mvp/ui/fragment/main/MainCategoryFragment.java
// public class MainCategoryFragment extends MySupportFragment<MainCategoryPresenter> implements MainCategoryContract.View {
//
// @BindView(R.id.toolbar)
// Toolbar mToolbar;
// @BindView(R.id.recyclerview)
// RecyclerView mRecyclerView;
//
// @OnClick(R.id.ll_toolbar)
// void openDrawer() {
// EventBus.getDefault().post(new MainTag(), "openDrawer");
// }
//
// public static MainCategoryFragment newInstance() {
// return new MainCategoryFragment();
// }
//
// @Override
// public void setupFragmentComponent(AppComponent appComponent) {
// DaggerMainCategoryComponent.builder()
// .appComponent(appComponent)
// .mainCategoryModule(new MainCategoryModule(this))
// .build()
// .inject(this);
// }
//
// @Override
// public View initView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// // 要让Fragment中的onCreateOptionsMenu()被回调,必须调用setHasOptionsMenu(true);
// setHasOptionsMenu(true);
// View view = inflater.inflate(R.layout.fragment_category_main, container, false);
// return view;
// }
//
// @Override
// public void initData(Bundle savedInstanceState) {
// }
//
// @Override
// public void setData(Object data) {
// }
//
// @Override
// public void onSupportVisible() {
// super.onSupportVisible();
// // 必须让Fragment中的Toolbar成为Activity的ActionBar,否则setHasOptionsMenu(true)就没有意义了。
// ((AppCompatActivity) _mActivity).setSupportActionBar(mToolbar);
// ((AppCompatActivity) _mActivity).getSupportActionBar().setDisplayShowTitleEnabled(false);
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// // 必须调用menu.clear();清空菜单栏,否则可能会出现Activity中的menu与Fragment中的menu重叠。
// menu.clear();
// inflater.inflate(R.menu.main_category_menu, menu);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// switch (item.getItemId()) {
// case R.id.main_download:
// break;
// case R.id.main_search:
// break;
// }
// return super.onOptionsItemSelected(item);
// }
//
// @Override
// public void showLoading() {
//
// }
//
// @Override
// public void hideLoading() {
//
// }
//
// @Override
// public void showMessage(String message) {
//
// }
//
// @Override
// public void launchActivity(Intent intent) {
//
// }
//
// @Override
// public void killMyself() {
//
// }
// }
// Path: app/src/main/java/com/lqr/biliblili/di/component/MainCategoryComponent.java
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.di.scope.FragmentScope;
import com.lqr.biliblili.di.module.MainCategoryModule;
import com.lqr.biliblili.mvp.ui.fragment.main.MainCategoryFragment;
import dagger.Component;
package com.lqr.biliblili.di.component;
@FragmentScope
@Component(modules = MainCategoryModule.class, dependencies = AppComponent.class)
public interface MainCategoryComponent { | void inject(MainCategoryFragment fragment); |
GitLqr/LQRBiliBlili | app/src/main/java/com/lqr/biliblili/app/config/applyOptions/intercept/UserAgentInterceptor.java | // Path: app/src/main/java/com/lqr/biliblili/app/data/api/Api.java
// public interface Api {
// String LIVE_BASE_URL = "http://api.live.bilibili.com/";
// String RECOMMEND_BASE_URL = "https://app.bilibili.com/";
// String VIDEO_DETAIL_SUMMARY_BASE_URL = "https://app.bilibili.com/";
// String VIDEO_DETAIL_REPLY_BASE_URL = "https://api.bilibili.com/";
//
// // 没有登录的情况下,使用这个User-Agent
// String COMMON_UA_STR = "Mozilla/5.0 BiliDroid/5.15.0 (bbcallen@gmail.com)";
// }
| import com.lqr.biliblili.app.data.api.Api;
import java.io.IOException;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response; | package com.lqr.biliblili.app.config.applyOptions.intercept;
/**
* 添加UA拦截器,B站请求API需要加上UA才能正常使用
*/
public class UserAgentInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request originalRequest = chain.request();
Request requestWithUserAgent = originalRequest.newBuilder()
.removeHeader("User-Agent") | // Path: app/src/main/java/com/lqr/biliblili/app/data/api/Api.java
// public interface Api {
// String LIVE_BASE_URL = "http://api.live.bilibili.com/";
// String RECOMMEND_BASE_URL = "https://app.bilibili.com/";
// String VIDEO_DETAIL_SUMMARY_BASE_URL = "https://app.bilibili.com/";
// String VIDEO_DETAIL_REPLY_BASE_URL = "https://api.bilibili.com/";
//
// // 没有登录的情况下,使用这个User-Agent
// String COMMON_UA_STR = "Mozilla/5.0 BiliDroid/5.15.0 (bbcallen@gmail.com)";
// }
// Path: app/src/main/java/com/lqr/biliblili/app/config/applyOptions/intercept/UserAgentInterceptor.java
import com.lqr.biliblili.app.data.api.Api;
import java.io.IOException;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
package com.lqr.biliblili.app.config.applyOptions.intercept;
/**
* 添加UA拦截器,B站请求API需要加上UA才能正常使用
*/
public class UserAgentInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request originalRequest = chain.request();
Request requestWithUserAgent = originalRequest.newBuilder()
.removeHeader("User-Agent") | .addHeader("User-Agent", Api.COMMON_UA_STR) |
devang29/FACE-RECOGNITION-BASED-ATTENDANCE-MANAGEMENT-SYSTEM | Pre_FRAMS/src/Pre_FRAMS/sample_report.java | // Path: Pre_FRAMS/src/business_logic/MySQL.java
// public class MySQL
// {
// public String HOST = "jdbc:mysql://localhost:3380/project";
// public String USERNAME = "root";
// public String PASSWORD = "devang2993";
// public MySQL()
// {
//
// }
// }
| import business_logic.MySQL;
import java.awt.Dimension;
import java.awt.Frame;
import static java.awt.Frame.getFrames;
import java.awt.Toolkit;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Map;
import javax.swing.JFrame;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.swing.JRViewer; | package Pre_FRAMS;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Ray24
*/
/**
*
* @author Hans Kristanto
*/
public class sample_report {
Connection conn = null;
public sample_report(){ | // Path: Pre_FRAMS/src/business_logic/MySQL.java
// public class MySQL
// {
// public String HOST = "jdbc:mysql://localhost:3380/project";
// public String USERNAME = "root";
// public String PASSWORD = "devang2993";
// public MySQL()
// {
//
// }
// }
// Path: Pre_FRAMS/src/Pre_FRAMS/sample_report.java
import business_logic.MySQL;
import java.awt.Dimension;
import java.awt.Frame;
import static java.awt.Frame.getFrames;
import java.awt.Toolkit;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Map;
import javax.swing.JFrame;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.swing.JRViewer;
package Pre_FRAMS;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Ray24
*/
/**
*
* @author Hans Kristanto
*/
public class sample_report {
Connection conn = null;
public sample_report(){ | MySQL sql=new MySQL(); |
devang29/FACE-RECOGNITION-BASED-ATTENDANCE-MANAGEMENT-SYSTEM | Pre_FRAMS/src/reports/Sample_Faculty.java | // Path: Pre_FRAMS/src/business_logic/MySQL.java
// public class MySQL
// {
// public String HOST = "jdbc:mysql://localhost:3380/project";
// public String USERNAME = "root";
// public String PASSWORD = "devang2993";
// public MySQL()
// {
//
// }
// }
| import business_logic.MySQL;
import com.sun.rowset.CachedRowSetImpl;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.HashMap;
import java.sql.*;
import javax.sql.rowset.CachedRowSet; | package reports;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Ray24
*/
/**
*
* @author Hans Kristanto
*/
public class Sample_Faculty {
Connection conn = null;
ResultSet rs=null,rs1=null,rs4=null;
Statement stmt=null,stmt1=null;
HashMap m=new HashMap();
public Sample_Faculty(){ | // Path: Pre_FRAMS/src/business_logic/MySQL.java
// public class MySQL
// {
// public String HOST = "jdbc:mysql://localhost:3380/project";
// public String USERNAME = "root";
// public String PASSWORD = "devang2993";
// public MySQL()
// {
//
// }
// }
// Path: Pre_FRAMS/src/reports/Sample_Faculty.java
import business_logic.MySQL;
import com.sun.rowset.CachedRowSetImpl;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.HashMap;
import java.sql.*;
import javax.sql.rowset.CachedRowSet;
package reports;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Ray24
*/
/**
*
* @author Hans Kristanto
*/
public class Sample_Faculty {
Connection conn = null;
ResultSet rs=null,rs1=null,rs4=null;
Statement stmt=null,stmt1=null;
HashMap m=new HashMap();
public Sample_Faculty(){ | MySQL sql=new MySQL(); |
devang29/FACE-RECOGNITION-BASED-ATTENDANCE-MANAGEMENT-SYSTEM | Pre_FRAMS/src/Pre_FRAMS/aggregate_att.java | // Path: Pre_FRAMS/src/business_logic/MySQL.java
// public class MySQL
// {
// public String HOST = "jdbc:mysql://localhost:3380/project";
// public String USERNAME = "root";
// public String PASSWORD = "devang2993";
// public MySQL()
// {
//
// }
// }
//
// Path: Pre_FRAMS/src/business_logic/department.java
// public class department {
// Connection con=null;
// Statement stmt=null;
// ResultSet rs=null;
// public department()
// {
// MySQL sql=new MySQL();
// try
// {
// Class.forName("com.mysql.jdbc.Driver");
// con=DriverManager.getConnection(sql.HOST,sql.USERNAME,sql.PASSWORD);
// stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
// rs=stmt.executeQuery("select * from department");
// }
// catch(ClassNotFoundException | SQLException cnfe)
// {
// System.out.println(cnfe.getMessage());
// }
// }
//
// public boolean insert(String deptid,String deptname)
// {
// boolean i=false;
// try
// {
//
// rs.moveToInsertRow();
// rs.updateString(1, deptid);
// rs.updateString(2, deptname);
//
// rs.insertRow();
// i=true;
// }
// catch (SQLException ex) {i=false;}
// return i;
// }
//
// public boolean delete(String deptid)
// {
// boolean i=false;
// try {
// if(!rs.isBeforeFirst())
// {rs.beforeFirst();}
// while(rs.next())
// {
// String id=rs.getString(1);
// if(id.equals(deptid))
// {
// rs.deleteRow();
// i=true;
// break;
// }
// }
// }
// catch (SQLException ex) {
// i=false;
// }
// return i;
// }
//
// public String[] getAllDept()
// {
// String data[]=null;
// int i=0;
// try {
// rs.last();
// data=new String[rs.getRow()];
// if(!rs.isBeforeFirst())
// {rs.beforeFirst();}
// while(rs.next())
// {
// data[i]=rs.getString(2);
// i=i+1;
// }
// }
// catch (SQLException ex) {
// data=null;
// }
// return data;
// }
//
// public String getDept(String deptid)
// {
// String data=null;
//
// try {
// if(!rs.isBeforeFirst())
// {rs.beforeFirst();}
// while(rs.next())
// {
// String id=rs.getString(1);
// if(id.equals(deptid))
// {
// data=rs.getString(2);
// break;
// }
// else{data=null;}
// }
// }
// catch (SQLException ex) {
// data=null;
// }
// return data;
// }
//
// public String getDeptID(String dept)
// {
// String data=null;
//
// try {
// if(!rs.isBeforeFirst())
// {rs.beforeFirst();}
// while(rs.next())
// {
// String id=rs.getString(2);
// if(id.equals(dept))
// {
// data=rs.getString(1);
// break;
// }
// else{data=null;}
// }
// }
// catch (SQLException ex) {
// data=null;
// }
// return data;
// }
//
// public boolean update(String deptid,String deptname)
// {
// boolean i=false;
// try {
// if(!rs.isBeforeFirst())
// {rs.beforeFirst();}
// while(rs.next())
// {
// String id=rs.getString(1);
// if(id.equals(deptid))
// {
// rs.updateString(2, deptname);
// rs.updateRow();
// i=true;
// break;
// }
// }
// }
// catch (SQLException ex) {
// i=false;
// }
// return i;
// }
//
// }
| import business_logic.MySQL;
import business_logic.department;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.HashMap;
import java.sql.*;
import javax.swing.JPanel;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.swing.JRViewer; | package Pre_FRAMS;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Ray24
*/
/**
*
* @author Hans Kristanto
*/
public class aggregate_att {
Connection conn = null;
ResultSet rs=null,rs1=null,rs4=null;
Statement stmt=null,stmt1=null;
HashMap m=new HashMap();
public aggregate_att(){ | // Path: Pre_FRAMS/src/business_logic/MySQL.java
// public class MySQL
// {
// public String HOST = "jdbc:mysql://localhost:3380/project";
// public String USERNAME = "root";
// public String PASSWORD = "devang2993";
// public MySQL()
// {
//
// }
// }
//
// Path: Pre_FRAMS/src/business_logic/department.java
// public class department {
// Connection con=null;
// Statement stmt=null;
// ResultSet rs=null;
// public department()
// {
// MySQL sql=new MySQL();
// try
// {
// Class.forName("com.mysql.jdbc.Driver");
// con=DriverManager.getConnection(sql.HOST,sql.USERNAME,sql.PASSWORD);
// stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
// rs=stmt.executeQuery("select * from department");
// }
// catch(ClassNotFoundException | SQLException cnfe)
// {
// System.out.println(cnfe.getMessage());
// }
// }
//
// public boolean insert(String deptid,String deptname)
// {
// boolean i=false;
// try
// {
//
// rs.moveToInsertRow();
// rs.updateString(1, deptid);
// rs.updateString(2, deptname);
//
// rs.insertRow();
// i=true;
// }
// catch (SQLException ex) {i=false;}
// return i;
// }
//
// public boolean delete(String deptid)
// {
// boolean i=false;
// try {
// if(!rs.isBeforeFirst())
// {rs.beforeFirst();}
// while(rs.next())
// {
// String id=rs.getString(1);
// if(id.equals(deptid))
// {
// rs.deleteRow();
// i=true;
// break;
// }
// }
// }
// catch (SQLException ex) {
// i=false;
// }
// return i;
// }
//
// public String[] getAllDept()
// {
// String data[]=null;
// int i=0;
// try {
// rs.last();
// data=new String[rs.getRow()];
// if(!rs.isBeforeFirst())
// {rs.beforeFirst();}
// while(rs.next())
// {
// data[i]=rs.getString(2);
// i=i+1;
// }
// }
// catch (SQLException ex) {
// data=null;
// }
// return data;
// }
//
// public String getDept(String deptid)
// {
// String data=null;
//
// try {
// if(!rs.isBeforeFirst())
// {rs.beforeFirst();}
// while(rs.next())
// {
// String id=rs.getString(1);
// if(id.equals(deptid))
// {
// data=rs.getString(2);
// break;
// }
// else{data=null;}
// }
// }
// catch (SQLException ex) {
// data=null;
// }
// return data;
// }
//
// public String getDeptID(String dept)
// {
// String data=null;
//
// try {
// if(!rs.isBeforeFirst())
// {rs.beforeFirst();}
// while(rs.next())
// {
// String id=rs.getString(2);
// if(id.equals(dept))
// {
// data=rs.getString(1);
// break;
// }
// else{data=null;}
// }
// }
// catch (SQLException ex) {
// data=null;
// }
// return data;
// }
//
// public boolean update(String deptid,String deptname)
// {
// boolean i=false;
// try {
// if(!rs.isBeforeFirst())
// {rs.beforeFirst();}
// while(rs.next())
// {
// String id=rs.getString(1);
// if(id.equals(deptid))
// {
// rs.updateString(2, deptname);
// rs.updateRow();
// i=true;
// break;
// }
// }
// }
// catch (SQLException ex) {
// i=false;
// }
// return i;
// }
//
// }
// Path: Pre_FRAMS/src/Pre_FRAMS/aggregate_att.java
import business_logic.MySQL;
import business_logic.department;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.HashMap;
import java.sql.*;
import javax.swing.JPanel;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.swing.JRViewer;
package Pre_FRAMS;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Ray24
*/
/**
*
* @author Hans Kristanto
*/
public class aggregate_att {
Connection conn = null;
ResultSet rs=null,rs1=null,rs4=null;
Statement stmt=null,stmt1=null;
HashMap m=new HashMap();
public aggregate_att(){ | MySQL sql=new MySQL(); |
devang29/FACE-RECOGNITION-BASED-ATTENDANCE-MANAGEMENT-SYSTEM | Server Client/src/Server_Client/Faculty_Home.java | // Path: Server Client/src/reports/DataBean.java
// public class DataBean {
// private String name;
// private String stu_id;
// private String percentage;
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setPercentage(String occupation) {
// this.percentage = occupation;
// }
//
// public String getPercentage() {
// return this.percentage;
// }
//
// public void setStu_id(String place) {
// this.stu_id = place;
// }
//
// public String getStu_id() {
// return this.stu_id;
// }
//
//
// }
//
// Path: Pre_FRAMS/src/reports/DataBeanMaker.java
// public class DataBeanMaker {
// public ArrayList<DataBean> getDataBeanList(ResultSet rs) {
// ArrayList<DataBean> dataBeanList = new ArrayList<DataBean>();
//
// // //dataBeanList.add(produce("Babji, Chetty", "Engineer", "Nuremberg", "Germany"));
// // dataBeanList.add(produce("Albert Einstein", "Engineer", "Ulm"));
// // dataBeanList.add(produce("Alfred Hitchcock", "Movie Director", "London"));
// // dataBeanList.add(produce("Wernher Von Braun", "Rocket Scientist", "Wyrzysk"));
// // dataBeanList.add(produce("Sigmund Freud", "Neurologist", "Pribor"));
// // dataBeanList.add(produce("Mahatma Gandhi", "Lawyer", "Gujarat"));
// // dataBeanList.add(produce("Sachin Tendulkar", "Cricket Player","Mumbai"));
// // dataBeanList.add(produce("Michael Schumacher", "F1 Racer", "Cologne"));
// try {
// while(rs.next())
// {
// //CustomBean cb=new CustomBean
// System.out.println(rs.getString(1)+","+rs.getString(2)+","+rs.getString(3));
// dataBeanList.add(produce(rs.getString(1),rs.getString(2),rs.getString(3)));
// //ds_list.add(cb);
//
// }
// } catch (SQLException ex) {
// // Logger.getLogger(Faculty_Home.class.getName()).log(Level.SEVERE, null, ex);
// }
//
// return dataBeanList;
// }
//
// private DataBean produce(String place,String name, String occupation) {
// DataBean dataBean = new DataBean();
//
// dataBean.setName(name);
// dataBean.setPercentage(occupation);
// dataBean.setStu_id(place);
// //dataBean.setCountry(country);
//
// return dataBean;
// }
// }
| import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.sql.rowset.CachedRowSet;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRResultSetDataSource;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.swing.JRViewer;
import reports.DataBean;
import reports.DataBeanMaker; | {
jv.removeAll();
panel_report.removeAll();
SwingUtilities.updateComponentTreeUI(jv);
SwingUtilities.updateComponentTreeUI(panel_report);
oos.writeObject("ReportGen");
oos.writeObject(facid);
oos.writeObject(facname);
oos.writeObject(cmb_dept.getSelectedItem());
oos.writeObject(cmb_sem.getSelectedItem());
oos.writeObject(cmb_div.getSelectedItem());
oos.writeObject(cmb_sub.getSelectedItem());
oos.writeObject(date_start.getDate().toString());
oos.writeObject(date_end.getDate().toString());
CachedRowSet rs=(CachedRowSet) ois.readObject();
//System.out.println("ResultSet goit....");
HashMap m=new HashMap();
m.put("dept_name",cmb_dept.getSelectedItem());
m.put("semester",cmb_sem.getSelectedItem());
m.put("division",cmb_div.getSelectedItem());
//m.put("SubDataSource",jrds);
//m.put("REPORT_DATA_SOURCE",jrds);
m.put("subject",cmb_sub.getSelectedItem());
m.put("faculty",facname);
m.put("s_date",df.format(date_start.getDate()));
m.put("e_date",df.format(date_end.getDate()));
InputStream inputStream = getClass().getResourceAsStream("/reports/test_jasper.jrxml");
| // Path: Server Client/src/reports/DataBean.java
// public class DataBean {
// private String name;
// private String stu_id;
// private String percentage;
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setPercentage(String occupation) {
// this.percentage = occupation;
// }
//
// public String getPercentage() {
// return this.percentage;
// }
//
// public void setStu_id(String place) {
// this.stu_id = place;
// }
//
// public String getStu_id() {
// return this.stu_id;
// }
//
//
// }
//
// Path: Pre_FRAMS/src/reports/DataBeanMaker.java
// public class DataBeanMaker {
// public ArrayList<DataBean> getDataBeanList(ResultSet rs) {
// ArrayList<DataBean> dataBeanList = new ArrayList<DataBean>();
//
// // //dataBeanList.add(produce("Babji, Chetty", "Engineer", "Nuremberg", "Germany"));
// // dataBeanList.add(produce("Albert Einstein", "Engineer", "Ulm"));
// // dataBeanList.add(produce("Alfred Hitchcock", "Movie Director", "London"));
// // dataBeanList.add(produce("Wernher Von Braun", "Rocket Scientist", "Wyrzysk"));
// // dataBeanList.add(produce("Sigmund Freud", "Neurologist", "Pribor"));
// // dataBeanList.add(produce("Mahatma Gandhi", "Lawyer", "Gujarat"));
// // dataBeanList.add(produce("Sachin Tendulkar", "Cricket Player","Mumbai"));
// // dataBeanList.add(produce("Michael Schumacher", "F1 Racer", "Cologne"));
// try {
// while(rs.next())
// {
// //CustomBean cb=new CustomBean
// System.out.println(rs.getString(1)+","+rs.getString(2)+","+rs.getString(3));
// dataBeanList.add(produce(rs.getString(1),rs.getString(2),rs.getString(3)));
// //ds_list.add(cb);
//
// }
// } catch (SQLException ex) {
// // Logger.getLogger(Faculty_Home.class.getName()).log(Level.SEVERE, null, ex);
// }
//
// return dataBeanList;
// }
//
// private DataBean produce(String place,String name, String occupation) {
// DataBean dataBean = new DataBean();
//
// dataBean.setName(name);
// dataBean.setPercentage(occupation);
// dataBean.setStu_id(place);
// //dataBean.setCountry(country);
//
// return dataBean;
// }
// }
// Path: Server Client/src/Server_Client/Faculty_Home.java
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.sql.rowset.CachedRowSet;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRResultSetDataSource;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.swing.JRViewer;
import reports.DataBean;
import reports.DataBeanMaker;
{
jv.removeAll();
panel_report.removeAll();
SwingUtilities.updateComponentTreeUI(jv);
SwingUtilities.updateComponentTreeUI(panel_report);
oos.writeObject("ReportGen");
oos.writeObject(facid);
oos.writeObject(facname);
oos.writeObject(cmb_dept.getSelectedItem());
oos.writeObject(cmb_sem.getSelectedItem());
oos.writeObject(cmb_div.getSelectedItem());
oos.writeObject(cmb_sub.getSelectedItem());
oos.writeObject(date_start.getDate().toString());
oos.writeObject(date_end.getDate().toString());
CachedRowSet rs=(CachedRowSet) ois.readObject();
//System.out.println("ResultSet goit....");
HashMap m=new HashMap();
m.put("dept_name",cmb_dept.getSelectedItem());
m.put("semester",cmb_sem.getSelectedItem());
m.put("division",cmb_div.getSelectedItem());
//m.put("SubDataSource",jrds);
//m.put("REPORT_DATA_SOURCE",jrds);
m.put("subject",cmb_sub.getSelectedItem());
m.put("faculty",facname);
m.put("s_date",df.format(date_start.getDate()));
m.put("e_date",df.format(date_end.getDate()));
InputStream inputStream = getClass().getResourceAsStream("/reports/test_jasper.jrxml");
| DataBeanMaker dataBeanMaker = new DataBeanMaker(); |
devang29/FACE-RECOGNITION-BASED-ATTENDANCE-MANAGEMENT-SYSTEM | Server Client/src/Server_Client/Faculty_Home.java | // Path: Server Client/src/reports/DataBean.java
// public class DataBean {
// private String name;
// private String stu_id;
// private String percentage;
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setPercentage(String occupation) {
// this.percentage = occupation;
// }
//
// public String getPercentage() {
// return this.percentage;
// }
//
// public void setStu_id(String place) {
// this.stu_id = place;
// }
//
// public String getStu_id() {
// return this.stu_id;
// }
//
//
// }
//
// Path: Pre_FRAMS/src/reports/DataBeanMaker.java
// public class DataBeanMaker {
// public ArrayList<DataBean> getDataBeanList(ResultSet rs) {
// ArrayList<DataBean> dataBeanList = new ArrayList<DataBean>();
//
// // //dataBeanList.add(produce("Babji, Chetty", "Engineer", "Nuremberg", "Germany"));
// // dataBeanList.add(produce("Albert Einstein", "Engineer", "Ulm"));
// // dataBeanList.add(produce("Alfred Hitchcock", "Movie Director", "London"));
// // dataBeanList.add(produce("Wernher Von Braun", "Rocket Scientist", "Wyrzysk"));
// // dataBeanList.add(produce("Sigmund Freud", "Neurologist", "Pribor"));
// // dataBeanList.add(produce("Mahatma Gandhi", "Lawyer", "Gujarat"));
// // dataBeanList.add(produce("Sachin Tendulkar", "Cricket Player","Mumbai"));
// // dataBeanList.add(produce("Michael Schumacher", "F1 Racer", "Cologne"));
// try {
// while(rs.next())
// {
// //CustomBean cb=new CustomBean
// System.out.println(rs.getString(1)+","+rs.getString(2)+","+rs.getString(3));
// dataBeanList.add(produce(rs.getString(1),rs.getString(2),rs.getString(3)));
// //ds_list.add(cb);
//
// }
// } catch (SQLException ex) {
// // Logger.getLogger(Faculty_Home.class.getName()).log(Level.SEVERE, null, ex);
// }
//
// return dataBeanList;
// }
//
// private DataBean produce(String place,String name, String occupation) {
// DataBean dataBean = new DataBean();
//
// dataBean.setName(name);
// dataBean.setPercentage(occupation);
// dataBean.setStu_id(place);
// //dataBean.setCountry(country);
//
// return dataBean;
// }
// }
| import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.sql.rowset.CachedRowSet;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRResultSetDataSource;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.swing.JRViewer;
import reports.DataBean;
import reports.DataBeanMaker; | jv.removeAll();
panel_report.removeAll();
SwingUtilities.updateComponentTreeUI(jv);
SwingUtilities.updateComponentTreeUI(panel_report);
oos.writeObject("ReportGen");
oos.writeObject(facid);
oos.writeObject(facname);
oos.writeObject(cmb_dept.getSelectedItem());
oos.writeObject(cmb_sem.getSelectedItem());
oos.writeObject(cmb_div.getSelectedItem());
oos.writeObject(cmb_sub.getSelectedItem());
oos.writeObject(date_start.getDate().toString());
oos.writeObject(date_end.getDate().toString());
CachedRowSet rs=(CachedRowSet) ois.readObject();
//System.out.println("ResultSet goit....");
HashMap m=new HashMap();
m.put("dept_name",cmb_dept.getSelectedItem());
m.put("semester",cmb_sem.getSelectedItem());
m.put("division",cmb_div.getSelectedItem());
//m.put("SubDataSource",jrds);
//m.put("REPORT_DATA_SOURCE",jrds);
m.put("subject",cmb_sub.getSelectedItem());
m.put("faculty",facname);
m.put("s_date",df.format(date_start.getDate()));
m.put("e_date",df.format(date_end.getDate()));
InputStream inputStream = getClass().getResourceAsStream("/reports/test_jasper.jrxml");
DataBeanMaker dataBeanMaker = new DataBeanMaker(); | // Path: Server Client/src/reports/DataBean.java
// public class DataBean {
// private String name;
// private String stu_id;
// private String percentage;
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setPercentage(String occupation) {
// this.percentage = occupation;
// }
//
// public String getPercentage() {
// return this.percentage;
// }
//
// public void setStu_id(String place) {
// this.stu_id = place;
// }
//
// public String getStu_id() {
// return this.stu_id;
// }
//
//
// }
//
// Path: Pre_FRAMS/src/reports/DataBeanMaker.java
// public class DataBeanMaker {
// public ArrayList<DataBean> getDataBeanList(ResultSet rs) {
// ArrayList<DataBean> dataBeanList = new ArrayList<DataBean>();
//
// // //dataBeanList.add(produce("Babji, Chetty", "Engineer", "Nuremberg", "Germany"));
// // dataBeanList.add(produce("Albert Einstein", "Engineer", "Ulm"));
// // dataBeanList.add(produce("Alfred Hitchcock", "Movie Director", "London"));
// // dataBeanList.add(produce("Wernher Von Braun", "Rocket Scientist", "Wyrzysk"));
// // dataBeanList.add(produce("Sigmund Freud", "Neurologist", "Pribor"));
// // dataBeanList.add(produce("Mahatma Gandhi", "Lawyer", "Gujarat"));
// // dataBeanList.add(produce("Sachin Tendulkar", "Cricket Player","Mumbai"));
// // dataBeanList.add(produce("Michael Schumacher", "F1 Racer", "Cologne"));
// try {
// while(rs.next())
// {
// //CustomBean cb=new CustomBean
// System.out.println(rs.getString(1)+","+rs.getString(2)+","+rs.getString(3));
// dataBeanList.add(produce(rs.getString(1),rs.getString(2),rs.getString(3)));
// //ds_list.add(cb);
//
// }
// } catch (SQLException ex) {
// // Logger.getLogger(Faculty_Home.class.getName()).log(Level.SEVERE, null, ex);
// }
//
// return dataBeanList;
// }
//
// private DataBean produce(String place,String name, String occupation) {
// DataBean dataBean = new DataBean();
//
// dataBean.setName(name);
// dataBean.setPercentage(occupation);
// dataBean.setStu_id(place);
// //dataBean.setCountry(country);
//
// return dataBean;
// }
// }
// Path: Server Client/src/Server_Client/Faculty_Home.java
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.sql.rowset.CachedRowSet;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRResultSetDataSource;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.swing.JRViewer;
import reports.DataBean;
import reports.DataBeanMaker;
jv.removeAll();
panel_report.removeAll();
SwingUtilities.updateComponentTreeUI(jv);
SwingUtilities.updateComponentTreeUI(panel_report);
oos.writeObject("ReportGen");
oos.writeObject(facid);
oos.writeObject(facname);
oos.writeObject(cmb_dept.getSelectedItem());
oos.writeObject(cmb_sem.getSelectedItem());
oos.writeObject(cmb_div.getSelectedItem());
oos.writeObject(cmb_sub.getSelectedItem());
oos.writeObject(date_start.getDate().toString());
oos.writeObject(date_end.getDate().toString());
CachedRowSet rs=(CachedRowSet) ois.readObject();
//System.out.println("ResultSet goit....");
HashMap m=new HashMap();
m.put("dept_name",cmb_dept.getSelectedItem());
m.put("semester",cmb_sem.getSelectedItem());
m.put("division",cmb_div.getSelectedItem());
//m.put("SubDataSource",jrds);
//m.put("REPORT_DATA_SOURCE",jrds);
m.put("subject",cmb_sub.getSelectedItem());
m.put("faculty",facname);
m.put("s_date",df.format(date_start.getDate()));
m.put("e_date",df.format(date_end.getDate()));
InputStream inputStream = getClass().getResourceAsStream("/reports/test_jasper.jrxml");
DataBeanMaker dataBeanMaker = new DataBeanMaker(); | ArrayList<DataBean> dataBeanList = dataBeanMaker.getDataBeanList(rs); |
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
| import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
| package jp.co.rakuten.rit.roma.client.commands;
public abstract class AbstractCommand implements Command, CommandID {
protected Command next;
protected AbstractCommand() {
this(null);
}
protected AbstractCommand(Command next) {
this.next = next;
}
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
package jp.co.rakuten.rit.roma.client.commands;
public abstract class AbstractCommand implements Command, CommandID {
protected Command next;
protected AbstractCommand() {
this(null);
}
protected AbstractCommand(Command next) {
this.next = next;
}
| public boolean execute(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/ExpiredSwapAndInsertCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class ExpiredSwapAndInsertCommand extends UpdateCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/ExpiredSwapAndInsertCommand.java
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class ExpiredSwapAndInsertCommand extends UpdateCommand {
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/ExpiredSwapAndInsertCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class ExpiredSwapAndInsertCommand extends UpdateCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/ExpiredSwapAndInsertCommand.java
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class ExpiredSwapAndInsertCommand extends UpdateCommand {
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/ClearCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class ClearCommand extends AbstractCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/ClearCommand.java
import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class ClearCommand extends AbstractCommand {
@Override
| public boolean execute(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/ClearCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class ClearCommand extends AbstractCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/ClearCommand.java
import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class ClearCommand extends AbstractCommand {
@Override
| public boolean execute(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/ClearCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class ClearCommand extends AbstractCommand {
@Override
public boolean execute(CommandContext context) throws ClientException {
try {
// alist_clear <key>\r\n
StringBuilder sb = new StringBuilder();
sb.append(ListCommandID.STR_ALIST_CLEAR)
.append(ListCommandID.STR_WHITE_SPACE)
.append(context.get(CommandContext.KEY))
.append(ListCommandID.STR_CRLF);
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/ClearCommand.java
import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class ClearCommand extends AbstractCommand {
@Override
public boolean execute(CommandContext context) throws ClientException {
try {
// alist_clear <key>\r\n
StringBuilder sb = new StringBuilder();
sb.append(ListCommandID.STR_ALIST_CLEAR)
.append(ListCommandID.STR_WHITE_SPACE)
.append(context.get(CommandContext.KEY))
.append(ListCommandID.STR_CRLF);
| Connection conn = (Connection) context.get(CommandContext.CONNECTION);
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/LengthCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class LengthCommand extends AbstractCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/LengthCommand.java
import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class LengthCommand extends AbstractCommand {
@Override
| public boolean execute(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/LengthCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class LengthCommand extends AbstractCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/LengthCommand.java
import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class LengthCommand extends AbstractCommand {
@Override
| public boolean execute(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/LengthCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class LengthCommand extends AbstractCommand {
@Override
public boolean execute(CommandContext context) throws ClientException {
try {
// alist_length <key>\r\n
StringBuilder sb = new StringBuilder();
sb.append(ListCommandID.STR_ALIST_LENGTH)
.append(ListCommandID.STR_WHITE_SPACE)
.append(context.get(CommandContext.KEY))
.append(ListCommandID.STR_CRLF);
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/LengthCommand.java
import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class LengthCommand extends AbstractCommand {
@Override
public boolean execute(CommandContext context) throws ClientException {
try {
// alist_length <key>\r\n
StringBuilder sb = new StringBuilder();
sb.append(ListCommandID.STR_ALIST_LENGTH)
.append(ListCommandID.STR_WHITE_SPACE)
.append(context.get(CommandContext.KEY))
.append(ListCommandID.STR_CRLF);
| Connection conn = (Connection) context.get(CommandContext.CONNECTION);
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/IncrAndDecrCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
| import java.io.IOException;
import java.math.BigInteger;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
| package jp.co.rakuten.rit.roma.client.commands;
public class IncrAndDecrCommand extends AbstractCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/IncrAndDecrCommand.java
import java.io.IOException;
import java.math.BigInteger;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
package jp.co.rakuten.rit.roma.client.commands;
public class IncrAndDecrCommand extends AbstractCommand {
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/IncrAndDecrCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
| import java.io.IOException;
import java.math.BigInteger;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
| package jp.co.rakuten.rit.roma.client.commands;
public class IncrAndDecrCommand extends AbstractCommand {
@Override
protected void create(CommandContext context) throws ClientException {
StringBuilder sb = (StringBuilder) context.get(CommandContext.STRING_DATA);
sb.append(getCommand())
.append(STR_WHITE_SPACE)
.append(context.get(CommandContext.KEY))
.append(STR_ESC)
.append(context.get(CommandContext.HASH_NAME))
.append(STR_WHITE_SPACE)
.append(context.get(CommandContext.VALUE))
.append(STR_CRLF);
context.put(CommandContext.STRING_DATA, sb);
}
protected String getCommand() throws ClientException {
throw new UnsupportedOperationException();
}
@Override
protected void sendAndReceive(CommandContext context) throws IOException,
ClientException {
StringBuilder sb = (StringBuilder) context.get(CommandContext.STRING_DATA);
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/IncrAndDecrCommand.java
import java.io.IOException;
import java.math.BigInteger;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
package jp.co.rakuten.rit.roma.client.commands;
public class IncrAndDecrCommand extends AbstractCommand {
@Override
protected void create(CommandContext context) throws ClientException {
StringBuilder sb = (StringBuilder) context.get(CommandContext.STRING_DATA);
sb.append(getCommand())
.append(STR_WHITE_SPACE)
.append(context.get(CommandContext.KEY))
.append(STR_ESC)
.append(context.get(CommandContext.HASH_NAME))
.append(STR_WHITE_SPACE)
.append(context.get(CommandContext.VALUE))
.append(STR_CRLF);
context.put(CommandContext.STRING_DATA, sb);
}
protected String getCommand() throws ClientException {
throw new UnsupportedOperationException();
}
@Override
protected void sendAndReceive(CommandContext context) throws IOException,
ClientException {
StringBuilder sb = (StringBuilder) context.get(CommandContext.STRING_DATA);
| Connection conn = (Connection) context.get(CommandContext.CONNECTION);
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/SwapAndPushCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class SwapAndPushCommand extends UpdateCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/SwapAndPushCommand.java
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class SwapAndPushCommand extends UpdateCommand {
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/SwapAndPushCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class SwapAndPushCommand extends UpdateCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/SwapAndPushCommand.java
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class SwapAndPushCommand extends UpdateCommand {
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/SwapAndSizedInsertCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class SwapAndSizedInsertCommand extends UpdateCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/SwapAndSizedInsertCommand.java
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class SwapAndSizedInsertCommand extends UpdateCommand {
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/SwapAndSizedInsertCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class SwapAndSizedInsertCommand extends UpdateCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/SwapAndSizedInsertCommand.java
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class SwapAndSizedInsertCommand extends UpdateCommand {
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/MapcountCountupCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
import net.arnx.jsonic.JSON;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class MapcountCountupCommand extends AbstractCommand {
@SuppressWarnings("unchecked")
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/MapcountCountupCommand.java
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
import net.arnx.jsonic.JSON;
package jp.co.rakuten.rit.roma.client.util.commands;
public class MapcountCountupCommand extends AbstractCommand {
@SuppressWarnings("unchecked")
@Override
| public boolean execute(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/MapcountCountupCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
import net.arnx.jsonic.JSON;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class MapcountCountupCommand extends AbstractCommand {
@SuppressWarnings("unchecked")
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/MapcountCountupCommand.java
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
import net.arnx.jsonic.JSON;
package jp.co.rakuten.rit.roma.client.util.commands;
public class MapcountCountupCommand extends AbstractCommand {
@SuppressWarnings("unchecked")
@Override
| public boolean execute(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/GetsWithTimeCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class GetsWithTimeCommand extends AbstractCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/GetsWithTimeCommand.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class GetsWithTimeCommand extends AbstractCommand {
@Override
| public boolean execute(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/GetsWithTimeCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class GetsWithTimeCommand extends AbstractCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/GetsWithTimeCommand.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class GetsWithTimeCommand extends AbstractCommand {
@Override
| public boolean execute(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/GetCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
| import java.io.IOException;
import java.util.StringTokenizer;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
| package jp.co.rakuten.rit.roma.client.commands;
public class GetCommand extends AbstractCommand implements CommandID {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/GetCommand.java
import java.io.IOException;
import java.util.StringTokenizer;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
package jp.co.rakuten.rit.roma.client.commands;
public class GetCommand extends AbstractCommand implements CommandID {
@Override
| public boolean execute(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/GetCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
| import java.io.IOException;
import java.util.StringTokenizer;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
| package jp.co.rakuten.rit.roma.client.commands;
public class GetCommand extends AbstractCommand implements CommandID {
@Override
public boolean execute(CommandContext context) throws ClientException {
try {
// "get key\r\n"
StringBuilder sb = new StringBuilder();
sb.append(STR_GET)
.append(STR_WHITE_SPACE)
.append(context.get(CommandContext.KEY))
.append(STR_ESC)
.append(context.get(CommandContext.HASH_NAME))
.append(STR_CRLF);
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/GetCommand.java
import java.io.IOException;
import java.util.StringTokenizer;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
package jp.co.rakuten.rit.roma.client.commands;
public class GetCommand extends AbstractCommand implements CommandID {
@Override
public boolean execute(CommandContext context) throws ClientException {
try {
// "get key\r\n"
StringBuilder sb = new StringBuilder();
sb.append(STR_GET)
.append(STR_WHITE_SPACE)
.append(context.get(CommandContext.KEY))
.append(STR_ESC)
.append(context.get(CommandContext.HASH_NAME))
.append(STR_CRLF);
| Connection conn = (Connection) context.get(CommandContext.CONNECTION);
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/SizedInsertCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class SizedInsertCommand extends UpdateCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/SizedInsertCommand.java
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class SizedInsertCommand extends UpdateCommand {
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/SizedInsertCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class SizedInsertCommand extends UpdateCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/SizedInsertCommand.java
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class SizedInsertCommand extends UpdateCommand {
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/InsertCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class InsertCommand extends UpdateCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/InsertCommand.java
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class InsertCommand extends UpdateCommand {
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/InsertCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class InsertCommand extends UpdateCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/InsertCommand.java
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class InsertCommand extends UpdateCommand {
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/test/java/jp/co/rakuten/rit/roma/client/commands/CommandFactoryImplTest.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
| import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import junit.framework.TestCase;
| package jp.co.rakuten.rit.roma.client.commands;
public class CommandFactoryImplTest extends TestCase {
public void testDummy() {
assertTrue(true);
}
public void XtestCreateCommand() throws Exception {
TimeoutFilter.timeout = 10;
CommandContext context = new CommandContext();
context.put(CommandContext.CONNECTION_POOL, new MockConnectionPool());
CommandFactoryImpl fact = new CommandFactoryImpl();
fact.createCommand(1, new FailOverFilter(new TimeoutFilter(
new TestCommand())));
Command command = fact.getCommand(1);
command.execute(context);
}
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
// Path: java/client/src/test/java/jp/co/rakuten/rit/roma/client/commands/CommandFactoryImplTest.java
import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import junit.framework.TestCase;
package jp.co.rakuten.rit.roma.client.commands;
public class CommandFactoryImplTest extends TestCase {
public void testDummy() {
assertTrue(true);
}
public void XtestCreateCommand() throws Exception {
TimeoutFilter.timeout = 10;
CommandContext context = new CommandContext();
context.put(CommandContext.CONNECTION_POOL, new MockConnectionPool());
CommandFactoryImpl fact = new CommandFactoryImpl();
fact.createCommand(1, new FailOverFilter(new TimeoutFilter(
new TestCommand())));
Command command = fact.getCommand(1);
command.execute(context);
}
| public static class TestCommand extends AbstractCommand {
|
roma/roma-java-client | java/client/src/test/java/jp/co/rakuten/rit/roma/client/commands/CommandFactoryImplTest.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
| import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import junit.framework.TestCase;
| package jp.co.rakuten.rit.roma.client.commands;
public class CommandFactoryImplTest extends TestCase {
public void testDummy() {
assertTrue(true);
}
public void XtestCreateCommand() throws Exception {
TimeoutFilter.timeout = 10;
CommandContext context = new CommandContext();
context.put(CommandContext.CONNECTION_POOL, new MockConnectionPool());
CommandFactoryImpl fact = new CommandFactoryImpl();
fact.createCommand(1, new FailOverFilter(new TimeoutFilter(
new TestCommand())));
Command command = fact.getCommand(1);
command.execute(context);
}
public static class TestCommand extends AbstractCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
// Path: java/client/src/test/java/jp/co/rakuten/rit/roma/client/commands/CommandFactoryImplTest.java
import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import junit.framework.TestCase;
package jp.co.rakuten.rit.roma.client.commands;
public class CommandFactoryImplTest extends TestCase {
public void testDummy() {
assertTrue(true);
}
public void XtestCreateCommand() throws Exception {
TimeoutFilter.timeout = 10;
CommandContext context = new CommandContext();
context.put(CommandContext.CONNECTION_POOL, new MockConnectionPool());
CommandFactoryImpl fact = new CommandFactoryImpl();
fact.createCommand(1, new FailOverFilter(new TimeoutFilter(
new TestCommand())));
Command command = fact.getCommand(1);
command.execute(context);
}
public static class TestCommand extends AbstractCommand {
@Override
| public boolean execute(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/ExpiredSwapAndSizedInsertCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class ExpiredSwapAndSizedInsertCommand extends UpdateCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/ExpiredSwapAndSizedInsertCommand.java
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class ExpiredSwapAndSizedInsertCommand extends UpdateCommand {
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/ExpiredSwapAndSizedInsertCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class ExpiredSwapAndSizedInsertCommand extends UpdateCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/ExpiredSwapAndSizedInsertCommand.java
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class ExpiredSwapAndSizedInsertCommand extends UpdateCommand {
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/JoinCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import java.util.StringTokenizer;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class JoinCommand extends AbstractCommand {
public static final String SEP = "_$$_";
public static final String NULL = "";
public static final String RANGE = "..";
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/JoinCommand.java
import java.io.IOException;
import java.util.StringTokenizer;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class JoinCommand extends AbstractCommand {
public static final String SEP = "_$$_";
public static final String NULL = "";
public static final String RANGE = "..";
@Override
| public boolean execute(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/JoinCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import java.util.StringTokenizer;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class JoinCommand extends AbstractCommand {
public static final String SEP = "_$$_";
public static final String NULL = "";
public static final String RANGE = "..";
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/JoinCommand.java
import java.io.IOException;
import java.util.StringTokenizer;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class JoinCommand extends AbstractCommand {
public static final String SEP = "_$$_";
public static final String NULL = "";
public static final String RANGE = "..";
@Override
| public boolean execute(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/JoinWithTimeCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import java.util.StringTokenizer;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class JoinWithTimeCommand extends AbstractCommand {
public static final String SEP = "_$$_";
public static final String NULL = "";
public static final String RANGE = "..";
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/JoinWithTimeCommand.java
import java.io.IOException;
import java.util.StringTokenizer;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class JoinWithTimeCommand extends AbstractCommand {
public static final String SEP = "_$$_";
public static final String NULL = "";
public static final String RANGE = "..";
@Override
| public boolean execute(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/JoinWithTimeCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import java.util.StringTokenizer;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class JoinWithTimeCommand extends AbstractCommand {
public static final String SEP = "_$$_";
public static final String NULL = "";
public static final String RANGE = "..";
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/JoinWithTimeCommand.java
import java.io.IOException;
import java.util.StringTokenizer;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class JoinWithTimeCommand extends AbstractCommand {
public static final String SEP = "_$$_";
public static final String NULL = "";
public static final String RANGE = "..";
@Override
| public boolean execute(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/ExpiredSwapAndSizedPushCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class ExpiredSwapAndSizedPushCommand extends UpdateCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/ExpiredSwapAndSizedPushCommand.java
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class ExpiredSwapAndSizedPushCommand extends UpdateCommand {
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/ExpiredSwapAndSizedPushCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class ExpiredSwapAndSizedPushCommand extends UpdateCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/ExpiredSwapAndSizedPushCommand.java
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class ExpiredSwapAndSizedPushCommand extends UpdateCommand {
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/DeleteCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
| import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
| package jp.co.rakuten.rit.roma.client.commands;
public class DeleteCommand extends AbstractCommand implements CommandID {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/DeleteCommand.java
import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
package jp.co.rakuten.rit.roma.client.commands;
public class DeleteCommand extends AbstractCommand implements CommandID {
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/DeleteCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
| import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
| package jp.co.rakuten.rit.roma.client.commands;
public class DeleteCommand extends AbstractCommand implements CommandID {
@Override
protected void create(CommandContext context) throws ClientException {
// delete <key> [<time>] [noreply]\r\n
StringBuilder sb = (StringBuilder) context.get(CommandContext.STRING_DATA);
sb.append(STR_DELETE)
.append(STR_WHITE_SPACE)
.append(context.get(CommandContext.KEY))
.append(STR_ESC)
.append(context.get(CommandContext.HASH_NAME))
.append(STR_CRLF);
context.put(CommandContext.STRING_DATA, sb);
}
@Override
protected void sendAndReceive(CommandContext context) throws IOException,
ClientException {
StringBuilder sb = (StringBuilder) context.get(CommandContext.STRING_DATA);
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/DeleteCommand.java
import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
package jp.co.rakuten.rit.roma.client.commands;
public class DeleteCommand extends AbstractCommand implements CommandID {
@Override
protected void create(CommandContext context) throws ClientException {
// delete <key> [<time>] [noreply]\r\n
StringBuilder sb = (StringBuilder) context.get(CommandContext.STRING_DATA);
sb.append(STR_DELETE)
.append(STR_WHITE_SPACE)
.append(context.get(CommandContext.KEY))
.append(STR_ESC)
.append(context.get(CommandContext.HASH_NAME))
.append(STR_CRLF);
context.put(CommandContext.STRING_DATA, sb);
}
@Override
protected void sendAndReceive(CommandContext context) throws IOException,
ClientException {
StringBuilder sb = (StringBuilder) context.get(CommandContext.STRING_DATA);
| Connection conn = (Connection) context.get(CommandContext.CONNECTION);
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/DecrCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
| import jp.co.rakuten.rit.roma.client.ClientException;
| package jp.co.rakuten.rit.roma.client.commands;
public class DecrCommand extends IncrAndDecrCommand implements CommandID {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/DecrCommand.java
import jp.co.rakuten.rit.roma.client.ClientException;
package jp.co.rakuten.rit.roma.client.commands;
public class DecrCommand extends IncrAndDecrCommand implements CommandID {
@Override
| public String getCommand() throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/ExpiredSwapAndPushCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class ExpiredSwapAndPushCommand extends UpdateCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/ExpiredSwapAndPushCommand.java
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class ExpiredSwapAndPushCommand extends UpdateCommand {
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/ExpiredSwapAndPushCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class ExpiredSwapAndPushCommand extends UpdateCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/ExpiredSwapAndPushCommand.java
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class ExpiredSwapAndPushCommand extends UpdateCommand {
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/test/java/jp/co/rakuten/rit/roma/client/RomaClientImplPerfTest.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/TimeoutFilter.java
// public class TimeoutFilter extends AbstractCommand {
// // The maximum time to wait (millis)
// public static long timeout = Long.parseLong(Config.DEFAULT_TIMEOUT_PERIOD);
// public static int numOfThreads = Integer
// .parseInt(Config.DEFAULT_NUM_OF_THREADS);
//
// public TimeoutFilter(Command next) {
// super(next);
// }
//
// // public static void shutdown() { }
//
// public TimeoutFilter() {
// }
//
// @Override
// public boolean execute(CommandContext context) throws ClientException {
// int commandID = (Integer) context.get(CommandContext.COMMAND_ID);
// Node node = null;
// ConnectionPool connPool = null;
// Connection conn = null;
// Throwable t = null;
// boolean ret = false;
// boolean usepool = commandID != CommandID.ROUTING_DUMP;
// try {
// node = (Node) context.get(CommandContext.NODE);
// if (usepool) { // general commands
// connPool = (ConnectionPool) context.get(CommandContext.CONNECTION_POOL);
// conn = connPool.get(node);
// conn.setTimeout((int) timeout);
// context.put(CommandContext.CONNECTION, conn);
// } else { // routingdump, routingmkh
// Socket sock = new Socket(node.getHost(), node.getPort());
// conn = new Connection(sock);
// conn.setTimeout((int) timeout);
// context.put(CommandContext.CONNECTION, conn);
// }
// ret = next.execute(context);
//
// if (conn != null) {
// if (usepool) { // general commands
// conn.setTimeout(0);
// connPool.put(node, conn);
// } else { // routingdump, routingmkh
// try {
// if (conn != null)
// conn.close();
// } catch (IOException e1) {
// }
// }
// }
// return ret;
// } catch (java.net.SocketTimeoutException e) {
// t = e;
// } catch (IOException e) {
// t = e;
// }
//
// if (usepool) { // general commands
// connPool.delete(node, conn);
// } else { // routingdump, routingmkh
// try {
// if (conn != null)
// conn.close();
// } catch (IOException e1) {
// }
// }
// throw new ClientException(new TimeoutException(t));
// }
//
// @Override
// protected void create(CommandContext context) throws ClientException {
// throw new UnsupportedOperationException();
// }
//
// @Override
// protected boolean parseResult(CommandContext context) throws ClientException {
// throw new UnsupportedOperationException();
// }
//
// @Override
// protected void sendAndReceive(CommandContext context) throws IOException,
// ClientException {
// throw new UnsupportedOperationException();
// }
// }
| import java.util.Properties;
import jp.co.rakuten.rit.roma.client.commands.TimeoutFilter;
import junit.framework.TestCase;
| package jp.co.rakuten.rit.roma.client;
public class RomaClientImplPerfTest extends TestCase {
private static String NODE_ID = AllTests.NODE_ID;
private static String KEY_PREFIX = RomaClientImplPerfTest.class.getName();
private static RomaClient CLIENT = null;
public static int BIG_LOOP_COUNT = 100;
public static int SMALL_LOOP_COUNT = 1000;
public static int SIZE_OF_DATA = 100;
public static int NUM_OF_THREADS = 5;
public static long PERIOD_OF_SLEEP = 1;
public static long PERIOD_OF_TIMEOUT = 300;
public RomaClientImplPerfTest() {
super();
}
@Override
public void setUp() throws Exception {
RomaClientFactory factory = RomaClientFactory.getInstance();
CLIENT = factory.newRomaClient(new Properties());
CLIENT.open(Node.create(NODE_ID));
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/TimeoutFilter.java
// public class TimeoutFilter extends AbstractCommand {
// // The maximum time to wait (millis)
// public static long timeout = Long.parseLong(Config.DEFAULT_TIMEOUT_PERIOD);
// public static int numOfThreads = Integer
// .parseInt(Config.DEFAULT_NUM_OF_THREADS);
//
// public TimeoutFilter(Command next) {
// super(next);
// }
//
// // public static void shutdown() { }
//
// public TimeoutFilter() {
// }
//
// @Override
// public boolean execute(CommandContext context) throws ClientException {
// int commandID = (Integer) context.get(CommandContext.COMMAND_ID);
// Node node = null;
// ConnectionPool connPool = null;
// Connection conn = null;
// Throwable t = null;
// boolean ret = false;
// boolean usepool = commandID != CommandID.ROUTING_DUMP;
// try {
// node = (Node) context.get(CommandContext.NODE);
// if (usepool) { // general commands
// connPool = (ConnectionPool) context.get(CommandContext.CONNECTION_POOL);
// conn = connPool.get(node);
// conn.setTimeout((int) timeout);
// context.put(CommandContext.CONNECTION, conn);
// } else { // routingdump, routingmkh
// Socket sock = new Socket(node.getHost(), node.getPort());
// conn = new Connection(sock);
// conn.setTimeout((int) timeout);
// context.put(CommandContext.CONNECTION, conn);
// }
// ret = next.execute(context);
//
// if (conn != null) {
// if (usepool) { // general commands
// conn.setTimeout(0);
// connPool.put(node, conn);
// } else { // routingdump, routingmkh
// try {
// if (conn != null)
// conn.close();
// } catch (IOException e1) {
// }
// }
// }
// return ret;
// } catch (java.net.SocketTimeoutException e) {
// t = e;
// } catch (IOException e) {
// t = e;
// }
//
// if (usepool) { // general commands
// connPool.delete(node, conn);
// } else { // routingdump, routingmkh
// try {
// if (conn != null)
// conn.close();
// } catch (IOException e1) {
// }
// }
// throw new ClientException(new TimeoutException(t));
// }
//
// @Override
// protected void create(CommandContext context) throws ClientException {
// throw new UnsupportedOperationException();
// }
//
// @Override
// protected boolean parseResult(CommandContext context) throws ClientException {
// throw new UnsupportedOperationException();
// }
//
// @Override
// protected void sendAndReceive(CommandContext context) throws IOException,
// ClientException {
// throw new UnsupportedOperationException();
// }
// }
// Path: java/client/src/test/java/jp/co/rakuten/rit/roma/client/RomaClientImplPerfTest.java
import java.util.Properties;
import jp.co.rakuten.rit.roma.client.commands.TimeoutFilter;
import junit.framework.TestCase;
package jp.co.rakuten.rit.roma.client;
public class RomaClientImplPerfTest extends TestCase {
private static String NODE_ID = AllTests.NODE_ID;
private static String KEY_PREFIX = RomaClientImplPerfTest.class.getName();
private static RomaClient CLIENT = null;
public static int BIG_LOOP_COUNT = 100;
public static int SMALL_LOOP_COUNT = 1000;
public static int SIZE_OF_DATA = 100;
public static int NUM_OF_THREADS = 5;
public static long PERIOD_OF_SLEEP = 1;
public static long PERIOD_OF_TIMEOUT = 300;
public RomaClientImplPerfTest() {
super();
}
@Override
public void setUp() throws Exception {
RomaClientFactory factory = RomaClientFactory.getInstance();
CLIENT = factory.newRomaClient(new Properties());
CLIENT.open(Node.create(NODE_ID));
| TimeoutFilter.timeout = 100 * 1000;
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/PrependCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
| import jp.co.rakuten.rit.roma.client.ClientException;
| package jp.co.rakuten.rit.roma.client.commands;
public class PrependCommand extends StoreCommand implements CommandID {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/PrependCommand.java
import jp.co.rakuten.rit.roma.client.ClientException;
package jp.co.rakuten.rit.roma.client.commands;
public class PrependCommand extends StoreCommand implements CommandID {
@Override
| public String getCommand() throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/RoutingdumpCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
| import java.io.IOException;
import net.arnx.jsonic.JSON;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
| package jp.co.rakuten.rit.roma.client.commands;
public class RoutingdumpCommand extends AbstractCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/RoutingdumpCommand.java
import java.io.IOException;
import net.arnx.jsonic.JSON;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
package jp.co.rakuten.rit.roma.client.commands;
public class RoutingdumpCommand extends AbstractCommand {
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/RoutingdumpCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
| import java.io.IOException;
import net.arnx.jsonic.JSON;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
| package jp.co.rakuten.rit.roma.client.commands;
public class RoutingdumpCommand extends AbstractCommand {
@Override
protected void create(CommandContext context) throws ClientException {
StringBuilder sb = (StringBuilder) context.get(CommandContext.STRING_DATA);
sb.append("routingdump json\r\n");
context.put(CommandContext.STRING_DATA, sb);
}
@Override
protected void sendAndReceive(CommandContext context) throws IOException,
ClientException {
StringBuilder sb = (StringBuilder) context.get(CommandContext.STRING_DATA);
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/RoutingdumpCommand.java
import java.io.IOException;
import net.arnx.jsonic.JSON;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
package jp.co.rakuten.rit.roma.client.commands;
public class RoutingdumpCommand extends AbstractCommand {
@Override
protected void create(CommandContext context) throws ClientException {
StringBuilder sb = (StringBuilder) context.get(CommandContext.STRING_DATA);
sb.append("routingdump json\r\n");
context.put(CommandContext.STRING_DATA, sb);
}
@Override
protected void sendAndReceive(CommandContext context) throws IOException,
ClientException {
StringBuilder sb = (StringBuilder) context.get(CommandContext.STRING_DATA);
| Connection conn = (Connection) context.get(CommandContext.CONNECTION);
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandFactoryImpl.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/CommandFactory.java
// public interface CommandFactory {
// public Command getCommand(int commandID);
//
// public void createCommand(int commandID, Command command);
// }
| import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.CommandFactory; | package jp.co.rakuten.rit.roma.client.commands;
public class CommandFactoryImpl implements CommandFactory {
// protected HashMap<Integer, Command> commands = new HashMap<Integer, Command>();
protected Map<Integer, Command> commands = new ConcurrentHashMap<Integer, Command>();
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/CommandFactory.java
// public interface CommandFactory {
// public Command getCommand(int commandID);
//
// public void createCommand(int commandID, Command command);
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandFactoryImpl.java
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.CommandFactory;
package jp.co.rakuten.rit.roma.client.commands;
public class CommandFactoryImpl implements CommandFactory {
// protected HashMap<Integer, Command> commands = new HashMap<Integer, Command>();
protected Map<Integer, Command> commands = new ConcurrentHashMap<Integer, Command>();
| public CommandFactoryImpl() throws ClientException { |
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/DeleteCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class DeleteCommand extends AbstractCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/DeleteCommand.java
import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class DeleteCommand extends AbstractCommand {
@Override
| public boolean execute(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/DeleteCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class DeleteCommand extends AbstractCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/DeleteCommand.java
import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class DeleteCommand extends AbstractCommand {
@Override
| public boolean execute(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/DeleteCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class DeleteCommand extends AbstractCommand {
@Override
public boolean execute(CommandContext context) throws ClientException {
try {
// alist_delete <key> <bytes>\r\n
// <element>\r\n
StringBuilder sb = new StringBuilder();
sb.append(ListCommandID.STR_ALIST_DELETE)
.append(ListCommandID.STR_WHITE_SPACE)
.append(context.get(CommandContext.KEY))
.append(ListCommandID.STR_WHITE_SPACE)
.append(((byte[]) context.get(CommandContext.VALUE)).length)
.append(ListCommandID.STR_CRLF);
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/DeleteCommand.java
import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class DeleteCommand extends AbstractCommand {
@Override
public boolean execute(CommandContext context) throws ClientException {
try {
// alist_delete <key> <bytes>\r\n
// <element>\r\n
StringBuilder sb = new StringBuilder();
sb.append(ListCommandID.STR_ALIST_DELETE)
.append(ListCommandID.STR_WHITE_SPACE)
.append(context.get(CommandContext.KEY))
.append(ListCommandID.STR_WHITE_SPACE)
.append(((byte[]) context.get(CommandContext.VALUE)).length)
.append(ListCommandID.STR_CRLF);
| Connection conn = (Connection) context.get(CommandContext.CONNECTION);
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/MapcountGetCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import net.arnx.jsonic.JSON;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class MapcountGetCommand extends AbstractCommand {
@SuppressWarnings("unchecked")
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/MapcountGetCommand.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import net.arnx.jsonic.JSON;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class MapcountGetCommand extends AbstractCommand {
@SuppressWarnings("unchecked")
@Override
| public boolean execute(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/MapcountGetCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import net.arnx.jsonic.JSON;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class MapcountGetCommand extends AbstractCommand {
@SuppressWarnings("unchecked")
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/MapcountGetCommand.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import net.arnx.jsonic.JSON;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class MapcountGetCommand extends AbstractCommand {
@SuppressWarnings("unchecked")
@Override
| public boolean execute(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AppendCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
| import jp.co.rakuten.rit.roma.client.ClientException;
| package jp.co.rakuten.rit.roma.client.commands;
public class AppendCommand extends StoreCommand implements CommandID {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AppendCommand.java
import jp.co.rakuten.rit.roma.client.ClientException;
package jp.co.rakuten.rit.roma.client.commands;
public class AppendCommand extends StoreCommand implements CommandID {
@Override
| public String getCommand() throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/SetCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
| import jp.co.rakuten.rit.roma.client.ClientException;
| package jp.co.rakuten.rit.roma.client.commands;
public class SetCommand extends StoreCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/SetCommand.java
import jp.co.rakuten.rit.roma.client.ClientException;
package jp.co.rakuten.rit.roma.client.commands;
public class SetCommand extends StoreCommand {
@Override
| public String getCommand() throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/UpdateCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class UpdateCommand extends AbstractCommand {
public static final String INDEX = "index";
public static final String ARRAY_SIZE = "array-size";
public static final String SEP = "_$$_";
public static final String EXPIRY = "expiry";
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/UpdateCommand.java
import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class UpdateCommand extends AbstractCommand {
public static final String INDEX = "index";
public static final String ARRAY_SIZE = "array-size";
public static final String SEP = "_$$_";
public static final String EXPIRY = "expiry";
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/UpdateCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class UpdateCommand extends AbstractCommand {
public static final String INDEX = "index";
public static final String ARRAY_SIZE = "array-size";
public static final String SEP = "_$$_";
public static final String EXPIRY = "expiry";
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/UpdateCommand.java
import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class UpdateCommand extends AbstractCommand {
public static final String INDEX = "index";
public static final String ARRAY_SIZE = "array-size";
public static final String SEP = "_$$_";
public static final String EXPIRY = "expiry";
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/UpdateCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class UpdateCommand extends AbstractCommand {
public static final String INDEX = "index";
public static final String ARRAY_SIZE = "array-size";
public static final String SEP = "_$$_";
public static final String EXPIRY = "expiry";
@Override
protected void create(CommandContext context) throws ClientException {
throw new UnsupportedOperationException();
}
@Override
protected void sendAndReceive(CommandContext context) throws IOException,
ClientException {
StringBuilder sb = (StringBuilder) context.get(CommandContext.STRING_DATA);
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/UpdateCommand.java
import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class UpdateCommand extends AbstractCommand {
public static final String INDEX = "index";
public static final String ARRAY_SIZE = "array-size";
public static final String SEP = "_$$_";
public static final String EXPIRY = "expiry";
@Override
protected void create(CommandContext context) throws ClientException {
throw new UnsupportedOperationException();
}
@Override
protected void sendAndReceive(CommandContext context) throws IOException,
ClientException {
StringBuilder sb = (StringBuilder) context.get(CommandContext.STRING_DATA);
| Connection conn = (Connection) context.get(CommandContext.CONNECTION);
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/DeleteAtCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class DeleteAtCommand extends AbstractCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/DeleteAtCommand.java
import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class DeleteAtCommand extends AbstractCommand {
@Override
| public boolean execute(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/DeleteAtCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class DeleteAtCommand extends AbstractCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/DeleteAtCommand.java
import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class DeleteAtCommand extends AbstractCommand {
@Override
| public boolean execute(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/DeleteAtCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class DeleteAtCommand extends AbstractCommand {
@Override
public boolean execute(CommandContext context) throws ClientException {
try {
// alist_delete_at <key> <index>\r\n
StringBuilder sb = new StringBuilder();
sb.append(ListCommandID.STR_ALIST_DELETE_AT)
.append(ListCommandID.STR_WHITE_SPACE)
.append(context.get(CommandContext.KEY))
.append(ListCommandID.STR_WHITE_SPACE)
.append(new String((byte[]) context.get(CommandContext.VALUE)))
.append(ListCommandID.STR_CRLF);
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/DeleteAtCommand.java
import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class DeleteAtCommand extends AbstractCommand {
@Override
public boolean execute(CommandContext context) throws ClientException {
try {
// alist_delete_at <key> <index>\r\n
StringBuilder sb = new StringBuilder();
sb.append(ListCommandID.STR_ALIST_DELETE_AT)
.append(ListCommandID.STR_WHITE_SPACE)
.append(context.get(CommandContext.KEY))
.append(ListCommandID.STR_WHITE_SPACE)
.append(new String((byte[]) context.get(CommandContext.VALUE)))
.append(ListCommandID.STR_CRLF);
| Connection conn = (Connection) context.get(CommandContext.CONNECTION);
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/StoreCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
| import java.io.IOException;
import java.util.Date;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
| package jp.co.rakuten.rit.roma.client.commands;
public class StoreCommand extends AbstractCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/StoreCommand.java
import java.io.IOException;
import java.util.Date;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
package jp.co.rakuten.rit.roma.client.commands;
public class StoreCommand extends AbstractCommand {
@Override
| public void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/StoreCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
| import java.io.IOException;
import java.util.Date;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
| Object obj = context.get(CommandContext.EXPIRY);
String expiry;
if (obj instanceof Date) {
// the type of object is deprecated
expiry = "" + ((long) (((Date) obj).getTime() / 1000));
} else {
expiry = (String) obj;
}
sb.append(getCommand())
.append(STR_WHITE_SPACE)
.append(context.get(CommandContext.KEY))
.append(STR_ESC)
.append(context.get(CommandContext.HASH_NAME))
.append(STR_WHITE_SPACE)
.append(context.get(CommandContext.HASH))
.append(STR_WHITE_SPACE)
.append(expiry)
.append(STR_WHITE_SPACE)
.append(((byte[]) context.get(CommandContext.VALUE)).length)
.append(STR_CRLF);
context.put(CommandContext.STRING_DATA, sb);
}
protected String getCommand() throws ClientException {
throw new UnsupportedOperationException();
}
@Override
public void sendAndReceive(CommandContext context) throws IOException {
StringBuilder sb = (StringBuilder) context.get(CommandContext.STRING_DATA);
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/StoreCommand.java
import java.io.IOException;
import java.util.Date;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
Object obj = context.get(CommandContext.EXPIRY);
String expiry;
if (obj instanceof Date) {
// the type of object is deprecated
expiry = "" + ((long) (((Date) obj).getTime() / 1000));
} else {
expiry = (String) obj;
}
sb.append(getCommand())
.append(STR_WHITE_SPACE)
.append(context.get(CommandContext.KEY))
.append(STR_ESC)
.append(context.get(CommandContext.HASH_NAME))
.append(STR_WHITE_SPACE)
.append(context.get(CommandContext.HASH))
.append(STR_WHITE_SPACE)
.append(expiry)
.append(STR_WHITE_SPACE)
.append(((byte[]) context.get(CommandContext.VALUE)).length)
.append(STR_CRLF);
context.put(CommandContext.STRING_DATA, sb);
}
protected String getCommand() throws ClientException {
throw new UnsupportedOperationException();
}
@Override
public void sendAndReceive(CommandContext context) throws IOException {
StringBuilder sb = (StringBuilder) context.get(CommandContext.STRING_DATA);
| Connection conn = (Connection) context.get(CommandContext.CONNECTION);
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/SizedPushCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class SizedPushCommand extends UpdateCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/SizedPushCommand.java
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class SizedPushCommand extends UpdateCommand {
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/SizedPushCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class SizedPushCommand extends UpdateCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/SizedPushCommand.java
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class SizedPushCommand extends UpdateCommand {
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/RoutingmhtCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
| import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
| package jp.co.rakuten.rit.roma.client.commands;
public class RoutingmhtCommand extends AbstractCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/RoutingmhtCommand.java
import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
package jp.co.rakuten.rit.roma.client.commands;
public class RoutingmhtCommand extends AbstractCommand {
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/RoutingmhtCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
| import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
| package jp.co.rakuten.rit.roma.client.commands;
public class RoutingmhtCommand extends AbstractCommand {
@Override
protected void create(CommandContext context) throws ClientException {
StringBuilder sb = (StringBuilder) context.get(CommandContext.STRING_DATA);
sb.append("mklhash 0\r\n");
context.put(CommandContext.STRING_DATA, sb);
}
@Override
protected void sendAndReceive(CommandContext context) throws IOException,
ClientException {
StringBuilder sb = (StringBuilder) context.get(CommandContext.STRING_DATA);
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/RoutingmhtCommand.java
import java.io.IOException;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
package jp.co.rakuten.rit.roma.client.commands;
public class RoutingmhtCommand extends AbstractCommand {
@Override
protected void create(CommandContext context) throws ClientException {
StringBuilder sb = (StringBuilder) context.get(CommandContext.STRING_DATA);
sb.append("mklhash 0\r\n");
context.put(CommandContext.STRING_DATA, sb);
}
@Override
protected void sendAndReceive(CommandContext context) throws IOException,
ClientException {
StringBuilder sb = (StringBuilder) context.get(CommandContext.STRING_DATA);
| Connection conn = (Connection) context.get(CommandContext.CONNECTION);
|
roma/roma-java-client | java/client/src/test/java/jp/co/rakuten/rit/roma/client/RomaClientImplTest.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/TimeoutFilter.java
// public class TimeoutFilter extends AbstractCommand {
// // The maximum time to wait (millis)
// public static long timeout = Long.parseLong(Config.DEFAULT_TIMEOUT_PERIOD);
// public static int numOfThreads = Integer
// .parseInt(Config.DEFAULT_NUM_OF_THREADS);
//
// public TimeoutFilter(Command next) {
// super(next);
// }
//
// // public static void shutdown() { }
//
// public TimeoutFilter() {
// }
//
// @Override
// public boolean execute(CommandContext context) throws ClientException {
// int commandID = (Integer) context.get(CommandContext.COMMAND_ID);
// Node node = null;
// ConnectionPool connPool = null;
// Connection conn = null;
// Throwable t = null;
// boolean ret = false;
// boolean usepool = commandID != CommandID.ROUTING_DUMP;
// try {
// node = (Node) context.get(CommandContext.NODE);
// if (usepool) { // general commands
// connPool = (ConnectionPool) context.get(CommandContext.CONNECTION_POOL);
// conn = connPool.get(node);
// conn.setTimeout((int) timeout);
// context.put(CommandContext.CONNECTION, conn);
// } else { // routingdump, routingmkh
// Socket sock = new Socket(node.getHost(), node.getPort());
// conn = new Connection(sock);
// conn.setTimeout((int) timeout);
// context.put(CommandContext.CONNECTION, conn);
// }
// ret = next.execute(context);
//
// if (conn != null) {
// if (usepool) { // general commands
// conn.setTimeout(0);
// connPool.put(node, conn);
// } else { // routingdump, routingmkh
// try {
// if (conn != null)
// conn.close();
// } catch (IOException e1) {
// }
// }
// }
// return ret;
// } catch (java.net.SocketTimeoutException e) {
// t = e;
// } catch (IOException e) {
// t = e;
// }
//
// if (usepool) { // general commands
// connPool.delete(node, conn);
// } else { // routingdump, routingmkh
// try {
// if (conn != null)
// conn.close();
// } catch (IOException e1) {
// }
// }
// throw new ClientException(new TimeoutException(t));
// }
//
// @Override
// protected void create(CommandContext context) throws ClientException {
// throw new UnsupportedOperationException();
// }
//
// @Override
// protected boolean parseResult(CommandContext context) throws ClientException {
// throw new UnsupportedOperationException();
// }
//
// @Override
// protected void sendAndReceive(CommandContext context) throws IOException,
// ClientException {
// throw new UnsupportedOperationException();
// }
// }
| import java.net.Socket;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import jp.co.rakuten.rit.roma.client.commands.TimeoutFilter;
import junit.framework.TestCase; | package jp.co.rakuten.rit.roma.client;
public class RomaClientImplTest extends TestCase {
private static String NODE_ID = AllTests.NODE_ID;
private static String KEY_PREFIX = RomaClientImplTest.class.getName();
private static RomaClient CLIENT = null;
private static String KEY = null;
public RomaClientImplTest() {
super();
}
@Override
public void setUp() throws Exception {
RomaClientFactory factory = RomaClientFactory.getInstance();
CLIENT = factory.newRomaClient(new Properties());
CLIENT.open(Node.create(NODE_ID)); | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/TimeoutFilter.java
// public class TimeoutFilter extends AbstractCommand {
// // The maximum time to wait (millis)
// public static long timeout = Long.parseLong(Config.DEFAULT_TIMEOUT_PERIOD);
// public static int numOfThreads = Integer
// .parseInt(Config.DEFAULT_NUM_OF_THREADS);
//
// public TimeoutFilter(Command next) {
// super(next);
// }
//
// // public static void shutdown() { }
//
// public TimeoutFilter() {
// }
//
// @Override
// public boolean execute(CommandContext context) throws ClientException {
// int commandID = (Integer) context.get(CommandContext.COMMAND_ID);
// Node node = null;
// ConnectionPool connPool = null;
// Connection conn = null;
// Throwable t = null;
// boolean ret = false;
// boolean usepool = commandID != CommandID.ROUTING_DUMP;
// try {
// node = (Node) context.get(CommandContext.NODE);
// if (usepool) { // general commands
// connPool = (ConnectionPool) context.get(CommandContext.CONNECTION_POOL);
// conn = connPool.get(node);
// conn.setTimeout((int) timeout);
// context.put(CommandContext.CONNECTION, conn);
// } else { // routingdump, routingmkh
// Socket sock = new Socket(node.getHost(), node.getPort());
// conn = new Connection(sock);
// conn.setTimeout((int) timeout);
// context.put(CommandContext.CONNECTION, conn);
// }
// ret = next.execute(context);
//
// if (conn != null) {
// if (usepool) { // general commands
// conn.setTimeout(0);
// connPool.put(node, conn);
// } else { // routingdump, routingmkh
// try {
// if (conn != null)
// conn.close();
// } catch (IOException e1) {
// }
// }
// }
// return ret;
// } catch (java.net.SocketTimeoutException e) {
// t = e;
// } catch (IOException e) {
// t = e;
// }
//
// if (usepool) { // general commands
// connPool.delete(node, conn);
// } else { // routingdump, routingmkh
// try {
// if (conn != null)
// conn.close();
// } catch (IOException e1) {
// }
// }
// throw new ClientException(new TimeoutException(t));
// }
//
// @Override
// protected void create(CommandContext context) throws ClientException {
// throw new UnsupportedOperationException();
// }
//
// @Override
// protected boolean parseResult(CommandContext context) throws ClientException {
// throw new UnsupportedOperationException();
// }
//
// @Override
// protected void sendAndReceive(CommandContext context) throws IOException,
// ClientException {
// throw new UnsupportedOperationException();
// }
// }
// Path: java/client/src/test/java/jp/co/rakuten/rit/roma/client/RomaClientImplTest.java
import java.net.Socket;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import jp.co.rakuten.rit.roma.client.commands.TimeoutFilter;
import junit.framework.TestCase;
package jp.co.rakuten.rit.roma.client;
public class RomaClientImplTest extends TestCase {
private static String NODE_ID = AllTests.NODE_ID;
private static String KEY_PREFIX = RomaClientImplTest.class.getName();
private static RomaClient CLIENT = null;
private static String KEY = null;
public RomaClientImplTest() {
super();
}
@Override
public void setUp() throws Exception {
RomaClientFactory factory = RomaClientFactory.getInstance();
CLIENT = factory.newRomaClient(new Properties());
CLIENT.open(Node.create(NODE_ID)); | TimeoutFilter.timeout = 100 * 1000; |
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/SwapAndInsertCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class SwapAndInsertCommand extends UpdateCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/SwapAndInsertCommand.java
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class SwapAndInsertCommand extends UpdateCommand {
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/SwapAndInsertCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class SwapAndInsertCommand extends UpdateCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/SwapAndInsertCommand.java
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class SwapAndInsertCommand extends UpdateCommand {
@Override
| protected void create(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/GetsCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
| import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
| package jp.co.rakuten.rit.roma.client.commands;
public class GetsCommand extends AbstractCommand {
@SuppressWarnings("unchecked")
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/GetsCommand.java
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
package jp.co.rakuten.rit.roma.client.commands;
public class GetsCommand extends AbstractCommand {
@SuppressWarnings("unchecked")
@Override
| public boolean execute(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/GetsCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
| import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
| package jp.co.rakuten.rit.roma.client.commands;
public class GetsCommand extends AbstractCommand {
@SuppressWarnings("unchecked")
@Override
public boolean execute(CommandContext context) throws ClientException {
try {
// "gets <key>*\r\n"
StringBuilder sb = new StringBuilder();
List<String> keys = (List<String>) context.get(CommandContext.KEYS);
sb.append(STR_GETS);
for (Iterator<String> iter = keys.iterator(); iter.hasNext();) {
sb.append(STR_WHITE_SPACE)
.append(iter.next())
.append(STR_ESC)
.append(context.get(CommandContext.HASH_NAME));
}
sb.append(STR_CRLF);
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/GetsCommand.java
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
package jp.co.rakuten.rit.roma.client.commands;
public class GetsCommand extends AbstractCommand {
@SuppressWarnings("unchecked")
@Override
public boolean execute(CommandContext context) throws ClientException {
try {
// "gets <key>*\r\n"
StringBuilder sb = new StringBuilder();
List<String> keys = (List<String>) context.get(CommandContext.KEYS);
sb.append(STR_GETS);
for (Iterator<String> iter = keys.iterator(); iter.hasNext();) {
sb.append(STR_WHITE_SPACE)
.append(iter.next())
.append(STR_ESC)
.append(context.get(CommandContext.HASH_NAME));
}
sb.append(STR_CRLF);
| Connection conn = (Connection) context.get(CommandContext.CONNECTION);
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/GetsCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class GetsCommand extends AbstractCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/GetsCommand.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class GetsCommand extends AbstractCommand {
@Override
| public boolean execute(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/GetsCommand.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
| import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
| package jp.co.rakuten.rit.roma.client.util.commands;
public class GetsCommand extends AbstractCommand {
@Override
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ClientException.java
// public class ClientException extends Exception {
// private static final long serialVersionUID = -7032182229500031385L;
//
// public ClientException() {
// super();
// }
//
// public ClientException(Throwable cause) {
// super(cause);
// }
//
// public ClientException(String reason) {
// super(reason);
// }
//
// public ClientException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/AbstractCommand.java
// public abstract class AbstractCommand implements Command, CommandID {
// protected Command next;
//
// protected AbstractCommand() {
// this(null);
// }
//
// protected AbstractCommand(Command next) {
// this.next = next;
// }
//
// public boolean execute(CommandContext context) throws ClientException {
// try {
// StringBuilder sb = new StringBuilder();
// context.put(CommandContext.STRING_DATA, sb);
// create(context);
// sendAndReceive(context);
// return parseResult(context);
// } catch (IOException e) {
// throw new ClientException(e);
// }
// }
//
// protected abstract void create(CommandContext context) throws ClientException;
//
// protected abstract void sendAndReceive(CommandContext context)
// throws IOException, ClientException;
//
// protected abstract boolean parseResult(CommandContext context)
// throws ClientException;
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/commands/CommandContext.java
// public class CommandContext extends HashMap<String, Object> {
// private static final long serialVersionUID = 3317922575242590794L;
// public static final String COMMAND_ID = "COMMAND_ID";
// public static final String RESULT = "RESULT";
// public static final String CONNECTION = "CONNECTION";
// public static final String KEY = "KEY";
// public static final String KEYS = "KEYS";
// public static final String HASH_NAME = "HASH_NAME";
// public static final String HASH = "HASH";
// public static final String VALUE = "VALUE";
// public static final String EXPIRY = "EXPIRY";
// public static final String EXCEPTION = "EXCEPTION";
// public static final String STRING_DATA = "STRING_DATA";
// public static final String NODE = "NODE";
// public static final String ROUTING_TABLE = "ROUTINGTABLE";
// public static final String CONNECTION_POOL = "CONNECTIONPOOL";
// public static final String CAS_ID = "CAS_ID";
//
// public CommandContext() {
// super();
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
// }
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/util/commands/GetsCommand.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import jp.co.rakuten.rit.roma.client.ClientException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.commands.AbstractCommand;
import jp.co.rakuten.rit.roma.client.commands.CommandContext;
package jp.co.rakuten.rit.roma.client.util.commands;
public class GetsCommand extends AbstractCommand {
@Override
| public boolean execute(CommandContext context) throws ClientException {
|
roma/roma-java-client | java/client/src/test/java/jp/co/rakuten/rit/roma/client/commands/MockConnectionPool.java | // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ConnectionPool.java
// public interface ConnectionPool {
// public Connection get(Node node) throws IOException;
//
// public void put(Node node, Connection conn) throws IOException;
//
// public void delete(Node node, Connection conn);
//
// public void deleteAll(Node node);
//
// public void closeAll();
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Node.java
// public class Node {
// public static List<Node> create(List<String> IDs) {
// List<Node> result = new ArrayList<Node>(IDs.size());
// Iterator<String> iter = IDs.iterator();
// while (iter.hasNext()) {
// result.add(create(iter.next()));
// }
// return result;
// }
//
// public static Node create(String ID) {
// int index = ID.indexOf('_');
// String host = ID.substring(0, index);
// try {
// int port = Integer.parseInt(ID.substring(index + 1, ID.length()));
// return new Node(host, port);
// } catch (NumberFormatException e) {
// throw e;
// // return null;
// }
// }
//
// String host;
// int port;
// String ID;
//
// Node(String host, int port) {
// this.host = host;
// this.port = port;
// this.ID = this.host + "_" + this.port;
// }
//
// public String getHost() {
// return host;
// }
//
// public int getPort() {
// return port;
// }
//
// @Override
// public int hashCode() {
// return this.ID.hashCode();
// }
//
// @Override
// public boolean equals(Object obj) {
// if (!(obj instanceof Node)) {
// return false;
// }
//
// Node n = (Node) obj;
// return n.host.equals(this.host) && n.port == this.port;
// }
//
// @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append(host).append("_").append(port);
// return sb.toString();
// }
// }
| import java.io.IOException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.ConnectionPool;
import jp.co.rakuten.rit.roma.client.Node; | package jp.co.rakuten.rit.roma.client.commands;
public class MockConnectionPool implements ConnectionPool {
public void closeAll() {
}
| // Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Connection.java
// public class Connection {
// public Socket sock;
//
// public ExtInputStream in;
//
// public OutputStream out;
//
// /**
// * Construct a connection to a ROMA process.
// *
// * @param sock
// * - a socket of the ROMA process to connect to
// * @throws IOException
// * - if creating this connection fails
// */
// public Connection(final Socket sock) throws IOException {
// this.sock = sock;
// this.in = new ExtInputStream(sock.getInputStream());
// this.out = new BufferedOutputStream(sock.getOutputStream());
// }
//
// public void setTimeout(int timeout) throws SocketException {
// this.sock.setSoTimeout(timeout);
// }
//
// /**
// * Close this connection.
// *
// * @throws IOException
// * - if closing this connection fails
// */
// public void close() throws IOException {
// if (in != null) {
// in.close();
// }
// if (out != null) {
// out.close();
// }
// if (sock != null) {
// sock.close();
// }
// }
//
// public static long TIME = 0;
//
// public class ExtInputStream extends BufferedInputStream {
//
// private byte[] one_byte = new byte[1];
//
// ExtInputStream(InputStream in) {
// super(in);
// }
//
// public void read(int byteLen) throws IOException {
// for (int i = 0; i < byteLen; ++i) {
// super.read(one_byte);
// }
// }
//
// public String readLine() throws IOException {
// StringBuilder ret = new StringBuilder();
//
// long t = System.currentTimeMillis();
//
// while (super.read(one_byte) > 0) {
// if (one_byte[0] == 0x0d) { // \r
// break;
// } else {
// ret.append((char) one_byte[0]);
// }
// }
//
// TIME = TIME + (System.currentTimeMillis() - t);
//
// super.read(one_byte); // \n
// return ret.toString();
// }
// }
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/ConnectionPool.java
// public interface ConnectionPool {
// public Connection get(Node node) throws IOException;
//
// public void put(Node node, Connection conn) throws IOException;
//
// public void delete(Node node, Connection conn);
//
// public void deleteAll(Node node);
//
// public void closeAll();
// }
//
// Path: java/client/src/main/java/jp/co/rakuten/rit/roma/client/Node.java
// public class Node {
// public static List<Node> create(List<String> IDs) {
// List<Node> result = new ArrayList<Node>(IDs.size());
// Iterator<String> iter = IDs.iterator();
// while (iter.hasNext()) {
// result.add(create(iter.next()));
// }
// return result;
// }
//
// public static Node create(String ID) {
// int index = ID.indexOf('_');
// String host = ID.substring(0, index);
// try {
// int port = Integer.parseInt(ID.substring(index + 1, ID.length()));
// return new Node(host, port);
// } catch (NumberFormatException e) {
// throw e;
// // return null;
// }
// }
//
// String host;
// int port;
// String ID;
//
// Node(String host, int port) {
// this.host = host;
// this.port = port;
// this.ID = this.host + "_" + this.port;
// }
//
// public String getHost() {
// return host;
// }
//
// public int getPort() {
// return port;
// }
//
// @Override
// public int hashCode() {
// return this.ID.hashCode();
// }
//
// @Override
// public boolean equals(Object obj) {
// if (!(obj instanceof Node)) {
// return false;
// }
//
// Node n = (Node) obj;
// return n.host.equals(this.host) && n.port == this.port;
// }
//
// @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append(host).append("_").append(port);
// return sb.toString();
// }
// }
// Path: java/client/src/test/java/jp/co/rakuten/rit/roma/client/commands/MockConnectionPool.java
import java.io.IOException;
import jp.co.rakuten.rit.roma.client.Connection;
import jp.co.rakuten.rit.roma.client.ConnectionPool;
import jp.co.rakuten.rit.roma.client.Node;
package jp.co.rakuten.rit.roma.client.commands;
public class MockConnectionPool implements ConnectionPool {
public void closeAll() {
}
| public void delete(Node node, Connection conn) { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.